PaintSurface.h
1/* Copyright (C) 2015 Marc Boris Duerner
2 Copyright (C) 2015 Laurentiu-Gheorghe Crisan
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 As a special exception, you may use this file as part of a free
10 software library without restriction. Specifically, if other files
11 instantiate templates or use macros or inline functions from this
12 file, or you compile this file and link it with other files to
13 produce an executable, this file does not by itself cause the
14 resulting executable to be covered by the GNU General Public
15 License. This exception does not however invalidate any other
16 reasons why the executable file might be covered by the GNU Library
17 General Public License.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 MA 02110-1301 USA
28*/
29
30#ifndef Pt_Gfx_PaintSurface_h
31#define Pt_Gfx_PaintSurface_h
32
33#include <Pt/Gfx/Api.h>
34#include <Pt/Gfx/ImageFormat.h>
35#include <Pt/Gfx/Scaling.h>
36#include <Pt/NonCopyable.h>
37#include <Pt/System/Path.h>
38
39#include <vector>
40
41namespace Pt {
42
43namespace Gfx {
44
45class PaintContext;
46
65class PT_GFX_API PaintSurface : private NonCopyable
66{
67 friend class PainterBase;
68 friend class PaintContext;
69 friend class Canvas;
70
71 protected:
75
76 public:
79 virtual ~PaintSurface();
80
83 const Gfx::ImageFormat& format() const;
84
87 const Gfx::SizeF& size() const;
88
91 const Scaling& scaling() const;
92
95 Canvas* getCanvas(Canvas* canvas);
96
99 void sync();
100
103 void finish();
104
105 protected:
109
110 protected:
113 virtual const Gfx::ImageFormat& onGetFormat() const = 0;
114
117 virtual const Gfx::SizeF& onGetSize() const = 0;
118
121 virtual const Scaling& onGetScaling() const = 0;
122
123 protected:
127
131
134 virtual void onReleaseCanvas() = 0;
135
138 virtual void onSync() = 0;
139
142 virtual void onFinish() = 0;
143
144 private:
147 void attachPainter(PainterBase& painter);
148
151 void detachPainter(PainterBase& painter);
152
155 void attachContext(PaintContext& context);
156
159 void detachContext(PaintContext& context);
160
161 private:
164 void onDetachCanvas(Canvas& canvas);
165
166 private:
167 Canvas* _canvas;
168 PainterBase* _painter;
169 PaintContext* _context;
170 void* _reserved;
171};
172
173} // namespace
174
175} // namespace
176
177#endif
Backend that executes drawing commands.
Definition Canvas.h:66
Runtime pixel format.
Definition ImageFormat.h:72
Active painting session on a surface.
Definition PaintContext.h:61
Canvas * getCanvas(Canvas *canvas)
Returns a canvas for backend drawing.
virtual const Gfx::SizeF & onGetSize() const =0
Returns the size in physical pixel.
virtual Gfx::Canvas * onCreateCanvas(Gfx::Canvas *reuse)=0
Creates a Canvas.
PaintSurface()
Default constructor.
virtual void onReleaseCanvas()=0
Releases the current Canvas.
virtual const Gfx::ImageFormat & onGetFormat() const =0
Returns the image format.
virtual ~PaintSurface()
Destructor.
virtual void onSync()=0
Synchronizes pending operations to the surface.
void finish()
Finishes painting to the surface.
void invalidate()
Invalidates the currently active paint canvas.
const Gfx::ImageFormat & format() const
Returns the image format.
const Scaling & scaling() const
Returns the scaling from logical to physical pixels.
const Gfx::SizeF & size() const
Returns the size in physical pixels.
virtual const Scaling & onGetScaling() const =0
Returns the scaling fro logical to physical pixels.
virtual Gfx::Canvas * onGetCanvas(Gfx::Canvas *reuse)
Returns a reusable canvas instance.
virtual void onFinish()=0
Finishes painting to the surface.
void sync()
Synchronizes pending operations to the surface.
Conversion between logical units and pixels.
Definition Scaling.h:52
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
Graphics and imaging services.
Definition Api-Argb32Image.h:12
Core module.
Definition Allocator.h:33