Scroom  0.14
Layer Class Reference

#include <tiledbitmaplayer.hh>

Inheritance diagram for Layer:
Inheritance graph
Collaboration diagram for Layer:
Collaboration graph

Public Types

using Ptr = boost::shared_ptr< Layer >
 
- Public Types inherited from Viewable
using Ptr = boost::shared_ptr< Viewable >
 
using WeakPtr = boost::weak_ptr< Viewable >
 

Public Member Functions

int getHorTileCount () const
 
int getVerTileCount () const
 
CompressedTile::Ptr getTile (int i, int j)
 
CompressedTileLinegetTileLine (int j)
 
void fetchData (SourcePresentation::Ptr sp, const ThreadPool::WeakQueue::Ptr &queue, std::function< void()> on_finished)
 
int getWidth () const
 
int getHeight () const
 
int getDepth () const
 
Scroom::Utils::Rectangle< int > getRect () const
 
Scroom::Bookkeeping::Token registerObserver (const TileInitialisationObserver::Ptr &observer)
 
Scroom::MemoryBlobs::PageProvider::Ptr getPageProvider ()
 
void open (ViewInterface::WeakPtr vi) override
 
void close (ViewInterface::WeakPtr vi) override
 
- Public Member Functions inherited from Scroom::Utils::Base
 Base ()=default
 
 Base (const Base &)=delete
 
 Base (Base &&)=delete
 
Baseoperator= (const Base &)=delete
 
Baseoperator= (Base &&)=delete
 
virtual ~Base ()=default
 
template<typename R >
boost::shared_ptr< R > shared_from_this ()
 
template<typename R >
boost::shared_ptr< R const > shared_from_this () const
 

Static Public Member Functions

static Ptr create (int depth, int layerWidth, int layerHeight, int bpp, Scroom::MemoryBlobs::PageProvider::Ptr provider)
 
static Ptr create (int layerWidth, int layerHeight, int bpp)
 

Private Member Functions

 Layer (int depth, int layerWidth, int layerHeight, int bpp, Scroom::MemoryBlobs::PageProvider::Ptr provider)
 Layer. More...
 

Private Attributes

int depth
 
int width
 
int height
 
int horTileCount
 
int verTileCount
 
CompressedTileGrid tiles
 
CompressedTile::Ptr outOfBounds
 
CompressedTileLine lineOutOfBounds
 
Scroom::MemoryBlobs::PageProvider::Ptr pageProvider
 

Member Typedef Documentation

◆ Ptr

using Layer::Ptr = boost::shared_ptr<Layer>

Constructor & Destructor Documentation

◆ Layer()

Layer::Layer ( int  depth,
int  layerWidth,
int  layerHeight,
int  bpp,
Scroom::MemoryBlobs::PageProvider::Ptr  provider 
)
private

Layer.

71  : depth(depth_)
72  , width(layerWidth)
73  , height(layerHeight)
74  , horTileCount((width + TILESIZE - 1) / TILESIZE)
76  , pageProvider(std::move(provider))
77 {
78  for(int j = 0; j < verTileCount; j++)
79  {
80  tiles.emplace_back();
81  CompressedTileLine& tl = tiles[j];
82  for(int i = 0; i < horTileCount; i++)
83  {
84  CompressedTile::Ptr const tile = CompressedTile::create(depth_, i, j, bpp, pageProvider);
85  tl.push_back(tile);
86  }
87  }
88 
90  for(int i = 0; i < horTileCount; i++)
91  {
92  lineOutOfBounds.push_back(outOfBounds);
93  }
94 
95  spdlog::debug("Layer {} ({} bpp), {}*{}, TileCount {}*{}", depth_, bpp, width, height, horTileCount, verTileCount);
96 }

Referenced by create().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ close()

void Layer::close ( ViewInterface::WeakPtr  vi)
overridevirtual

Gets called just before the View is destroyed

Precondition
Should be called from within a Gdk critical section (i.e. between gdk_threads_enter() and gdk_threads_leave() calls)

Implements Viewable.

174 {
175  for(CompressedTileLine const& line: tiles)
176  {
177  for(const CompressedTile::Ptr& tile: line)
178  {
179  tile->close(vi);
180  }
181  }
182  for(const CompressedTile::Ptr& tile: lineOutOfBounds)
183  {
184  tile->close(vi);
185  }
186  outOfBounds->close(vi);
187 }

◆ create() [1/2]

Layer::Ptr Layer::create ( int  depth,
int  layerWidth,
int  layerHeight,
int  bpp,
Scroom::MemoryBlobs::PageProvider::Ptr  provider 
)
static
99 {
100  return Ptr(new Layer(depth, layerWidth, layerHeight, bpp, std::move(provider)));
101 }

Referenced by create(), TiledBitmap::initialize(), and Tiff::open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create() [2/2]

Layer::Ptr Layer::create ( int  layerWidth,
int  layerHeight,
int  bpp 
)
static
104 {
105  Scroom::MemoryBlobs::PageProvider::Ptr const provider = createProvider(layerWidth, layerHeight, bpp);
106 
107  return create(0, layerWidth, layerHeight, bpp, provider);
108 }
Here is the call graph for this function:

◆ fetchData()

void Layer::fetchData ( SourcePresentation::Ptr  sp,
const ThreadPool::WeakQueue::Ptr queue,
std::function< void()>  on_finished 
)
149 {
150  DataFetcher const df(
151  shared_from_this<Layer>(), height, horTileCount, verTileCount, std::move(sp), queue, std::move(on_finished));
152  CpuBound()->schedule(df, DATAFETCH_PRIO, queue);
153 }
Here is the call graph for this function:

◆ getDepth()

int Layer::getDepth ( ) const
inline
278 { return depth; }

◆ getHeight()

int Layer::getHeight ( ) const
inline
276 { return height; }

◆ getHorTileCount()

int Layer::getHorTileCount ( ) const
124 { return horTileCount; }

◆ getPageProvider()

Scroom::MemoryBlobs::PageProvider::Ptr Layer::getPageProvider ( )
inline
284 { return pageProvider; }

◆ getRect()

Scroom::Utils::Rectangle<int> Layer::getRect ( ) const
inline
280 { return {0, 0, width, height}; }

◆ getTile()

CompressedTile::Ptr Layer::getTile ( int  i,
int  j 
)
129 {
130  if(0 <= i && i < horTileCount && 0 <= j && j < verTileCount)
131  {
132  return tiles[j][i];
133  }
134 
135  return outOfBounds;
136 }

◆ getTileLine()

CompressedTileLine & Layer::getTileLine ( int  j)
139 {
140  if(0 <= j && j < verTileCount)
141  {
142  return tiles[j];
143  }
144 
145  return lineOutOfBounds;
146 }

◆ getVerTileCount()

int Layer::getVerTileCount ( ) const
126 { return verTileCount; }

◆ getWidth()

int Layer::getWidth ( ) const
inline
274 { return width; }

◆ open()

void Layer::open ( ViewInterface::WeakPtr  vi)
overridevirtual

Gets called just after the View is created

Precondition
Should be called from within a Gdk critical section (i.e. between gdk_threads_enter() and gdk_threads_leave() calls)

Implements Viewable.

158 {
159  for(CompressedTileLine const& line: tiles)
160  {
161  for(const CompressedTile::Ptr& tile: line)
162  {
163  tile->open(vi);
164  }
165  }
166  for(const CompressedTile::Ptr& tile: lineOutOfBounds)
167  {
168  tile->open(vi);
169  }
170  outOfBounds->open(vi);
171 }

◆ registerObserver()

Scroom::Bookkeeping::Token Layer::registerObserver ( const TileInitialisationObserver::Ptr observer)
111 {
113 
114  for(auto& line: tiles)
115  {
116  for(auto& tile: line)
117  {
118  t.add(tile->registerObserver(observer));
119  }
120  }
121  return t;
122 }
Here is the call graph for this function:

Member Data Documentation

◆ depth

int Layer::depth
private

Referenced by create(), and getDepth().

◆ height

int Layer::height
private

Referenced by fetchData(), getHeight(), getRect(), and Layer().

◆ horTileCount

int Layer::horTileCount
private

◆ lineOutOfBounds

CompressedTileLine Layer::lineOutOfBounds
private

Referenced by close(), getTileLine(), Layer(), and open().

◆ outOfBounds

CompressedTile::Ptr Layer::outOfBounds
private

Referenced by close(), getTile(), Layer(), and open().

◆ pageProvider

Scroom::MemoryBlobs::PageProvider::Ptr Layer::pageProvider
private

Referenced by getPageProvider(), and Layer().

◆ tiles

CompressedTileGrid Layer::tiles
private

◆ verTileCount

int Layer::verTileCount
private

◆ width

int Layer::width
private

Referenced by getRect(), getWidth(), and Layer().


The documentation for this class was generated from the following files:
Scroom::MemoryBlobs::PageProvider::Ptr
boost::shared_ptr< PageProvider > Ptr
Definition: memoryblobs.hh:41
Layer::width
int width
Definition: tiledbitmaplayer.hh:251
Layer::Ptr
boost::shared_ptr< Layer > Ptr
Definition: tiledbitmaplayer.hh:247
Layer::tiles
CompressedTileGrid tiles
Definition: tiledbitmaplayer.hh:255
Layer::verTileCount
int verTileCount
Definition: tiledbitmaplayer.hh:254
createProvider
static Scroom::MemoryBlobs::PageProvider::Ptr createProvider(double width, double height, int bpp)
Definition: layer.cc:25
CompressedTile::create
static Ptr create(int depth, int x, int y, int bpp, const Scroom::MemoryBlobs::PageProvider::Ptr &provider, TileStateInternal state=TSI_UNINITIALIZED)
Definition: compressedtile.cc:32
Layer::height
int height
Definition: tiledbitmaplayer.hh:252
Layer::outOfBounds
CompressedTile::Ptr outOfBounds
Definition: tiledbitmaplayer.hh:256
Layer::lineOutOfBounds
CompressedTileLine lineOutOfBounds
Definition: tiledbitmaplayer.hh:257
Layer::pageProvider
Scroom::MemoryBlobs::PageProvider::Ptr pageProvider
Definition: tiledbitmaplayer.hh:258
Layer::horTileCount
int horTileCount
Definition: tiledbitmaplayer.hh:253
Layer::depth
int depth
Definition: tiledbitmaplayer.hh:250
CpuBound
ThreadPool::Ptr CpuBound()
Definition: threadpoolimpl.cc:452
TSI_OUT_OF_BOUNDS
@ TSI_OUT_OF_BOUNDS
Definition: tiledbitmaplayer.hh:38
CompressedTile::Ptr
boost::shared_ptr< CompressedTile > Ptr
Definition: tiledbitmaplayer.hh:108
TILESIZE
#define TILESIZE
Definition: tiledbitmaplayer.hh:28
Layer::create
static Ptr create(int depth, int layerWidth, int layerHeight, int bpp, Scroom::MemoryBlobs::PageProvider::Ptr provider)
Definition: layer.cc:98
CompressedTileLine
std::vector< CompressedTile::Ptr > CompressedTileLine
Definition: tiledbitmaplayer.hh:237
DATAFETCH_PRIO
#define DATAFETCH_PRIO
Definition: local.hh:11
DataFetcher
Definition: layer.cc:42
Scroom::Bookkeeping::Token
Definition: bookkeeping.hh:37
Scroom::Bookkeeping::Token::add
void add(const Stuff &s) const
Definition: bookkeepingimpl.hh:191
Layer::Layer
Layer(int depth, int layerWidth, int layerHeight, int bpp, Scroom::MemoryBlobs::PageProvider::Ptr provider)
Layer.
Definition: layer.cc:70