Modify DrawBitmap for Premultiplied image drawing
authorhoonik.lee <hoonik.lee@samsung.com>
Thu, 2 May 2013 08:24:07 +0000 (17:24 +0900)
committerhoonik.lee <hoonik.lee@samsung.com>
Thu, 2 May 2013 08:46:48 +0000 (17:46 +0900)
Change-Id: I6308119bbb6f529286ea7f78f6e1e5c472a92fa2
Signed-off-by: hoonik.lee <hoonik.lee@samsung.com>
src/graphics/FGrp_Canvas.cpp

index 8cd4ca5..b0793e0 100644 (file)
@@ -1320,7 +1320,7 @@ _Canvas::DrawBitmap(const _Util::Rectangle<double>& rectD, const _Bitmap& bitmap
                const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo();
 
                {
-                       if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32 && GetCompositeMode() != COMPOSITE_MODE_SRC_OVER)
+                       if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32 && (GetCompositeMode() != COMPOSITE_MODE_SRC_OVER || bitmap.__isPremultiplied))
                        {
                                _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch);
                                _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver);
@@ -1488,7 +1488,7 @@ _Canvas::DrawBitmap(const _Util::Point<double>& pointD, const _Bitmap& bitmap)
                                _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch);
                                _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
 
-                               if (srcBufferInfo.pixelFormat == PIXEL_FORMAT_RGB565 && srcImage.enableColorKey == 0 && dstBufferInfo.pixelFormat == PIXEL_FORMAT_ARGB8888 && !this->__isClipBoundsSet)
+                               if (srcBufferInfo.pixelFormat == PIXEL_FORMAT_RGB565 && srcImage.enableColorKey == 0 && dstBufferInfo.pixelFormat == PIXEL_FORMAT_ARGB8888 && !this->__isClipBoundsSet && alphaConstant >= 255)
                                {
                                        pixman_image_t* pPixmanSrc = pixman_image_create_bits(PIXMAN_r5g6b5, srcBufferInfo.width, srcBufferInfo.height, (uint32_t*)srcBufferInfo.pPixels, srcBufferInfo.pitch);
                                        pixman_image_t* pPixmanDst = pixman_image_create_bits(PIXMAN_a8r8g8b8, dstBufferInfo.width, dstBufferInfo.height, (uint32_t*)dstBufferInfo.pPixels, dstBufferInfo.pitch);
@@ -1511,7 +1511,7 @@ _Canvas::DrawBitmap(const _Util::Point<double>& pointD, const _Bitmap& bitmap)
                                }
                        }
                        {
-                               bool isPixmanSupported = (!this->__useStableRenderer && GetCompositeMode() != COMPOSITE_MODE_SRC_OVER);
+                               bool isPixmanSupported = (!this->__useStableRenderer && (GetCompositeMode() != COMPOSITE_MODE_SRC_OVER || bitmap.__isPremultiplied));
 
                                if (isPixmanSupported)
                                {
@@ -1613,7 +1613,7 @@ _Canvas::DrawBitmap(const _Util::Rectangle<double>& destRectD, const _Bitmap& sr
                const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo();
 
                {
-                       if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32 && GetCompositeMode() != COMPOSITE_MODE_SRC_OVER)
+                       if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32 && (GetCompositeMode() != COMPOSITE_MODE_SRC_OVER || srcBitmap.__isPremultiplied))
                        {
                                _Util::Rectangle<int> srcBounds =
                                {
@@ -1789,7 +1789,7 @@ _Canvas::DrawBitmapForNinePatchedBitmap(const Rectangle& destRect, const _Bitmap
                const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo();
 
                {
-                       if (srcBufferInfo.bitsPerPixel == 32 && GetCompositeMode() != COMPOSITE_MODE_SRC_OVER)
+                       if (srcBufferInfo.bitsPerPixel == 32 && (GetCompositeMode() != COMPOSITE_MODE_SRC_OVER || srcBitmap.__isPremultiplied))
                        {
                                _Util::Rectangle<int> outRect = { 0, 0, -1, -1 };
                                _Util::Rectangle<int> dstRect = { destRect.x, destRect.y, destRect.width, destRect.height };