summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/xpdf/TileCache.h
blob: bea58c4c8fc1846e953e63bb2fedbc9c0ce53062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//========================================================================
//
// TileCache.h
//
// Copyright 2014 Glyph & Cog, LLC
//
//========================================================================

#ifndef TILECACHE_H
#define TILECACHE_H

#include <aconf.h>

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

#include "gtypes.h"
#include "SplashTypes.h"

class SplashBitmap;
class SplashOutputDev;
class DisplayState;
class CachedTileDesc;
class TileCacheThreadPool;
class TileDesc;

//------------------------------------------------------------------------

class TileCache {
public:

  TileCache(DisplayState *stateA);
  ~TileCache();

  // Set the list of currently displayed tiles (TileDesc objects).
  void setActiveTileList(GList *tiles);

  // Return the bitmap for a tile.  The tile must be on the current
  // active list.  This can return NULL if tile rasterization hasn't
  // started yet.  If <finished> is non-NULL, *<finished> will be set
  // to true if rasterization of this bitmap is finished, false
  // otherwise.
  SplashBitmap *getTileBitmap(TileDesc *tile, GBool *finished);

  // Set a callback to be called whenever a tile rasterization is
  // finished.  NB: this callback will be called from a worker thread.
  void setTileDoneCbk(void (*cbk)(void *data), void *data)
    { tileDoneCbk = cbk; tileDoneCbkData = data; }

  void paperColorChanged();
  void reverseVideoChanged();
  void optionalContentChanged();
  void docChanged();
  void forceRedraw();

private:

  int findTile(TileDesc *tile, GList *tileList);
  void cleanCache();
  void flushCache(GBool wait);
  void removeTile(CachedTileDesc *ct);
  GBool hasUnstartedTiles();
  CachedTileDesc *getUnstartedTile();
  static void startPageCbk(void *data);
  void rasterizeTile(CachedTileDesc *tile);
  static GBool abortCheckCbk(void *data);

  DisplayState *state;
  GList *cache;			// [CachedTileDesc]
  TileCacheThreadPool *threadPool;
  void (*tileDoneCbk)(void *data);
  void *tileDoneCbkData;

  friend class TileCacheThreadPool;
};

#endif