Modify DrawBitmap for floating-point decision problem
authorhoonik.lee <hoonik.lee@samsung.com>
Wed, 15 May 2013 04:16:25 +0000 (13:16 +0900)
committerhoonik.lee <hoonik.lee@samsung.com>
Wed, 15 May 2013 04:51:53 +0000 (13:51 +0900)
Change-Id: Ibb3b26114a9a55f491eeb4a788e9078c857e980b
Signed-off-by: hoonik.lee <hoonik.lee@samsung.com>
src/graphics/FGrp_Canvas.cpp
src/graphics/FGrp_CanvasImpl.cpp
src/graphics/FGrp_CanvasPixman.cpp

index e6e49e2..f85f0e8 100644 (file)
@@ -1615,16 +1615,8 @@ _Canvas::DrawBitmap(const _Util::Rectangle<double>& destRectD, const _Bitmap& sr
                {
                        if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32 && (GetCompositeMode() != COMPOSITE_MODE_SRC_OVER || srcBitmap.__isPremultiplied))
                        {
-                               _Util::Rectangle<int> srcBounds =
-                               {
-                                       int(Math::Floor(srcRectD.x)),
-                                       int(Math::Floor(srcRectD.y)),
-                                       int(Math::Ceiling(srcRectD.x + srcRectD.w) - Math::Floor(srcRectD.x)),
-                                       int(Math::Ceiling(srcRectD.y + srcRectD.h) - Math::Floor(srcRectD.y))
-                               };
-
                                _Util::Pixmap srcImageUnclipped(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch);
-                               _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcBounds.x, srcBounds.y, srcBounds.w, srcBounds.h);
+                               _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcRect.x, srcRect.y, srcRect.w, srcRect.h);
                                _ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver);
 
                                _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch);
index 61dbb85..3b0e428 100644 (file)
@@ -1066,6 +1066,11 @@ _CanvasImpl::DrawBitmap(const FloatRectangle& vcRectF, const _BitmapImpl& bitmap
                return this->DrawBitmap(FloatPoint(vcRectF.x, vcRectF.y), bitmap);
        }
 
+       if (_FloatToIntForSize(vcRectF.width) == bitmap.GetWidth() && _FloatToIntForSize(vcRectF.height) == bitmap.GetHeight())
+       {
+               return this->DrawBitmap(FloatPoint(vcRectF.x, vcRectF.y), bitmap);
+       }
+
        // check if bimap can be drew in canvas area.
        FloatRectangle rtCanvasF = _GetBoundsRelF(*this);
 
@@ -1187,6 +1192,11 @@ _CanvasImpl::DrawBitmap(const FloatRectangle& vcDestRectF, const _BitmapImpl& sr
                SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, "The specified region of source bitmap is out of range.");
        }
 
+       if (vcSrcRectF.width == srcBitmap.GetWidthF() && vcSrcRectF.height == srcBitmap.GetHeightF())
+       {
+               return this->DrawBitmap(vcDestRectF, srcBitmap);
+       }
+
        // check if srcRect is in bitmap's area.
        result r = _Util::Validate(vcSrcRectF, FloatRectangle(0, 0, srcBitmap.GetWidthF(), srcBitmap.GetHeightF()));
 
index 0bce78e..980abb6 100644 (file)
@@ -373,7 +373,7 @@ bool CopyPixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics:
                {
                        pixman_transform_t transform;
                        pixman_transform_init_identity(&transform);
-                       pixman_transform_translate(&transform, NULL, pixman_double_to_fixed(-xDest), pixman_double_to_fixed(-yDest));
+                       pixman_transform_translate(&transform, NULL, pixman_double_to_fixed(-(xDest-0.5), pixman_double_to_fixed(-(yDest-0.5));
 
                        return CompositePixmap(dstImage, srcImage, rop, filter, transform, PIXMAN_REPEAT_NONE);
                }
@@ -436,7 +436,7 @@ bool ScalePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics
                }
        default:
                {
-                       pixman_transform_t transform = Tizen::Graphics::_Pixman::GetTransform(srcImage.width, srcImage.height, xDest, yDest, wDest, hDest);
+                       pixman_transform_t transform = Tizen::Graphics::_Pixman::GetTransform(srcImage.width, srcImage.height, xDest-0.5, yDest-0.5, wDest, hDest);
 
                        return CompositePixmap(dstImage, srcImage, rop, filter, transform, PIXMAN_REPEAT_NONE);
                }