Remove TypeRegistration from deprecated Image classes
[platform/core/uifw/dali-core.git] / dali / internal / event / images / encoded-buffer-image-impl.cpp
index f7bf280..255709a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/common/ref-counted-dali-vector.h>
 #include <dali/internal/event/common/thread-local-storage.h>
 #include <dali/integration-api/platform-abstraction.h>
 
@@ -33,7 +34,12 @@ namespace Internal
 
 namespace
 {
-TypeRegistration mType( typeid( Dali::EncodedBufferImage ), typeid( Dali::Image ), NULL );
+
+/** Raw bytes of a resource laid out exactly as it would be in a file, but in memory. */
+typedef Dali::RefCountedVector<uint8_t> RequestBuffer;
+/** Counting smart pointer for managing a buffer of raw bytes. */
+typedef IntrusivePtr<RequestBuffer>     RequestBufferPtr;
+
 } // unnamed namespace
 
 EncodedBufferImagePtr EncodedBufferImage::New( const uint8_t * const encodedImage,
@@ -62,8 +68,8 @@ EncodedBufferImagePtr EncodedBufferImage::New( const uint8_t * const encodedImag
   // Get image size from buffer
   Dali::Integration::PlatformAbstraction& platformAbstraction = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction();
   const ImageDimensions expectedSize = platformAbstraction.GetClosestImageSize( buffer, size, fittingMode, samplingMode, orientationCorrection );
-  image->mWidth = (unsigned int) expectedSize.GetWidth();
-  image->mHeight = (unsigned int) expectedSize.GetHeight();
+  image->mWidth = static_cast<unsigned int>( expectedSize.GetWidth() );
+  image->mHeight = static_cast<unsigned int>( expectedSize.GetHeight() );
 
   // Load the image synchronously
   Integration::BitmapPtr bitmap = platformAbstraction.DecodeBuffer( resourceType, &(buffer->GetVector()[0]), encodedImageByteCount );
@@ -75,10 +81,10 @@ EncodedBufferImagePtr EncodedBufferImage::New( const uint8_t * const encodedImag
 
     //Create texture
     Pixel::Format format = bitmap->GetPixelFormat();
-    image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, format, width, height );
+    image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, format, width, height );
 
     //Upload data to the texture
-    size_t bufferSize = bitmap->GetBufferSize();
+    uint32_t bufferSize = bitmap->GetBufferSize();
     PixelDataPtr pixelData = PixelData::New( bitmap->GetBufferOwnership(), bufferSize, width, height, format,
                                              static_cast< Dali::PixelData::ReleaseFunction >( bitmap->GetReleaseFunction() ) );
     image->mTexture->Upload( pixelData );
@@ -97,7 +103,7 @@ EncodedBufferImagePtr EncodedBufferImage::New( const uint8_t * const encodedImag
   }
   else
   {
-    image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u );
+    image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u );
     image->mWidth = image->mHeight = 0u;
   }