Modify anti-aliasing issue of DrawBitmap
authorhoonik.lee <hoonik.lee@samsung.com>
Tue, 2 Apr 2013 05:00:48 +0000 (14:00 +0900)
committerhoonik.lee <hoonik.lee@samsung.com>
Tue, 2 Apr 2013 05:00:48 +0000 (14:00 +0900)
Change-Id: I991771b2fb34289ece5c298ee69af8401e94e90c
Signed-off-by: hoonik.lee <hoonik.lee@samsung.com>
src/graphics/FGrp_Canvas.cpp
src/graphics/FGrp_Canvas.h
src/graphics/FGrp_CanvasImpl.cpp
src/graphics/FGrp_CanvasPixman.cpp
src/graphics/FGrp_CanvasPixman.h

index 7e9546f..de7c223 100755 (executable)
@@ -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<double>& point, const _Bitmap& bitmap, const _Util::Point<double>& 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");
 
index b29bb06..6707788 100644 (file)
@@ -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<double>& point, const _Bitmap& bitmap, const _Util::Point<double>& pivot, double degree);
        result DrawNinePatchedBitmap(const Rectangle& rect, const _Bitmap& bitmap);
        result DrawNineTiledBitmap(const Rectangle& rect, const _Bitmap& bitmap);
 
index 427c24f..54112e3 100755 (executable)
@@ -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<double> pcPointD = _Util::Convert<FloatPoint, _Util::Point<double> >(pcPointF);
+               _Util::Point<double> pcPivotD = _Util::Convert<FloatPoint, _Util::Point<double> >(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<FloatPoint, _Util::Point<double> >(vcPointF), *pBitmapEx, _Util::Convert<FloatPoint, _Util::Point<double> >(vcPivotF), double(degree));
        }
 }
 
index ca2095d..53374f0 100644 (file)
@@ -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)
        {
index d84163f..ee43731 100644 (file)
@@ -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);