2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_CanvasImpl.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] The memory is insufficient.");
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)
169 , _pShowCallbackFunc(null)
170 , _pShowCallbackParam(null)
172 _pNativeCanvas = new (std::nothrow) _Canvas;
173 _pCoordHolder = new (std::nothrow) _CanvasCoordHolder;
175 if (_pNativeCanvas == null || _pCoordHolder == null)
177 delete _pCoordHolder;
178 delete _pNativeCanvas;
180 _pCoordHolder = null;
181 _pNativeCanvas = null;
185 _CanvasImpl::~_CanvasImpl(void)
193 delete _pCoordHolder;
194 delete _pNativeCanvas;
198 _CanvasImpl::Construct(void)
200 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
202 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory.");
204 result r = this->_pNativeCanvas->Construct();
208 Rectangle pcRect = this->_pNativeCanvas->GetBounds();
210 _Util::Rectangle<int> pcUtilRect = { pcRect.x, pcRect.y, pcRect.width, pcRect.height };
212 this->_pCoordHolder->ResetFromPc(pcUtilRect);
219 _CanvasImpl::Construct(const Rectangle& vcRect)
221 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
223 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory.");
225 SysTryReturnResult(NID_GRP, vcRect.width > 0 && vcRect.height > 0, E_OUT_OF_RANGE,
226 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
229 _Util::Rectangle<int> vcUtilRect = { vcRect.x, vcRect.y, vcRect.width, vcRect.height };
231 this->_pCoordHolder->ResetFromVc(vcUtilRect);
233 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
235 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
236 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
238 return this->_pNativeCanvas->Construct(pcRect);
242 _CanvasImpl::Construct(const BufferInfo& bufferInfo)
244 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
246 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory.");
248 SysTryReturnResult(NID_GRP, (bufferInfo.width > 0) && (bufferInfo.height > 0) && (bufferInfo.pitch > 0)
250 , "Invalid argument (BufferInfo::width = %d, BufferInfo::height = %d, BufferInfo::pitch = %d)"
251 , bufferInfo.width, bufferInfo.height, bufferInfo.pitch);
253 SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel > 0
255 , "Invalid argument (BufferInfo::bitsPerPixel = %d)"
256 , bufferInfo.bitsPerPixel);
258 SysTryReturnResult(NID_GRP, (bufferInfo.pixelFormat > PIXEL_FORMAT_MIN) && (bufferInfo.pixelFormat < PIXEL_FORMAT_MAX)
260 , "Invalid argument (BufferInfo::pixelFormat = %d)"
261 , bufferInfo.pixelFormat);
263 SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel == 32
264 , E_UNSUPPORTED_FORMAT
265 , "Unsupported format (BufferInfo::bitsPerPixel = %d)"
266 , bufferInfo.bitsPerPixel);
268 SysTryReturnResult(NID_GRP, bufferInfo.pixelFormat == PIXEL_FORMAT_ARGB8888
269 , E_UNSUPPORTED_FORMAT
270 , "Unsupported format (BufferInfo::pixelFormat = %d)"
271 , bufferInfo.pixelFormat);
273 if (bufferInfo.pPixels == null)
275 const _BufferInfoImpl* pBufferInfoImpl = _BufferInfoImpl::GetInstance(bufferInfo);
279 Handle handle = pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE);
281 if (handle != 0) // not INVALID_HANDLE
283 result r = this->Construct(handle);
285 // OUT_OF_RANGE does not occur
286 SysTryReturn(NID_GRP, (r == E_SUCCESS) && this->IsConstructed(), r, r, "[%s] Propagating.", GetErrorMessage(r));
288 _Util::Rectangle<int> pcUtilRect = { 0, 0, this->_pNativeCanvas->__pSurface->GetWidth(), this->_pNativeCanvas->__pSurface->GetHeight() };
290 this->_pCoordHolder->ResetFromPc(pcUtilRect);
296 SysTryReturnResult(NID_GRP, false
298 , "Invalid argument (BufferInfo::pPixels = null)");
302 result r = this->_pNativeCanvas->Construct(bufferInfo);
304 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
306 _Util::Rectangle<int> pcUtilRect = { 0, 0, this->_pNativeCanvas->__pSurface->GetWidth(), this->_pNativeCanvas->__pSurface->GetHeight() };
308 this->_pCoordHolder->ResetFromPc(pcUtilRect);
317 _CanvasImpl::Construct(Handle windowHandle)
319 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
321 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory.");
323 return this->_pNativeCanvas->Construct(windowHandle);
327 _CanvasImpl::Construct(Handle windowHandle, const Rectangle& vcRect)
329 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
331 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory.");
333 SysTryReturnResult(NID_GRP, vcRect.width >= 0 && vcRect.height >= 0, E_OUT_OF_RANGE,
334 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
337 _Util::Rectangle<int> vcUtilRect = { vcRect.x, vcRect.y, vcRect.width, vcRect.height };
339 this->_pCoordHolder->ResetFromVc(vcUtilRect);
343 pcRect.x = _ResUtil::ConvertToPhyCoord(vcRect.x);
344 pcRect.y = _ResUtil::ConvertToPhyCoord(vcRect.y);
345 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
346 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
348 return this->_pNativeCanvas->Construct(windowHandle, pcRect);
352 _CanvasImpl::Construct(const FloatRectangle& vcRectF)
354 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
356 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory.");
358 SysTryReturnResult(NID_GRP, vcRectF.width > 0.0f && vcRectF.height > 0.0f, E_OUT_OF_RANGE,
359 "The given rectangle(width:%f,height:%f) is out of range.", vcRectF.width,
362 _Util::Rectangle<float> vcUtilRectF = { vcRectF.x, vcRectF.y, vcRectF.width, vcRectF.height };
364 this->_pCoordHolder->ResetFromVc(vcUtilRectF);
366 if (_ResUtil::NeedToConvertCoord())
370 pcRect.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.x));
371 pcRect.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.y));
372 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
373 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
375 return this->_pNativeCanvas->Construct(pcRect);
381 vcRect.x = this->_pCoordHolder->canvasPos.vcInt.x;
382 vcRect.y = this->_pCoordHolder->canvasPos.vcInt.y;
383 vcRect.width = this->_pCoordHolder->canvasSize.vcInt.w;
384 vcRect.height = this->_pCoordHolder->canvasSize.vcInt.h;
386 return this->_pNativeCanvas->Construct(vcRect);
391 _CanvasImpl::Construct(Handle windowHandle, const FloatRectangle& vcRectF)
393 SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet.");
395 SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory.");
397 SysTryReturnResult(NID_GRP, vcRectF.width >= 0.0f && vcRectF.height >= 0.0f, E_OUT_OF_RANGE,
398 "The given rectangle(width:%f,height:%f) is out of range.", vcRectF.width,
401 _Util::Rectangle<float> vcUtilRectF = { vcRectF.x, vcRectF.y, vcRectF.width, vcRectF.height };
403 this->_pCoordHolder->ResetFromVc(vcUtilRectF);
407 pcRect.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.x));
408 pcRect.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcRectF.y));
409 pcRect.width = this->_pCoordHolder->canvasSize.pcInt.w;
410 pcRect.height = this->_pCoordHolder->canvasSize.pcInt.h;
412 return this->_pNativeCanvas->Construct(windowHandle, pcRect);
416 _CanvasImpl::IsConstructed(void) const
418 return (this->_pNativeCanvas != null) && this->_pNativeCanvas->IsValid();
422 _CanvasImpl::Clear(void)
424 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
426 return this->_pNativeCanvas->Clear();
430 _CanvasImpl::Clear(const Rectangle& vcRect)
432 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
434 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
435 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE,
436 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
439 if ((vcRect.width == 0) || (vcRect.height == 0))
444 Rectangle rtCanvas = _GetBoundsRel(*this);
446 if (rtCanvas.IsEmpty())
451 result r = _Util::Validate(vcRect, rtCanvas);
453 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
455 if (_ResUtil::NeedToConvertCoord())
457 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
459 return this->_pNativeCanvas->Clear(pcRect);
463 return this->_pNativeCanvas->Clear(vcRect);
468 _CanvasImpl::Clear(const FloatRectangle& vcRectF)
470 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
472 SysTryReturnResult(NID_GRP, &vcRectF, E_OUT_OF_RANGE, "The given rectangle is invalid.");
473 SysTryReturnResult(NID_GRP, (vcRectF.width >= 0.0f) && (vcRectF.height >= 0.0f), E_OUT_OF_RANGE,
474 "The given rectangle(width:%f,height:%f) is out of range.", vcRectF.width,
477 if ((vcRectF.width == 0.0f) || (vcRectF.height == 0.0f))
482 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
484 if (rtCanvasF.IsEmpty())
489 result r = _Util::Validate(vcRectF, rtCanvasF);
491 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
493 if (_ResUtil::NeedToConvertCoord())
495 FloatRectangle pcRectF = _ResUtil::ConvertToPhyCoord(vcRectF);
496 Rectangle pcRect(_FloatToIntForPos(pcRectF.x), _FloatToIntForPos(pcRectF.y), _FloatToIntForSize(pcRectF.width), _FloatToIntForSize(pcRectF.height));
498 return this->_pNativeCanvas->Clear(pcRect);
502 Rectangle vcRect(_FloatToIntForPos(vcRectF.x), _FloatToIntForPos(vcRectF.y), _FloatToIntForSize(vcRectF.width), _FloatToIntForSize(vcRectF.height));
504 return this->_pNativeCanvas->Clear(vcRect);
509 _CanvasImpl::Copy(const Point& vcDestPoint, const _CanvasImpl& canvas, const Rectangle& vcSrcRect)
511 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
513 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid.");
515 Rectangle srcRectCanvas = _GetBoundsRel(canvas);
517 if (srcRectCanvas.IsEmpty())
522 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
524 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
526 // check if destRect is in this canvas.
527 Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height);
528 Rectangle destRectCanvas = _GetBoundsRel(*this);
530 if (destRectCanvas.IsEmpty())
535 r = _Util::Validate(destRect, destRectCanvas);
537 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
539 EXTRACT_CANVASEX(_pNativeCanvas, canvas);
542 if (_ResUtil::NeedToConvertCoord())
544 Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint);
545 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
547 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect);
551 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect);
556 _CanvasImpl::Copy(const FloatPoint& vcDestPointF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF)
558 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
560 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
562 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
564 if (srcRectCanvasF.IsEmpty())
569 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
571 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
573 // check if destRect is in this canvas.
574 FloatRectangle destRectF(vcDestPointF.x, vcDestPointF.y, vcSrcRectF.width, vcSrcRectF.height);
575 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
577 if (destRectCanvasF.IsEmpty())
582 r = _Util::Validate(destRectF, destRectCanvasF);
584 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
586 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
588 if (_ResUtil::NeedToConvertCoord())
590 FloatPoint pcDestPointF = _ResUtil::ConvertToPhyCoord(vcDestPointF);
591 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
593 Point pcDestPoint(_FloatToIntForPos(pcDestPointF.x), _FloatToIntForPos(pcDestPointF.y));
594 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
596 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect);
600 Point vcDestPoint(_FloatToIntForPos(vcDestPointF.x), _FloatToIntForPos(vcDestPointF.y));
601 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
603 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect);
608 _CanvasImpl::Copy(const Rectangle& vcDestRect, const _CanvasImpl& canvas, const Rectangle& vcSrcRect)
610 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
612 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid.");
614 // check if srcRect is in source canvas.
615 Rectangle srcRectCanvas = _GetBoundsRel(canvas);
617 if (srcRectCanvas.IsEmpty())
622 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
624 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
626 // check if destRect is in this canvas.
627 Rectangle destRectCanvas = _GetBoundsRel(*this);
629 if (destRectCanvas.IsEmpty())
634 r = _Util::Validate(vcDestRect, destRectCanvas);
636 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
638 EXTRACT_CANVASEX(_pNativeCanvas, canvas);
640 if (_ResUtil::NeedToConvertCoord())
642 Rectangle pcDestRect = _ResUtil::ConvertToPhyCoord(vcDestRect);
643 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
645 return this->_pNativeCanvas->Copy(pcDestRect, *_pNativeCanvas, pcSrcRect);
649 return this->_pNativeCanvas->Copy(vcDestRect, *_pNativeCanvas, vcSrcRect);
654 _CanvasImpl::Copy(const FloatRectangle& vcDestRectF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF)
656 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
658 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
660 // check if srcRect is in source canvas.
661 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
663 if (srcRectCanvasF.IsEmpty())
668 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
670 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
672 // check if destRect is in this canvas.
673 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
675 if (destRectCanvasF.IsEmpty())
680 r = _Util::Validate(vcDestRectF, destRectCanvasF);
682 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
684 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
686 if (_ResUtil::NeedToConvertCoord())
688 FloatRectangle pcDestRectF = _ResUtil::ConvertToPhyCoord(vcDestRectF);
689 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
691 Rectangle pcDestRect(_FloatToIntForPos(pcDestRectF.x), _FloatToIntForPos(pcDestRectF.y), _FloatToIntForSize(pcDestRectF.width), _FloatToIntForSize(pcDestRectF.height));
692 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
694 return this->_pNativeCanvas->Copy(pcDestRect, *_pNativeCanvas, pcSrcRect);
698 Rectangle vcDestRect(_FloatToIntForPos(vcDestRectF.x), _FloatToIntForPos(vcDestRectF.y), _FloatToIntForSize(vcDestRectF.width), _FloatToIntForSize(vcDestRectF.height));
699 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
701 return this->_pNativeCanvas->Copy(vcDestRect, *_pNativeCanvas, vcSrcRect);
706 _CanvasImpl::Copy(const Point& vcDestPoint, const _CanvasImpl& canvas, const Rectangle& vcSrcRect, CompositeMode compositeMode)
708 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
710 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid.");
712 switch (compositeMode)
714 case COMPOSITE_MODE_CLEAR:
715 case COMPOSITE_MODE_SRC:
716 case COMPOSITE_MODE_DST:
717 case COMPOSITE_MODE_SRC_OVER:
718 case COMPOSITE_MODE_DST_OVER:
719 case COMPOSITE_MODE_SRC_IN:
720 case COMPOSITE_MODE_DST_IN:
721 case COMPOSITE_MODE_SRC_OUT:
722 case COMPOSITE_MODE_DST_OUT:
723 case COMPOSITE_MODE_SRC_ATOP:
724 case COMPOSITE_MODE_DST_ATOP:
725 case COMPOSITE_MODE_DST_XOR:
726 case COMPOSITE_MODE_ADD:
727 case COMPOSITE_MODE_SATURATE:
728 case COMPOSITE_MODE_MULTIPLY:
729 case COMPOSITE_MODE_SCREEN:
730 case COMPOSITE_MODE_OVERLAY:
731 case COMPOSITE_MODE_DARKEN:
732 case COMPOSITE_MODE_LIGHTEN:
735 SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "The specified composite mode is invalid.");
738 Rectangle srcRectCanvas = _GetBoundsRel(canvas);
740 if (srcRectCanvas.IsEmpty())
745 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
747 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
749 // check if destRect is in this canvas.
750 Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height);
751 Rectangle destRectCanvas = _GetBoundsRel(*this);
753 if (destRectCanvas.IsEmpty())
758 r = _Util::Validate(destRect, destRectCanvas);
760 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
762 EXTRACT_CANVASEX(_pNativeCanvas, canvas);
765 if (_ResUtil::NeedToConvertCoord())
767 Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint);
768 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
770 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect, compositeMode);
774 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect, compositeMode);
779 _CanvasImpl::Copy(const FloatPoint& vcDestPointF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF, CompositeMode compositeMode)
781 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
783 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
785 switch (compositeMode)
787 case COMPOSITE_MODE_CLEAR:
788 case COMPOSITE_MODE_SRC:
789 case COMPOSITE_MODE_DST:
790 case COMPOSITE_MODE_SRC_OVER:
791 case COMPOSITE_MODE_DST_OVER:
792 case COMPOSITE_MODE_SRC_IN:
793 case COMPOSITE_MODE_DST_IN:
794 case COMPOSITE_MODE_SRC_OUT:
795 case COMPOSITE_MODE_DST_OUT:
796 case COMPOSITE_MODE_SRC_ATOP:
797 case COMPOSITE_MODE_DST_ATOP:
798 case COMPOSITE_MODE_DST_XOR:
799 case COMPOSITE_MODE_ADD:
800 case COMPOSITE_MODE_SATURATE:
801 case COMPOSITE_MODE_MULTIPLY:
802 case COMPOSITE_MODE_SCREEN:
803 case COMPOSITE_MODE_OVERLAY:
804 case COMPOSITE_MODE_DARKEN:
805 case COMPOSITE_MODE_LIGHTEN:
808 SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "The specified composite mode is invalid.");
811 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
813 if (srcRectCanvasF.IsEmpty())
818 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
820 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
822 // check if destRect is in this canvas.
823 FloatRectangle destRectF(vcDestPointF.x, vcDestPointF.y, vcSrcRectF.width, vcSrcRectF.height);
824 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
826 if (destRectCanvasF.IsEmpty())
831 r = _Util::Validate(destRectF, destRectCanvasF);
833 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
835 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
838 if (_ResUtil::NeedToConvertCoord())
840 FloatPoint pcDestPointF = _ResUtil::ConvertToPhyCoord(vcDestPointF);
841 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
843 Point pcDestPoint(_FloatToIntForPos(pcDestPointF.x), _FloatToIntForPos(pcDestPointF.y));
844 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
846 return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect, compositeMode);
850 Point vcDestPoint(_FloatToIntForPos(vcDestPointF.x), _FloatToIntForPos(vcDestPointF.y));
851 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
853 return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect, compositeMode);
858 _CanvasImpl::CopyEx(const Point& vcDestPoint, const _CanvasImpl& srcCanvas, const Rectangle& vcSrcRect)
860 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
862 if (this != &srcCanvas)
864 return this->Copy(vcDestPoint, srcCanvas, vcSrcRect);
867 // validity check as _CanvasImpl::Copy()
868 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
870 Rectangle srcRectCanvas = _GetBoundsRel(srcCanvas);
872 if (srcRectCanvas.IsEmpty())
877 result r = _Util::Validate(vcSrcRect, srcRectCanvas);
879 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
881 // check if destRect is in this canvas.
882 Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height);
883 Rectangle destRectCanvas = _GetBoundsRel(*this);
885 if (destRectCanvas.IsEmpty())
890 r = _Util::Validate(destRect, destRectCanvas);
892 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
894 int pixelPerLine = 0;
897 BufferInfo bufferInfo;
899 result r = this->_pNativeCanvas->Lock(bufferInfo);
902 SysTryReturn(NID_GRP, r == E_SUCCESS, r, E_SYSTEM, "[] ");
904 this->_pNativeCanvas->Unlock();
906 pixelPerLine = bufferInfo.pitch / (bufferInfo.bitsPerPixel / 8);
909 //?? Auto-scaling should be applied to vc**** parameters later
910 int sourDistance = vcSrcRect.y * pixelPerLine + vcSrcRect.x;
911 int destDistance = vcDestPoint.y * pixelPerLine + vcDestPoint.x;
913 typedef result (_Canvas::* FnCopy)(const Point&, const _Canvas&, const Rectangle&);
914 FnCopy fnCopy = (destDistance < sourDistance) ? FnCopy(&_Canvas::Copy) : FnCopy(&_Canvas::CopyReverse);
918 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
920 if (_ResUtil::NeedToConvertCoord())
922 Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint);
923 Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect);
925 return (this->_pNativeCanvas->*fnCopy)(pcDestPoint, *_pNativeCanvas, pcSrcRect);
929 return (this->_pNativeCanvas->*fnCopy)(vcDestPoint, *_pNativeCanvas, vcSrcRect);
938 _CanvasImpl::CopyEx(const FloatPoint& vcDestPointF, const _CanvasImpl& srcCanvas, const FloatRectangle& vcSrcRectF)
940 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
942 if (this != &srcCanvas)
944 return this->Copy(vcDestPointF, srcCanvas, vcSrcRectF);
947 // validity check as _CanvasImpl::Copy()
948 SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid.");
950 FloatRectangle srcRectCanvasF = _GetBoundsRelF(srcCanvas);
952 if (srcRectCanvasF.IsEmpty())
957 result r = _Util::Validate(vcSrcRectF, srcRectCanvasF);
959 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
961 // check if destRect is in this canvas.
962 FloatRectangle destRectF(vcDestPointF.x, vcDestPointF.y, vcSrcRectF.width, vcSrcRectF.height);
963 FloatRectangle destRectCanvasF = _GetBoundsRelF(*this);
965 if (destRectCanvasF.IsEmpty())
970 r = _Util::Validate(destRectF, destRectCanvasF);
972 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
974 int pixelPerLine = 0;
977 BufferInfo bufferInfo;
979 result r = this->_pNativeCanvas->Lock(bufferInfo);
982 SysTryReturn(NID_GRP, r == E_SUCCESS, r, E_SYSTEM, "[] ");
984 this->_pNativeCanvas->Unlock();
986 pixelPerLine = bufferInfo.pitch / (bufferInfo.bitsPerPixel / 8);
989 Point vcDestPoint(_FloatToIntForPos(vcDestPointF.x), _FloatToIntForPos(vcDestPointF.y));
990 Rectangle vcSrcRect(_FloatToIntForPos(vcSrcRectF.x), _FloatToIntForPos(vcSrcRectF.y), _FloatToIntForSize(vcSrcRectF.width), _FloatToIntForSize(vcSrcRectF.height));
992 //?? Auto-scaling should be applied to vc**** parameters later
993 int sourDistance = vcSrcRect.y * pixelPerLine + vcSrcRect.x;
994 int destDistance = vcDestPoint.y * pixelPerLine + vcDestPoint.x;
996 typedef result (_Canvas::* FnCopy)(const Point&, const _Canvas&, const Rectangle&);
997 FnCopy fnCopyF = (destDistance < sourDistance) ? FnCopy(&_Canvas::Copy) : FnCopy(&_Canvas::CopyReverse);
1001 EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas);
1003 if (_ResUtil::NeedToConvertCoord())
1005 FloatPoint pcDestPointF = _ResUtil::ConvertToPhyCoord(vcDestPointF);
1006 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
1008 Point pcDestPoint(_FloatToIntForPos(pcDestPointF.x), _FloatToIntForPos(pcDestPointF.y));
1009 Rectangle pcSrcRect(_FloatToIntForPos(pcSrcRectF.x), _FloatToIntForPos(pcSrcRectF.y), _FloatToIntForSize(pcSrcRectF.width), _FloatToIntForSize(pcSrcRectF.height));
1011 return (this->_pNativeCanvas->*fnCopyF)(pcDestPoint, *_pNativeCanvas, pcSrcRect);
1015 return (this->_pNativeCanvas->*fnCopyF)(vcDestPoint, *_pNativeCanvas, vcSrcRect);
1024 _CanvasImpl::DrawArc(const FloatRectangle& vcBounds, float startAngle, float endAngle, ArcStyle arcStyle)
1026 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1027 SysTryReturnResult(NID_GRP, ARC_STYLE_MIN < arcStyle && arcStyle < ARC_STYLE_MAX, E_INVALID_ARG, "The invalid arc type(%d) is given.", arcStyle);
1028 SysTryReturnResult(NID_GRP, &vcBounds, E_INVALID_ARG, "The given rectangle is invalid.");
1029 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0.0f) && (vcBounds.height >= 0.0f), E_OUT_OF_RANGE,
1030 "The given rectangle(width:%f,height:%f) is out of range.", vcBounds.width, vcBounds.height);
1032 return _CanvasImplPrivate::DrawArc(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcBounds), double(startAngle), double(endAngle), arcStyle);
1036 _CanvasImpl::DrawArc(const Rectangle& vcBounds, int startAngle, int endAngle, ArcStyle arcStyle)
1038 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1039 SysTryReturnResult(NID_GRP, ARC_STYLE_MIN < arcStyle && arcStyle < ARC_STYLE_MAX, E_INVALID_ARG, "The invalid arc type(%d) is given.", arcStyle);
1040 SysTryReturnResult(NID_GRP, &vcBounds, E_INVALID_ARG, "The given rectangle is invalid.");
1041 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE,
1042 "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height);
1044 return _CanvasImplPrivate::DrawArc(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcBounds), double(startAngle), double(endAngle), arcStyle);
1048 _CanvasImpl::DrawBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap)
1050 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1052 return this->DrawBitmap(FloatRectangle(float(vcRect.x), float(vcRect.y), float(vcRect.width), float(vcRect.height)), bitmap);
1056 _CanvasImpl::DrawBitmap(const FloatRectangle& vcRectF, const _BitmapImpl& bitmap)
1058 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1060 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1061 SysTryReturnResult(NID_GRP, &vcRectF, E_INVALID_ARG, "The source rectangle is invalid.");
1063 // @ykahn vcRectF.width in [bitmap.GetActualWidth()..bitmap.GetWidthF()]
1064 if (vcRectF.width == bitmap.GetWidthF() && vcRectF.height == bitmap.GetHeightF())
1066 return this->DrawBitmap(FloatPoint(vcRectF.x, vcRectF.y), bitmap);
1069 // check if bimap can be drew in canvas area.
1070 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
1072 if (rtCanvasF.IsEmpty())
1077 result r = _Util::Validate(vcRectF, rtCanvasF);
1079 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1081 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1083 if (_ResUtil::NeedToConvertCoord())
1085 FloatRectangle pcRectF = _ResUtil::ConvertToPhyCoord(vcRectF);
1087 _Util::Rectangle<double> pcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcRectF);
1089 return this->_pNativeCanvas->DrawBitmap(pcRectD, *pBitmapEx);
1093 _Util::Rectangle<double> vcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRectF);
1095 return this->_pNativeCanvas->DrawBitmap(vcRectD, *pBitmapEx);
1100 _CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap)
1102 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1104 return this->DrawBitmap(FloatPoint(float(vcPoint.x), float(vcPoint.y)), bitmap);
1108 _CanvasImpl::DrawBitmap(const FloatPoint& vcPointF, const _BitmapImpl& bitmap)
1110 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1112 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1114 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
1116 if (rtCanvasF.IsEmpty())
1121 result r = _Util::Validate(FloatRectangle(vcPointF.x, vcPointF.y, bitmap.GetWidthF(), bitmap.GetHeightF()), rtCanvasF);
1123 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1125 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1127 if (_ResUtil::NeedToConvertCoord())
1129 Tizen::Graphics::Dimension virSize;
1130 Tizen::Graphics::Dimension phySize;
1131 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1133 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
1134 _Util::Point<double> pcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPointF);
1138 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1140 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pScaledBitmapEx);
1144 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pBitmapEx);
1149 _Util::Point<double> vcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(vcPointF);
1151 return this->_pNativeCanvas->DrawBitmap(vcPointD, *pBitmapEx);
1156 _CanvasImpl::DrawBitmap(const Rectangle& vcDestRect, const _BitmapImpl& srcBitmap, const Rectangle& vcSrcRect)
1158 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1160 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)));
1164 _CanvasImpl::DrawBitmap(const FloatRectangle& vcDestRectF, const _BitmapImpl& srcBitmap, const FloatRectangle& vcSrcRectF)
1166 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1168 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(srcBitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1170 SysTryReturnResult(NID_GRP, (&vcSrcRectF) && (&vcDestRectF), E_INVALID_ARG, "The given rectangle is invalid.");
1172 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);
1173 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);
1175 if (vcSrcRectF.width == 0.0f || vcSrcRectF.height == 0.0f)
1180 if (vcDestRectF.width == 0.0f || vcDestRectF.height == 0.0f)
1185 if ((vcSrcRectF.x < 0.0f) || (vcSrcRectF.y < 0.0f) || (vcSrcRectF.x + vcSrcRectF.width > srcBitmap.GetWidthF()) || (vcSrcRectF.y + vcSrcRectF.height > srcBitmap.GetHeightF()))
1187 SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, "The specified region of source bitmap is out of range.");
1190 // check if srcRect is in bitmap's area.
1191 result r = _Util::Validate(vcSrcRectF, FloatRectangle(0, 0, srcBitmap.GetWidthF(), srcBitmap.GetHeightF()));
1193 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1195 // check if destRect is in this canvas.
1196 FloatRectangle rtCanvas = _GetBoundsRelF(*this);
1198 if (rtCanvas.IsEmpty())
1203 r = _Util::Validate(vcDestRectF, rtCanvas);
1205 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1207 EXTRACT_BITMAPEX(pBitmapEx, srcBitmap);
1209 if (_ResUtil::NeedToConvertCoord())
1211 Tizen::Graphics::Dimension virSize;
1212 Tizen::Graphics::Dimension phySize;
1213 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(srcBitmap, virSize, phySize);
1215 FloatRectangle pcDestRectF = _ResUtil::ConvertToPhyCoord(vcDestRectF);
1217 _Util::Rectangle<double> pcDestRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcDestRectF);
1221 _Util::Rectangle<double> vcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcSrcRectF);
1223 return this->_pNativeCanvas->DrawBitmap(pcDestRectD, *pBitmapEx, vcSrcRectD);
1227 FloatRectangle pcSrcRectF = _ResUtil::ConvertToPhyCoord(vcSrcRectF);
1229 _Util::Rectangle<double> pcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(pcSrcRectF);
1231 return this->_pNativeCanvas->DrawBitmap(pcDestRectD, *pBitmapEx, pcSrcRectD);
1236 _Util::Rectangle<double> vcSrcRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcSrcRectF);
1237 _Util::Rectangle<double> vcDestRectD = _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcDestRectF);
1239 return this->_pNativeCanvas->DrawBitmap(vcDestRectD, *pBitmapEx, vcSrcRectD);
1244 _CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap, FlipDirection dir)
1246 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1248 return this->DrawBitmap(FloatPoint(float(vcPoint.x), float(vcPoint.y)), bitmap, dir);
1252 _CanvasImpl::DrawBitmap(const FloatPoint& vcPointF, const _BitmapImpl& bitmap, FlipDirection dir)
1254 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1256 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1260 case FLIP_DIRECTION_HORIZONTAL:
1261 case FLIP_DIRECTION_VERTICAL:
1264 SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "FlipStyle(%d) is invalid.", dir);
1268 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1270 if (_ResUtil::NeedToConvertCoord())
1272 Tizen::Graphics::Dimension virSize;
1273 Tizen::Graphics::Dimension phySize;
1274 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1276 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
1278 _Util::Point<double> pcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPointF);
1282 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1284 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pScaledBitmapEx, dir);
1288 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pBitmapEx, dir);
1293 _Util::Point<double> vcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(vcPointF);
1295 return this->_pNativeCanvas->DrawBitmap(vcPointD, *pBitmapEx, dir);
1300 _CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap, const Point& vcPivot, int degree)
1302 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1304 return this->DrawBitmap(FloatPoint(float(vcPoint.x), float(vcPoint.y)), bitmap, FloatPoint(float(vcPivot.x), float(vcPivot.y)), float(degree));
1308 _CanvasImpl::DrawBitmap(const FloatPoint& vcPointF, const _BitmapImpl& bitmap, const FloatPoint& vcPivotF, float degree)
1310 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1312 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1314 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1316 if (_ResUtil::NeedToConvertCoord())
1318 Tizen::Graphics::Dimension virSize;
1319 Tizen::Graphics::Dimension phySize;
1320 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1322 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
1323 FloatPoint pcPivotF = _ResUtil::ConvertToPhyCoord(vcPivotF);
1325 _Util::Point<double> pcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPointF);
1326 _Util::Point<double> pcPivotD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPivotF);
1330 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1332 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pScaledBitmapEx, pcPivotD, double(degree));
1336 return this->_pNativeCanvas->DrawBitmap(pcPointD, *pBitmapEx, pcPivotD, double(degree));
1341 return this->_pNativeCanvas->DrawBitmap(_Util::Convert<FloatPoint, _Util::Point<double> >(vcPointF), *pBitmapEx, _Util::Convert<FloatPoint, _Util::Point<double> >(vcPivotF), double(degree));
1346 _CanvasImpl::DrawNinePatchedBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap)
1348 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1350 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1352 SysTryReturnResult(NID_GRP, bitmap.IsNinePatchedBitmap(), E_INVALID_ARG, "The source bitmap is not a nine patched bitmap.");
1354 // check if bimap can be drew in canvas area.
1355 Rectangle rtCanvas = _GetBoundsRel(*this);
1357 if (rtCanvas.IsEmpty())
1359 SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas.");
1362 result r = _Util::Validate(vcRect, rtCanvas);
1364 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1366 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1368 if (_ResUtil::NeedToConvertCoord())
1370 Tizen::Graphics::Dimension virSize;
1371 Tizen::Graphics::Dimension phySize;
1372 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1374 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
1378 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1380 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pScaledBitmapEx);
1384 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pBitmapEx);
1389 return this->_pNativeCanvas->DrawNinePatchedBitmap(vcRect, *pBitmapEx);
1394 _CanvasImpl::DrawNinePatchedBitmap(const FloatRectangle& vcRectF, const _BitmapImpl& bitmap)
1396 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1398 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1400 SysTryReturnResult(NID_GRP, bitmap.IsNinePatchedBitmap(), E_INVALID_ARG, "The source bitmap is not a nine patched bitmap.");
1402 // check if bimap can be drew in canvas area.
1403 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
1405 if (rtCanvasF.IsEmpty())
1407 SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas.");
1410 result r = _Util::Validate(vcRectF, rtCanvasF);
1412 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
1414 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1416 if (_ResUtil::NeedToConvertCoord())
1418 Tizen::Graphics::Dimension virSize;
1419 Tizen::Graphics::Dimension phySize;
1420 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1422 FloatRectangle pcRectF = _ResUtil::ConvertToPhyCoord(vcRectF);
1424 Rectangle pcRect(_FloatToIntForPos(pcRectF.x), _FloatToIntForPos(pcRectF.y), _FloatToIntForSize(pcRectF.width), _FloatToIntForSize(pcRectF.height));
1428 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1430 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pScaledBitmapEx);
1434 return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pBitmapEx);
1439 Rectangle vcRect(_FloatToIntForPos(vcRectF.x), _FloatToIntForPos(vcRectF.y), _FloatToIntForSize(vcRectF.width), _FloatToIntForSize(vcRectF.height));
1441 return this->_pNativeCanvas->DrawNinePatchedBitmap(vcRect, *pBitmapEx);
1446 _CanvasImpl::DrawNineTiledBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap)
1448 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1450 SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid.");
1452 SysTryReturnResult(NID_GRP, bitmap.IsNinePatchedBitmap(), E_INVALID_ARG, "The source bitmap is not a nine tiled bitmap.");
1454 // check if bimap can be drew in canvas area.
1455 Rectangle rtCanvas = _GetBoundsRel(*this);
1457 if (rtCanvas.IsEmpty())
1459 SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas.");
1462 result r = _Util::Validate(vcRect, rtCanvas);
1469 EXTRACT_BITMAPEX(pBitmapEx, bitmap);
1471 if (_ResUtil::NeedToConvertCoord())
1473 Tizen::Graphics::Dimension virSize;
1474 Tizen::Graphics::Dimension phySize;
1475 bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize);
1477 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
1481 EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap);
1483 return this->_pNativeCanvas->DrawNineTiledBitmap(pcRect, *pScaledBitmapEx);
1487 return this->_pNativeCanvas->DrawNineTiledBitmap(pcRect, *pBitmapEx);
1492 return this->_pNativeCanvas->DrawNineTiledBitmap(vcRect, *pBitmapEx);
1497 _CanvasImpl::DrawEllipse(const Rectangle& vcBounds)
1499 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1500 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1501 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE,
1502 "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height);
1504 return _CanvasImplPrivate::DrawEllipse(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcBounds));
1508 _CanvasImpl::DrawEllipse(const FloatRectangle& vcBounds)
1510 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1511 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1512 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0.0f) && (vcBounds.height >= 0.0f), E_OUT_OF_RANGE,
1513 "The given rectangle(width:%f,height:%f) is out of range.", vcBounds.width, vcBounds.height);
1515 return _CanvasImplPrivate::DrawEllipse(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcBounds));
1519 _CanvasImpl::DrawLine(const Point& vcPoint1, const Point& vcPoint2)
1521 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1523 return _CanvasImplPrivate::DrawLine(this,
1524 _Util::Convert<Point, _Util::Point<double> >(vcPoint1),
1525 _Util::Convert<Point, _Util::Point<double> >(vcPoint2));
1529 _CanvasImpl::DrawLine(const FloatPoint& vcPoint1, const FloatPoint& vcPoint2)
1531 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1533 return _CanvasImplPrivate::DrawLine(this,
1534 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint1),
1535 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint2));
1539 _CanvasImpl::DrawPolygon(const Tizen::Base::Collection::IList& vcPoints)
1541 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1543 int numPoint = vcPoints.GetCount();
1545 SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint);
1547 if (numPoint < 2) // TBD.
1552 std::unique_ptr<_Util::Point<double>[]> doublePoint;
1555 _Util::Point<double>* pDoublePoint = _Util::Convert<Tizen::Base::Collection::IList, _Util::Point<double>*>(vcPoints);
1557 SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid.");
1559 doublePoint.reset(pDoublePoint);
1562 if (_ResUtil::NeedToConvertCoord())
1564 for (int i = 0; i < numPoint; i++)
1566 doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]);
1569 return this->_pNativeCanvas->DrawPolygon(doublePoint.get(), numPoint);
1573 return this->_pNativeCanvas->DrawPolygon(doublePoint.get(), numPoint);
1578 _CanvasImpl::DrawPolyline(const Tizen::Base::Collection::IList& vcPoints)
1580 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1582 int numPoint = vcPoints.GetCount();
1584 SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint);
1591 std::unique_ptr<_Util::Point<double>[]> doublePoint;
1594 _Util::Point<double>* pDoublePoint = _Util::Convert<Tizen::Base::Collection::IList, _Util::Point<double>*>(vcPoints);
1596 SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid.");
1598 doublePoint.reset(pDoublePoint);
1601 if (_ResUtil::NeedToConvertCoord())
1603 for (int i = 0; i < numPoint; i++)
1605 doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]);
1608 return this->_pNativeCanvas->DrawPolyline(doublePoint.get(), numPoint);
1612 return this->_pNativeCanvas->DrawPolyline(doublePoint.get(), numPoint);
1617 _CanvasImpl::DrawRectangle(const Rectangle& vcRect)
1619 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1620 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1621 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);
1623 return _CanvasImplPrivate::DrawRectangle(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect));
1627 _CanvasImpl::DrawRectangle(const FloatRectangle& vcRect)
1629 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1630 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1631 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);
1633 return _CanvasImplPrivate::DrawRectangle(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect));
1637 _CanvasImpl::DrawRoundRectangle(const Rectangle& vcRect, const Dimension& vcArcDim)
1639 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1640 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1641 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);
1642 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);
1644 return _CanvasImplPrivate::DrawRoundRectangle(this, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<Dimension, _Util::Dimension<double> >(vcArcDim));
1648 _CanvasImpl::DrawRoundRectangle(const FloatRectangle& vcRect, const FloatDimension& vcArcDim)
1650 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1651 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1652 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);
1653 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);
1655 return _CanvasImplPrivate::DrawRoundRectangle(this, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<FloatDimension, _Util::Dimension<double> >(vcArcDim));
1659 _CanvasImpl::DrawTriangle(const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3)
1661 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1663 return _CanvasImplPrivate::DrawTriangle(this,
1664 _Util::Convert<Point, _Util::Point<double> >(vcPoint1),
1665 _Util::Convert<Point, _Util::Point<double> >(vcPoint2),
1666 _Util::Convert<Point, _Util::Point<double> >(vcPoint3));
1670 _CanvasImpl::DrawTriangle(const FloatPoint& vcPoint1, const FloatPoint& vcPoint2, const FloatPoint& vcPoint3)
1672 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1674 return _CanvasImplPrivate::DrawTriangle(this,
1675 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint1),
1676 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint2),
1677 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint3));
1681 _CanvasImpl::FillEllipse(const Color& color, const Rectangle& vcBounds)
1683 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1684 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1685 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE,
1686 "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height);
1688 return _CanvasImplPrivate::FillEllipse(this, color, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcBounds));
1692 _CanvasImpl::FillEllipse(const Color& color, const FloatRectangle& vcBounds)
1694 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1695 SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1696 SysTryReturnResult(NID_GRP, (vcBounds.width >= 0.0f) && (vcBounds.height >= 0.0f), E_OUT_OF_RANGE,
1697 "The given rectangle(width:%f,height:%f) is out of range.", vcBounds.width, vcBounds.height);
1699 return _CanvasImplPrivate::FillEllipse(this, color, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcBounds));
1703 _CanvasImpl::FillPolygon(const Color& color, const Tizen::Base::Collection::IList& vcPoints)
1705 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1707 SysTryReturnResult(NID_GRP, &vcPoints, E_INVALID_ARG, "The given rectangle is invalid.");
1709 int numPoint = vcPoints.GetCount();
1711 SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint);
1713 if (numPoint < 3) // TBD.
1718 std::unique_ptr<_Util::Point<double>[]> doublePoint;
1721 _Util::Point<double>* pDoublePoint = _Util::Convert<Tizen::Base::Collection::IList, _Util::Point<double>*>(vcPoints);
1723 SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid.");
1725 doublePoint.reset(pDoublePoint);
1728 if (_ResUtil::NeedToConvertCoord())
1730 for (int i = 0; i < numPoint; i++)
1732 doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]);
1735 return this->_pNativeCanvas->FillPolygon(color, doublePoint.get(), numPoint);
1739 return this->_pNativeCanvas->FillPolygon(color, doublePoint.get(), numPoint);
1744 _CanvasImpl::FillRectangle(const Color& color, const Rectangle& vcRect)
1746 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1747 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1748 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);
1750 return _CanvasImplPrivate::FillRectangle(this, color, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect));
1754 _CanvasImpl::FillRectangle(const Color& color, const FloatRectangle& vcRect)
1756 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1757 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
1758 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);
1760 return _CanvasImplPrivate::FillRectangle(this, color, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect));
1764 _CanvasImpl::FillRoundRectangle(const Color& color, const Rectangle& vcRect, const Dimension& vcArcDim)
1766 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1767 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1768 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);
1769 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);
1771 return _CanvasImplPrivate::FillRoundRectangle(this, color, _Util::Convert<Rectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<Dimension, _Util::Dimension<double> >(vcArcDim));
1775 _CanvasImpl::FillRoundRectangle(const Color& color, const FloatRectangle& vcRect, const FloatDimension& vcArcDim)
1777 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1778 SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid.");
1779 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);
1780 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);
1782 return _CanvasImplPrivate::FillRoundRectangle(this, color, _Util::Convert<FloatRectangle, _Util::Rectangle<double> >(vcRect), _Util::Convert<FloatDimension, _Util::Dimension<double> >(vcArcDim));
1786 _CanvasImpl::FillTriangle(const Color& color, const FloatPoint& vcPoint1, const FloatPoint& vcPoint2, const FloatPoint& vcPoint3)
1788 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1790 return _CanvasImplPrivate::FillTriangle(this, color,
1791 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint1),
1792 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint2),
1793 _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint3));
1797 _CanvasImpl::FillTriangle(const Color& color, const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3)
1799 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1801 return _CanvasImplPrivate::FillTriangle(this, color,
1802 _Util::Convert<Point, _Util::Point<double> >(vcPoint1),
1803 _Util::Convert<Point, _Util::Point<double> >(vcPoint2),
1804 _Util::Convert<Point, _Util::Point<double> >(vcPoint3));
1808 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text)
1810 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1812 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1814 if (_ResUtil::NeedToConvertCoord())
1816 Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint);
1818 return this->_pNativeCanvas->DrawText(pcPoint, text);
1822 return this->_pNativeCanvas->DrawText(vcPoint, text);
1827 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, int length)
1829 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1830 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1831 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);
1833 if (text.GetLength() == 0)
1838 if (_ResUtil::NeedToConvertCoord())
1840 Point pcPt = _ResUtil::ConvertToPhyCoord(vcPoint);
1842 return this->_pNativeCanvas->DrawText(pcPt, text, startIndex, length);
1846 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length);
1851 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, const Color& outlineColor)
1853 const char* pNotConstructedYet = "[E_OPERATION_FAILED] This instance is not constructed yet.";
1855 SysTryReturn(NID_GRP, this, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1856 SysTryReturn(NID_GRP, this->_pNativeCanvas, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1857 SysTryReturn(NID_GRP, this->_pNativeCanvas->IsValid(), E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1859 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1861 return this->DrawText(vcPoint, text, startIndex, text.GetLength(), outlineColor);
1865 _CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor)
1867 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1869 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1871 SysTryReturnResult(NID_GRP, length >= 0, E_OUT_OF_RANGE,
1872 "The value of the length (%d) is outside the valid range defined by the method.",
1875 if (text.GetLength() == 0)
1880 if (_ResUtil::NeedToConvertCoord())
1882 Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint);
1884 return this->_pNativeCanvas->DrawText(pcPoint, text, startIndex, length, outlineColor);
1888 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length, outlineColor);
1893 _CanvasImpl::DrawText(const Point& vcPoint, const EnrichedText& etext)
1895 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1897 const _EnrichedTextImpl* pImpl = _EnrichedTextImpl::GetInstance(etext);
1901 return E_OPERATION_FAILED;
1904 Tizen::Graphics::_Text::TextObject* pTextObject = const_cast <_EnrichedTextImpl*>(pImpl)->GetTextObject();
1906 if (pTextObject == null)
1908 return E_OPERATION_FAILED;
1911 FloatRectangle bounds = pImpl->GetBoundsF();
1912 FloatRectangle rect(vcPoint.x, vcPoint.y, bounds.width, bounds.height);
1914 pTextObject->SetBounds(rect);
1915 pTextObject->Draw(*this);
1921 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text)
1923 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1925 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1927 if (_ResUtil::NeedToConvertCoord())
1930 pcPoint.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.x));
1931 pcPoint.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.y));
1933 return this->_pNativeCanvas->DrawText(pcPoint, text);
1938 vcPoint.x = _FloatToIntForPos(vcPointF.x);
1939 vcPoint.y = _FloatToIntForPos(vcPointF.y);
1941 return this->_pNativeCanvas->DrawText(vcPoint, text);
1946 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text, int startIndex, int length)
1948 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1949 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1950 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);
1952 if (text.GetLength() == 0)
1957 if (_ResUtil::NeedToConvertCoord())
1960 pcPoint.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.x));
1961 pcPoint.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.y));
1963 return this->_pNativeCanvas->DrawText(pcPoint, text, startIndex, length);
1968 vcPoint.x = _FloatToIntForPos(vcPointF.x);
1969 vcPoint.y = _FloatToIntForPos(vcPointF.y);
1971 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length);
1976 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text, int startIndex, const Color& outlineColor)
1978 const char* pNotConstructedYet = "[E_OPERATION_FAILED] This instance is not constructed yet.";
1980 SysTryReturn(NID_GRP, this, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1981 SysTryReturn(NID_GRP, this->_pNativeCanvas, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1982 SysTryReturn(NID_GRP, this->_pNativeCanvas->IsValid(), E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet);
1984 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
1987 vcPoint.x = _FloatToIntForPos(vcPointF.x);
1988 vcPoint.y = _FloatToIntForPos(vcPointF.y);
1990 return this->DrawText(vcPoint, text, startIndex, text.GetLength(), outlineColor);
1994 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor)
1996 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
1998 SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength());
2000 SysTryReturnResult(NID_GRP, length >= 0, E_OUT_OF_RANGE,
2001 "The value of the length (%d) is outside the valid range defined by the method.",
2004 if (text.GetLength() == 0)
2009 if (_ResUtil::NeedToConvertCoord())
2012 pcPoint.x = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.x));
2013 pcPoint.y = _FloatToIntForPos(_ResUtil::ConvertToPhyCoord(vcPointF.y));
2015 return this->_pNativeCanvas->DrawText(pcPoint, text, startIndex, length, outlineColor);
2020 vcPoint.x = _FloatToIntForPos(vcPointF.x);
2021 vcPoint.y = _FloatToIntForPos(vcPointF.y);
2023 return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length, outlineColor);
2028 _CanvasImpl::DrawText(const FloatPoint& vcPointF, const EnrichedText& etext)
2030 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2032 const _EnrichedTextImpl* pImpl = _EnrichedTextImpl::GetInstance(etext);
2036 return E_OPERATION_FAILED;
2039 Tizen::Graphics::_Text::TextObject* pTextObject = const_cast <_EnrichedTextImpl*>(pImpl)->GetTextObject();
2041 if (pTextObject == null)
2043 return E_OPERATION_FAILED;
2046 FloatRectangle bounds = pImpl->GetBoundsF();
2047 FloatRectangle rect(vcPointF.x, vcPointF.y, bounds.width, bounds.height);
2049 pTextObject->SetBounds(rect);
2050 pTextObject->Draw(*this);
2056 _CanvasImpl::GetBounds(void) const
2058 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Rectangle(), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2060 if (_ResUtil::NeedToConvertCoord())
2062 const _Util::Point<int>& pos = this->_pCoordHolder->canvasPos.vcInt;
2063 const _Util::Dimension<int>& vcSize = this->_pCoordHolder->canvasSize.vcInt;
2064 const Rectangle boundsFromPi = this->_pNativeCanvas->GetBounds();
2066 if ((vcSize.w == 0 && boundsFromPi.width > 0) || (vcSize.h == 0 && boundsFromPi.height > 0))
2068 _CanvasImpl* pThis = const_cast<_CanvasImpl*>(this);
2070 _Util::Dimension<int> intPcSize = { boundsFromPi.width, boundsFromPi.height };
2072 pThis->_pCoordHolder->AssignCanvasSizeFromPcSize(intPcSize);
2075 // exception from the window canvas
2076 if (boundsFromPi.x == 0 && boundsFromPi.y == 0)
2078 return Rectangle(0, 0, vcSize.w, vcSize.h);
2082 return Rectangle(pos.x, pos.y, vcSize.w, vcSize.h);
2087 return this->_pNativeCanvas->GetBounds();
2092 _CanvasImpl::GetBoundsF(void) const
2094 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, FloatRectangle(), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2096 const Rectangle boundsFromPi = this->_pNativeCanvas->GetBounds();
2098 if (_ResUtil::NeedToConvertCoord())
2100 const _Util::Point<float>& posF = this->_pCoordHolder->canvasPos.vcFloat;
2101 const _Util::Dimension<float>& vcSizeF = this->_pCoordHolder->canvasSize.vcFloat;
2103 // exception from the window canvas
2104 if (boundsFromPi.x == 0 && boundsFromPi.y == 0)
2106 return FloatRectangle(0.0f, 0.0f, vcSizeF.w, vcSizeF.h);
2110 return FloatRectangle(posF.x, posF.y, vcSizeF.w, vcSizeF.h);
2115 return FloatRectangle(static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.width), static_cast<float>(boundsFromPi.height));
2121 _CanvasImpl::GetActualBounds(void) const
2123 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, FloatRectangle(), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2125 const Rectangle boundsFromPi = this->_pNativeCanvas->GetBounds();
2127 if (_ResUtil::NeedToConvertCoord())
2129 const _Util::Point<float>& actualPosF = this->_pCoordHolder->canvasPos.vcFloatActual;
2130 const _Util::Dimension<float>& vcActualSizeF = this->_pCoordHolder->canvasSize.vcFloatActual;
2132 // exception from the window canvas
2133 if (boundsFromPi.x == 0 && boundsFromPi.y == 0)
2135 return FloatRectangle(0.0f, 0.0f, vcActualSizeF.w, vcActualSizeF.h);
2139 return FloatRectangle(actualPosF.x, actualPosF.y, vcActualSizeF.w, vcActualSizeF.h);
2144 return FloatRectangle(static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.x), static_cast<float>(boundsFromPi.width), static_cast<float>(boundsFromPi.height));
2149 _CanvasImpl::GetLineStyle() const
2151 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, LINE_STYLE_MAX, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2153 return this->_pNativeCanvas->GetLineStyle();
2157 _CanvasImpl::GetLineWidth() const
2159 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, -1, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2161 return this->_pCoordHolder->lineWidth.vcInt;
2165 _CanvasImpl::GetLineWidthF() const
2167 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, -1.0f, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2169 return this->_pCoordHolder->lineWidth.vcFloat;
2173 _CanvasImpl::GetLineCapStyle() const
2175 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, LINE_CAP_STYLE_ROUND, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2177 return this->_pNativeCanvas->GetLineCapStyle();
2181 _CanvasImpl::GetLineJoinStyle() const
2183 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, LINE_JOIN_STYLE_ROUND, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2185 return this->_pNativeCanvas->GetLineJoinStyle();
2189 _CanvasImpl::SetLineStyle(LineStyle style)
2191 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2193 SysTryReturnResult(NID_GRP, LINE_STYLE_MIN < style && style < LINE_STYLE_MAX, E_INVALID_ARG, "The given line style(%d) is out of range.", style);
2195 return this->_pNativeCanvas->SetLineStyle(style);
2199 _CanvasImpl::SetLineWidth(int vcWidth)
2201 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2203 SysTryReturnResult(NID_GRP, vcWidth > 0, E_OUT_OF_RANGE, "The given line width(%d) is out of range.", vcWidth);
2205 result r = E_SUCCESS;
2207 if (_ResUtil::NeedToConvertCoord())
2209 int pcWidth = _ResUtil::ConvertToPhyCoordSize(vcWidth);
2210 float pcWidthF = _ResUtil::ConvertToPhyCoordSize(float(vcWidth));
2212 if (vcWidth > 0 && pcWidth == 0)
2217 r = this->_pNativeCanvas->SetLineWidth(pcWidth, pcWidthF);
2221 r = this->_pNativeCanvas->SetLineWidth(vcWidth, float(vcWidth));
2226 this->_pCoordHolder->AssignLineWidthFromVc(vcWidth);
2233 _CanvasImpl::SetLineWidth(float vcWidthF)
2235 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2237 SysTryReturnResult(NID_GRP, vcWidthF > 0.0f, E_OUT_OF_RANGE, "The given line width(%f) is out of range.", vcWidthF);
2239 result r = E_SUCCESS;
2241 if (_ResUtil::NeedToConvertCoord())
2243 float pcWidthF = _ResUtil::ConvertToPhyCoordSize(vcWidthF);
2245 r = this->_pNativeCanvas->SetLineWidth(pcWidthF);
2249 r = this->_pNativeCanvas->SetLineWidth(vcWidthF);
2254 this->_pCoordHolder->AssignLineWidthFromVc(vcWidthF);
2261 _CanvasImpl::SetLineCapStyle(LineCapStyle lineCapStyle)
2263 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2265 switch (lineCapStyle)
2267 case LINE_CAP_STYLE_ROUND:
2268 case LINE_CAP_STYLE_BUTT:
2269 case LINE_CAP_STYLE_SQUARE:
2272 SysTryReturn(NID_GRP, false, E_INVALID_ARG, E_INVALID_ARG, "The given line cap style is out of range.");
2275 return this->_pNativeCanvas->SetLineCapStyle(lineCapStyle);
2279 _CanvasImpl::SetLineJoinStyle(LineJoinStyle lineJoinStyle)
2281 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2283 switch (lineJoinStyle)
2285 case LINE_JOIN_STYLE_ROUND:
2286 case LINE_JOIN_STYLE_MITER:
2287 case LINE_JOIN_STYLE_BEVEL:
2290 SysTryReturn(NID_GRP, false, E_INVALID_ARG, E_INVALID_ARG, "The given line join style is out of range.");
2293 return this->_pNativeCanvas->SetLineJoinStyle(lineJoinStyle);
2297 _CanvasImpl::GetDashPattern(Tizen::Base::Collection::IListT<int>& pattern, int& offset)
2299 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2301 pattern.RemoveAll();
2303 result r = E_SUCCESS;
2305 float floatValue = 0.0f;
2307 for (int i = 0; i < this->_dashList.GetCount(); i++)
2309 this->_dashList.GetAt(i, floatValue);
2311 r = pattern.Add(_FloatToIntForPos(floatValue));
2324 case E_OPERATION_FAILED:
2325 case E_OUT_OF_MEMORY:
2326 SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
2329 SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT<int>::AddItems() failed");
2334 offset = int(this->_dashOffset);
2340 _CanvasImpl::GetDashPattern(Tizen::Base::Collection::IListT<float>& pattern, float& offset)
2342 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2344 pattern.RemoveAll();
2346 result r = pattern.AddItems(this->_dashList);
2353 case E_OPERATION_FAILED:
2354 case E_OUT_OF_MEMORY:
2355 SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
2358 SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT<int>::AddItems() failed");
2363 offset = static_cast<float>(this->_dashOffset);
2369 _CanvasImpl::SetDashPattern(const Tizen::Base::Collection::IListT<int>& pattern, int offset)
2371 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2373 result r = E_SUCCESS;
2375 // It is NOT the strong guarantee for an exception
2376 this->_dashList.RemoveAll();
2380 for (int i = 0; i < pattern.GetCount(); i++)
2382 pattern.GetAt(i, intValue);
2383 r = this->_dashList.Add(float(intValue));
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");
2406 int dashIntValue = 0;
2407 Tizen::Graphics::_Util::AccumList<double> dashValueList;
2409 for (int i = 0; i < pattern.GetCount(); i++)
2411 pattern.GetAt(i, dashIntValue);
2412 dashValueList.Push(double(dashIntValue));
2415 r = this->_pNativeCanvas->SetDashPattern(dashValueList, double(offset));
2416 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2418 this->_dashOffset = offset;
2425 _CanvasImpl::SetDashPattern(const Tizen::Base::Collection::IListT<float>& pattern, float offset)
2427 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2429 result r = E_SUCCESS;
2431 // It is NOT the strong guarantee for an exception
2432 this->_dashList.RemoveAll();
2434 r = this->_dashList.AddItems(pattern);
2441 case E_OPERATION_FAILED:
2442 case E_OUT_OF_MEMORY:
2443 SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
2446 SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT<int>::AddItems() failed");
2452 float dashIntValue = 0.0f;
2453 Tizen::Graphics::_Util::AccumList<double> dashValueList;
2455 for (int i = 0; i < pattern.GetCount(); i++)
2457 pattern.GetAt(i, dashIntValue);
2458 dashValueList.Push(double(dashIntValue));
2461 r = this->_pNativeCanvas->SetDashPattern(dashValueList, double(offset));
2462 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2464 this->_dashOffset = _FloatToIntForPos(offset);
2471 _CanvasImpl::SetDrawingQuality(BitmapDrawingQuality quality)
2473 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2477 case BITMAP_DRAWING_QUALITY_LOW:
2478 case BITMAP_DRAWING_QUALITY_MID:
2479 case BITMAP_DRAWING_QUALITY_HIGH:
2482 SysLogException(NID_GRP, E_INVALID_ARG, "The specified drawing quality(%d) is invalid.", quality);
2483 return E_INVALID_ARG;
2486 this->_pNativeCanvas->SetDrawingQuality(quality);
2491 BitmapDrawingQuality
2492 _CanvasImpl::GetDrawingQuality(void) const
2494 return (INSTANCE_IS_VALID) ? this->_pNativeCanvas->GetDrawingQuality() : BITMAP_DRAWING_QUALITY_LOW;
2498 _CanvasImpl::SetCompositeMode(CompositeMode compositeMode)
2500 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2502 switch (compositeMode)
2504 case COMPOSITE_MODE_CLEAR:
2505 case COMPOSITE_MODE_SRC:
2506 case COMPOSITE_MODE_DST:
2507 case COMPOSITE_MODE_SRC_OVER:
2508 case COMPOSITE_MODE_DST_OVER:
2509 case COMPOSITE_MODE_SRC_IN:
2510 case COMPOSITE_MODE_DST_IN:
2511 case COMPOSITE_MODE_SRC_OUT:
2512 case COMPOSITE_MODE_DST_OUT:
2513 case COMPOSITE_MODE_SRC_ATOP:
2514 case COMPOSITE_MODE_DST_ATOP:
2515 case COMPOSITE_MODE_DST_XOR:
2516 case COMPOSITE_MODE_ADD:
2517 case COMPOSITE_MODE_SATURATE:
2518 case COMPOSITE_MODE_MULTIPLY:
2519 case COMPOSITE_MODE_SCREEN:
2520 case COMPOSITE_MODE_OVERLAY:
2521 case COMPOSITE_MODE_DARKEN:
2522 case COMPOSITE_MODE_LIGHTEN:
2525 SysLogException(NID_GRP, E_INVALID_ARG, "The specified composite mode(%d) is invalid.", compositeMode);
2526 return E_INVALID_ARG;
2529 this->_pNativeCanvas->SetCompositeMode(compositeMode);
2535 _CanvasImpl::GetCompositeMode(void) const
2537 return (INSTANCE_IS_VALID) ? this->_pNativeCanvas->GetCompositeMode() : COMPOSITE_MODE_SRC_OVER;
2541 _CanvasImpl::GetPixel(const Point& vcPoint, Color& color) const
2543 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2545 Rectangle rtCanvas = _GetBoundsRel(*this);
2547 SysTryReturnResult(NID_GRP, !rtCanvas.IsEmpty(), E_OUT_OF_RANGE, "Cannot get the bounds of the canvas.");
2549 result r = _Util::Validate(vcPoint, rtCanvas);
2551 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2553 if (_ResUtil::NeedToConvertCoord())
2555 Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint);
2557 return this->_pNativeCanvas->GetPixel(pcPoint, color);
2561 return this->_pNativeCanvas->GetPixel(vcPoint, color);
2566 _CanvasImpl::GetPixel(const FloatPoint& vcPointF, Color& color) const
2568 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2570 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
2572 SysTryReturnResult(NID_GRP, !rtCanvasF.IsEmpty(), E_OUT_OF_RANGE, "Cannot get the bounds of the canvas.");
2574 result r = _Util::Validate(vcPointF, rtCanvasF);
2576 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2578 if (_ResUtil::NeedToConvertCoord())
2580 FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF);
2582 Point pcPoint(_FloatToIntForPos(pcPointF.x), _FloatToIntForPos(pcPointF.y));
2584 return this->_pNativeCanvas->GetPixel(pcPoint, color);
2588 Point vcPoint(_FloatToIntForPos(vcPointF.x), _FloatToIntForPos(vcPointF.y));
2590 return this->_pNativeCanvas->GetPixel(vcPoint, color);
2595 _CanvasImpl::SetPixel(const FloatPoint& vcPoint)
2597 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2599 return _CanvasImplPrivate::SetPixel(this, _Util::Convert<FloatPoint, _Util::Point<double> >(vcPoint));
2603 _CanvasImpl::SetPixel(const Point& vcPoint)
2605 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2607 return _CanvasImplPrivate::SetPixel(this, _Util::Convert<Point, _Util::Point<int> >(vcPoint));
2613 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2615 if (this->_pShowCallbackFunc)
2617 if (this->_pShowCallbackFunc(this->_pShowCallbackParam))
2623 result r = E_SUCCESS;
2624 Rectangle rect = this->GetBounds();
2626 r = this->_pNativeCanvas->Show();
2632 _CanvasImpl::Show(const Rectangle& vcRect)
2634 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2636 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
2637 SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE,
2638 "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width,
2641 if (this->_pShowCallbackFunc)
2643 if (this->_pShowCallbackFunc(this->_pShowCallbackParam))
2649 result r = E_SUCCESS;
2650 Rectangle rect = this->GetBounds();
2652 if (_ResUtil::NeedToConvertCoord())
2654 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect);
2656 r = this->_pNativeCanvas->Show(pcRect);
2660 r = this->_pNativeCanvas->Show(vcRect);
2667 _CanvasImpl::SetFont(const Font& font)
2669 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2670 SysTryReturnResult(NID_GRP, _FontImpl::GetInstance(font) && _FontImpl::GetInstance(font)->IsConstructed(), E_INVALID_ARG, "The given font is not constructed.");
2671 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());
2673 // should keep clone font
2674 Font* pFont = _FontImpl::CloneN(font);
2678 SysTryLog(NID_GRP, pFont, "[] Fails to allocate memory for font resource.");
2680 this->_pFont = null;
2683 // 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?
2684 // or just setting defult font?!
2685 return E_OPERATION_FAILED;
2688 EXTRACT_FONTEX(pFontEx, *pFont);
2689 result r = this->_pNativeCanvas->SetFont(*pFontEx);
2690 SysTryCatch(NID_GRP, E_SUCCESS == r, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Fails to set font.");
2692 // succeed making cloned font, then keep it and replace old one.
2695 delete this->_pFont;
2696 this->_pFont = null;
2699 this->_pFont = pFont;
2711 _CanvasImpl::GetFontN(void)
2713 result r = E_SUCCESS;
2719 SysTryCatch(NID_GRP, INSTANCE_IS_VALID, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2721 // we have the font user set
2724 pFont = _FontImpl::CloneN(*(this->_pFont));
2725 SysTryCatch(NID_GRP, pFont, r = E_OUT_OF_MEMORY, E_OPERATION_FAILED, "[E_OUT_OF_MEMORY] Failed to create Font instance.");
2729 // make font instance with the attribute of system default font
2748 _CanvasImpl::SetTextOrigin(TextOrigin origin)
2750 if (INSTANCE_IS_VALID)
2754 case TEXT_ORIGIN_LEFT_TOP:
2755 case TEXT_ORIGIN_BASELINE:
2756 this->_pNativeCanvas->__textOrigin = origin;
2763 _CanvasImpl::SetClipBounds(const Rectangle& vcRect)
2765 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2767 SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid.");
2768 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);
2770 Rectangle rtCanvas = _GetBoundsRel(*this);
2772 result r = _Util::Validate(vcRect, rtCanvas);
2774 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2776 Rectangle revisedVcRect;
2781 int x2 = vcRect.x + vcRect.width;
2782 int y2 = vcRect.y + vcRect.height;
2784 x1 = (x1 > 0) ? x1 : 0;
2785 y1 = (y1 > 0) ? y1 : 0;
2786 x2 = (x2 < rtCanvas.width) ? x2 : rtCanvas.width;
2787 y2 = (y2 < rtCanvas.height) ? y2 : rtCanvas.height;
2789 revisedVcRect.x = x1;
2790 revisedVcRect.y = y1;
2791 revisedVcRect.width = x2 - x1;
2792 revisedVcRect.height = y2 - y1;
2795 if (_ResUtil::NeedToConvertCoord())
2797 Rectangle pcRect = _ResUtil::ConvertToPhyCoord(revisedVcRect);
2800 pcRect.width = (pcRect.width >= 0) ? pcRect.width : 1;
2801 pcRect.height = (pcRect.height >= 0) ? pcRect.height : 1;
2803 result r = this->_pNativeCanvas->SetClipBounds(pcRect);
2807 _Util::Rectangle<int> vcRect =
2811 revisedVcRect.width,
2812 revisedVcRect.height
2815 this->_pCoordHolder->AssignClipBoundsFromVcSize(vcRect);
2822 result r = this->_pNativeCanvas->SetClipBounds(revisedVcRect);
2826 _Util::Rectangle<int> vcRect =
2830 revisedVcRect.width,
2831 revisedVcRect.height
2834 this->_pCoordHolder->AssignClipBoundsFromVcSize(vcRect);
2842 _CanvasImpl::SetClipBounds(const FloatRectangle& vcRectF)
2844 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2846 SysTryReturnResult(NID_GRP, &vcRectF, E_OUT_OF_RANGE, "The given rectangle is invalid.");
2847 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);
2849 FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
2851 result r = _Util::Validate(vcRectF, rtCanvasF);
2853 SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating.");
2855 FloatRectangle revisedVcRectF;
2858 float x1 = vcRectF.x;
2859 float y1 = vcRectF.y;
2860 float x2 = vcRectF.x + vcRectF.width;
2861 float y2 = vcRectF.y + vcRectF.height;
2863 x1 = (x1 > 0) ? x1 : 0;
2864 y1 = (y1 > 0) ? y1 : 0;
2865 x2 = (x2 < rtCanvasF.width) ? x2 : rtCanvasF.width;
2866 y2 = (y2 < rtCanvasF.height) ? y2 : rtCanvasF.height;
2868 revisedVcRectF.x = x1;
2869 revisedVcRectF.y = y1;
2870 revisedVcRectF.width = x2 - x1;
2871 revisedVcRectF.height = y2 - y1;
2874 _CanvasCoordHolder coordHolder;
2877 _Util::Rectangle<float> tempRevisedVcRectF =
2881 revisedVcRectF.width,
2882 revisedVcRectF.height
2885 coordHolder.AssignClipBoundsFromVcSize(tempRevisedVcRectF);
2890 coordHolder.clipBounds.pcInt.x,
2891 coordHolder.clipBounds.pcInt.y,
2892 coordHolder.clipBounds.pcInt.w,
2893 coordHolder.clipBounds.pcInt.h
2896 r = this->_pNativeCanvas->SetClipBounds(pcRect);
2900 this->_pCoordHolder->clipBounds = coordHolder.clipBounds;
2907 _CanvasImpl::GetClipBounds(void) const
2911 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, rect, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2913 if (_ResUtil::NeedToConvertCoord())
2915 const _Util::Rectangle<int>& bounds = this->_pCoordHolder->clipBounds.vcInt;
2917 return Rectangle(bounds.x, bounds.y, bounds.w, bounds.h);
2921 return this->_pNativeCanvas->GetClipBounds();
2926 _CanvasImpl::GetClipBoundsF(void) const
2928 FloatRectangle rectF;
2930 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, rectF, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2932 const _Util::Rectangle<float>& boundsF = this->_pCoordHolder->clipBounds.vcFloat;
2934 return FloatRectangle(boundsF.x, boundsF.y, boundsF.w, boundsF.h);
2938 _CanvasImpl::Lock(BufferInfo& info, long timeout)
2940 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2942 SysTryReturnResult(NID_GRP, (static_cast <unsigned long>(timeout) == INFINITE) || (timeout >= 0), E_INVALID_ARG,
2943 "'timeout(=%d)' is not valid.",
2946 return this->_pNativeCanvas->Lock(info, timeout);
2950 _CanvasImpl::Unlock()
2952 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2954 return this->_pNativeCanvas->Unlock();
2958 _CanvasImpl::SetForegroundColor(const Color& fgColor)
2960 SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2962 return this->_pNativeCanvas->SetForegroundColor(fgColor);
2966 _CanvasImpl::GetForegroundColor(void) const
2968 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Color::GetColor(COLOR_ID_BLACK), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2970 return this->_pNativeCanvas->GetForegroundColor();
2974 _CanvasImpl::SetBackgroundColor(const Color& bgColor)
2976 SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2978 return this->_pNativeCanvas->SetBackgroundColor(bgColor);
2982 _CanvasImpl::GetBackgroundColor(void) const
2984 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Color::GetColor(COLOR_ID_BLACK), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
2986 return this->_pNativeCanvas->GetBackgroundColor();
2990 _CanvasImpl::SetPosition(const Point& vcPoint)
2992 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
2994 return this->SetPosition(vcPoint.x, vcPoint.y);
2998 _CanvasImpl::SetPosition(int vcX, int vcY)
3000 SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
3002 _CanvasCoordHolder tempCoordHolder;
3003 tempCoordHolder.AssignCanvasPosFromVc(vcX, vcY);
3005 result r = E_SUCCESS;
3007 if (_ResUtil::NeedToConvertCoord())
3009 Point pcPoint(tempCoordHolder.canvasPos.pcInt.x, tempCoordHolder.canvasPos.pcInt.y);
3011 r = this->_pNativeCanvas->SetPosition(pcPoint.x, pcPoint.y);
3015 r = this->_pNativeCanvas->SetPosition(vcX, vcY);
3020 this->_pCoordHolder->canvasPos = tempCoordHolder.canvasPos;
3028 _CanvasImpl::GetSubCanvasN(const Rectangle& subRegion) const
3030 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, null, E_OPERATION_FAILED, "This instance is not constructed yet.");
3032 _Canvas* pSourceNativeCanvas = this->_pNativeCanvas;
3034 std::auto_ptr <Canvas> subCanvas(new (std::nothrow) Canvas);
3036 Canvas* pSubCanvas = subCanvas.get();
3038 SysTryReturn(NID_GRP, pSubCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
3040 _CanvasImpl* pSubCanvasImpl = _CanvasImpl::GetInstance(*pSubCanvas);
3042 SysTryReturn(NID_GRP, pSubCanvasImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
3044 if (_ResUtil::NeedToConvertCoord())
3046 Rectangle subRegionPC = _ResUtil::ConvertToPhyCoord(subRegion);
3048 subRegionPC.width = (subRegionPC.width > 0) ? subRegionPC.width : 1;
3049 subRegionPC.height = (subRegionPC.height > 0) ? subRegionPC.height : 1;
3051 result r = pSubCanvasImpl->_pNativeCanvas->Construct(pSourceNativeCanvas, subRegionPC);
3053 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3055 pSubCanvasImpl->_pCoordHolder->Init(subRegion);
3056 pSubCanvasImpl->_pCoordHolder->canvasSize.pcInt.w = subRegionPC.width;
3057 pSubCanvasImpl->_pCoordHolder->canvasSize.pcInt.h = subRegionPC.height;
3061 result r = pSubCanvasImpl->_pNativeCanvas->Construct(pSourceNativeCanvas, subRegion);
3063 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
3068 pSubCanvasImpl->SetFont(*this->_pFont);
3071 if (this->_pPriorityFont)
3073 pSubCanvasImpl->SetPriorityFont(*this->_pPriorityFont);
3076 return subCanvas.release();
3080 _CanvasImpl::GetSubCanvasFN(const FloatRectangle& subRegion) const
3083 Rectangle intSubRegion(static_cast<int>(subRegion.x), static_cast<int>(subRegion.y), static_cast<int>(subRegion.width), static_cast<int>(subRegion.height));
3085 return this->GetSubCanvasN(intSubRegion);
3089 _CanvasImpl::SetAntialiasingEnabled(bool enable)
3091 SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet.");
3093 return this->_pNativeCanvas->SetAntialiasingEnabled(enable);
3097 _CanvasImpl::IsAntialiasingEnabled(void) const
3099 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, false, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3101 return this->_pNativeCanvas->IsAntialiasingEnabled();
3105 _CanvasImpl::SetPriorityFont(const Font& font)
3109 // check input param
3110 SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.");
3111 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());
3113 Font* pFont = &(const_cast <Font&>(font));
3115 EXTRACT_FONTEX(pFontEx, *pFont);
3116 result r = this->_pNativeCanvas->SetPriorityFont(*pFontEx);
3117 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3118 // overwrite existing priority font
3119 this->_pPriorityFont = pFont;
3125 _CanvasImpl::ResetPriorityFont(void)
3127 if (INSTANCE_IS_VALID)
3129 this->_pPriorityFont = null;
3130 this->_pNativeCanvas->ResetPriorityFont();
3135 _CanvasImpl::SetStableRenderer(bool isStable)
3137 if (INSTANCE_IS_VALID)
3139 this->_pNativeCanvas->__useStableRenderer = isStable;
3144 _CanvasImpl::SetFrameInfoCallback(void* (*pGetDefaultFrameNativeHandle)(void), void* (*pGetDefaultFrameHandle)(void))
3146 _GetDefaultFrameEcoreEvasHandle = (pGetDefaultFrameNativeHandle) ? pGetDefaultFrameNativeHandle : _GetNull;
3147 _GetDefaultFrameEvasHandle = (pGetDefaultFrameHandle) ? pGetDefaultFrameHandle : _GetNull;
3151 _CanvasImpl::SetThemeInfoCallback(Color (*pGetDefaultForegroundColor)(void), Color (*pGetDefaultBackgroundColor)(void))
3153 _GetDefaultForegroundColor = (pGetDefaultForegroundColor) ? pGetDefaultForegroundColor : _GetBlack;
3154 _GetDefaultBackgroundColor = (pGetDefaultBackgroundColor) ? pGetDefaultBackgroundColor : _GetWhite;
3158 _CanvasImpl::GetInstance(Canvas& canvas)
3160 return (&canvas != null) ? canvas.__pImpl : null;
3164 _CanvasImpl::GetInstance(const Canvas& canvas)
3166 return (&canvas != null) ? canvas.__pImpl : null;
3169 }} // Tizen::Graphics