add param to prevent lazy decoding in GetBitmapN onlyt for internal
authorwoo <s-w.woo@samsung.com>
Tue, 4 Jun 2013 13:42:42 +0000 (22:42 +0900)
committerwoo <s-w.woo@samsung.com>
Mon, 10 Jun 2013 02:58:16 +0000 (11:58 +0900)
Change-Id: I82b33388d2e194408eaf974faa3058e9a89f7cfb
Signed-off-by: woo <s-w.woo@samsung.com>
src/app/FApp_AppResourceBitmap.cpp
src/app/FApp_AppResourceBitmap.h
src/app/FApp_AppResourceBitmapUtil.cpp
src/app/FApp_AppResourceBitmapUtil.h

index d25bb2a..2896113 100644 (file)
@@ -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;
 }
index 2f1547a..f443440 100644 (file)
@@ -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 <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
        */
-       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);
 
index 19646e3..8d106ec 100644 (file)
@@ -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<ByteBuffer> 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();
index a001027..07a45c5 100644 (file)
@@ -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"");