From abaf1098f4b37854964fee46b6436e0d4a3c1558 Mon Sep 17 00:00:00 2001 From: "hoonik.lee" Date: Tue, 2 Apr 2013 14:00:48 +0900 Subject: [PATCH] Modify anti-aliasing issue of DrawBitmap Change-Id: I991771b2fb34289ece5c298ee69af8401e94e90c Signed-off-by: hoonik.lee --- src/graphics/FGrp_Canvas.cpp | 6 +++--- src/graphics/FGrp_Canvas.h | 2 +- src/graphics/FGrp_CanvasImpl.cpp | 42 ++++++-------------------------------- src/graphics/FGrp_CanvasPixman.cpp | 18 +++++++++++++++- src/graphics/FGrp_CanvasPixman.h | 2 +- 5 files changed, 28 insertions(+), 42 deletions(-) diff --git a/src/graphics/FGrp_Canvas.cpp b/src/graphics/FGrp_Canvas.cpp index 7e9546f..de7c223 100755 --- a/src/graphics/FGrp_Canvas.cpp +++ b/src/graphics/FGrp_Canvas.cpp @@ -2003,7 +2003,7 @@ _Canvas::DrawBitmap(const Point& point, const _Bitmap& bitmap, FlipDirection dir } result -_Canvas::DrawBitmap(const Point& point, const _Bitmap& bitmap, const Point& pivot, double degree) +_Canvas::DrawBitmap(const _Util::Point& point, const _Bitmap& bitmap, const _Util::Point& pivot, double degree) { SysTryReturnResult(NID_GRP, &bitmap && bitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); @@ -2067,8 +2067,8 @@ _Canvas::DrawBitmap(const Point& point, const _Bitmap& bitmap, const Point& pivo _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); // angle, xOffset, yOffset - Tizen::Graphics::_Effect::RotateDesc rotateDesc = { int(degree), pivot.x, pivot.y }; - bool pass = Tizen::Graphics::_Effect::RotateImage(dstImage, point.x - clipRect.x, point.y - clipRect.y, srcImage, rotateDesc, alphaConstant); + Tizen::Graphics::_Effect::RotateDesc rotateDesc = { int(degree), int(pivot.x), int(pivot.y) }; + bool pass = Tizen::Graphics::_Effect::RotateImage(dstImage, int(point.x) - clipRect.x, int(point.y) - clipRect.y, srcImage, rotateDesc, alphaConstant); SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); diff --git a/src/graphics/FGrp_Canvas.h b/src/graphics/FGrp_Canvas.h index b29bb06..6707788 100644 --- a/src/graphics/FGrp_Canvas.h +++ b/src/graphics/FGrp_Canvas.h @@ -157,7 +157,7 @@ public: result DrawBitmap(const Rectangle& destRect, const _Bitmap& srcBitmap, const Rectangle& srcRect); result DrawBitmapForNinePatchedBitmap(const Rectangle& destRect, const _Bitmap& srcBitmap, const Rectangle& srcRect); result DrawBitmap(const Point& point, const _Bitmap& bitmap, FlipDirection dir); - result DrawBitmap(const Point& point, const _Bitmap& bitmap, const Point& pivot, double degree); + result DrawBitmap(const _Util::Point& point, const _Bitmap& bitmap, const _Util::Point& pivot, double degree); result DrawNinePatchedBitmap(const Rectangle& rect, const _Bitmap& bitmap); result DrawNineTiledBitmap(const Rectangle& rect, const _Bitmap& bitmap); diff --git a/src/graphics/FGrp_CanvasImpl.cpp b/src/graphics/FGrp_CanvasImpl.cpp index 427c24f..54112e3 100755 --- a/src/graphics/FGrp_CanvasImpl.cpp +++ b/src/graphics/FGrp_CanvasImpl.cpp @@ -1505,34 +1505,7 @@ _CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap, const P { SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); - SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid."); - - EXTRACT_BITMAPEX(pBitmapEx, bitmap); - - if (_ResUtil::NeedToConvertCoord()) - { - Tizen::Graphics::Dimension virSize; - Tizen::Graphics::Dimension phySize; - bool lazyScaling = Tizen::Graphics::_IsLazyScalingBitmap(bitmap, virSize, phySize); - - Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); - Point pcPivot = _ResUtil::ConvertToPhyCoord(vcPivot); - - if (lazyScaling) - { - EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap); - - return this->_pNativeCanvas->DrawBitmap(pcPoint, *pScaledBitmapEx, pcPivot, double(degree)); - } - else - { - return this->_pNativeCanvas->DrawBitmap(pcPoint, *pBitmapEx, pcPivot, double(degree)); - } - } - else - { - return this->_pNativeCanvas->DrawBitmap(vcPoint, *pBitmapEx, vcPivot, double(degree)); - } + return this->DrawBitmap(FloatPoint(float(vcPoint.x), float(vcPoint.y)), bitmap, FloatPoint(float(vcPivot.x), float(vcPivot.y)), float(degree)); } result @@ -1553,26 +1526,23 @@ _CanvasImpl::DrawBitmap(const FloatPoint& vcPointF, const _BitmapImpl& bitmap, c FloatPoint pcPointF = _ResUtil::ConvertToPhyCoord(vcPointF); FloatPoint pcPivotF = _ResUtil::ConvertToPhyCoord(vcPivotF); - Point pcPoint(_FloatToIntForPos(pcPointF.x), _FloatToIntForPos(pcPointF.y)); - Point pcPivot(_FloatToIntForPos(pcPivotF.x), _FloatToIntForPos(pcPivotF.y)); + _Util::Point pcPointD = _Util::Convert >(pcPointF); + _Util::Point pcPivotD = _Util::Convert >(pcPivotF); if (lazyScaling) { EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap); - return this->_pNativeCanvas->DrawBitmap(pcPoint, *pScaledBitmapEx, pcPivot, double(degree)); + return this->_pNativeCanvas->DrawBitmap(pcPointD, *pScaledBitmapEx, pcPivotD, double(degree)); } else { - return this->_pNativeCanvas->DrawBitmap(pcPoint, *pBitmapEx, pcPivot, double(degree)); + return this->_pNativeCanvas->DrawBitmap(pcPointD, *pBitmapEx, pcPivotD, double(degree)); } } else { - Point vcPoint(_FloatToIntForPos(vcPointF.x), _FloatToIntForPos(vcPointF.y)); - Point vcPivot(_FloatToIntForPos(vcPivotF.x), _FloatToIntForPos(vcPivotF.y)); - - return this->_pNativeCanvas->DrawBitmap(vcPoint, *pBitmapEx, vcPivot, double(degree)); + return this->_pNativeCanvas->DrawBitmap(_Util::Convert >(vcPointF), *pBitmapEx, _Util::Convert >(vcPivotF), double(degree)); } } diff --git a/src/graphics/FGrp_CanvasPixman.cpp b/src/graphics/FGrp_CanvasPixman.cpp index ca2095d..53374f0 100644 --- a/src/graphics/FGrp_CanvasPixman.cpp +++ b/src/graphics/FGrp_CanvasPixman.cpp @@ -136,6 +136,22 @@ pixman_transform_t GetTransform(int xDest, int yDest, double degree, int xPivot, return transform; } +pixman_transform_t GetTransform(double xDest, double yDest, double degree, double xPivot, double yPivot) +{ + pixman_transform_t transform; + + double c = cos(degree * 3.141592 / 180.0); + double s = sin(degree * 3.141592 / 180.0); + + pixman_transform_init_identity(&transform); + + pixman_transform_translate(&transform, NULL, pixman_double_to_fixed(-xDest), pixman_double_to_fixed(-yDest)); + pixman_transform_rotate(&transform, NULL, pixman_double_to_fixed(c), pixman_double_to_fixed(s)); + pixman_transform_translate(&transform, NULL, pixman_double_to_fixed(xPivot), pixman_double_to_fixed(yPivot)); + + return transform; +} + pixman_transform_t GetTransform(int srcWidth, int srcHeight, int dstWidth, int dstHeight) { pixman_transform_t transform; @@ -387,7 +403,7 @@ bool ScalePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics return CompositePixmap(dstImage, srcImage, rop, filter, transform, PIXMAN_REPEAT_NORMAL); } -bool RotatePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::CompositeMode compositeMode, int xDest, int yDest, double degree, int xPivot, int yPivot) +bool RotatePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::CompositeMode compositeMode, double xDest, double yDest, double degree, double xPivot, double yPivot) { if (dstImage.width <= 0 || dstImage.height <= 0) { diff --git a/src/graphics/FGrp_CanvasPixman.h b/src/graphics/FGrp_CanvasPixman.h index d84163f..ee43731 100644 --- a/src/graphics/FGrp_CanvasPixman.h +++ b/src/graphics/FGrp_CanvasPixman.h @@ -47,7 +47,7 @@ bool ResizePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapScalingQuality scalingQuality); bool -RotatePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::CompositeMode compositeMode, int xDest, int yDest, double degree, int xPivot, int yPivot); +RotatePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::CompositeMode compositeMode, double xDest, double yDest, double degree, double xPivot, double yPivot); bool FlipPixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::CompositeMode compositeMode, int xDest, int yDest); -- 2.7.4