Scroom  0.14
tiled-bitmap.hh
Go to the documentation of this file.
1 /*
2  * Scroom - Generic viewer for 2D data
3  * Copyright (C) 2009-2022 Kees-Jan Dijkzeul
4  *
5  * SPDX-License-Identifier: LGPL-2.1
6  */
7 
8 #pragma once
9 
10 #include <list>
11 #include <map>
12 
13 #include <boost/enable_shared_from_this.hpp>
14 #include <boost/shared_ptr.hpp>
15 #include <boost/thread/mutex.hpp>
16 
17 #include <scroom/interface.hh>
21 #include <scroom/threadpool.hh>
24 
25 #include "layercoordinator.hh"
26 #include "tiledbitmapviewdata.hh"
27 
29  : public TiledBitmapInterface
31  , public virtual Scroom::Utils::Base
32 {
33 public:
34  using Ptr = boost::shared_ptr<TiledBitmap>;
35  using WeakPtr = boost::weak_ptr<TiledBitmap>;
36  using ViewDataMap = std::map<ViewInterface::WeakPtr, TiledBitmapViewData::Ptr>;
37 
38 private:
42  std::vector<Layer::Ptr> layers;
43  std::list<LayerCoordinator::Ptr> coordinators;
44  boost::mutex viewDataMutex;
46  int tileCount{0};
47  boost::mutex tileFinishedMutex;
51 
52 public:
53  static Ptr create(int bitmapWidth, int bitmapHeight, LayerSpec const& ls);
54  static Ptr create(const Layer::Ptr& bottom, const LayerSpec& ls);
55 
56  ~TiledBitmap() override;
57  TiledBitmap(const TiledBitmap&) = delete;
58  TiledBitmap(TiledBitmap&&) = delete;
59  TiledBitmap operator=(const TiledBitmap&) = delete;
60  TiledBitmap operator=(TiledBitmap&&) = delete;
61 
62 private:
64 
65  void initialize();
66  void initialize(const Layer::Ptr& bottom);
67 
68 private:
69  static void drawTile(cairo_t* cr, const CompressedTile::Ptr& tile, const Scroom::Utils::Rectangle<double>& viewArea);
70  void connect(Layer::Ptr const& layer, Layer::Ptr const& prevLayer, const LayerOperations::Ptr& prevLo);
71 
72 public:
74  // TiledBitmapInterface
75 
76 public:
77  void setSource(SourcePresentation::Ptr sp) override;
78  Layer::Ptr getBottomLayer() override;
79 
80  void open(ViewInterface::WeakPtr viewInterface) override;
81  void close(ViewInterface::WeakPtr vi) override;
82  void redraw(ViewInterface::Ptr const& vi,
83  cairo_t* cr,
84  Scroom::Utils::Rectangle<double> const& presentationArea,
85  int zoom) override;
86  void clearCaches(ViewInterface::Ptr vi) override;
87 
89  // TileInitialisationObserver
90 
91  void tileCreated(const CompressedTile::Ptr& tile) override;
92  void tileFinished(const CompressedTile::Ptr& tile) override;
93 
95  // Helpers
97 };
tiledbitmapviewdata.hh
UNUSED
#define UNUSED(x)
Definition: unused.hh:10
Scroom::MemoryBlobs::PageProvider::Ptr
boost::shared_ptr< PageProvider > Ptr
Definition: memoryblobs.hh:41
Scroom::Utils::StuffList
std::list< Stuff > StuffList
Definition: stuff.hh:20
TiledBitmap::setSource
void setSource(SourcePresentation::Ptr sp) override
Definition: tiled-bitmap.cc:176
Scroom::Utils::Rectangle::x
value_type x() const
Definition: rectangle.hh:125
threadpool.hh
TiledBitmap::tileCount
int tileCount
Definition: tiled-bitmap.hh:46
Layer::Ptr
boost::shared_ptr< Layer > Ptr
Definition: tiledbitmaplayer.hh:247
TiledBitmap::bitmapWidth
int bitmapWidth
Definition: tiled-bitmap.hh:39
Scroom::Utils::Rectangle::width
value_type width() const
Definition: rectangle.hh:129
TiledBitmap::ls
LayerSpec ls
Definition: tiled-bitmap.hh:41
TiledBitmap::create
static Ptr create(int bitmapWidth, int bitmapHeight, LayerSpec const &ls)
Definition: tiled-bitmap.cc:70
Scroom::TiledBitmap::scheduleLoadingBitmap
Scroom::Utils::Stuff scheduleLoadingBitmap(const SourcePresentation::Ptr &sp, const Layer::Ptr &layer, const ProgressInterface::Ptr &progress)
Definition: tiled-bitmap.cc:33
Viewable::WeakPtr
boost::weak_ptr< Viewable > WeakPtr
Definition: presentationinterface.hh:36
progressinterfacehelpers.hh
TiledBitmap::tileFinishedCount
int tileFinishedCount
Definition: tiled-bitmap.hh:48
TiledBitmap::initialize
void initialize()
Definition: tiled-bitmap.cc:131
Scroom
Definition: assertions.hh:14
TiledBitmap::registrations
Scroom::Utils::StuffList registrations
Definition: tiled-bitmap.hh:50
ThreadPool::Queue::createAsync
static Ptr createAsync()
Definition: threadpoolimpl.cc:379
TiledBitmap::redraw
void redraw(ViewInterface::Ptr const &vi, cairo_t *cr, Scroom::Utils::Rectangle< double > const &presentationArea, int zoom) override
Definition: tiled-bitmap.cc:201
ConstTile::Ptr
boost::shared_ptr< ConstTile > Ptr
Definition: tile.hh:47
TileAreaForIndex
Scroom::Utils::Rectangle< int > TileAreaForIndex(Scroom::Utils::Point< int > tileIndex)
Definition: tiled-bitmap.cc:62
TiledBitmapViewData::Ptr
boost::shared_ptr< TiledBitmapViewData > Ptr
Definition: tiledbitmapviewdata.hh:25
ProgressInterface::Ptr
boost::shared_ptr< ProgressInterface > Ptr
Definition: progressinterface.hh:20
Scroom::Utils::Rectangle::intersection
Rectangle intersection(const Rectangle &other) const
Definition: rectangle.hh:95
ViewInterface::Ptr
boost::shared_ptr< ViewInterface > Ptr
Definition: viewinterface.hh:193
Sequentially
ThreadPool::Ptr Sequentially()
Definition: threadpoolimpl.cc:459
SourcePresentation::Ptr
boost::shared_ptr< SourcePresentation > Ptr
Definition: tiledbitmapinterface.hh:198
TiledBitmap::tileFinishedMutex
boost::mutex tileFinishedMutex
Definition: tiled-bitmap.hh:47
Scroom::Utils::Detail::abort
void abort() __attribute__((noreturn))
Definition: assertions.cc:126
LayerSpec
std::vector< LayerOperations::Ptr > LayerSpec
Definition: tiledbitmapinterface.hh:190
TiledBitmap::clearCaches
void clearCaches(ViewInterface::Ptr vi) override
Definition: tiled-bitmap.cc:275
TileViewState::Ptr
boost::shared_ptr< TileViewState > Ptr
Definition: tileviewstate.hh:27
TiledBitmap::viewData
ViewDataMap viewData
Definition: tiled-bitmap.hh:45
Scroom::GtkHelpers::sync_on_ui_thread
void sync_on_ui_thread(T f)
Definition: gtk-helpers.hh:59
TiledBitmap::bitmapHeight
int bitmapHeight
Definition: tiled-bitmap.hh:40
TiledBitmap
Definition: tiled-bitmap.hh:28
TiledBitmap::connect
void connect(Layer::Ptr const &layer, Layer::Ptr const &prevLayer, const LayerOperations::Ptr &prevLo)
Definition: tiled-bitmap.cc:141
tiled-bitmap.hh
TiledBitmapViewData::create
static Ptr create(const ViewInterface::WeakPtr &viewInterface)
Definition: tiledbitmapviewdata.cc:20
TiledBitmap::open
void open(ViewInterface::WeakPtr viewInterface) override
Definition: tiled-bitmap.cc:285
opentiledbitmapinterface.hh
ViewInterface::WeakPtr
boost::weak_ptr< ViewInterface > WeakPtr
Definition: viewinterface.hh:194
TiledBitmap::Ptr
boost::shared_ptr< TiledBitmap > Ptr
Definition: tiled-bitmap.hh:34
LayerCoordinator::create
static Ptr create(CompressedTile::Ptr targetTile, LayerOperations::Ptr lo)
Definition: layercoordinator.cc:19
TiledBitmap::coordinators
std::list< LayerCoordinator::Ptr > coordinators
Definition: tiled-bitmap.hh:43
layercoordinator.hh
tiledbitmaplayer.hh
tiledbitmapinterface.hh
Scroom::Utils::Base
Definition: utilities.hh:30
Scroom::Utils::on_destruction
boost::shared_ptr< void > on_destruction(F f)
Definition: utilities.hh:75
Scroom::Utils::Stuff
boost::shared_ptr< void > Stuff
Definition: stuff.hh:18
TiledBitmap::progressBroadcaster
Scroom::Utils::ProgressInterfaceBroadcaster::Ptr progressBroadcaster
Definition: tiled-bitmap.hh:49
TiledBitmap::~TiledBitmap
~TiledBitmap() override
Definition: tiled-bitmap.cc:133
createTiledBitmap
TiledBitmapInterface::Ptr createTiledBitmap(int bitmapWidth, int bitmapHeight, LayerSpec const &ls)
Definition: tiled-bitmap.cc:28
TiledBitmap::layers
std::vector< Layer::Ptr > layers
Definition: tiled-bitmap.hh:42
scroominterface.hh
TiledBitmap::tileCreated
void tileCreated(const CompressedTile::Ptr &tile) override
Definition: tiled-bitmap.cc:317
Scroom::Utils::Rectangle::getLeft
value_type getLeft() const
Definition: rectangle.hh:110
TiledBitmap::ViewDataMap
std::map< ViewInterface::WeakPtr, TiledBitmapViewData::Ptr > ViewDataMap
Definition: tiled-bitmap.hh:36
TiledBitmap::viewDataMutex
boost::mutex viewDataMutex
Definition: tiled-bitmap.hh:44
pixelSizeFromZoom
double pixelSizeFromZoom(int zoom)
Definition: cairo-helpers.cc:112
Scroom::Utils::Rectangle::height
value_type height() const
Definition: rectangle.hh:131
drawRectangleContour
void drawRectangleContour(cairo_t *cr, Scroom::Utils::Rectangle< double > const &viewArea)
Definition: cairo-helpers.cc:31
LayerCoordinator::Ptr
boost::shared_ptr< LayerCoordinator > Ptr
Definition: layercoordinator.hh:33
TiledBitmap::TiledBitmap
TiledBitmap(const TiledBitmap &)=delete
CompressedTile::Ptr
boost::shared_ptr< CompressedTile > Ptr
Definition: tiledbitmaplayer.hh:108
TILESIZE
#define TILESIZE
Definition: tiledbitmaplayer.hh:28
TiledBitmap::progressInterface
ProgressInterface::Ptr progressInterface()
Definition: tiled-bitmap.hh:96
LayerOperations::Ptr
boost::shared_ptr< LayerOperations > Ptr
Definition: tiledbitmapinterface.hh:53
TiledBitmap::drawTile
static void drawTile(cairo_t *cr, const CompressedTile::Ptr &tile, const Scroom::Utils::Rectangle< double > &viewArea)
Definition: tiled-bitmap.cc:183
defect_message
#define defect_message(m)
Definition: assertions.hh:43
Layer::create
static Ptr create(int depth, int layerWidth, int layerHeight, int bpp, Scroom::MemoryBlobs::PageProvider::Ptr provider)
Definition: layer.cc:98
TiledBitmapInterface::Ptr
boost::shared_ptr< TiledBitmapInterface > Ptr
Definition: tiledbitmapinterface.hh:239
CompressedTileLine
std::vector< CompressedTile::Ptr > CompressedTileLine
Definition: tiledbitmaplayer.hh:237
Scroom::Utils::Rectangle::y
value_type y() const
Definition: rectangle.hh:127
TiledBitmap::getBottomLayer
Layer::Ptr getBottomLayer() override
Definition: tiled-bitmap.cc:181
TileInitialisationObserver
Definition: tiledbitmaplayer.hh:49
unused.hh
Scroom::Utils::Rectangle< int >
Viewable::Ptr
boost::shared_ptr< Viewable > Ptr
Definition: presentationinterface.hh:35
Scroom::Utils::ProgressInterfaceBroadcaster::Ptr
boost::shared_ptr< ProgressInterfaceBroadcaster > Ptr
Definition: progressinterfacehelpers.hh:131
interface.hh
TiledBitmap::tileFinished
void tileFinished(const CompressedTile::Ptr &tile) override
Definition: tiled-bitmap.cc:323
tileviewstate.hh
cairo-helpers.hh
semaphore.hh
TiledBitmap::close
void close(ViewInterface::WeakPtr vi) override
Definition: tiled-bitmap.cc:299
create
void create(NewPresentationInterface *interface)
Definition: loader.cc:175
TiledBitmap::operator=
TiledBitmap operator=(const TiledBitmap &)=delete
TiledBitmapInterface
Definition: tiledbitmapinterface.hh:236
Scroom::Utils::Point< int >