From: jisun10.lee Date: Mon, 25 Mar 2013 13:22:45 +0000 (+0900) Subject: Use SetAsPremultiplied function & Change DrawBitmap in Capture X-Git-Tag: accepted/tizen_2.1/20130425.033138~731^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de287e86384971836cceb6a01e32b41fba09852f;p=platform%2Fframework%2Fnative%2Fuifw.git Use SetAsPremultiplied function & Change DrawBitmap in Capture Change-Id: I6643555595b889fdb411a29e347b70be057da578 --- diff --git a/src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp b/src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp index a190faf..0bf3baf 100644 --- a/src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp +++ b/src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp @@ -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; } diff --git a/src/ui/animations/FUiAnim_VisualElementImpl.cpp b/src/ui/animations/FUiAnim_VisualElementImpl.cpp index 4506f6e..ab69f03 100644 --- a/src/ui/animations/FUiAnim_VisualElementImpl.cpp +++ b/src/ui/animations/FUiAnim_VisualElementImpl.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -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;