2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_CanvasImpl.h
20 * @brief This is the header file for the _CanvasImpl class.
22 * This header file contains the declarations of the %_CanvasImpl class.
26 #ifndef _FGRP_INTERNAL_CANVASIMPL_H_
27 #define _FGRP_INTERNAL_CANVASIMPL_H_
30 #include <FBaseObject.h>
31 #include <FGrpCanvasCommon.h>
32 #include <FBaseColArrayListT.h>
35 namespace Tizen { namespace Base { namespace Collection
38 }}} // Tizen::Base::Collection
40 namespace Tizen { namespace Ui { namespace Animations
42 class _VisualElementCanvas;
43 }}} // Tizen::Ui::Animations
45 namespace Tizen { namespace Graphics
64 // * @enum BitmapDrawingQuality
66 // * Defines the bitmap drawing quality.
70 enum BitmapDrawingQuality
72 BITMAP_DRAWING_QUALITY_LOW, // The low-quality but high-performance
73 BITMAP_DRAWING_QUALITY_MID, // The mid-quality
74 BITMAP_DRAWING_QUALITY_HIGH // The high-quality but low-performance
83 /* For test, CR not approved */
86 BLENDING_MODE_CLEAR, // [0, 0]
87 BLENDING_MODE_SRC, // [Sa, Sc]
88 BLENDING_MODE_DST, // [Da, Dc]
89 BLENDING_MODE_SRC_OVER, // [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc]
90 BLENDING_MODE_DST_OVER, // [Sa + (1 - Sa)*Da, Rc = Dc + (1 - Da)*Sc]
91 BLENDING_MODE_SRC_IN, // [Sa * Da, Sc * Da]
92 BLENDING_MODE_DST_IN, // [Sa * Da, Sa * Dc]
93 BLENDING_MODE_SRC_OUT, // [Sa * (1 - Da), Sc * (1 - Da)]
94 BLENDING_MODE_DST_OUT, // [Da * (1 - Sa), Dc * (1 - Sa)]
95 BLENDING_MODE_SRC_ATOP, // [Da, Sc * Da + (1 - Sa) * Dc]
96 BLENDING_MODE_DST_ATOP, // [Sa, Sa * Dc + Sc * (1 - Da)]
97 BLENDING_MODE_DST_XOR, // [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
99 BLENDING_MODE_SATURATE, // Saturate(S + D)
100 // Pixman extension 1
101 BLENDING_MODE_MULTIPLY, // [Sa * Da, Sc * Dc]
102 BLENDING_MODE_SCREEN, // [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc]
103 BLENDING_MODE_OVERLAY,
104 BLENDING_MODE_DARKEN, // [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)]
105 BLENDING_MODE_LIGHTEN, // [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)]
106 // Pixman extension 2
107 BLENDING_MODE_COLOR_DODGE,
108 BLENDING_MODE_COLOR_BURN,
109 BLENDING_MODE_HARD_LIGHT,
110 BLENDING_MODE_SOFT_LIGHT,
111 BLENDING_MODE_DIFFERENCE,
112 BLENDING_MODE_EXCLUSION
115 class _OSP_EXPORT_ _CanvasImpl
116 : public Tizen::Base::Object
120 virtual ~_CanvasImpl(void);
122 result Construct(void);
123 result Construct(const Rectangle& rect);
124 result Construct(Handle windowHandle, const Rectangle& rect);
125 result Construct(const BufferInfo& bufferInfo);
127 bool IsConstructed(void) const;
130 result Clear(const Rectangle& rect);
132 result Copy(const Point& destPoint, const _CanvasImpl& srcCanvas, const Rectangle& srcRect);
133 result Copy(const Rectangle& destRect, const _CanvasImpl& srcCanvas, const Rectangle& srcRect);
134 result Copy(const Point& destPoint, const _CanvasImpl& srcCanvas, const Rectangle& srcRect, BlendingMode blendingMode);
136 result CopyEx(const Point& destPoint, const _CanvasImpl& srcCanvas, const Rectangle& srcRect);
138 LineStyle GetLineStyle(void) const;
139 int GetLineWidth(void) const;
140 result SetLineStyle(LineStyle style);
141 result SetLineWidth(int width);
143 result GetDashPattern(Tizen::Base::Collection::IListT<int>& pattern, int& offset);
144 result SetDashPattern(const Tizen::Base::Collection::IListT<int>& pattern, int offset);
146 result SetDrawingQuality(BitmapDrawingQuality quality);
147 BitmapDrawingQuality GetDrawingQuality(void) const;
149 result SetBlendingMode(BlendingMode blendingMode);
150 BlendingMode GetBlendingMode(void) const;
152 result GetPixel(const Point& point, Color& color) const;
154 result SetPixel(const Point& point);
155 result SetPixel(const FloatPoint& point); // floating-point version
157 result DrawRectangle(const Rectangle& rect);
158 result DrawRectangle(const FloatRectangle& rect); // floating-point version
159 result FillRectangle(const Color& color, const Rectangle& rect);
160 result FillRectangle(const Color& color, const FloatRectangle& rect); // floating-point version
162 result DrawRoundRectangle(const Rectangle& rect, const Dimension& arcDim);
163 result DrawRoundRectangle(const FloatRectangle& rect, const FloatDimension& arcDim); // floating-point version
164 result FillRoundRectangle(const Color& color, const Rectangle& rect, const Dimension& arcDim);
165 result FillRoundRectangle(const Color& color, const FloatRectangle& rect, const FloatDimension& arcDim); // floating-point version
167 result DrawEllipse(const Rectangle& rect);
168 result DrawEllipse(const FloatRectangle& rect); // floating-point version
169 result FillEllipse(const Color& color, const Rectangle& rect);
170 result FillEllipse(const Color& color, const FloatRectangle& rect); // floating-point version
172 result DrawArc(const Rectangle& rect, int startAngle, int endAngle, ArcStyle arcStyle);
173 result DrawArc(const FloatRectangle& rect, float startAngle, float endAngle, ArcStyle arcStyle); // floating-point version
175 result DrawTriangle(const Point& point1, const Point& point2, const Point& point3);
176 result DrawTriangle(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& point3); // floating-point version
177 result FillTriangle(const Color& color, const Point& point1, const Point& point2, const Point& point3);
178 result FillTriangle(const Color& color, const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& point3); // floating-point version
180 result DrawLine(const Point& point1, const Point& point2);
181 result DrawLine(const FloatPoint& point1, const FloatPoint& point2); // floating-point version
182 result DrawPolyline(const Tizen::Base::Collection::IList& points);
183 result DrawPolygon(const Tizen::Base::Collection::IList& points);
184 result FillPolygon(const Color& color, const Tizen::Base::Collection::IList& points);
186 result SetFont(const Font& font);
187 Font* GetFontN(void);
189 void SetTextOrigin(TextOrigin origin);
191 result DrawText(const Point& point, const Tizen::Base::String& text);
192 result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length);
193 result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, const Color& outlineColor);
194 result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor);
195 result DrawText(const Point& point, const EnrichedText& enrichedText);
197 result DrawBitmap(const Point& point, const _BitmapImpl& bitmap);
198 result DrawBitmap(const FloatPoint& point, const _BitmapImpl& bitmap); // floating-point version
199 result DrawBitmap(const Rectangle& rect, const _BitmapImpl& bitmap);
200 result DrawBitmap(const FloatRectangle& rect, const _BitmapImpl& bitmap); // floating-point version
201 result DrawBitmap(const Rectangle& destRect, const _BitmapImpl& srcBitmap, const Rectangle& srcRect);
202 result DrawBitmap(const FloatRectangle& destRect, const _BitmapImpl& srcBitmap, const FloatRectangle& srcRect); // floating-point version
203 result DrawBitmap(const Point& point, const _BitmapImpl& bitmap, FlipDirection dir);
204 result DrawBitmap(const FloatPoint& point, const _BitmapImpl& bitmap, FlipDirection dir); // floating-point version
205 result DrawBitmap(const Point& point, const _BitmapImpl& bitmap, const Point& pivot, int degree);
206 result DrawBitmap(const FloatPoint& point, const _BitmapImpl& bitmap, const FloatPoint& pivot, float degree); // floating-point version
207 result DrawNinePatchedBitmap(const Rectangle& rect, const _BitmapImpl& bitmap);
208 result DrawNinePatchedBitmap(const FloatRectangle& rect, const _BitmapImpl& bitmap); // floating-point version
211 result Show(const Rectangle& rect);
213 Rectangle GetBounds(void) const;
215 result SetClipBounds(const Rectangle& rect);
216 Rectangle GetClipBounds(void) const;
218 result Lock(BufferInfo& info, long timeout = INFINITE);
221 void SetForegroundColor(const Color& color);
222 Color GetForegroundColor(void) const;
223 void SetBackgroundColor(const Color& color);
224 Color GetBackgroundColor(void) const;
226 result SetPosition(const Point& point);
227 result SetPosition(int x, int y);
229 Canvas* GetSubCanvasN(const Rectangle& subRegion) const;
232 * Sets a priority font to the %_CanvasImpl. This font have priority at user font which is installed through _CanvasImpl::SetFont()
234 * @return An error code
235 * @param[in] pFont The font @n
236 * It should be constructed before being passed to this method.
237 * @exception E_SUCCESS The method is successful.
238 * @exception E_INVALID_ARG The specified input parameter is invalid.
239 * @exception E_OPERATION_FAILED This instance is in an invalid state.
241 result SetPriorityFont(const Font& font);
244 * Resets a priority font
246 void ResetPriorityFont(void);
248 // for performance test
249 void SetStableRenderer(bool isStable);
251 // for removing the Ui dependency
252 static void SetFrameInfoCallback(void* (*pGetDefaultFrameNativeHandle)(void), void* (*pGetDefaultFrameHandle)(void));
253 static void SetThemeInfoCallback(Color (*pGetDefaultForegroundColor)(void), Color (*pGetDefaultBackgroundColor)(void));
255 static _CanvasImpl* GetInstance(Canvas& canvas);
256 static const _CanvasImpl* GetInstance(const Canvas& canvas);
259 _CanvasImpl(const _CanvasImpl& canvas);
260 _CanvasImpl& operator =(const _CanvasImpl& value);
263 _Canvas* _pNativeCanvas;
264 struct _CanvasCoordHolder* _pCoordHolder;
266 Font* _pPriorityFont;
267 Tizen::Base::Collection::ArrayListT<int> _dashList;
270 friend class _Canvas;
271 friend class _CanvasImplPrivate;
272 friend class _BitmapImpl;
273 friend class TextElement;
274 friend class Tizen::Ui::Animations::_VisualElementCanvas;
278 }} // Tizen::Graphics
280 #endif // _FGRP_INTERNAL_CANVASIMPL_H_