Use SetAsPremultiplied function & Change DrawBitmap in Capture
authorjisun10.lee <jisun10.lee@samsung.com>
Mon, 25 Mar 2013 13:22:45 +0000 (22:22 +0900)
committerjisun10.lee <jisun10.lee@samsung.com>
Mon, 25 Mar 2013 13:27:04 +0000 (22:27 +0900)
Change-Id: I6643555595b889fdb411a29e347b70be057da578

src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp
src/ui/animations/FUiAnim_VisualElementImpl.cpp

index a190faf..0bf3baf 100644 (file)
@@ -52,19 +52,6 @@ _VisualElementCoordinateSystem::Initialize(void)
                scaleFactorX = pCoordSys->GetTransformer()->GetHorizontalScaleFactor();
                scaleFactorY = pCoordSys->GetTransformer()->GetVerticalScaleFactor();
 
-               // WARNING:
-               //      1. The values 'scaleFactorX' and 'scaleFactorY' may be greater than expected 'cause of float-error.
-               //      So, it is needed to cut-off some significant digits to ensure the scale factors are always less or equal than real values.
-               //      The cut-off position should be lower than the compensation value(> 10^3 due to rounding), too.
-               //      2. The number fo siginificant digits for float is about 6 (5 for sure).
-               //      So, the scaleFactor to cut-off should be less or equal than 10^6.
-
-               const float scaleFactor = 1000.0f / floatIntegralEpsilon;
-               //SysAssert(scaleFactor <= 1000000.0f);
-
-               scaleFactorX = floorf(scaleFactorX * scaleFactor) / scaleFactor;
-               scaleFactorY = floorf(scaleFactorY * scaleFactor) / scaleFactor;
-
                needScale = true;
        }
 
index 4506f6e..ab69f03 100644 (file)
@@ -34,6 +34,7 @@
 #include <FGrpBufferInfo.h>
 #include <FBaseByteBuffer.h>
 #include <FGrp_CanvasImpl.h>
+#include <FGrp_BitmapImpl.h>
 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
 #include <FUiAnimVisualElementPropertyAnimation.h>
 #include <FUiAnimVisualElementAnimationGroup.h>
@@ -6408,56 +6409,26 @@ _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDes
 
                                        if(pStart)
                                        {
-                                               byte* pCopy = new (std::nothrow) byte[info.height*(info.pitch)];
-                                               if (pCopy)
-                                               {
-                                                       memcpy(pCopy, pStart, info.height*(info.pitch));
+                                               ByteBuffer buffer;
+                                               result r = buffer.Construct(pStart, 0, info.height*(info.pitch), info.height*(info.pitch));
 
-                                                       for (int y = 0; y < info.height; y++)
+                                               if (r == E_SUCCESS)
+                                               {
+                                                       Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888);
+                                                       if (pBitmap)
                                                        {
-                                                               for (int x = 0; x < info.width; x++)
-                                                               {
-                                                                       unsigned int* pAddr = (unsigned int*)((unsigned char*)pCopy + info.pitch * y + x * 4);
-                                                                       int a = ((*pAddr) >> 24) & 0xff;
-                                                                       int r = ((*pAddr) >> 16) & 0xff;
-                                                                       int g = ((*pAddr) >> 8) & 0xff;
-                                                                       int b = ((*pAddr) >> 0) & 0xff;
-                                                                       if (a > 0)
-                                                                       {
-                                                                               float fa = (float)a / 255.0f;
-                                                                               r = r / fa;
-                                                                               g = g / fa;
-                                                                               b = b / fa;
-                                                                               *pAddr = (a << 24) | (r << 16) | (g << 8) | b;
-                                                                       }
-                                                               }
-                                                       }
+                                                               _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied();
+                                                               pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
 
-                                                       ByteBuffer buffer;
-                                                       result r = buffer.Construct(pCopy, 0, info.height*(info.pitch), info.height*(info.pitch));
+                                                               FloatRectangle outputRect(rectDest.x + bounds.x, rectDest.y + bounds.y, drawRect.width, drawRect.height);
 
-                                                       if (r == E_SUCCESS)
-                                                       {
-                                                               Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888);
-                                                               if (pBitmap)
-                                                               {
-                                                                       pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
-                                                                       FloatRectangle outputRect(rectDest.x + bounds.x, rectDest.y + bounds.y, drawRect.width, drawRect.height);
-                                                                       _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(outputRect.x, outputRect.y, outputRect.width, outputRect.height);
-                                                                       _VisualElementCoordinateSystem::ConvertRectangleToLogical(outputRect.x, outputRect.y, outputRect.width, outputRect.height);
-
-                                                                       FloatRectangle srcRect(drawRect.x, drawRect.y, info.width, info.height);
-                                                                       _VisualElementCoordinateSystem::ConvertDimensionToLogical(srcRect.width, srcRect.height);
-
-                                                                       Rectangle outputR(outputRect.x, outputRect.y, outputRect.width, outputRect.height);
-                                                                       Rectangle srcR(srcRect.x, srcRect.y, srcRect.width, srcRect.height);
-                                                                       outputCanvas.DrawBitmap(outputR, *pBitmap, srcR);
-
-                                                                       delete pBitmap;
-                                                               }
-                                                       }
+                                                               _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
+                                                               _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
+
+                                                               outputCanvas.DrawBitmap(outputRect, *pBitmap, drawRect);
 
-                                                       delete [] pCopy;
+                                                               delete pBitmap;
+                                                       }
                                                }
                                        }
                                }
@@ -6472,7 +6443,7 @@ _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDes
                        _Colorf bgcolorf = pNativeNode->GetBackgroundColor();
                        Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255);
 
-                       Point point;
+                       FloatPoint point;
                        point.x = rectDest.x + bounds.x;
                        point.y = rectDest.y + bounds.y;