From: woo Date: Tue, 4 Jun 2013 13:42:42 +0000 (+0900) Subject: add param to prevent lazy decoding in GetBitmapN onlyt for internal X-Git-Tag: submit/tizen_2.2/20130714.153149~579^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0dddb23b066d74f41baba7556138426c3a5dab7;p=framework%2Fosp%2Fuifw.git add param to prevent lazy decoding in GetBitmapN onlyt for internal Change-Id: I82b33388d2e194408eaf974faa3058e9a89f7cfb Signed-off-by: woo --- diff --git a/src/app/FApp_AppResourceBitmap.cpp b/src/app/FApp_AppResourceBitmap.cpp index d25bb2a..2896113 100644 --- a/src/app/FApp_AppResourceBitmap.cpp +++ b/src/app/FApp_AppResourceBitmap.cpp @@ -64,7 +64,7 @@ _AppResourceBitmap::Get_AppResourceBitmapN(int type, const String& value) } Bitmap* -_AppResourceBitmap::GetBitmapN(const String& imageFileName, BitmapPixelFormat pixelFormat) const +_AppResourceBitmap::GetBitmapN(const String& imageFileName, BitmapPixelFormat pixelFormat, bool lazyDecoding) const { ClearLastResult(); SysTryReturn(NID_APP, imageFileName.IsEmpty() == false, null, E_INVALID_ARG, "[%s] The specified input parameter is invalid.", imageFileName.GetPointer()); @@ -97,23 +97,21 @@ _AppResourceBitmap::GetBitmapN(const String& imageFileName, BitmapPixelFormat pi { if (_ImageUtil::HasAlphaChannel(resourcePath)) { - pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_ARGB8888, imageScaling); + pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_ARGB8888, imageScaling, null, lazyDecoding); } else { const Color& magentaColor = Color::GetColor(COLOR_ID_MAGENTA); - pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_RGB565, imageScaling, &magentaColor); + pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_RGB565, imageScaling, &magentaColor, lazyDecoding); } } else { - pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, pixelFormat, imageScaling); + pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, pixelFormat, imageScaling, null, lazyDecoding); } - - SysSecureLog(NID_APP, "The current value of bitmap path is %S(%S) and pixel format is %d", resourcePath.GetPointer(), imageScaling?L"scaled":L"not scaled", pixelFormat); - r = GetLastResult(); - SysTryReturn(NID_APP, pBitmap != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_APP, (pBitmap != null) && (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysSecureLog(NID_APP, "The current value of bitmap path is %S(%S) and pixel format is %d", resourcePath.GetPointer(), imageScaling?L"scaled":L"not scaled", pixelFormat); return pBitmap; } diff --git a/src/app/FApp_AppResourceBitmap.h b/src/app/FApp_AppResourceBitmap.h index 2f1547a..f443440 100644 --- a/src/app/FApp_AppResourceBitmap.h +++ b/src/app/FApp_AppResourceBitmap.h @@ -65,7 +65,7 @@ public: * @remarks The specific error code can be accessed using the GetLastResult() method. * @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer here. */ - virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const; + virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, bool lazyDecoding = true) const; static _AppResourceBitmap* Get_AppResourceBitmapN(int type, const Tizen::Base::String& value); diff --git a/src/app/FApp_AppResourceBitmapUtil.cpp b/src/app/FApp_AppResourceBitmapUtil.cpp index 19646e3..8d106ec 100644 --- a/src/app/FApp_AppResourceBitmapUtil.cpp +++ b/src/app/FApp_AppResourceBitmapUtil.cpp @@ -388,7 +388,7 @@ _AppResourceBitmapUtil::GetResourcePath(const String& fileName, String& resource // GetBitmapN Bitmap* _AppResourceBitmapUtil::GetBitmapN(const String& resourcePath, const _Density resourceDensity, - BitmapPixelFormat pixelFormat, bool imageScaling, const Color* pChromaKeyColor) const + BitmapPixelFormat pixelFormat, bool imageScaling, const Color* pChromaKeyColor, bool lazyDecoding) const { ClearLastResult(); SysTryReturn(NID_APP, (pixelFormat > BITMAP_PIXEL_FORMAT_MIN && pixelFormat < BITMAP_PIXEL_FORMAT_MAX), null, @@ -400,10 +400,28 @@ _AppResourceBitmapUtil::GetBitmapN(const String& resourcePath, const _Density re if (!pChromaKeyColor && imageScaling == false) // NonScaling { - pBitmap.reset(new (std::nothrow) Bitmap()); - SysTryReturn(NID_APP, pBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + if (lazyDecoding) + { + pBitmap.reset(new (std::nothrow) Bitmap()); + SysTryReturn(NID_APP, pBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); - r = _BitmapImpl::GetInstance(*pBitmap)->Construct(resourcePath, pixelFormat); + r = _BitmapImpl::GetInstance(*pBitmap)->Construct(resourcePath, pixelFormat); + } + else + { + MediaPixelFormat format = ConvertBitmapPixelFormatToMediaPixelFormat(pixelFormat); + int imageWidth(-1); + int imageHeight(-1); + + std::unique_ptr pBuffer(_ImageDecoder::DecodeToBufferN(resourcePath, format, imageWidth, imageHeight)); + r = GetLastResult(); + SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_APP, pBuffer != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + pBitmap.reset(_BitmapImpl::GetNonScaledBitmapN(*pBuffer, Dimension(imageWidth, imageHeight), pixelFormat)); + SysTryReturn(NID_APP, pBitmap != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + r = GetLastResult(); + } SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); return pBitmap.release(); diff --git a/src/app/FApp_AppResourceBitmapUtil.h b/src/app/FApp_AppResourceBitmapUtil.h index a001027..07a45c5 100644 --- a/src/app/FApp_AppResourceBitmapUtil.h +++ b/src/app/FApp_AppResourceBitmapUtil.h @@ -90,7 +90,7 @@ public: // Create Bitmap from real image path Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& resourcePath, _Density resourceDensity, - Tizen::Graphics::BitmapPixelFormat pixelFormat, bool imageScaling, const Tizen::Graphics::Color* pChromaKeyColor = null) const; + Tizen::Graphics::BitmapPixelFormat pixelFormat, bool imageScaling, const Tizen::Graphics::Color* pChromaKeyColor = null, bool lazyDecoding = true) const; static _AppResourceBitmapUtil* GetInstanceN(int type = APP_RESOURCE_DEFAULT, const Tizen::Base::String& value = L"");