2 * Copyright 2009, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
6 * Michael Lotz <mmlr@mlotz.ch>
8 #ifndef REMOTE_DRAWING_ENGINE_H
9 #define REMOTE_DRAWING_ENGINE_H
11 #include "DrawingEngine.h"
12 #include "DrawState.h"
13 #include "RemoteHWInterface.h"
14 #include "ServerFont.h"
20 class BitmapDrawingEngine
;
23 class RemoteDrawingEngine
: public DrawingEngine
{
26 RemoteHWInterface
* interface
);
27 virtual ~RemoteDrawingEngine();
29 // HWInterfaceListener interface
30 virtual void FrameBufferChanged();
32 virtual void SetCopyToFrontEnabled(bool enabled
);
35 virtual status_t
ReadBitmap(ServerBitmap
* bitmap
,
36 bool drawCursor
, BRect bounds
);
38 // clipping for all drawing functions, passing a NULL region
39 // will remove any clipping (drawing allowed everywhere)
40 virtual void ConstrainClippingRegion(const BRegion
* region
);
42 virtual void SetDrawState(const DrawState
* state
,
43 int32 xOffset
= 0, int32 yOffset
= 0);
45 virtual void SetHighColor(const rgb_color
& color
);
46 virtual void SetLowColor(const rgb_color
& color
);
47 virtual void SetPenSize(float size
);
48 virtual void SetStrokeMode(cap_mode lineCap
,
49 join_mode joinMode
, float miterLimit
);
50 virtual void SetPattern(const struct pattern
& pattern
);
51 virtual void SetDrawingMode(drawing_mode mode
);
52 virtual void SetDrawingMode(drawing_mode mode
,
53 drawing_mode
& oldMode
);
54 virtual void SetBlendingMode(source_alpha srcAlpha
,
55 alpha_function alphaFunc
);
56 virtual void SetFont(const ServerFont
& font
);
57 virtual void SetFont(const DrawState
* state
);
58 virtual void SetTransform(const BAffineTransform
& transform
);
61 virtual void InvertRect(BRect rect
);
63 virtual void DrawBitmap(ServerBitmap
* bitmap
,
64 const BRect
& bitmapRect
,
65 const BRect
& viewRect
, uint32 options
= 0);
68 virtual void DrawArc(BRect rect
, const float& angle
,
69 const float& span
, bool filled
);
70 virtual void FillArc(BRect rect
, const float& angle
,
72 const BGradient
& gradient
);
74 virtual void DrawBezier(BPoint
* points
, bool filled
);
75 virtual void FillBezier(BPoint
* points
,
76 const BGradient
& gradient
);
78 virtual void DrawEllipse(BRect rect
, bool filled
);
79 virtual void FillEllipse(BRect rect
,
80 const BGradient
& gradient
);
82 virtual void DrawPolygon(BPoint
* pointList
, int32 numPoints
,
83 BRect bounds
, bool filled
, bool closed
);
84 virtual void FillPolygon(BPoint
* pointList
, int32 numPoints
,
85 BRect bounds
, const BGradient
& gradient
,
88 // these rgb_color versions are used internally by the server
89 virtual void StrokePoint(const BPoint
& point
,
90 const rgb_color
& color
);
91 virtual void StrokeRect(BRect rect
, const rgb_color
&color
);
92 virtual void FillRect(BRect rect
, const rgb_color
&color
);
93 virtual void FillRegion(BRegion
& region
,
94 const rgb_color
& color
);
96 virtual void StrokeRect(BRect rect
);
97 virtual void FillRect(BRect rect
);
98 virtual void FillRect(BRect rect
, const BGradient
& gradient
);
100 virtual void FillRegion(BRegion
& region
);
101 virtual void FillRegion(BRegion
& region
,
102 const BGradient
& gradient
);
104 virtual void DrawRoundRect(BRect rect
, float xRadius
,
105 float yRadius
, bool filled
);
106 virtual void FillRoundRect(BRect rect
, float xRadius
,
107 float yRadius
, const BGradient
& gradient
);
109 virtual void DrawShape(const BRect
& bounds
,
110 int32 opCount
, const uint32
* opList
,
111 int32 pointCount
, const BPoint
* pointList
,
113 const BPoint
& viewToScreenOffset
,
115 virtual void FillShape(const BRect
& bounds
,
116 int32 opCount
, const uint32
* opList
,
117 int32 pointCount
, const BPoint
* pointList
,
118 const BGradient
& gradient
,
119 const BPoint
& viewToScreenOffset
,
122 virtual void DrawTriangle(BPoint
* points
,
123 const BRect
& bounds
, bool filled
);
124 virtual void FillTriangle(BPoint
* points
,
126 const BGradient
& gradient
);
128 // these versions are used by the Decorator
129 virtual void StrokeLine(const BPoint
& start
,
130 const BPoint
& end
, const rgb_color
& color
);
131 virtual void StrokeLine(const BPoint
& start
,
133 virtual void StrokeLineArray(int32 numlines
,
134 const ViewLineArrayInfo
* data
);
136 // returns the pen position behind the (virtually) drawn string
137 virtual BPoint
DrawString(const char* string
, int32 length
,
139 escapement_delta
* delta
= NULL
);
140 virtual BPoint
DrawString(const char* string
, int32 length
,
141 const BPoint
* offsets
);
143 virtual float StringWidth(const char* string
, int32 length
,
144 escapement_delta
* delta
= NULL
);
146 // software rendering backend invoked by CopyRegion() for the sorted
148 virtual BRect
CopyRect(BRect rect
, int32 xOffset
,
149 int32 yOffset
) const;
152 status_t
_AddCallback();
154 static bool _DrawingEngineResult(void* cookie
,
155 RemoteMessage
& message
);
157 BRect
_BuildBounds(BPoint
* points
, int32 pointCount
);
158 status_t
_ExtractBitmapRegions(ServerBitmap
& bitmap
,
159 uint32 options
, const BRect
& bitmapRect
,
160 const BRect
& viewRect
, double xScale
,
161 double yScale
, BRegion
& region
,
162 UtilityBitmap
**& bitmaps
);
164 RemoteHWInterface
* fHWInterface
;
168 BRegion fClippingRegion
;
172 sem_id fResultNotify
;
173 BPoint fDrawStringResult
;
174 float fStringWidthResult
;
175 BBitmap
* fReadBitmapResult
;
177 BitmapDrawingEngine
* fBitmapDrawingEngine
;
180 #endif // REMOTE_DRAWING_ENGINE_H