Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
LayerCoordinator Class Reference

#include <layercoordinator.hh>

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

Public Types

using Ptr = std::shared_ptr< LayerCoordinator >
 
- Public Types inherited from TileInitialisationObserver
using Ptr = std::shared_ptr< TileInitialisationObserver >
 
using WeakPtr = std::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.
 
- Public Member Functions inherited from TileInitialisationObserver
virtual void tileCreated (const std::shared_ptr< CompressedTile > &tile)
 
- 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 >
std::shared_ptr< R > shared_from_this ()
 
template<typename R >
std::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.
 

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 = std::shared_ptr<LayerCoordinator>

Constructor & Destructor Documentation

◆ ~LayerCoordinator()

LayerCoordinator::~LayerCoordinator ( )
override
31{
32 registrations.clear();
33 sourceTiles.clear();
34}
Scroom::Utils::StuffList registrations
Definition layercoordinator.hh:26
std::map< CompressedTile::Ptr, std::pair< int, int > > sourceTiles
Definition layercoordinator.hh:25

◆ LayerCoordinator() [1/3]

LayerCoordinator::LayerCoordinator ( const LayerCoordinator )
delete

◆ LayerCoordinator() [2/3]

LayerCoordinator::LayerCoordinator ( LayerCoordinator &&  )
delete

◆ LayerCoordinator() [3/3]

LayerCoordinator::LayerCoordinator ( CompressedTile::Ptr  targetTile,
LayerOperations::Ptr  lo 
)
private
24 : targetTile(std::move(targetTile_))
25 , lo(std::move(lo_))
26
27{
28}
LayerOperations::Ptr lo
Definition layercoordinator.hh:27
CompressedTile::Ptr targetTile
Definition layercoordinator.hh:23

Member Function Documentation

◆ addSourceTile()

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

◆ create()

LayerCoordinator::Ptr LayerCoordinator::create ( CompressedTile::Ptr  targetTile,
LayerOperations::Ptr  lo 
)
static
19{
20 return LayerCoordinator::Ptr(new LayerCoordinator(std::move(targetTile), std::move(lo)));
21}
Definition layercoordinator.hh:21
std::shared_ptr< LayerCoordinator > Ptr
Definition layercoordinator.hh:32

Referenced by TiledBitmap::connect().

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 Scroom::Utils::Stuff const s = targetTile->initialize();
69 const std::pair<int, int> location = sourceTiles[tile];
70 const int x = location.first;
71 const int y = location.second;
72
74 {
75 targetTileData = targetTile->getTileSync();
76 }
77 ConstTile::Ptr const source = tile->getConstTileSync();
78
79 lo->reduce(targetTileData, source, x, y);
80
81 boost::unique_lock<boost::mutex> const lock(mut);
84 {
85 targetTile->reportFinished();
86 targetTileData.reset();
87 }
88}
std::shared_ptr< ConstTile > Ptr
Definition tile.hh:45
Tile::Ptr targetTileData
Definition layercoordinator.hh:24
std::shared_ptr< void > Stuff
Definition stuff.hh:17
BitmapSurface::Ptr const s
Definition transformpresentation_test.cc:70

◆ tileFinished()

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

TileInitialisationObserver.

Reimplemented from TileInitialisationObserver.

49{
50 ConstTile::Ptr const tileData = tile->getConstTileAsync();
51 require(tileData);
52
53 CpuBound()->schedule(
54 [me = shared_from_this<LayerCoordinator>(), tile, tileData] { me->reduceSourceTile(tile, tileData); }, REDUCE_PRIO
55 );
56}
#define require(expr)
Definition assertions.hh:30
#define REDUCE_PRIO
Definition local.hh:12
ThreadPool::Ptr CpuBound()
Definition threadpoolimpl.cc:455
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
29{0};

Referenced by addSourceTile(), and reduceSourceTile().


The documentation for this class was generated from the following files: