From 67105ae1df04135f256b2847632d188f515a5052 Mon Sep 17 00:00:00 2001 From: Dae young Ryu Date: Wed, 10 Jul 2013 15:48:19 +0900 Subject: [PATCH] fix : capture API bug - scaling Change-Id: If7f9fd5a605ab903dfd7e622ea4e20a6391b8e79 Signed-off-by: Dae young Ryu --- src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp | 4 +- src/ui/animations/FUiAnim_VisualElementImpl.cpp | 67 +++++++++++++++++++++---- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp b/src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp index 49bf451..eddea40 100644 --- a/src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp +++ b/src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp @@ -563,14 +563,14 @@ _FrameAnimatorImpl::PrepareCapture(void) SysTryReturnResult(NID_UI_ANIM, (pCanvas), E_SYSTEM, "A system error has been occurred. Failed to get canvas."); currentBounds.SetPosition(0, 0); - _VisualElementImpl::GetInstance(*__pCurrentFormVisualElement)->Capture(*pCanvas, currentBounds, true); + _VisualElementImpl::GetInstance(*__pCurrentFormVisualElement)->Capture(*pCanvas, currentBounds, currentBounds, true); delete pCanvas; pCanvas = __pNextCaptureVisualElement->GetCanvasN(); SysTryReturnResult(NID_UI_ANIM, (pCanvas), E_SYSTEM, "A system error has been occurred. Failed to get canvas."); nextBounds.SetPosition(0, 0); - _VisualElementImpl::GetInstance(*__pNextFormVisualElement)->Capture(*pCanvas, nextBounds, true); + _VisualElementImpl::GetInstance(*__pNextFormVisualElement)->Capture(*pCanvas, nextBounds, nextBounds, true); delete pCanvas; return E_SUCCESS; diff --git a/src/ui/animations/FUiAnim_VisualElementImpl.cpp b/src/ui/animations/FUiAnim_VisualElementImpl.cpp index e0826a1..cb4bd53 100644 --- a/src/ui/animations/FUiAnim_VisualElementImpl.cpp +++ b/src/ui/animations/FUiAnim_VisualElementImpl.cpp @@ -6084,6 +6084,20 @@ _VisualElementImpl::TransformVectorFromOrigin(const Tizen::Graphics::FloatPoint3 return FloatPoint3(x, y, z); } +/* + * VE ------------------------------------- surface + * <----40---> <------- 80 -------> + * +---------+ +------------------+ + * | | scaleX = 2.0f | (pStart) | + * +---------+ +------------------+ + * when capture (0,0,20,20) + * pCopy: width = 20 * scaleX = 40 + * +---------+ + * | pCopy | + * +---------+ + */ + + result _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDest, _VisualElementImpl& reference, const FloatRectangle& rectRef, const FloatRectangle& clipRect, bool withChilren, int depth) { @@ -6132,11 +6146,21 @@ _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDes } #else - if (__pSharedData->pSurface) + if (__pSharedData->pSurface ) { _EflVisualElementSurfaceImpl* pSurfImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*__pSharedData->pSurface)); - if(pSurfImpl && pSurfImpl->GetNativeHandle() ) + bool validContentsBounds = true; + + if(__useContentBounds) + { + if(__contentBounds.x < 0.0f || __contentBounds.y < 0.0f || __contentBounds.width > 1.0f || __contentBounds.height > 1.0f ) + { + validContentsBounds = false; + } + } + + if(likely(validContentsBounds) && pSurfImpl && pSurfImpl->GetNativeHandle() ) { BufferInfo info; byte* pStart = null; @@ -6164,24 +6188,38 @@ _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDes if(pStart) { - _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height); + float scaleX = 1.0f; + float scaleY = 1.0f; + + if(!__useContentBounds) + { + scaleX = (float)info.width/(float)__bounds.width; + scaleY = (float)info.height/(float)__bounds.height; + } + else + { + scaleX = ((float)info.width * __contentBounds.width)/(float)__bounds.width; + scaleY = ((float)info.height * __contentBounds.height)/(float)__bounds.height; + } + + +// _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height); BufferInfo copyInfo; copyInfo.bitsPerPixel = info.bitsPerPixel; - copyInfo.width = drawRect.width; - copyInfo.height = drawRect.height; + copyInfo.width = drawRect.width*scaleX; + copyInfo.height = drawRect.height*scaleY; copyInfo.pitch = (info.pitch/info.width)*copyInfo.width; byte* pCopy = new (std::nothrow) byte[copyInfo.height*(copyInfo.pitch)]; if (pCopy) { - //memcpy(pCopy, pStart, info.height*(info.pitch)); - + pStart += info.pitch * int(drawRect.y*scaleY) + int(drawRect.x*scaleX) * info.bitsPerPixel/8; for (int y = 0; y < copyInfo.height; y++) { - unsigned int* pSrc = (unsigned int*)((unsigned char*)pStart + info.pitch * (y + int(drawRect.y)) + int(drawRect.x) * 4); - unsigned int* pAddr = (unsigned int*)((unsigned char*)pCopy + copyInfo.pitch * y); + unsigned int* pSrc = (unsigned int*)(pStart + info.pitch * y); + unsigned int* pAddr = (unsigned int*)(pCopy + copyInfo.pitch * y); for (int x = 0; x < copyInfo.width; x++) { int a = ((*pSrc) >> 24) & 0xff; @@ -6196,12 +6234,16 @@ _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDes b = b / fa; *pAddr = (a << 24) | (r << 16) | (g << 8) | b; } + else + { + *pAddr = 0; + } pSrc++; pAddr++; } } - _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height); +// _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height); ByteBuffer buffer; @@ -6214,6 +6256,10 @@ _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDes { _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied(); pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f)); + if(!_FloatCompare(scaleX , 1.0f) && !_FloatCompare(scaleY,1.0f)) + { + pBitmap->Scale(FloatDimension(drawRect.width,drawRect.height)); + } FloatRectangle outputRect(rectDest.x + bounds.x - rectRef.x, rectDest.y + bounds.y - rectRef.y, drawRect.width, drawRect.height); FloatRectangle srcRect = outputRect; @@ -6367,6 +6413,7 @@ _VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDes Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888); if (pBitmap) { + pBitmap->Scale(FloatDimension(__bounds.width,__bounds.height)); _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied(); pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f)); -- 2.7.4