2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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.cpp
20 * @brief This is the implementation file for _CanvasImpl class.
27 #include <unique_ptr.h>
29 #include <FBaseSysLog.h>
31 #include "FGrp_BufferInfoImpl.h"
32 #include "FGrp_Callback.h"
33 #include "FGrp_CanvasImpl.h"
34 #include "FGrp_BitmapUtil.h"
35 #include "FGrp_Bitmap.h"
36 #include "FGrp_CanvasCoordHolder.h"
37 #include "FGrp_Canvas.h"
38 #include "FGrp_CanvasImplPrivate.h"
39 #include "FGrp_FontUtil.h"
40 #include "FGrp_EnrichedTextImpl.h"
41 #include "util/FGrp_Util.h"
42 #include "FGrp_TextTextObject.h"
44 using namespace Tizen::Base;
45 using namespace Tizen::Base::Collection;
48 #define EXTRACT_CANVASEX(pVar, canvas) Tizen::Graphics::_Canvas * pVar = canvas._pNativeCanvas
49 #define EXTRACT_BITMAPEX(pVar, bitmap) Tizen::Graphics::_Bitmap * pVar = Tizen::Graphics::_GetBitmapEx(bitmap)
50 #define EXTRACT_FONTEX(pVar, font) Tizen::Graphics::_Font * pVar = Tizen::Graphics::_GetFontEx(font)
51 #define EXTRACT_SCALED_BITMAPEX(pVar, bitmap) Tizen::Graphics::_Bitmap * pVar = Tizen::Graphics::_GetScaledBitmapEx(bitmap)
53 #define IsSucceeded(X) (!IsFailed(X))
55 #define INSTANCE_IS_VALID (this && (this->_pNativeCanvas && this->_pNativeCanvas->IsValid()))
56 #define CANVAS_IS_VALID(canvas) (&canvas && (canvas._pNativeCanvas && canvas._pNativeCanvas->IsValid()))
58 #define BITMAP_IS_VALID(bitmap) (&bitmap && const_cast<_BitmapImpl*>(&bitmap)->__CheckValidity())
64 // retrieving bounds rectangle which has (0,0,w,h).
65 Tizen::Graphics::Rectangle
66 _GetBoundsRel(const Tizen::Graphics::_CanvasImpl& canvas)
68 Tizen::Graphics::Rectangle rect = canvas.GetBounds();
75 Tizen::Graphics::FloatRectangle
76 _GetBoundsRelF(const Tizen::Graphics::_CanvasImpl& canvas)
78 Tizen::Graphics::FloatRectangle rectF = canvas.GetBoundsF();
87 _ExpandClippingAreaForLineWidth(Tizen::Graphics::Rectangle& rtCanvas, T lineWidth)
89 int lineWidthHalf = (lineWidth + 1) / 2;
91 rtCanvas.x -= lineWidthHalf;
92 rtCanvas.y -= lineWidthHalf;
93 rtCanvas.width += lineWidthHalf * 2;
94 rtCanvas.height += lineWidthHalf * 2;
99 namespace Tizen { namespace Graphics { namespace _Util
103 inline Tizen::Graphics::Point Convert<Tizen::Graphics::FloatPoint, Tizen::Graphics::Point>(const Tizen::Graphics::FloatPoint& point)
105 return Tizen::Graphics::Point(int(point.x), int(point.y));
109 inline Tizen::Graphics::Rectangle Convert<Tizen::Graphics::FloatRectangle, Tizen::Graphics::Rectangle>(const Tizen::Graphics::FloatRectangle& rect)
111 return Tizen::Graphics::Rectangle(int(rect.x), int(rect.y), int(rect.width), int(rect.height));
115 _Util::Point<double>* Convert<Tizen::Base::Collection::IList, _Util::Point<double>*>(const Tizen::Base::Collection::IList& points)
117 int count = points.GetCount();
119 std::unique_ptr<_Util::Point<double>[]> pPointArray(new (std::nothrow) _Util::Point<double>[count]);
121 SysTryReturn(NID_GRP, pPointArray, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
124 for (int i = 0; i < count; i++)
126 const Tizen::Graphics::Point* pPoint = dynamic_cast <const Tizen::Graphics::Point*>(points.GetAt(i));
130 pPointArray[i].x = double(pPoint->x);
131 pPointArray[i].y = double(pPoint->y);
135 const Tizen::Graphics::FloatPoint* pFloatPoint = dynamic_cast <const Tizen::Graphics::FloatPoint*>(points.GetAt(i));
139 pPointArray[i].x = double(pFloatPoint->x);
140 pPointArray[i].y = double(pFloatPoint->y);
150 return pPointArray.release();
153 } // Tizen::Graphics::_Util
155 }} // Tizen::Graphics
157 ////////////////////////////////////////////////////////////////////////////////
160 namespace Tizen { namespace Graphics
163 _CanvasImpl::_CanvasImpl(void)
170 , _pShowCallbackFunc(null)
171 , _pShowCallbackParam(null)
173 _pNativeCanvas = new (std::nothrow) _Canvas;
174 _pCoordHolder = new (std::nothrow) _CanvasCoordHolder;
176 if (_pNativeCanvas == null || _pCoordHolder == null)
178 delete _pCoordHolder;
179 delete _pNativeCanvas;
181 _pCoordHolder = null;
182 _pNativeCanvas = null;
185 _Util::CarveMagicKey(*this, _magicKey);
188 _CanvasImpl::~_CanvasImpl(void)
196 delete _pCoordHolder;
197 delete _pNativeCanvas;
199 _Util::EraseMagicKey(*this, _magicKey);
203 _CanvasImpl::Construct(void)
205 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
207 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
209 result r = this->_pNativeCanvas->Construct();
213 Rectangle pcRect = this->_pNativeCanvas->GetBounds();
215 _Util::Rectangle<int> pcUtilRect = { pcRect.x, pcRect.y, pcRect.width, pcRect.height };
217 this->_pCoordHolder->ResetFromPc(pcUtilRect);
224 _CanvasImpl::Construct(const Rectangle& vcRect)
226 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
228 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
230 SysTryReturnResult(NID_GRP, vcRect.width > 0 && vcRect.height > 0, E_OUT_OF_RANGE,
231 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
234 _Util::Rectangle<int> vcUtilRect = { vcRect.x, vcRect.y, vcRect.width, vcRect.height };
236 this->_pCoordHolder->ResetFromVc(vcUtilRect);
238 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
240 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
241 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
243 return this->_pNativeCanvas->Construct(pcRect);
247 _CanvasImpl::Construct(const BufferInfo& bufferInfo)
249 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
251 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
253 SysTryReturnResult(NID_GRP, (bufferInfo.width > 0) && (bufferInfo.height > 0) && (bufferInfo.pitch > 0)
255 , "Invalid argument (BufferInfo::width = %d, BufferInfo::height = %d, BufferInfo::pitch = %d)"
256 , bufferInfo.width, bufferInfo.height, bufferInfo.pitch);
258 SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel > 0
260 , "Invalid argument (BufferInfo::bitsPerPixel = %d)"
261 , bufferInfo.bitsPerPixel);
263 SysTryReturnResult(NID_GRP, (bufferInfo.pixelFormat > PIXEL_FORMAT_MIN) && (bufferInfo.pixelFormat < PIXEL_FORMAT_MAX)
265 , "Invalid argument (BufferInfo::pixelFormat = %d)"
266 , bufferInfo.pixelFormat);
268 SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel == 32
269 , E_UNSUPPORTED_FORMAT
270 , "Unsupported format (BufferInfo::bitsPerPixel = %d)"
271 , bufferInfo.bitsPerPixel);
273 SysTryReturnResult(NID_GRP, bufferInfo.pixelFormat == PIXEL_FORMAT_ARGB8888
274 , E_UNSUPPORTED_FORMAT
275 , "Unsupported format (BufferInfo::pixelFormat = %d)"
276 , bufferInfo.pixelFormat);
278 if (bufferInfo.pPixels == null)
280 const _BufferInfoImpl* pBufferInfoImpl = _BufferInfoImpl::GetInstance(bufferInfo);
284 Handle handle = pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE);
286 if (handle != 0) // not INVALID_HANDLE
288 result r = this->Construct(handle);
290 // OUT_OF_RANGE does not occur
291 SysTryReturn(NID_GRP, (r == E_SUCCESS) && this->IsConstructed(), r, r, "[%s] Propagating.", GetErrorMessage(r));
293 _Util::Rectangle<int> pcUtilRect = { 0, 0, this->_pNativeCanvas->__pSurface->GetWidth(), this->_pNativeCanvas->__pSurface->GetHeight() };
295 this->_pCoordHolder->ResetFromPc(pcUtilRect);
301 SysTryReturnResult(NID_GRP, false
303 , "Invalid argument (BufferInfo::pPixels = null)");
307 result r = this->_pNativeCanvas->Construct(bufferInfo);
309 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
311 _Util::Rectangle<int> pcUtilRect = { 0, 0, this->_pNativeCanvas->__pSurface->GetWidth(), this->_pNativeCanvas->__pSurface->GetHeight() };
313 this->_pCoordHolder->ResetFromPc(pcUtilRect);
322 _CanvasImpl::Construct(Handle windowHandle)
324 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
326 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
328 return this->_pNativeCanvas->Construct(windowHandle);
332 _CanvasImpl::Construct(Handle windowHandle, const Rectangle& vcRect)
334 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
336 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
338 SysTryReturnResult(NID_GRP, vcRect.width >= 0 && vcRect.height >= 0, E_OUT_OF_RANGE,
339 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
342 _Util::Rectangle<int> vcUtilRect = { vcRect.x, vcRect.y, vcRect.width, vcRect.height };
344 this->_pCoordHolder->ResetFromVc(vcUtilRect);
348 pcRect.x = _ResUtil::ConvertToPhyCoord(vcRect.x);
349 pcRect.y = _ResUtil::ConvertToPhyCoord(vcRect.y);
350 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
351 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
353 return this->_pNativeCanvas->Construct(windowHandle, pcRect);
357 _CanvasImpl::Construct(const FloatRectangle& vcRectF)
359 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
361 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
363 SysTryReturnResult(NID_GRP, vcRectF.width > 0.0f && vcRectF.height > 0.0f, E_OUT_OF_RANGE,
364 "The given rectangle(width:%f,height:%f) is out of range.", vcRectF.width,
367 _Util::Rectangle<float> vcUtilRectF = { vcRectF.x, vcRectF.y, vcRectF.width, vcRectF.height };
369 this->_pCoordHolder->ResetFromVc(vcUtilRectF);
371 if (_ResUtil::NeedToConvertCoord())
375 pcRect.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.x));
376 pcRect.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.y));
377 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
378 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
380 return this->_pNativeCanvas->Construct(pcRect);
386 vcRect.x = this->_pCoordHolder->canvasPos.vcInt.x;
387 vcRect.y = this->_pCoordHolder->canvasPos.vcInt.y;
388 vcRect.width = this->_pCoordHolder->canvasSize.vcInt.w;
389 vcRect.height = this->_pCoordHolder->canvasSize.vcInt.h;
391 return this->_pNativeCanvas->Construct(vcRect);
396 _CanvasImpl::Construct(Handle windowHandle, const FloatRectangle& vcRectF)
398 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
400 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed.");
402 SysTryReturnResult(NID_GRP, vcRectF.width >= 0.0f && vcRectF.height >= 0.0f, E_OUT_OF_RANGE,
403 "The given rectangle(width:%f,height:%f) is out of range.", vcRectF.width,
406 _Util::Rectangle<float> vcUtilRectF = { vcRectF.x, vcRectF.y, vcRectF.width, vcRectF.height };
408 this->_pCoordHolder->ResetFromVc(vcUtilRectF);
412 pcRect.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.x));
413 pcRect.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.y));
414 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
415 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
417 return this->_pNativeCanvas->Construct(windowHandle, pcRect);
421 _CanvasImpl::IsConstructed(void) const
423 return (this->_pNativeCanvas != null) && this->_pNativeCanvas->IsValid();
427 _CanvasImpl::Clear(void)
429 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
431 return this->_pNativeCanvas->Clear();
435 _CanvasImpl::Clear(const Rectangle& vcRect)
437 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
439 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
440 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE,
441 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
444 if ((vcRect.width == 0) || (vcRect.height == 0))
449 Rectangle rtCanvas = _GetBoundsRel(*this);
451 if (rtCanvas.IsEmpty())
456 result r = _Util::Validate(vcRect, rtCanvas);
458 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
460 if (_ResUtil::NeedToConvertCoord())
462 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
464 return this->_pNativeCanvas->Clear(pcRect);
468 return this->_pNativeCanvas->Clear(vcRect);
473 _CanvasImpl::Clear(const FloatRectangle& vcRectF)
475 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
477 SysTryReturnResult(NID_GRP, &vcRectF, E_OUT_OF_RANGE, "The given rectangle is invalid.");
478 SysTryReturnResult(NID_GRP, (vcRectF.width >= 0.0f) && (vcRectF.height >= 0.0f), E_OUT_OF_RANGE,
479 "The given rectangle(width:%f,height:%f) is out of range.", vcRectF.width,
482 if ((vcRectF.width == 0.0f) || (vcRectF.height == 0.0f))
487 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
489 if (rtCanvasF.IsEmpty())
494 result r = _Util::Validate(vcRectF, rtCanvasF);
496 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
498 if (_ResUtil::NeedToConvertCoord())
500 FloatRectangle pcRectF = _ResUtil::ConvertToPhyCoord(vcRectF);
501 Rectangle pcRect(_FloatToIntForPos(pcRectF.x), _FloatToIntForPos(pcRectF.y), _FloatToIntForSize(pcRectF.width), _FloatToIntForSize(pcRectF.height));
503 return this->_pNativeCanvas->Clear(pcRect);
507 Rectangle vcRect(_FloatToIntForPos(vcRectF.x), _FloatToIntForPos(vcRectF.y), _FloatToIntForSize(vcRectF.width), _FloatToIntForSize(vcRectF.height));
509 return this->_pNativeCanvas->Clear(vcRect);
514 _CanvasImpl::Copy(const Point& vcDestPoint, const _CanvasImpl& canvas, const Rectangle& vcSrcRect)
516 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
518 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid.");
520 Rectangle srcRectCanvas = _GetBoundsRel(canvas);
522 if (srcRectCanvas.IsEmpty())
527 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
529 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
531 // check if destRect is in this canvas.
532 Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height);
533 Rectangle destRectCanvas = _GetBoundsRel(*this);
535 if (destRectCanvas.IsEmpty())
540 r = _Util::Validate(destRect, destRectCanvas);
542 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
544 EXTRACT_CANVASEX(_pNativeCanvas, canvas);
547 if (_ResUtil::NeedToConvertCoord())
549 Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint);
550 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
552 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect);
556 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect);
561 _CanvasImpl::Copy(const FloatPoint& vcDestPointF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF)
563 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
565 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
567 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
569 if (srcRectCanvasF.IsEmpty())
574 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
576 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
578 // check if destRect is in this canvas.
579 FloatRectangle destRectF(vcDestPointF.x, vcDestPointF.y, vcSrcRectF.width, vcSrcRectF.height);
580 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
582 if (destRectCanvasF.IsEmpty())
587 r = _Util::Validate(destRectF, destRectCanvasF);
589 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
591 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
593 if (_ResUtil::NeedToConvertCoord())
595 FloatPoint pcDestPointF = _ResUtil::ConvertToPhyCoord(vcDestPointF);
596 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
598 Point pcDestPoint(_FloatToIntForPos(pcDestPointF.x), _FloatToIntForPos(pcDestPointF.y));
599 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
601 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect);
605 Point vcDestPoint(_FloatToIntForPos(vcDestPointF.x), _FloatToIntForPos(vcDestPointF.y));
606 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
608 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect);
613 _CanvasImpl::Copy(const Rectangle& vcDestRect, const _CanvasImpl& canvas, const Rectangle& vcSrcRect)
615 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
617 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid.");
619 // check if srcRect is in source canvas.
620 Rectangle srcRectCanvas = _GetBoundsRel(canvas);
622 if (srcRectCanvas.IsEmpty())
627 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
629 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
631 // check if destRect is in this canvas.
632 Rectangle destRectCanvas = _GetBoundsRel(*this);
634 if (destRectCanvas.IsEmpty())
639 r = _Util::Validate(vcDestRect, destRectCanvas);
641 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
643 EXTRACT_CANVASEX(_pNativeCanvas, canvas);
645 if (_ResUtil::NeedToConvertCoord())
647 Rectangle pcDestRect = _ResUtil::ConvertToPhyCoord(vcDestRect);
648 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
650 return this->_pNativeCanvas->Copy(pcDestRect, *_pNativeCanvas, pcSrcRect);
654 return this->_pNativeCanvas->Copy(vcDestRect, *_pNativeCanvas, vcSrcRect);
659 _CanvasImpl::Copy(const FloatRectangle& vcDestRectF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF)
661 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
663 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
665 // check if srcRect is in source canvas.
666 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
668 if (srcRectCanvasF.IsEmpty())
673 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
675 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
677 // check if destRect is in this canvas.
678 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
680 if (destRectCanvasF.IsEmpty())
685 r = _Util::Validate(vcDestRectF, destRectCanvasF);
687 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
689 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
691 if (_ResUtil::NeedToConvertCoord())
693 FloatRectangle pcDestRectF = _ResUtil::ConvertToPhyCoord(vcDestRectF);
694 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
696 Rectangle pcDestRect(_FloatToIntForPos(pcDestRectF.x), _FloatToIntForPos(pcDestRectF.y), _FloatToIntForSize(pcDestRectF.width), _FloatToIntForSize(pcDestRectF.height));
697 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
699 return this->_pNativeCanvas->Copy(pcDestRect, *_pNativeCanvas, pcSrcRect);
703 Rectangle vcDestRect(_FloatToIntForPos(vcDestRectF.x), _FloatToIntForPos(vcDestRectF.y), _FloatToIntForSize(vcDestRectF.width), _FloatToIntForSize(vcDestRectF.height));
704 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
706 return this->_pNativeCanvas->Copy(vcDestRect, *_pNativeCanvas, vcSrcRect);
711 _CanvasImpl::Copy(const Point& vcDestPoint, const _CanvasImpl& canvas, const Rectangle& vcSrcRect, CompositeMode compositeMode)
713 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
715 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid.");
717 switch (compositeMode)
719 case COMPOSITE_MODE_CLEAR:
720 case COMPOSITE_MODE_SRC:
721 case COMPOSITE_MODE_DST:
722 case COMPOSITE_MODE_SRC_OVER:
723 case COMPOSITE_MODE_DST_OVER:
724 case COMPOSITE_MODE_SRC_IN:
725 case COMPOSITE_MODE_DST_IN:
726 case COMPOSITE_MODE_SRC_OUT:
727 case COMPOSITE_MODE_DST_OUT:
728 case COMPOSITE_MODE_SRC_ATOP:
729 case COMPOSITE_MODE_DST_ATOP:
730 case COMPOSITE_MODE_DST_XOR:
731 case COMPOSITE_MODE_ADD:
732 case COMPOSITE_MODE_SATURATE:
733 case COMPOSITE_MODE_MULTIPLY:
734 case COMPOSITE_MODE_SCREEN:
735 case COMPOSITE_MODE_OVERLAY:
736 case COMPOSITE_MODE_DARKEN:
737 case COMPOSITE_MODE_LIGHTEN:
740 SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "The specified composite mode is invalid.");
743 Rectangle srcRectCanvas = _GetBoundsRel(canvas);
745 if (srcRectCanvas.IsEmpty())
750 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
752 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
754 // check if destRect is in this canvas.
755 Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height);
756 Rectangle destRectCanvas = _GetBoundsRel(*this);
758 if (destRectCanvas.IsEmpty())
763 r = _Util::Validate(destRect, destRectCanvas);
765 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
767 EXTRACT_CANVASEX(_pNativeCanvas, canvas);
770 if (_ResUtil::NeedToConvertCoord())
772 Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint);
773 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
775 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect, compositeMode);
779 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect, compositeMode);
784 _CanvasImpl::Copy(const FloatPoint& vcDestPointF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF, CompositeMode compositeMode)
786 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
788 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
790 switch (compositeMode)
792 case COMPOSITE_MODE_CLEAR:
793 case COMPOSITE_MODE_SRC:
794 case COMPOSITE_MODE_DST:
795 case COMPOSITE_MODE_SRC_OVER:
796 case COMPOSITE_MODE_DST_OVER:
797 case COMPOSITE_MODE_SRC_IN:
798 case COMPOSITE_MODE_DST_IN:
799 case COMPOSITE_MODE_SRC_OUT:
800 case COMPOSITE_MODE_DST_OUT:
801 case COMPOSITE_MODE_SRC_ATOP:
802 case COMPOSITE_MODE_DST_ATOP:
803 case COMPOSITE_MODE_DST_XOR:
804 case COMPOSITE_MODE_ADD:
805 case COMPOSITE_MODE_SATURATE:
806 case COMPOSITE_MODE_MULTIPLY:
807 case COMPOSITE_MODE_SCREEN:
808 case COMPOSITE_MODE_OVERLAY:
809 case COMPOSITE_MODE_DARKEN:
810 case COMPOSITE_MODE_LIGHTEN:
813 SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "The specified composite mode is invalid.");
816 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
818 if (srcRectCanvasF.IsEmpty())
823 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
825 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
827 // check if destRect is in this canvas.
828 FloatRectangle destRectF(vcDestPointF.x, vcDestPointF.y, vcSrcRectF.width, vcSrcRectF.height);
829 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
831 if (destRectCanvasF.IsEmpty())
836 r = _Util::Validate(destRectF, destRectCanvasF);
838 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
840 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
843 if (_ResUtil::NeedToConvertCoord())
845 FloatPoint pcDestPointF = _ResUtil::ConvertToPhyCoord(vcDestPointF);
846 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
848 Point pcDestPoint(_FloatToIntForPos(pcDestPointF.x), _FloatToIntForPos(pcDestPointF.y));
849 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
851 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect, compositeMode);
855 Point vcDestPoint(_FloatToIntForPos(vcDestPointF.x), _FloatToIntForPos(vcDestPointF.y));
856 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
858 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect, compositeMode);
863 _CanvasImpl::CopyEx(const Point& vcDestPoint, const _CanvasImpl& srcCanvas, const Rectangle& vcSrcRect)
865 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
867 if (this != &srcCanvas)
869 return this->Copy(vcDestPoint, srcCanvas, vcSrcRect);
872 // validity check as _CanvasImpl::Copy()
873 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
875 Rectangle srcRectCanvas = _GetBoundsRel(srcCanvas);
877 if (srcRectCanvas.IsEmpty())
882 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
884 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
886 // check if destRect is in this canvas.
887 Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height);
888 Rectangle destRectCanvas = _GetBoundsRel(*this);
890 if (destRectCanvas.IsEmpty())
895 r = _Util::Validate(destRect, destRectCanvas);
897 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
899 int pixelPerLine = 0;
902 BufferInfo bufferInfo;
904 result r = this->_pNativeCanvas->Lock(bufferInfo);
907 SysTryReturn(NID_GRP, r == E_SUCCESS, r, E_SYSTEM, "[] ");
909 this->_pNativeCanvas->Unlock();
911 pixelPerLine = bufferInfo.pitch / (bufferInfo.bitsPerPixel / 8);
914 //?? Auto-scaling should be applied to vc**** parameters later
915 int sourDistance = vcSrcRect.y * pixelPerLine + vcSrcRect.x;
916 int destDistance = vcDestPoint.y * pixelPerLine + vcDestPoint.x;
918 typedef result (_Canvas::* FnCopy)(const Point&, const _Canvas&, const Rectangle&);
919 FnCopy fnCopy = (destDistance < sourDistance) ? FnCopy(&_Canvas::Copy) : FnCopy(&_Canvas::CopyReverse);
923 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
925 if (_ResUtil::NeedToConvertCoord())
927 Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint);
928 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
930 return (this->_pNativeCanvas->*fnCopy)(pcDestPoint, *_pNativeCanvas, pcSrcRect);
934 return (this->_pNativeCanvas->*fnCopy)(vcDestPoint, *_pNativeCanvas, vcSrcRect);
943 _CanvasImpl::CopyEx(const FloatPoint& vcDestPointF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF)
945 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
947 if (this != &srcCanvas)
949 return this->Copy(vcDestPointF, srcCanvas, vcSrcRectF);
952 // validity check as _CanvasImpl::Copy()
953 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
955 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
957 if (srcRectCanvasF.IsEmpty())
962 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
964 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
966 // check if destRect is in this canvas.
967 FloatRectangle destRectF(vcDestPointF.x, vcDestPointF.y, vcSrcRectF.width, vcSrcRectF.height);
968 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
970 if (destRectCanvasF.IsEmpty())
975 r = _Util::Validate(destRectF, destRectCanvasF);
977 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
979 int pixelPerLine = 0;
982 BufferInfo bufferInfo;
984 result r = this->_pNativeCanvas->Lock(bufferInfo);
987 SysTryReturn(NID_GRP, r == E_SUCCESS, r, E_SYSTEM, "[] ");
989 this->_pNativeCanvas->Unlock();
991 pixelPerLine = bufferInfo.pitch / (bufferInfo.bitsPerPixel / 8);
994 Point vcDestPoint(_FloatToIntForPos(vcDestPointF.x), _FloatToIntForPos(vcDestPointF.y));
995 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
997 //?? Auto-scaling should be applied to vc**** parameters later
998 int sourDistance = vcSrcRect.y * pixelPerLine + vcSrcRect.x;
999 int destDistance = vcDestPoint.y * pixelPerLine + vcDestPoint.x;
1001 typedef result (_Canvas::* FnCopy)(const Point&, const _Canvas&, const Rectangle&);
1002 FnCopy fnCopyF = (destDistance < sourDistance) ? FnCopy(&_Canvas::Copy) : FnCopy(&_Canvas::CopyReverse);
1006 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
1008 if (_ResUtil::NeedToConvertCoord())
1010 FloatPoint pcDestPointF = _ResUtil::ConvertToPhyCoord(vcDestPointF);
1011 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
1013 Point pcDestPoint(_FloatToIntForPos(pcDestPointF.x), _FloatToIntForPos(pcDestPointF.y));
1014 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
1016 return (this->_pNativeCanvas->*fnCopyF)(pcDestPoint, *_pNativeCanvas, pcSrcRect);
1020 return (this->_pNativeCanvas->*fnCopyF)(vcDestPoint, *_pNativeCanvas, vcSrcRect);
1029 _CanvasImpl::DrawArc(const FloatRectangle& vcBounds, float startAngle, float endAngle, ArcStyle arcStyle)
1031 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1032 SysTryReturnResult(NID_GRP, ARC_STYLE_MIN < arcStyle && arcStyle < ARC_STYLE_MAX, E_INVALID_ARG, "The invalid arc type(%d) is given.", arcStyle);
1033 SysTryReturnResult(NID_GRP, &vcBounds, E_INVALID_ARG, "The given rectangle is invalid.");
1034 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0.0f) && (vcBounds.height >= 0.0f), E_OUT_OF_RANGE,
1035 "The given rectangle(width:%f,height:%f) is out of range.", vcBounds.width, vcBounds.height);
1037 return _CanvasImplPrivate::DrawArc(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcBounds), double(startAngle), double(endAngle), arcStyle);
1041 _CanvasImpl::DrawArc(const Rectangle& vcBounds, int startAngle, int endAngle, ArcStyle arcStyle)
1043 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1044 SysTryReturnResult(NID_GRP, ARC_STYLE_MIN < arcStyle && arcStyle < ARC_STYLE_MAX, E_INVALID_ARG, "The invalid arc type(%d) is given.", arcStyle);
1045 SysTryReturnResult(NID_GRP, &vcBounds, E_INVALID_ARG, "The given rectangle is invalid.");
1046 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE,
1047 "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height);
1049 return _CanvasImplPrivate::DrawArc(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcBounds), double(startAngle), double(endAngle), arcStyle);
1053 _CanvasImpl::DrawBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap)
1055 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1057 return this->DrawBitmap(FloatRectangle(float(vcRect.x), float(vcRect.y), float(vcRect.width), float(vcRect.height)), bitmap);
1061 _CanvasImpl::DrawBitmap(const FloatRectangle& vcRectF, const _BitmapImpl& bitmap)
1063 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1065 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1066 SysTryReturnResult(NID_GRP, &vcRectF, E_INVALID_ARG, "The source rectangle is invalid.");
1068 // @ykahn vcRectF.width in [bitmap.GetActualWidth()..bitmap.GetWidthF()]
1069 if (vcRectF.width == bitmap.GetWidthF() && vcRectF.height == bitmap.GetHeightF())
1071 return this->DrawBitmap(FloatPoint(vcRectF.x, vcRectF.y), bitmap);
1074 if (_FloatToIntForSize(vcRectF.width) == bitmap.GetWidth() && _FloatToIntForSize(vcRectF.height) == bitmap.GetHeight())
1076 return this->DrawBitmap(FloatPoint(vcRectF.x, vcRectF.y), bitmap);
1079 // check if bimap can be drew in canvas area.
1080 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
1082 if (rtCanvasF.IsEmpty())
1087 result r = _Util::Validate(vcRectF, rtCanvasF);
1089 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1091 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1093 if (_ResUtil::NeedToConvertCoord())
1095 FloatRectangle pcRectF = _ResUtil::ConvertToPhyCoord(vcRectF);
1097 _Util::Rectangle<double> pcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcRectF);
1099 return this->_pNativeCanvas->DrawBitmap(pcRectD, *pBitmapEx);
1103 _Util::Rectangle<double> vcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRectF);
1105 return this->_pNativeCanvas->DrawBitmap(vcRectD, *pBitmapEx);
1110 _CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap)
1112 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1114 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1116 Rectangle rtCanvas = _GetBoundsRel(*this);
1118 if (rtCanvas.IsEmpty())
1123 result r = _Util::Validate(Rectangle(vcPoint.x, vcPoint.y, bitmap.GetWidth(), bitmap.GetHeight()), rtCanvas);
1125 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1127 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1129 if (_ResUtil::NeedToConvertCoord())
1131 Tizen::Graphics::Dimension virSize;
1132 Tizen::Graphics::Dimension phySize;
1133 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1135 Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint);
1136 _Util::Point<int> pcPointI = _Util::Convert<Point, _Util::Point<int> >(pcPoint);
1140 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1142 return this->_pNativeCanvas->DrawBitmap(pcPointI, *pScaledBitmapEx);
1146 return this->_pNativeCanvas->DrawBitmap(pcPointI, *pBitmapEx);
1151 _Util::Point<int> vcPointI = _Util::Convert<Point, _Util::Point<int> >(vcPoint);
1153 return this->_pNativeCanvas->DrawBitmap(vcPointI, *pBitmapEx);
1158 _CanvasImpl::DrawBitmap(const FloatPoint& vcPointF, const _BitmapImpl& bitmap)
1160 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1162 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1164 // This code is executed using neon.acceleration.
1166 bool isXEqualToInteger = _Util::Abs(vcPointF.x - int(vcPointF.x)) <= 0.01;
1167 bool isYEqualToInteger = _Util::Abs(vcPointF.y - int(vcPointF.y)) <= 0.01;
1169 bool isCompositeModeUnbound = GetCompositeMode() == COMPOSITE_MODE_SRC_IN
1170 || GetCompositeMode() == COMPOSITE_MODE_DST_IN
1171 || GetCompositeMode() == COMPOSITE_MODE_SRC_OUT
1172 || GetCompositeMode() == COMPOSITE_MODE_DST_ATOP;
1174 if (isXEqualToInteger && isYEqualToInteger && !isCompositeModeUnbound)
1176 return this->DrawBitmap(Point(int(vcPointF.x), int(vcPointF.y)), bitmap);
1180 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
1182 if (rtCanvasF.IsEmpty())
1187 result r = _Util::Validate(FloatRectangle(vcPointF.x, vcPointF.y, bitmap.GetWidthF(), bitmap.GetHeightF()), rtCanvasF);
1189 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1191 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1193 if (_ResUtil::NeedToConvertCoord())
1195 Tizen::Graphics::Dimension virSize;
1196 Tizen::Graphics::Dimension phySize;
1197 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1199 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
1200 _Util::Point<double> pcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPointF);
1204 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1206 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pScaledBitmapEx);
1210 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pBitmapEx);
1215 _Util::Point<double> vcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(vcPointF);
1217 return this->_pNativeCanvas->DrawBitmap(vcPointD, *pBitmapEx);
1222 _CanvasImpl::DrawBitmap(const Rectangle& vcDestRect, const _BitmapImpl& srcBitmap, const Rectangle& vcSrcRect)
1224 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1226 return this->DrawBitmap(FloatRectangle(float(vcDestRect.x), float(vcDestRect.y), float(vcDestRect.width), float(vcDestRect.height)), srcBitmap, FloatRectangle(float(vcSrcRect.x), float(vcSrcRect.y), float(vcSrcRect.width), float(vcSrcRect.height)));
1230 _CanvasImpl::DrawBitmap(const FloatRectangle& vcDestRectF, const _BitmapImpl& srcBitmap, const FloatRectangle& vcSrcRectF)
1232 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1234 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(srcBitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1236 SysTryReturnResult(NID_GRP, (&vcSrcRectF) && (&vcDestRectF), E_INVALID_ARG, "The given rectangle is invalid.");
1238 SysTryReturnResult(NID_GRP, (vcSrcRectF.width >= 0.0f) && (vcSrcRectF.height >= 0.0f), E_OUT_OF_RANGE, "The given source rectangle(width:%f,height:%f) is out of range.", vcSrcRectF.width, vcSrcRectF.height);
1239 SysTryReturnResult(NID_GRP, (vcDestRectF.width >= 0.0f) && (vcDestRectF.height >= 0.0f), E_OUT_OF_RANGE, "The given destination rectangle(width:%f,height:%f) is out of range.", vcDestRectF.width, vcDestRectF.height);
1241 if (vcSrcRectF.width == 0.0f || vcSrcRectF.height == 0.0f)
1246 if (vcDestRectF.width == 0.0f || vcDestRectF.height == 0.0f)
1251 if ((vcSrcRectF.x < 0.0f) || (vcSrcRectF.y < 0.0f) || (vcSrcRectF.x + vcSrcRectF.width > srcBitmap.GetWidthF()) || (vcSrcRectF.y + vcSrcRectF.height > srcBitmap.GetHeightF()))
1253 SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, "The specified region of source bitmap is out of range.");
1256 if (vcSrcRectF.width == srcBitmap.GetWidthF() && vcSrcRectF.height == srcBitmap.GetHeightF())
1258 return this->DrawBitmap(vcDestRectF, srcBitmap);
1261 // check if srcRect is in bitmap's area.
1262 result r = _Util::Validate(vcSrcRectF, FloatRectangle(0, 0, srcBitmap.GetWidthF(), srcBitmap.GetHeightF()));
1264 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1266 // check if destRect is in this canvas.
1267 FloatRectangle rtCanvas = _GetBoundsRelF(*this);
1269 if (rtCanvas.IsEmpty())
1274 r = _Util::Validate(vcDestRectF, rtCanvas);
1276 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1278 EXTRACT_BITMAPEX(pBitmapEx, srcBitmap);
1280 if (_ResUtil::NeedToConvertCoord())
1282 Tizen::Graphics::Dimension virSize;
1283 Tizen::Graphics::Dimension phySize;
1284 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(srcBitmap, virSize, phySize);
1286 FloatRectangle pcDestRectF = _ResUtil::ConvertToPhyCoord(vcDestRectF);
1288 _Util::Rectangle<double> pcDestRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcDestRectF);
1292 _Util::Rectangle<double> vcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcSrcRectF);
1294 return this->_pNativeCanvas->DrawBitmap(pcDestRectD, *pBitmapEx, vcSrcRectD);
1298 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
1300 _Util::Rectangle<double> pcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcSrcRectF);
1302 return this->_pNativeCanvas->DrawBitmap(pcDestRectD, *pBitmapEx, pcSrcRectD);
1307 _Util::Rectangle<double> vcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcSrcRectF);
1308 _Util::Rectangle<double> vcDestRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcDestRectF);
1310 return this->_pNativeCanvas->DrawBitmap(vcDestRectD, *pBitmapEx, vcSrcRectD);
1315 _CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap, FlipDirection dir)
1317 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1319 return this->DrawBitmap(FloatPoint(float(vcPoint.x), float(vcPoint.y)), bitmap, dir);
1323 _CanvasImpl::DrawBitmap(const FloatPoint& vcPointF, const _BitmapImpl& bitmap, FlipDirection dir)
1325 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1327 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1331 case FLIP_DIRECTION_HORIZONTAL:
1332 case FLIP_DIRECTION_VERTICAL:
1335 SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "FlipStyle(%d) is invalid.", dir);
1339 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1341 if (_ResUtil::NeedToConvertCoord())
1343 Tizen::Graphics::Dimension virSize;
1344 Tizen::Graphics::Dimension phySize;
1345 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1347 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
1349 _Util::Point<double> pcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPointF);
1353 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1355 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pScaledBitmapEx, dir);
1359 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pBitmapEx, dir);
1364 _Util::Point<double> vcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(vcPointF);
1366 return this->_pNativeCanvas->DrawBitmap(vcPointD, *pBitmapEx, dir);
1371 _CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap, const Point& vcPivot, int degree)
1373 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1375 return this->DrawBitmap(FloatPoint(float(vcPoint.x), float(vcPoint.y)), bitmap, FloatPoint(float(vcPivot.x), float(vcPivot.y)), float(degree));
1379 _CanvasImpl::DrawBitmap(const FloatPoint& vcPointF, const _BitmapImpl& bitmap, const FloatPoint& vcPivotF, float degree)
1381 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1383 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1385 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1387 if (_ResUtil::NeedToConvertCoord())
1389 Tizen::Graphics::Dimension virSize;
1390 Tizen::Graphics::Dimension phySize;
1391 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1393 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
1394 FloatPoint pcPivotF = _ResUtil::ConvertToPhyCoord(vcPivotF);
1396 _Util::Point<double> pcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPointF);
1397 _Util::Point<double> pcPivotD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPivotF);
1401 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1403 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pScaledBitmapEx, pcPivotD, double(degree));
1407 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pBitmapEx, pcPivotD, double(degree));
1412 return this->_pNativeCanvas->DrawBitmap(_Util::Convert<FloatPoint, _Util::Point<double> >(vcPointF), *pBitmapEx, _Util::Convert<FloatPoint, _Util::Point<double> >(vcPivotF), double(degree));
1417 _CanvasImpl::DrawNinePatchedBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap)
1419 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1421 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1423 SysTryReturnResult(NID_GRP, bitmap.IsNinePatchedBitmap(), E_INVALID_ARG, "The source bitmap is not a nine patched bitmap.");
1425 // check if bimap can be drew in canvas area.
1426 Rectangle rtCanvas = _GetBoundsRel(*this);
1428 if (rtCanvas.IsEmpty())
1430 SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas.");
1433 result r = _Util::Validate(vcRect, rtCanvas);
1435 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1437 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1439 if (_ResUtil::NeedToConvertCoord())
1441 Tizen::Graphics::Dimension virSize;
1442 Tizen::Graphics::Dimension phySize;
1443 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1445 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
1449 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1451 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pScaledBitmapEx);
1455 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pBitmapEx);
1460 return this->_pNativeCanvas->DrawNinePatchedBitmap(vcRect, *pBitmapEx);
1465 _CanvasImpl::DrawNinePatchedBitmap(const FloatRectangle& vcRectF, const _BitmapImpl& bitmap)
1467 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1469 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1471 SysTryReturnResult(NID_GRP, bitmap.IsNinePatchedBitmap(), E_INVALID_ARG, "The source bitmap is not a nine patched bitmap.");
1473 // check if bimap can be drew in canvas area.
1474 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
1476 if (rtCanvasF.IsEmpty())
1478 SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas.");
1481 result r = _Util::Validate(vcRectF, rtCanvasF);
1483 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1485 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1487 if (_ResUtil::NeedToConvertCoord())
1489 Tizen::Graphics::Dimension virSize;
1490 Tizen::Graphics::Dimension phySize;
1491 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1493 FloatRectangle pcRectF = _ResUtil::ConvertToPhyCoord(vcRectF);
1495 Rectangle pcRect(_FloatToIntForPos(pcRectF.x), _FloatToIntForPos(pcRectF.y), _FloatToIntForSize(pcRectF.width), _FloatToIntForSize(pcRectF.height));
1499 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1501 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pScaledBitmapEx);
1505 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pBitmapEx);
1510 Rectangle vcRect(_FloatToIntForPos(vcRectF.x), _FloatToIntForPos(vcRectF.y), _FloatToIntForSize(vcRectF.width), _FloatToIntForSize(vcRectF.height));
1512 return this->_pNativeCanvas->DrawNinePatchedBitmap(vcRect, *pBitmapEx);
1517 _CanvasImpl::DrawNineTiledBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap)
1519 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1521 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1523 SysTryReturnResult(NID_GRP, bitmap.IsNinePatchedBitmap(), E_INVALID_ARG, "The source bitmap is not a nine tiled bitmap.");
1525 // check if bimap can be drew in canvas area.
1526 Rectangle rtCanvas = _GetBoundsRel(*this);
1528 if (rtCanvas.IsEmpty())
1530 SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas.");
1533 result r = _Util::Validate(vcRect, rtCanvas);
1540 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1542 if (_ResUtil::NeedToConvertCoord())
1544 Tizen::Graphics::Dimension virSize;
1545 Tizen::Graphics::Dimension phySize;
1546 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1548 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
1552 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1554 return this->_pNativeCanvas->DrawNineTiledBitmap(pcRect, *pScaledBitmapEx);
1558 return this->_pNativeCanvas->DrawNineTiledBitmap(pcRect, *pBitmapEx);
1563 return this->_pNativeCanvas->DrawNineTiledBitmap(vcRect, *pBitmapEx);
1568 _CanvasImpl::DrawEllipse(const Rectangle& vcBounds)
1570 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1571 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1572 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE,
1573 "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height);
1575 return _CanvasImplPrivate::DrawEllipse(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcBounds));
1579 _CanvasImpl::DrawEllipse(const FloatRectangle& vcBounds)
1581 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1582 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1583 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0.0f) && (vcBounds.height >= 0.0f), E_OUT_OF_RANGE,
1584 "The given rectangle(width:%f,height:%f) is out of range.", vcBounds.width, vcBounds.height);
1586 return _CanvasImplPrivate::DrawEllipse(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcBounds));
1590 _CanvasImpl::DrawLine(const Point& vcPoint1, const Point& vcPoint2)
1592 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1594 return _CanvasImplPrivate::DrawLine(this,
1595 _Util::Convert<Point, _Util::Point<double> >(vcPoint1),
1596 _Util::Convert<Point, _Util::Point<double> >(vcPoint2));
1600 _CanvasImpl::DrawLine(const FloatPoint& vcPoint1, const FloatPoint& vcPoint2)
1602 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1604 return _CanvasImplPrivate::DrawLine(this,
1605 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint1),
1606 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint2));
1610 _CanvasImpl::DrawPolygon(const Tizen::Base::Collection::IList& vcPoints)
1612 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1614 int numPoint = vcPoints.GetCount();
1616 SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint);
1618 if (numPoint < 2) // TBD.
1623 std::unique_ptr<_Util::Point<double>[]> doublePoint;
1626 _Util::Point<double>* pDoublePoint = _Util::Convert<Tizen::Base::Collection::IList, _Util::Point<double>*>(vcPoints);
1628 SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid.");
1630 doublePoint.reset(pDoublePoint);
1633 if (_ResUtil::NeedToConvertCoord())
1635 for (int i = 0; i < numPoint; i++)
1637 doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]);
1640 return this->_pNativeCanvas->DrawPolygon(doublePoint.get(), numPoint);
1644 return this->_pNativeCanvas->DrawPolygon(doublePoint.get(), numPoint);
1649 _CanvasImpl::DrawPolyline(const Tizen::Base::Collection::IList& vcPoints)
1651 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1653 int numPoint = vcPoints.GetCount();
1655 SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint);
1662 std::unique_ptr<_Util::Point<double>[]> doublePoint;
1665 _Util::Point<double>* pDoublePoint = _Util::Convert<Tizen::Base::Collection::IList, _Util::Point<double>*>(vcPoints);
1667 SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid.");
1669 doublePoint.reset(pDoublePoint);
1672 if (_ResUtil::NeedToConvertCoord())
1674 for (int i = 0; i < numPoint; i++)
1676 doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]);
1679 return this->_pNativeCanvas->DrawPolyline(doublePoint.get(), numPoint);
1683 return this->_pNativeCanvas->DrawPolyline(doublePoint.get(), numPoint);
1688 _CanvasImpl::DrawRectangle(const Rectangle& vcRect)
1690 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1691 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1692 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height);
1694 return _CanvasImplPrivate::DrawRectangle(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect));
1698 _CanvasImpl::DrawRectangle(const FloatRectangle& vcRect)
1700 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1701 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1702 SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%f,height:%f) is out of range.", vcRect.width, vcRect.height);
1704 return _CanvasImplPrivate::DrawRectangle(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect));
1708 _CanvasImpl::DrawRoundRectangle(const Rectangle& vcRect, const Dimension& vcArcDim)
1710 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1711 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1712 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height);
1713 SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0) && (vcArcDim.height >= 0), E_OUT_OF_RANGE, "The given arc size(width:%d,height:%d) is out of range.", vcArcDim.width, vcArcDim.height);
1715 return _CanvasImplPrivate::DrawRoundRectangle(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<Dimension, _Util::Dimension<double> >(vcArcDim));
1719 _CanvasImpl::DrawRoundRectangle(const FloatRectangle& vcRect, const FloatDimension& vcArcDim)
1721 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1722 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1723 SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%f,height:%f) is out of range.", vcRect.width, vcRect.height);
1724 SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0.0f) && (vcArcDim.height >= 0.0f), E_OUT_OF_RANGE, "The given arc size(width:%f,height:%f) is out of range.", vcArcDim.width, vcArcDim.height);
1726 return _CanvasImplPrivate::DrawRoundRectangle(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<FloatDimension, _Util::Dimension<double> >(vcArcDim));
1730 _CanvasImpl::DrawTriangle(const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3)
1732 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1734 return _CanvasImplPrivate::DrawTriangle(this,
1735 _Util::Convert<Point, _Util::Point<double> >(vcPoint1),
1736 _Util::Convert<Point, _Util::Point<double> >(vcPoint2),
1737 _Util::Convert<Point, _Util::Point<double> >(vcPoint3));
1741 _CanvasImpl::DrawTriangle(const FloatPoint& vcPoint1, const FloatPoint& vcPoint2, const FloatPoint& vcPoint3)
1743 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1745 return _CanvasImplPrivate::DrawTriangle(this,
1746 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint1),
1747 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint2),
1748 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint3));
1752 _CanvasImpl::FillEllipse(const Color& color, const Rectangle& vcBounds)
1754 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1755 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1756 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE,
1757 "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height);
1759 return _CanvasImplPrivate::FillEllipse(this, color, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcBounds));
1763 _CanvasImpl::FillEllipse(const Color& color, const FloatRectangle& vcBounds)
1765 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1766 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1767 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0.0f) && (vcBounds.height >= 0.0f), E_OUT_OF_RANGE,
1768 "The given rectangle(width:%f,height:%f) is out of range.", vcBounds.width, vcBounds.height);
1770 return _CanvasImplPrivate::FillEllipse(this, color, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcBounds));
1774 _CanvasImpl::FillPolygon(const Color& color, const Tizen::Base::Collection::IList& vcPoints)
1776 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1778 SysTryReturnResult(NID_GRP, &vcPoints, E_INVALID_ARG, "The given rectangle is invalid.");
1780 int numPoint = vcPoints.GetCount();
1782 SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint);
1784 if (numPoint < 3) // TBD.
1789 std::unique_ptr<_Util::Point<double>[]> doublePoint;
1792 _Util::Point<double>* pDoublePoint = _Util::Convert<Tizen::Base::Collection::IList, _Util::Point<double>*>(vcPoints);
1794 SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid.");
1796 doublePoint.reset(pDoublePoint);
1799 if (_ResUtil::NeedToConvertCoord())
1801 for (int i = 0; i < numPoint; i++)
1803 doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]);
1806 return this->_pNativeCanvas->FillPolygon(color, doublePoint.get(), numPoint);
1810 return this->_pNativeCanvas->FillPolygon(color, doublePoint.get(), numPoint);
1815 _CanvasImpl::FillRectangle(const Color& color, const Rectangle& vcRect)
1817 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1818 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1819 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height);
1821 return _CanvasImplPrivate::FillRectangle(this, color, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect));
1825 _CanvasImpl::FillRectangle(const Color& color, const FloatRectangle& vcRect)
1827 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1828 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1829 SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%f,height:%f) is out of range.", vcRect.width, vcRect.height);
1831 return _CanvasImplPrivate::FillRectangle(this, color, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect));
1835 _CanvasImpl::FillRoundRectangle(const Color& color, const Rectangle& vcRect, const Dimension& vcArcDim)
1837 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1838 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1839 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height);
1840 SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0) && (vcArcDim.height >= 0), E_OUT_OF_RANGE, "The given arc size(width:%d,height:%d) is out of range.", vcArcDim.width, vcArcDim.height);
1842 return _CanvasImplPrivate::FillRoundRectangle(this, color, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<Dimension, _Util::Dimension<double> >(vcArcDim));
1846 _CanvasImpl::FillRoundRectangle(const Color& color, const FloatRectangle& vcRect, const FloatDimension& vcArcDim)
1848 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1849 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1850 SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%f,height:%f) is out of range.", vcRect.width, vcRect.height);
1851 SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0.0f) && (vcArcDim.height >= 0.0f), E_OUT_OF_RANGE, "The given arc size(width:%f,height:%f) is out of range.", vcArcDim.width, vcArcDim.height);
1853 return _CanvasImplPrivate::FillRoundRectangle(this, color, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<FloatDimension, _Util::Dimension<double> >(vcArcDim));
1857 _CanvasImpl::FillTriangle(const Color& color, const FloatPoint& vcPoint1, const FloatPoint& vcPoint2, const FloatPoint& vcPoint3)
1859 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1861 return _CanvasImplPrivate::FillTriangle(this, color,
1862 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint1),
1863 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint2),
1864 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint3));
1868 _CanvasImpl::FillTriangle(const Color& color, const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3)
1870 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1872 return _CanvasImplPrivate::FillTriangle(this, color,
1873 _Util::Convert<Point, _Util::Point<double> >(vcPoint1),
1874 _Util::Convert<Point, _Util::Point<double> >(vcPoint2),
1875 _Util::Convert<Point, _Util::Point<double> >(vcPoint3));
1879 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text)
1881 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1883 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1885 if (_ResUtil::NeedToConvertCoord())
1887 Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint);
1889 return this->_pNativeCanvas->DrawText(pcPoint, text);
1893 return this->_pNativeCanvas->DrawText(vcPoint, text);
1898 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, int length)
1900 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1901 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1902 SysTryReturnResult(NID_GRP, length >= 0 && startIndex >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE, "The value of the length (%d), startIndex(%d) are outside the valid range defined by the method.", length, startIndex);
1904 if (text.GetLength() == 0)
1909 if (_ResUtil::NeedToConvertCoord())
1911 Point pcPt = _ResUtil::ConvertToPhyCoord(vcPoint);
1913 return this->_pNativeCanvas->DrawText(pcPt, text, startIndex, length);
1917 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length);
1922 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, const Color& outlineColor)
1924 const char* pNotConstructedYet = "[E_OPERATION_FAILED] This instance is not constructed yet.";
1926 SysTryReturn(NID_GRP, this, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1927 SysTryReturn(NID_GRP, this->_pNativeCanvas, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1928 SysTryReturn(NID_GRP, this->_pNativeCanvas->IsValid(), E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1930 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1932 return this->DrawText(vcPoint, text, startIndex, text.GetLength(), outlineColor);
1936 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor)
1938 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1940 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1942 SysTryReturnResult(NID_GRP, length >= 0, E_OUT_OF_RANGE,
1943 "The value of the length (%d) is outside the valid range defined by the method.",
1946 if (text.GetLength() == 0)
1951 if (_ResUtil::NeedToConvertCoord())
1953 Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint);
1955 return this->_pNativeCanvas->DrawText(pcPoint, text, startIndex, length, outlineColor);
1959 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length, outlineColor);
1964 _CanvasImpl::DrawText(const Point& vcPoint, const EnrichedText& etext)
1966 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1968 const _EnrichedTextImpl* pImpl = _EnrichedTextImpl::GetInstance(etext);
1972 return E_OPERATION_FAILED;
1975 Tizen::Graphics::_Text::TextObject* pTextObject = const_cast <_EnrichedTextImpl*>(pImpl)->GetTextObject();
1977 if (pTextObject == null)
1979 return E_OPERATION_FAILED;
1982 FloatRectangle bounds = pImpl->GetBoundsF();
1983 FloatRectangle rect(float(vcPoint.x), float(vcPoint.y), bounds.width, bounds.height);
1985 pTextObject->SetBounds(rect);
1986 pTextObject->Draw(*this);
1992 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text)
1994 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1996 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1998 if (_ResUtil::NeedToConvertCoord())
2001 pcPoint.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.x));
2002 pcPoint.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.y));
2004 return this->_pNativeCanvas->DrawText(pcPoint, text);
2009 vcPoint.x = _FloatToIntForPos(vcPointF.x);
2010 vcPoint.y = _FloatToIntForPos(vcPointF.y);
2012 return this->_pNativeCanvas->DrawText(vcPoint, text);
2017 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text, int startIndex, int length)
2019 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2020 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
2021 SysTryReturnResult(NID_GRP, length >= 0 && startIndex >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE, "The value of the length (%d), startIndex(%d) are outside the valid range defined by the method.", length, startIndex);
2023 if (text.GetLength() == 0)
2028 if (_ResUtil::NeedToConvertCoord())
2031 pcPoint.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.x));
2032 pcPoint.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.y));
2034 return this->_pNativeCanvas->DrawText(pcPoint, text, startIndex, length);
2039 vcPoint.x = _FloatToIntForPos(vcPointF.x);
2040 vcPoint.y = _FloatToIntForPos(vcPointF.y);
2042 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length);
2047 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text, int startIndex, const Color& outlineColor)
2049 const char* pNotConstructedYet = "[E_OPERATION_FAILED] This instance is not constructed yet.";
2051 SysTryReturn(NID_GRP, this, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
2052 SysTryReturn(NID_GRP, this->_pNativeCanvas, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
2053 SysTryReturn(NID_GRP, this->_pNativeCanvas->IsValid(), E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
2055 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
2058 vcPoint.x = _FloatToIntForPos(vcPointF.x);
2059 vcPoint.y = _FloatToIntForPos(vcPointF.y);
2061 return this->DrawText(vcPoint, text, startIndex, text.GetLength(), outlineColor);
2065 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor)
2067 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2069 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
2071 SysTryReturnResult(NID_GRP, length >= 0, E_OUT_OF_RANGE,
2072 "The value of the length (%d) is outside the valid range defined by the method.",
2075 if (text.GetLength() == 0)
2080 if (_ResUtil::NeedToConvertCoord())
2083 pcPoint.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.x));
2084 pcPoint.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.y));
2086 return this->_pNativeCanvas->DrawText(pcPoint, text, startIndex, length, outlineColor);
2091 vcPoint.x = _FloatToIntForPos(vcPointF.x);
2092 vcPoint.y = _FloatToIntForPos(vcPointF.y);
2094 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length, outlineColor);
2099 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const EnrichedText& etext)
2101 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2103 const _EnrichedTextImpl* pImpl = _EnrichedTextImpl::GetInstance(etext);
2107 return E_OPERATION_FAILED;
2110 Tizen::Graphics::_Text::TextObject* pTextObject = const_cast <_EnrichedTextImpl*>(pImpl)->GetTextObject();
2112 if (pTextObject == null)
2114 return E_OPERATION_FAILED;
2117 FloatRectangle bounds = pImpl->GetBoundsF();
2118 FloatRectangle rect(vcPointF.x, vcPointF.y, bounds.width, bounds.height);
2120 pTextObject->SetBounds(rect);
2121 pTextObject->Draw(*this);
2127 _CanvasImpl::GetBounds(void) const
2129 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Rectangle(), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2131 if (_ResUtil::NeedToConvertCoord())
2133 const _Util::Point<int>& pos = this->_pCoordHolder->canvasPos.vcInt;
2134 const _Util::Dimension<int>& vcSize = this->_pCoordHolder->canvasSize.vcInt;
2135 const Rectangle boundsFromPi = this->_pNativeCanvas->GetBounds();
2137 if ((vcSize.w == 0 && boundsFromPi.width > 0) || (vcSize.h == 0 && boundsFromPi.height > 0))
2139 _CanvasImpl* pThis = const_cast<_CanvasImpl*>(this);
2141 _Util::Dimension<int> intPcSize = { boundsFromPi.width, boundsFromPi.height };
2143 pThis->_pCoordHolder->AssignCanvasSizeFromPcSize(intPcSize);
2146 // exception from the window canvas
2147 if (boundsFromPi.x == 0 && boundsFromPi.y == 0)
2149 return Rectangle(0, 0, vcSize.w, vcSize.h);
2153 return Rectangle(pos.x, pos.y, vcSize.w, vcSize.h);
2158 return this->_pNativeCanvas->GetBounds();
2163 _CanvasImpl::GetBoundsF(void) const
2165 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, FloatRectangle(), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2167 const Rectangle boundsFromPi = this->_pNativeCanvas->GetBounds();
2169 if (_ResUtil::NeedToConvertCoord())
2171 const _Util::Point<float>& posF = this->_pCoordHolder->canvasPos.vcFloat;
2172 const _Util::Dimension<float>& vcSizeF = this->_pCoordHolder->canvasSize.vcFloat;
2174 // exception from the window canvas
2175 if (boundsFromPi.x == 0 && boundsFromPi.y == 0)
2177 return FloatRectangle(0.0f, 0.0f, vcSizeF.w, vcSizeF.h);
2181 return FloatRectangle(posF.x, posF.y, vcSizeF.w, vcSizeF.h);
2186 return FloatRectangle(static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.width), static_cast<float>(boundsFromPi.height));
2192 _CanvasImpl::GetActualBounds(void) const
2194 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, FloatRectangle(), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2196 const Rectangle boundsFromPi = this->_pNativeCanvas->GetBounds();
2198 if (_ResUtil::NeedToConvertCoord())
2200 const _Util::Point<float>& actualPosF = this->_pCoordHolder->canvasPos.vcFloatActual;
2201 const _Util::Dimension<float>& vcActualSizeF = this->_pCoordHolder->canvasSize.vcFloatActual;
2203 // exception from the window canvas
2204 if (boundsFromPi.x == 0 && boundsFromPi.y == 0)
2206 return FloatRectangle(0.0f, 0.0f, vcActualSizeF.w, vcActualSizeF.h);
2210 return FloatRectangle(actualPosF.x, actualPosF.y, vcActualSizeF.w, vcActualSizeF.h);
2215 return FloatRectangle(static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.width), static_cast<float>(boundsFromPi.height));
2220 _CanvasImpl::GetLineStyle() const
2222 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, LINE_STYLE_MAX, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2224 return this->_pNativeCanvas->GetLineStyle();
2228 _CanvasImpl::GetLineWidth() const
2230 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, -1, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2232 return this->_pCoordHolder->lineWidth.vcInt;
2236 _CanvasImpl::GetLineWidthF() const
2238 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, -1.0f, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2240 return this->_pCoordHolder->lineWidth.vcFloat;
2244 _CanvasImpl::GetLineCapStyle() const
2246 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, LINE_CAP_STYLE_ROUND, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2248 return this->_pNativeCanvas->GetLineCapStyle();
2252 _CanvasImpl::GetLineJoinStyle() const
2254 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, LINE_JOIN_STYLE_ROUND, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2256 return this->_pNativeCanvas->GetLineJoinStyle();
2260 _CanvasImpl::SetLineStyle(LineStyle style)
2262 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2264 SysTryReturnResult(NID_GRP, LINE_STYLE_MIN < style && style < LINE_STYLE_MAX, E_INVALID_ARG, "The given line style(%d) is out of range.", style);
2266 return this->_pNativeCanvas->SetLineStyle(style);
2270 _CanvasImpl::SetLineWidth(int vcWidth)
2272 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2274 SysTryReturnResult(NID_GRP, vcWidth > 0, E_OUT_OF_RANGE, "The given line width(%d) is out of range.", vcWidth);
2276 result r = E_SUCCESS;
2278 if (_ResUtil::NeedToConvertCoord())
2280 int pcWidth = _ResUtil::ConvertToPhyCoordSize(vcWidth);
2281 float pcWidthF = _ResUtil::ConvertToPhyCoordSize(float(vcWidth));
2283 if (vcWidth > 0 && pcWidth == 0)
2288 r = this->_pNativeCanvas->SetLineWidth(pcWidth, pcWidthF);
2292 r = this->_pNativeCanvas->SetLineWidth(vcWidth, float(vcWidth));
2297 this->_pCoordHolder->AssignLineWidthFromVc(vcWidth);
2304 _CanvasImpl::SetLineWidth(float vcWidthF)
2306 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2308 SysTryReturnResult(NID_GRP, vcWidthF > 0.0f, E_OUT_OF_RANGE, "The given line width(%f) is out of range.", vcWidthF);
2310 result r = E_SUCCESS;
2312 if (_ResUtil::NeedToConvertCoord())
2314 float pcWidthF = _ResUtil::ConvertToPhyCoordSize(vcWidthF);
2316 r = this->_pNativeCanvas->SetLineWidth(pcWidthF);
2320 r = this->_pNativeCanvas->SetLineWidth(vcWidthF);
2325 this->_pCoordHolder->AssignLineWidthFromVc(vcWidthF);
2332 _CanvasImpl::SetLineCapStyle(LineCapStyle lineCapStyle)
2334 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2336 switch (lineCapStyle)
2338 case LINE_CAP_STYLE_ROUND:
2339 case LINE_CAP_STYLE_BUTT:
2340 case LINE_CAP_STYLE_SQUARE:
2343 SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "The given line cap style is out of range.");
2346 return this->_pNativeCanvas->SetLineCapStyle(lineCapStyle);
2350 _CanvasImpl::SetLineJoinStyle(LineJoinStyle lineJoinStyle)
2352 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2354 switch (lineJoinStyle)
2356 case LINE_JOIN_STYLE_ROUND:
2357 case LINE_JOIN_STYLE_MITER:
2358 case LINE_JOIN_STYLE_BEVEL:
2361 SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "The given line join style is out of range.");
2364 return this->_pNativeCanvas->SetLineJoinStyle(lineJoinStyle);
2368 _CanvasImpl::GetDashPattern(Tizen::Base::Collection::IListT<int>& pattern, int& offset)
2370 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2372 pattern.RemoveAll();
2374 result r = E_SUCCESS;
2376 float floatValue = 0.0f;
2378 for (int i = 0; i < this->_dashList.GetCount(); i++)
2380 this->_dashList.GetAt(i, floatValue);
2382 r = pattern.Add(_FloatToIntForPos(floatValue));
2395 case E_OPERATION_FAILED:
2396 case E_OUT_OF_MEMORY:
2397 SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
2400 SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT<int>::AddItems() failed");
2405 offset = int(this->_dashOffset);
2411 _CanvasImpl::GetDashPattern(Tizen::Base::Collection::IListT<float>& pattern, float& offset)
2413 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2415 pattern.RemoveAll();
2417 result r = pattern.AddItems(this->_dashList);
2424 case E_OPERATION_FAILED:
2425 case E_OUT_OF_MEMORY:
2426 SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
2429 SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT<int>::AddItems() failed");
2434 offset = static_cast<float>(this->_dashOffset);
2440 _CanvasImpl::SetDashPattern(const Tizen::Base::Collection::IListT<int>& pattern, int offset)
2442 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2446 for (int i = 0; i < pattern.GetCount(); i++)
2448 pattern.GetAt(i, dashValue);
2449 SysTryReturn(NID_GRP, dashValue >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] One of the values of the specified pattern is negative(%d).", dashValue);
2452 result r = E_SUCCESS;
2454 // It is NOT the strong guarantee for an exception
2455 this->_dashList.RemoveAll();
2459 for (int i = 0; i < pattern.GetCount(); i++)
2461 pattern.GetAt(i, intValue);
2462 r = this->_dashList.Add(float(intValue));
2474 case E_OPERATION_FAILED:
2475 case E_OUT_OF_MEMORY:
2476 SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
2479 SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT<int>::AddItems() failed");
2485 int dashIntValue = 0;
2486 Tizen::Graphics::_Util::AccumList<double> dashValueList;
2488 for (int i = 0; i < pattern.GetCount(); i++)
2490 pattern.GetAt(i, dashIntValue);
2491 dashValueList.Push(double(dashIntValue));
2494 r = this->_pNativeCanvas->SetDashPattern(dashValueList, double(offset));
2495 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2497 this->_dashOffset = offset;
2504 _CanvasImpl::SetDashPattern(const Tizen::Base::Collection::IListT<float>& pattern, float offset)
2506 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2508 float dashValue = 0.0f;
2510 for (int i = 0; i < pattern.GetCount(); i++)
2512 pattern.GetAt(i, dashValue);
2513 SysTryReturn(NID_GRP, dashValue >= 0.0f, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] One of the values of the specified pattern is negative(%f).", dashValue);
2516 result r = E_SUCCESS;
2518 // It is NOT the strong guarantee for an exception
2519 this->_dashList.RemoveAll();
2521 r = this->_dashList.AddItems(pattern);
2528 case E_OPERATION_FAILED:
2529 case E_OUT_OF_MEMORY:
2530 SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
2533 SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT<int>::AddItems() failed");
2539 float dashFloatValue = 0.0f;
2540 Tizen::Graphics::_Util::AccumList<double> dashValueList;
2542 for (int i = 0; i < pattern.GetCount(); i++)
2544 pattern.GetAt(i, dashFloatValue);
2545 dashValueList.Push(double(dashFloatValue));
2548 r = this->_pNativeCanvas->SetDashPattern(dashValueList, double(offset));
2549 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2551 this->_dashOffset = _FloatToIntForPos(offset);
2558 _CanvasImpl::SetDrawingQuality(BitmapDrawingQuality quality)
2560 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2564 case BITMAP_DRAWING_QUALITY_LOW:
2565 case BITMAP_DRAWING_QUALITY_MID:
2566 case BITMAP_DRAWING_QUALITY_HIGH:
2569 SysLogException(NID_GRP, E_INVALID_ARG, "The specified drawing quality(%d) is invalid.", quality);
2570 return E_INVALID_ARG;
2573 this->_pNativeCanvas->SetDrawingQuality(quality);
2578 BitmapDrawingQuality
2579 _CanvasImpl::GetDrawingQuality(void) const
2581 return (INSTANCE_IS_VALID) ? this->_pNativeCanvas->GetDrawingQuality() : BITMAP_DRAWING_QUALITY_LOW;
2585 _CanvasImpl::SetCompositeMode(CompositeMode compositeMode)
2587 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2589 switch (compositeMode)
2591 case COMPOSITE_MODE_CLEAR:
2592 case COMPOSITE_MODE_SRC:
2593 case COMPOSITE_MODE_DST:
2594 case COMPOSITE_MODE_SRC_OVER:
2595 case COMPOSITE_MODE_DST_OVER:
2596 case COMPOSITE_MODE_SRC_IN:
2597 case COMPOSITE_MODE_DST_IN:
2598 case COMPOSITE_MODE_SRC_OUT:
2599 case COMPOSITE_MODE_DST_OUT:
2600 case COMPOSITE_MODE_SRC_ATOP:
2601 case COMPOSITE_MODE_DST_ATOP:
2602 case COMPOSITE_MODE_DST_XOR:
2603 case COMPOSITE_MODE_ADD:
2604 case COMPOSITE_MODE_SATURATE:
2605 case COMPOSITE_MODE_MULTIPLY:
2606 case COMPOSITE_MODE_SCREEN:
2607 case COMPOSITE_MODE_OVERLAY:
2608 case COMPOSITE_MODE_DARKEN:
2609 case COMPOSITE_MODE_LIGHTEN:
2612 SysLogException(NID_GRP, E_INVALID_ARG, "The specified composite mode(%d) is invalid.", compositeMode);
2613 return E_INVALID_ARG;
2616 this->_pNativeCanvas->SetCompositeMode(compositeMode);
2622 _CanvasImpl::GetCompositeMode(void) const
2624 return (INSTANCE_IS_VALID) ? this->_pNativeCanvas->GetCompositeMode() : COMPOSITE_MODE_SRC_OVER;
2628 _CanvasImpl::GetPixel(const Point& vcPoint, Color& color) const
2630 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2632 Rectangle rtCanvas = _GetBoundsRel(*this);
2634 SysTryReturnResult(NID_GRP, !rtCanvas.IsEmpty(), E_OUT_OF_RANGE, "Cannot get the bounds of the canvas.");
2636 result r = _Util::Validate(vcPoint, rtCanvas);
2638 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2640 if (_ResUtil::NeedToConvertCoord())
2642 Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint);
2644 return this->_pNativeCanvas->GetPixel(pcPoint, color);
2648 return this->_pNativeCanvas->GetPixel(vcPoint, color);
2653 _CanvasImpl::GetPixel(const FloatPoint& vcPointF, Color& color) const
2655 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2657 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
2659 SysTryReturnResult(NID_GRP, !rtCanvasF.IsEmpty(), E_OUT_OF_RANGE, "Cannot get the bounds of the canvas.");
2661 result r = _Util::Validate(vcPointF, rtCanvasF);
2663 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2665 if (_ResUtil::NeedToConvertCoord())
2667 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
2669 Point pcPoint(_FloatToIntForPos(pcPointF.x), _FloatToIntForPos(pcPointF.y));
2671 return this->_pNativeCanvas->GetPixel(pcPoint, color);
2675 Point vcPoint(_FloatToIntForPos(vcPointF.x), _FloatToIntForPos(vcPointF.y));
2677 return this->_pNativeCanvas->GetPixel(vcPoint, color);
2682 _CanvasImpl::SetPixel(const FloatPoint& vcPoint)
2684 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2686 return _CanvasImplPrivate::SetPixel(this, _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint));
2690 _CanvasImpl::SetPixel(const Point& vcPoint)
2692 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2694 return _CanvasImplPrivate::SetPixel(this, _Util::Convert<Point, _Util::Point<int> >(vcPoint));
2700 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2702 if (this->_pShowCallbackFunc)
2704 if (this->_pShowCallbackFunc(this->_pShowCallbackParam))
2710 result r = E_SUCCESS;
2711 Rectangle rect = this->GetBounds();
2713 r = this->_pNativeCanvas->Show();
2719 _CanvasImpl::Show(const Rectangle& vcRect)
2721 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2723 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
2724 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE,
2725 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
2728 if (this->_pShowCallbackFunc)
2730 if (this->_pShowCallbackFunc(this->_pShowCallbackParam))
2736 result r = E_SUCCESS;
2737 Rectangle rect = this->GetBounds();
2739 if (_ResUtil::NeedToConvertCoord())
2741 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
2743 r = this->_pNativeCanvas->Show(pcRect);
2747 r = this->_pNativeCanvas->Show(vcRect);
2754 _CanvasImpl::SetFont(const Font& font)
2756 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2757 SysTryReturnResult(NID_GRP, _FontImpl::GetInstance(font) && _FontImpl::GetInstance(font)->IsConstructed(), E_INVALID_ARG, "The given font is not constructed.");
2758 SysTryReturnResult(NID_GRP, font.GetMaxHeight() > 0 && font.GetMaxWidth() > 0, E_INVALID_ARG, "The infomation of the given font is not valid. (maxWidth=%d,maxHeight=%d).", font.GetMaxWidth(), font.GetMaxHeight());
2760 // should keep clone font
2761 Font* pFont = _FontImpl::CloneN(font);
2765 SysTryLog(NID_GRP, pFont, "[] Fails to allocate memory for font resource.");
2767 this->_pFont = null;
2770 // we failed to make cloned font. so, return what? E_SYSTEM which is not defined in header?? or use E_OPERATION_FAILED again for different meaning?
2771 // or just setting defult font?!
2772 return E_OPERATION_FAILED;
2775 EXTRACT_FONTEX(pFontEx, *pFont);
2776 result r = this->_pNativeCanvas->SetFont(*pFontEx);
2777 SysTryCatch(NID_GRP, E_SUCCESS == r, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Fails to set font.");
2779 // succeed making cloned font, then keep it and replace old one.
2782 delete this->_pFont;
2783 this->_pFont = null;
2786 this->_pFont = pFont;
2798 _CanvasImpl::GetFontN(void)
2800 result r = E_SUCCESS;
2806 SysTryCatch(NID_GRP, INSTANCE_IS_VALID, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2808 // we have the font user set
2811 pFont = _FontImpl::CloneN(*(this->_pFont));
2812 SysTryCatch(NID_GRP, pFont, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create Font instance.");
2817 SysTryCatch(NID_GRP, pFont, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2819 const float defaultFontSize = _ResUtil::ConvertToVirCoordY(16.0f);
2820 result r = pFont->Construct(FONT_STYLE_PLAIN, defaultFontSize);
2821 SysTryCatch(NID_GRP, IsSucceeded(r), , r, "[%s] Propagating.", GetErrorMessage(r));
2839 _CanvasImpl::SetTextOrigin(TextOrigin origin)
2841 if (INSTANCE_IS_VALID)
2845 case TEXT_ORIGIN_LEFT_TOP:
2846 case TEXT_ORIGIN_BASELINE:
2847 this->_pNativeCanvas->__textOrigin = origin;
2854 _CanvasImpl::SetClipBounds(const Rectangle& vcRect)
2856 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2858 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
2859 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height);
2861 Rectangle rtCanvas = _GetBoundsRel(*this);
2863 result r = _Util::Validate(vcRect, rtCanvas);
2865 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2867 Rectangle revisedVcRect;
2872 int x2 = vcRect.x + vcRect.width;
2873 int y2 = vcRect.y + vcRect.height;
2875 x1 = (x1 > 0) ? x1 : 0;
2876 y1 = (y1 > 0) ? y1 : 0;
2877 x2 = (x2 < rtCanvas.width) ? x2 : rtCanvas.width;
2878 y2 = (y2 < rtCanvas.height) ? y2 : rtCanvas.height;
2880 revisedVcRect.x = x1;
2881 revisedVcRect.y = y1;
2882 revisedVcRect.width = x2 - x1;
2883 revisedVcRect.height = y2 - y1;
2886 if (_ResUtil::NeedToConvertCoord())
2888 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(revisedVcRect);
2891 pcRect.width = (pcRect.width >= 0) ? pcRect.width : 1;
2892 pcRect.height = (pcRect.height >= 0) ? pcRect.height : 1;
2894 result r = this->_pNativeCanvas->SetClipBounds(pcRect);
2898 _Util::Rectangle<int> vcRect =
2902 revisedVcRect.width,
2903 revisedVcRect.height
2906 this->_pCoordHolder->AssignClipBoundsFromVcSize(vcRect);
2913 result r = this->_pNativeCanvas->SetClipBounds(revisedVcRect);
2917 _Util::Rectangle<int> vcRect =
2921 revisedVcRect.width,
2922 revisedVcRect.height
2925 this->_pCoordHolder->AssignClipBoundsFromVcSize(vcRect);
2933 _CanvasImpl::SetClipBounds(const FloatRectangle& vcRectF)
2935 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2937 SysTryReturnResult(NID_GRP, &vcRectF, E_OUT_OF_RANGE, "The given rectangle is invalid.");
2938 SysTryReturnResult(NID_GRP, (vcRectF.width >= 0.0f) && (vcRectF.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%f,height:%f) is out of range.", vcRectF.width, vcRectF.height);
2940 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
2942 result r = _Util::Validate(vcRectF, rtCanvasF);
2944 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2946 FloatRectangle revisedVcRectF;
2949 float x1 = vcRectF.x;
2950 float y1 = vcRectF.y;
2951 float x2 = vcRectF.x + vcRectF.width;
2952 float y2 = vcRectF.y + vcRectF.height;
2954 x1 = (x1 > 0) ? x1 : 0;
2955 y1 = (y1 > 0) ? y1 : 0;
2956 x2 = (x2 < rtCanvasF.width) ? x2 : rtCanvasF.width;
2957 y2 = (y2 < rtCanvasF.height) ? y2 : rtCanvasF.height;
2959 revisedVcRectF.x = x1;
2960 revisedVcRectF.y = y1;
2961 revisedVcRectF.width = x2 - x1;
2962 revisedVcRectF.height = y2 - y1;
2965 _CanvasCoordHolder coordHolder;
2968 _Util::Rectangle<float> tempRevisedVcRectF =
2972 revisedVcRectF.width,
2973 revisedVcRectF.height
2976 coordHolder.AssignClipBoundsFromVcSize(tempRevisedVcRectF);
2981 coordHolder.clipBounds.pcInt.x,
2982 coordHolder.clipBounds.pcInt.y,
2983 coordHolder.clipBounds.pcInt.w,
2984 coordHolder.clipBounds.pcInt.h
2987 r = this->_pNativeCanvas->SetClipBounds(pcRect);
2991 this->_pCoordHolder->clipBounds = coordHolder.clipBounds;
2998 _CanvasImpl::GetClipBounds(void) const
3002 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, rect, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3004 if (_ResUtil::NeedToConvertCoord())
3006 const _Util::Rectangle<int>& bounds = this->_pCoordHolder->clipBounds.vcInt;
3008 return Rectangle(bounds.x, bounds.y, bounds.w, bounds.h);
3012 return this->_pNativeCanvas->GetClipBounds();
3017 _CanvasImpl::GetClipBoundsF(void) const
3019 FloatRectangle rectF;
3021 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, rectF, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3023 const _Util::Rectangle<float>& boundsF = this->_pCoordHolder->clipBounds.vcFloat;
3025 return FloatRectangle(boundsF.x, boundsF.y, boundsF.w, boundsF.h);
3029 _CanvasImpl::Lock(BufferInfo& info, long timeout)
3031 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
3033 SysTryReturnResult(NID_GRP, (static_cast <unsigned long>(timeout) == INFINITE) || (timeout >= 0), E_INVALID_ARG,
3034 "'timeout(=%d)' is not valid.",
3037 return this->_pNativeCanvas->Lock(info, timeout);
3041 _CanvasImpl::Unlock()
3043 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
3045 return this->_pNativeCanvas->Unlock();
3049 _CanvasImpl::SetForegroundColor(const Color& fgColor)
3051 SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3053 return this->_pNativeCanvas->SetForegroundColor(fgColor);
3057 _CanvasImpl::GetForegroundColor(void) const
3059 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Color::GetColor(COLOR_ID_BLACK), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3061 return this->_pNativeCanvas->GetForegroundColor();
3065 _CanvasImpl::SetBackgroundColor(const Color& bgColor)
3067 SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3069 return this->_pNativeCanvas->SetBackgroundColor(bgColor);
3073 _CanvasImpl::GetBackgroundColor(void) const
3075 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Color::GetColor(COLOR_ID_BLACK), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3077 return this->_pNativeCanvas->GetBackgroundColor();
3081 _CanvasImpl::SetPosition(const Point& vcPoint)
3083 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
3085 return this->SetPosition(vcPoint.x, vcPoint.y);
3089 _CanvasImpl::SetPosition(int vcX, int vcY)
3091 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
3093 _CanvasCoordHolder tempCoordHolder;
3094 tempCoordHolder.AssignCanvasPosFromVc(vcX, vcY);
3096 result r = E_SUCCESS;
3098 if (_ResUtil::NeedToConvertCoord())
3100 Point pcPoint(tempCoordHolder.canvasPos.pcInt.x, tempCoordHolder.canvasPos.pcInt.y);
3102 r = this->_pNativeCanvas->SetPosition(pcPoint.x, pcPoint.y);
3106 r = this->_pNativeCanvas->SetPosition(vcX, vcY);
3111 this->_pCoordHolder->canvasPos = tempCoordHolder.canvasPos;
3119 _CanvasImpl::GetSubCanvasN(const Rectangle& subRegion) const
3121 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, null, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3123 _Canvas* pSourceNativeCanvas = this->_pNativeCanvas;
3125 std::auto_ptr <Canvas> subCanvas(new (std::nothrow) Canvas);
3127 Canvas* pSubCanvas = subCanvas.get();
3129 SysTryReturn(NID_GRP, pSubCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3131 _CanvasImpl* pSubCanvasImpl = _CanvasImpl::GetInstance(*pSubCanvas);
3133 SysTryReturn(NID_GRP, pSubCanvasImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3135 if (_ResUtil::NeedToConvertCoord())
3137 Rectangle subRegionPC = _ResUtil::ConvertToPhyCoord(subRegion);
3139 subRegionPC.width = (subRegionPC.width > 0) ? subRegionPC.width : 1;
3140 subRegionPC.height = (subRegionPC.height > 0) ? subRegionPC.height : 1;
3142 result r = pSubCanvasImpl->_pNativeCanvas->Construct(pSourceNativeCanvas, subRegionPC);
3144 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3146 pSubCanvasImpl->_pCoordHolder->Init(subRegion);
3147 pSubCanvasImpl->_pCoordHolder->canvasSize.pcInt.w = subRegionPC.width;
3148 pSubCanvasImpl->_pCoordHolder->canvasSize.pcInt.h = subRegionPC.height;
3152 result r = pSubCanvasImpl->_pNativeCanvas->Construct(pSourceNativeCanvas, subRegion);
3154 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3159 pSubCanvasImpl->SetFont(*this->_pFont);
3162 if (this->_pPriorityFont)
3164 pSubCanvasImpl->SetPriorityFont(*this->_pPriorityFont);
3167 return subCanvas.release();
3171 _CanvasImpl::GetSubCanvasFN(const FloatRectangle& subRegion) const
3174 Rectangle intSubRegion(static_cast<int>(subRegion.x), static_cast<int>(subRegion.y), static_cast<int>(subRegion.width), static_cast<int>(subRegion.height));
3176 return this->GetSubCanvasN(intSubRegion);
3180 _CanvasImpl::SetAntialiasingEnabled(bool enable)
3182 SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "[E_OUT_OF_MEMORY] This instance is not constructed yet.");
3184 return this->_pNativeCanvas->SetAntialiasingEnabled(enable);
3188 _CanvasImpl::IsAntialiasingEnabled(void) const
3190 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, false, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3192 return this->_pNativeCanvas->IsAntialiasingEnabled();
3196 _CanvasImpl::SetPriorityFont(const Font& font)
3200 // check input param
3201 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3202 SysTryReturn(NID_GRP, font.GetMaxHeight() > 0 && font.GetMaxWidth() > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The infomation of the given font is not valid. (maxWidth=%d, maxHeight=%d).", font.GetMaxWidth(), font.GetMaxHeight());
3204 Font* pFont = &(const_cast <Font&>(font));
3206 EXTRACT_FONTEX(pFontEx, *pFont);
3207 result r = this->_pNativeCanvas->SetPriorityFont(*pFontEx);
3208 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3209 // overwrite existing priority font
3210 this->_pPriorityFont = pFont;
3216 _CanvasImpl::ResetPriorityFont(void)
3218 if (INSTANCE_IS_VALID)
3220 this->_pPriorityFont = null;
3221 this->_pNativeCanvas->ResetPriorityFont();
3226 _CanvasImpl::SetStableRenderer(bool isStable)
3228 if (INSTANCE_IS_VALID)
3230 this->_pNativeCanvas->__useStableRenderer = isStable;
3235 _CanvasImpl::SetFrameInfoCallback(void* (*pGetDefaultFrameNativeHandle)(void), void* (*pGetDefaultFrameHandle)(void))
3237 _GetDefaultFrameEcoreEvasHandle = (pGetDefaultFrameNativeHandle) ? pGetDefaultFrameNativeHandle : _GetNull;
3238 _GetDefaultFrameEvasHandle = (pGetDefaultFrameHandle) ? pGetDefaultFrameHandle : _GetNull;
3242 _CanvasImpl::SetThemeInfoCallback(Color (*pGetDefaultForegroundColor)(void), Color (*pGetDefaultBackgroundColor)(void))
3244 _GetDefaultForegroundColor = (pGetDefaultForegroundColor) ? pGetDefaultForegroundColor : _GetBlack;
3245 _GetDefaultBackgroundColor = (pGetDefaultBackgroundColor) ? pGetDefaultBackgroundColor : _GetWhite;
3249 _CanvasImpl::GetInstance(Canvas& canvas)
3251 return (&canvas != null) ? canvas.__pImpl : null;
3255 _CanvasImpl::GetInstance(const Canvas& canvas)
3257 return (&canvas != null) ? canvas.__pImpl : null;
3260 }} // Tizen::Graphics