Scroom  0.14
LayerCoordinator Class Reference

#include <layercoordinator.hh>

Inheritance diagram for LayerCoordinator:
Inheritance graph
Collaboration diagram for LayerCoordinator:
Collaboration graph

Public Types

using Ptr = boost::shared_ptr< LayerCoordinator >
 
- Public Types inherited from TileInitialisationObserver
using Ptr = boost::shared_ptr< TileInitialisationObserver >
 
using WeakPtr = boost::weak_ptr< TileInitialisationObserver >
 

Public Member Functions

 ~LayerCoordinator () override
 
 LayerCoordinator (const LayerCoordinator &)=delete
 
 LayerCoordinator (LayerCoordinator &&)=delete
 
LayerCoordinator operator= (const LayerCoordinator &)=delete
 
LayerCoordinator operator= (LayerCoordinator &&)=delete
 
void addSourceTile (int x, int y, const CompressedTile::Ptr &tile)
 
void tileFinished (const CompressedTile::Ptr &tile) override
 TileInitialisationObserver. More...
 
- Public Member Functions inherited from TileInitialisationObserver
virtual void tileCreated (const boost::shared_ptr< CompressedTile > &tile)
 
virtual void tileFinished (const boost::shared_ptr< CompressedTile > &tile)
 TileInitialisationObserver. More...
 
- 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 (CompressedTile::Ptr targetTile, LayerOperations::Ptr lo)
 

Private Member Functions

 LayerCoordinator (CompressedTile::Ptr targetTile, LayerOperations::Ptr lo)
 
void reduceSourceTile (const CompressedTile::Ptr &tile, ConstTile::Ptr const &tileData)
 Helpers. More...
 

Private Attributes

CompressedTile::Ptr targetTile
 
Tile::Ptr targetTileData
 
std::map< CompressedTile::Ptr, std::pair< int, int > > sourceTiles
 
Scroom::Utils::StuffList registrations
 
LayerOperations::Ptr lo
 
boost::mutex mut
 
int unfinishedSourceTiles {0}
 

Member Typedef Documentation

◆ Ptr

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

Constructor & Destructor Documentation

◆ ~LayerCoordinator()

LayerCoordinator::~LayerCoordinator ( )
override
32 {
33  registrations.clear();
34  sourceTiles.clear();
35 }

◆ LayerCoordinator() [1/3]

LayerCoordinator::LayerCoordinator ( const LayerCoordinator )
delete

Referenced by create().

Here is the caller graph for this function:

◆ LayerCoordinator() [2/3]

LayerCoordinator::LayerCoordinator ( LayerCoordinator &&  )
delete

◆ LayerCoordinator() [3/3]

LayerCoordinator::LayerCoordinator ( CompressedTile::Ptr  targetTile,
LayerOperations::Ptr  lo 
)
private
25  : targetTile(std::move(targetTile_))
26  , lo(std::move(lo_))
27 
28 {
29 }

Member Function Documentation

◆ addSourceTile()

void LayerCoordinator::addSourceTile ( int  x,
int  y,
const CompressedTile::Ptr tile 
)
38 {
39  boost::unique_lock<boost::mutex> const lock(mut);
40 
41  sourceTiles[tile] = std::make_pair(x, y);
42  registrations.emplace_back(tile->registerObserver(shared_from_this<LayerCoordinator>()));
44 }

◆ create()

LayerCoordinator::Ptr LayerCoordinator::create ( CompressedTile::Ptr  targetTile,
LayerOperations::Ptr  lo 
)
static
20 {
21  return LayerCoordinator::Ptr(new LayerCoordinator(std::move(targetTile), std::move(lo)));
22 }

Referenced by TiledBitmap::connect().

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

◆ operator=() [1/2]

LayerCoordinator LayerCoordinator::operator= ( const LayerCoordinator )
delete

◆ operator=() [2/2]

LayerCoordinator LayerCoordinator::operator= ( LayerCoordinator &&  )
delete

◆ reduceSourceTile()

void LayerCoordinator::reduceSourceTile ( const CompressedTile::Ptr tile,
ConstTile::Ptr const &  tileData 
)
private

Helpers.

62 {
63  // If tileData contains a valid pointer, then fetching
64  // sourcetiledata, below, will be instananeous. Otherwise, it will
65  // need to unzip the compressed tile.
66  //
67  // Other than that side-effect, we have no use for tileData
68  UNUSED(tileData);
69 
70  Scroom::Utils::Stuff const s = targetTile->initialize();
71  const std::pair<int, int> location = sourceTiles[tile];
72  const int x = location.first;
73  const int y = location.second;
74 
75  if(!targetTileData)
76  {
77  targetTileData = targetTile->getTileSync();
78  }
79  ConstTile::Ptr const source = tile->getConstTileSync();
80 
81  lo->reduce(targetTileData, source, x, y);
82 
83  boost::unique_lock<boost::mutex> const lock(mut);
86  {
87  targetTile->reportFinished();
88  targetTileData.reset();
89  }
90 }

Referenced by tileFinished().

Here is the caller graph for this function:

◆ tileFinished()

void LayerCoordinator::tileFinished ( const CompressedTile::Ptr tile)
override

TileInitialisationObserver.

50 {
51  ConstTile::Ptr const tileData = tile->getConstTileAsync();
52  require(tileData);
53 
54  CpuBound()->schedule(boost::bind(&LayerCoordinator::reduceSourceTile, shared_from_this<LayerCoordinator>(), tile, tileData),
55  REDUCE_PRIO);
56 }
Here is the call graph for this function:

Member Data Documentation

◆ lo

LayerOperations::Ptr LayerCoordinator::lo
private

Referenced by create(), and reduceSourceTile().

◆ mut

boost::mutex LayerCoordinator::mut
private

Referenced by addSourceTile(), and reduceSourceTile().

◆ registrations

Scroom::Utils::StuffList LayerCoordinator::registrations
private

Referenced by addSourceTile(), and ~LayerCoordinator().

◆ sourceTiles

std::map<CompressedTile::Ptr, std::pair<int, int> > LayerCoordinator::sourceTiles
private

◆ targetTile

CompressedTile::Ptr LayerCoordinator::targetTile
private

Referenced by create(), and reduceSourceTile().

◆ targetTileData

Tile::Ptr LayerCoordinator::targetTileData
private

Referenced by reduceSourceTile().

◆ unfinishedSourceTiles

int LayerCoordinator::unfinishedSourceTiles {0}
private

Referenced by addSourceTile(), and reduceSourceTile().


The documentation for this class was generated from the following files:
UNUSED
#define UNUSED(x)
Definition: unused.hh:10
LayerCoordinator::registrations
Scroom::Utils::StuffList registrations
Definition: layercoordinator.hh:27
LayerCoordinator::targetTileData
Tile::Ptr targetTileData
Definition: layercoordinator.hh:25
LayerCoordinator::unfinishedSourceTiles
int unfinishedSourceTiles
Definition: layercoordinator.hh:30
ConstTile::Ptr
boost::shared_ptr< ConstTile > Ptr
Definition: tile.hh:47
LayerCoordinator::LayerCoordinator
LayerCoordinator(const LayerCoordinator &)=delete
require
#define require(expr)
Definition: assertions.hh:28
LayerCoordinator::sourceTiles
std::map< CompressedTile::Ptr, std::pair< int, int > > sourceTiles
Definition: layercoordinator.hh:26
LayerCoordinator::mut
boost::mutex mut
Definition: layercoordinator.hh:29
CpuBound
ThreadPool::Ptr CpuBound()
Definition: threadpoolimpl.cc:452
Scroom::Utils::Stuff
boost::shared_ptr< void > Stuff
Definition: stuff.hh:18
LayerCoordinator::Ptr
boost::shared_ptr< LayerCoordinator > Ptr
Definition: layercoordinator.hh:33
LayerCoordinator::lo
LayerOperations::Ptr lo
Definition: layercoordinator.hh:28
LayerCoordinator::targetTile
CompressedTile::Ptr targetTile
Definition: layercoordinator.hh:24
REDUCE_PRIO
#define REDUCE_PRIO
Definition: local.hh:12
LayerCoordinator::reduceSourceTile
void reduceSourceTile(const CompressedTile::Ptr &tile, ConstTile::Ptr const &tileData)
Helpers.
Definition: layercoordinator.cc:61