btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / servers / app / Canvas.h
blob986dceef257b2ef01f637a3008f0d4668450a878
1 /*
2 * Copyright (c) 2001-2015, Haiku, Inc.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Adi Oanca <adioanca@gmail.com>
8 * Axel Dörfler, axeld@pinc-software.de
9 * Stephan Aßmus <superstippi@gmx.de>
10 * Marcus Overhagen <marcus@overhagen.de>
11 * Adrien Destugues <pulkomandy@pulkomandy.tk>
12 * Julian Harnath <julian.harnath@rwth-aachen.de>
14 #ifndef CANVAS_H
15 #define CANVAS_H
18 #include <Point.h>
20 #include "SimpleTransform.h"
23 class AlphaMask;
24 class BGradient;
25 class BRegion;
26 class DrawingEngine;
27 class DrawState;
28 class IntPoint;
29 class IntRect;
30 class Layer;
31 class ServerPicture;
32 class shape_data;
35 class Canvas {
36 public:
37 Canvas();
38 Canvas(const DrawState& state);
39 virtual ~Canvas();
41 status_t InitCheck() const;
43 virtual void PushState();
44 virtual void PopState();
45 DrawState* CurrentState() const { return fDrawState; }
46 void SetDrawState(DrawState* newState);
48 void SetDrawingOrigin(BPoint origin);
49 BPoint DrawingOrigin() const;
51 void SetScale(float scale);
52 float Scale() const;
54 void SetUserClipping(const BRegion* region);
55 // region is expected in view coordinates
57 bool ClipToRect(BRect rect, bool inverse);
58 void ClipToShape(shape_data* shape, bool inverse);
60 void SetAlphaMask(AlphaMask* mask);
61 AlphaMask* GetAlphaMask() const;
63 virtual IntRect Bounds() const = 0;
65 SimpleTransform LocalToScreenTransform() const;
66 SimpleTransform ScreenToLocalTransform() const;
67 SimpleTransform PenToScreenTransform() const;
68 SimpleTransform PenToLocalTransform() const;
69 SimpleTransform ScreenToPenTransform() const;
71 void BlendLayer(Layer* layer);
73 virtual DrawingEngine* GetDrawingEngine() const = 0;
74 virtual ServerPicture* GetPicture(int32 token) const = 0;
75 virtual void RebuildClipping(bool deep) = 0;
76 virtual void ResyncDrawState() {};
77 virtual void UpdateCurrentDrawingRegion() {};
79 protected:
80 virtual void _LocalToScreenTransform(
81 SimpleTransform& transform) const = 0;
82 virtual void _ScreenToLocalTransform(
83 SimpleTransform& transform) const = 0;
85 protected:
86 DrawState* fDrawState;
90 class OffscreenCanvas : public Canvas {
91 public:
92 OffscreenCanvas(DrawingEngine* engine,
93 const DrawState& state, const IntRect& bounds);
94 virtual ~OffscreenCanvas();
96 virtual DrawingEngine* GetDrawingEngine() const { return fDrawingEngine; }
98 virtual void RebuildClipping(bool deep) { /* TODO */ }
99 virtual void ResyncDrawState();
100 virtual void UpdateCurrentDrawingRegion();
101 virtual ServerPicture* GetPicture(int32 token) const
102 { /* TODO */ return NULL; }
103 virtual IntRect Bounds() const;
105 protected:
106 virtual void _LocalToScreenTransform(SimpleTransform&) const {}
107 virtual void _ScreenToLocalTransform(SimpleTransform&) const {}
109 private:
110 DrawingEngine* fDrawingEngine;
111 BRegion fCurrentDrawingRegion;
112 IntRect fBounds;
116 #endif // CANVAS_H