Changed image loaders to use new PixelBuffer class. 27/134927/9
authorDavid Steele <david.steele@samsung.com>
Tue, 20 Jun 2017 09:06:58 +0000 (10:06 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 28 Jun 2017 12:38:35 +0000 (13:38 +0100)
Migrating from PixelData to PixelBuffer internally. Public API
still offers PixelData where needed.

Through DevelAPI, it is now possible to retrieve a PixelBuffer from
AsyncImageLoader.

Removed BitmapLoader usage in favour of LoadImageFromFile().

Change-Id: Ib9e7b96cb6d643c0fb13e24b598131a3642a4b7c
Signed-off-by: David Steele <david.steele@samsung.com>
26 files changed:
automated-tests/resources/empty.bmp [new file with mode: 0644]
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit-styling/CMakeLists.txt
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp [deleted file]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.h [deleted file]
automated-tests/src/dali-toolkit/utc-Dali-CubeTransitionEffect.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/image-loader/async-image-loader-devel.cpp [new file with mode: 0644]
dali-toolkit/devel-api/image-loader/async-image-loader-devel.h [new file with mode: 0644]
dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp
dali-toolkit/internal/image-loader/async-image-loader-impl.cpp
dali-toolkit/internal/image-loader/async-image-loader-impl.h
dali-toolkit/internal/image-loader/image-atlas-impl.cpp
dali-toolkit/internal/image-loader/image-load-thread.cpp
dali-toolkit/internal/image-loader/image-load-thread.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/mesh/mesh-visual.cpp
dali-toolkit/internal/visuals/texture-manager.cpp
dali-toolkit/internal/visuals/texture-manager.h
dali-toolkit/public-api/image-loader/sync-image-loader.cpp

diff --git a/automated-tests/resources/empty.bmp b/automated-tests/resources/empty.bmp
new file mode 100644 (file)
index 0000000..29df0c2
Binary files /dev/null and b/automated-tests/resources/empty.bmp differ
index 6ec6207..b9554e9 100755 (executable)
@@ -7,24 +7,25 @@ SET(CAPI_LIB "dali-toolkit-internal")
 
 # List of test case sources (Only these get parsed for test cases)
 SET(TC_SOURCES
+ utc-Dali-BidirectionalSupport.cpp
+ utc-Dali-ColorConversion.cpp
+ utc-Dali-DebugRendering.cpp
+ utc-Dali-ItemView-internal.cpp
+ utc-Dali-LogicalModel.cpp
+ utc-Dali-PropertyHelper.cpp
  utc-Dali-Text-CharacterSetConversion.cpp
+ utc-Dali-Text-Controller.cpp
  utc-Dali-Text-Cursor.cpp
- utc-Dali-Text-Segmentation.cpp
- utc-Dali-Text-MultiLanguage.cpp
- utc-Dali-LogicalModel.cpp
- utc-Dali-BidirectionalSupport.cpp
- utc-Dali-Text-Shaping.cpp
- utc-Dali-VisualModel.cpp
  utc-Dali-Text-Layout.cpp
- utc-Dali-Text-Controller.cpp
- utc-Dali-VisualUrl.cpp
  utc-Dali-Text-Markup.cpp
+ utc-Dali-Text-MultiLanguage.cpp
+ utc-Dali-Text-Segmentation.cpp
+ utc-Dali-Text-Shaping.cpp
  utc-Dali-Text-Typesetter.cpp
  utc-Dali-Text-ViewModel.cpp
- utc-Dali-DebugRendering.cpp
- utc-Dali-ItemView-internal.cpp
- utc-Dali-PropertyHelper.cpp
- utc-Dali-ColorConversion.cpp
+ utc-Dali-TextureManager.cpp
+ utc-Dali-VisualModel.cpp
+ utc-Dali-VisualUrl.cpp
 )
 
 # Append list of test harness files (Won't get parsed for test cases)
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp
new file mode 100644 (file)
index 0000000..c38a70c
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+
+#include <stdlib.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/internal/visuals/texture-manager.h>
+#include <dali-toolkit/internal/visuals/texture-upload-observer.h>
+
+using namespace Dali::Toolkit::Internal;
+
+class TestObserver : public Dali::Toolkit::TextureUploadObserver
+{
+public:
+  TestObserver()
+  : mLoaded(false),
+    mObserverCalled(false)
+  {
+  }
+
+  void UploadComplete( bool loadSuccess, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect )
+  {
+    mLoaded = loadSuccess;
+    mObserverCalled = true;
+  }
+
+  bool mLoaded;
+  bool mObserverCalled;
+};
+
+
+int UtcTextureManagerRequestLoad(void)
+{
+  ToolkitTestApplication application;
+
+  TextureManager textureManager; // Create new texture manager
+
+  TestObserver observer;
+  std::string filename("image.png");
+
+  TextureManager::TextureId textureId = textureManager.RequestLoad(
+    filename,
+    ImageDimensions(),
+    FittingMode::SCALE_TO_FILL,
+    SamplingMode::BOX_THEN_LINEAR,
+    TextureManager::NO_ATLAS,
+    &observer );
+
+  const VisualUrl& url = textureManager.GetVisualUrl( textureId );
+
+  DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );
+
+  END_TEST;
+}
index caa901e..0ef2777 100644 (file)
@@ -16,7 +16,6 @@ LIST(APPEND TC_SOURCES
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
-   ../dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-color-controller.cpp
    ../dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
index 9b8bd63..521f265 100755 (executable)
@@ -70,7 +70,6 @@ LIST(APPEND TC_SOURCES
    dali-toolkit-test-utils/toolkit-adaptor.cpp
    dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp
    dali-toolkit-test-utils/toolkit-application.cpp
-   dali-toolkit-test-utils/toolkit-bitmap-loader.cpp
    dali-toolkit-test-utils/toolkit-clipboard.cpp
    dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp
    dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.cpp
deleted file mode 100644 (file)
index 61cbe4d..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// CLASS HEADER
-#include "toolkit-bitmap-loader.h"
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-object.h>
-#include <cstring>
-#include <semaphore.h>
-
-using namespace Dali;
-
-namespace Dali
-{
-namespace
-{
-Dali::BitmapLoader gBitmapLoader;
-}
-
-
-namespace Internal
-{
-
-class BitmapLoader : public BaseObject
-{
-public:
-  static IntrusivePtr<BitmapLoader> New( const std::string& url,
-                                         ImageDimensions size,
-                                         FittingMode::Type fittingMode,
-                                         SamplingMode::Type samplingMode,
-                                         bool orientationCorrection)
-  {
-    IntrusivePtr<BitmapLoader> internal = new BitmapLoader( url, size, fittingMode, samplingMode, orientationCorrection );
-    return internal;
-  }
-
-  BitmapLoader(const std::string& url,
-               ImageDimensions size,
-               FittingMode::Type fittingMode,
-               SamplingMode::Type samplingMode,
-               bool orientationCorrection)
-  : mSize(size),
-    mPixelData(),
-    mUrl(url)
-  {
-    sem_init( &mySemaphore, 0, 0 );
-  }
-
-  ~BitmapLoader(){}
-
-  void Load()
-  {
-    size_t bufferSize  = mSize.GetWidth() * mSize.GetHeight() * 4;
-    unsigned char* buffer = static_cast<unsigned char*>(malloc(bufferSize));
-    memset(buffer, 0, bufferSize);
-
-    mPixelData = Dali::PixelData::New( buffer, bufferSize, mSize.GetWidth(), mSize.GetHeight(), Pixel::RGBA8888, Dali::PixelData::FREE);
-
-    sem_post( &mySemaphore );
-  }
-
-  Dali::PixelData GetPixelData() const
-  {
-    return mPixelData;
-  }
-
-  const std::string& GetUrl() const
-  {
-    return mUrl;
-  }
-
-  bool IsLoaded()
-  {
-    return mPixelData ? true : false;
-  }
-
-  void WaitForLoading()
-  {
-    if( mPixelData )
-    {
-      return;
-    }
-    sem_wait( &mySemaphore );
-  }
-
-  ImageDimensions mSize;
-  Dali::PixelData mPixelData;
-  const std::string mUrl;
-  sem_t mySemaphore;
-};
-
-} // internal
-
-inline Internal::BitmapLoader& GetImplementation(Dali::BitmapLoader& handle)
-{
-  DALI_ASSERT_ALWAYS( handle && "handle is empty" );
-  BaseObject& object = handle.GetBaseObject();
-  return static_cast<Internal::BitmapLoader&>(object);
-}
-
-inline const Internal::BitmapLoader& GetImplementation(const Dali::BitmapLoader& handle)
-{
-  DALI_ASSERT_ALWAYS( handle && "handle is empty" );
-  const BaseObject& object = handle.GetBaseObject();
-  return static_cast<const Internal::BitmapLoader&>(object);
-}
-
-Dali::BitmapLoader Dali::BitmapLoader::New(std::string const&url, Dali::Uint16Pair size, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode, bool orientationCorrection)
-{
-  IntrusivePtr<Internal::BitmapLoader> internal = Internal::BitmapLoader::New(url, size, fittingMode, samplingMode, orientationCorrection);
-  gBitmapLoader = BitmapLoader(internal.Get());
-  return gBitmapLoader;
-}
-
-BitmapLoader::BitmapLoader()
-{
-}
-
-Dali::BitmapLoader::BitmapLoader(Dali::BitmapLoader const& handle)
-:BaseHandle(handle)
-{
-}
-Dali::BitmapLoader::BitmapLoader(Internal::BitmapLoader* internal)
-:BaseHandle(internal)
-{
-}
-Dali::BitmapLoader::~BitmapLoader()
-{
-}
-BitmapLoader& BitmapLoader::operator=(const BitmapLoader& rhs)
-{
-  BaseHandle::operator=(rhs);
-  return *this;
-}
-void Dali::BitmapLoader::Load()
-{
-  GetImplementation(*this).Load();
-}
-PixelData Dali::BitmapLoader::GetPixelData() const
-{
-  return GetImplementation(*this).GetPixelData();
-}
-std::string Dali::BitmapLoader::GetUrl() const
-{
-  return GetImplementation(*this).GetUrl();
-}
-bool Dali::BitmapLoader::IsLoaded()
-{
-  return GetImplementation(*this).IsLoaded();
-}
-void Dali::BitmapLoader::WaitForLoading()
-{
-  GetImplementation(*this).WaitForLoading();
-}
-
-BitmapLoader Dali::BitmapLoader::GetLatestCreated()
-{
-  return gBitmapLoader;
-}
-
-void Dali::BitmapLoader::ResetLatestCreated()
-{
-  gBitmapLoader.Reset();
-}
-
-} // Dali
diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-bitmap-loader.h
deleted file mode 100644 (file)
index acdc94a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef DALI_TOOLKIT_BITMAP_LOADER_H
-#define DALI_TOOLKIT_BITMAP_LOADER_H
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define DALI_BITMAP_LOADER_H
-
-#include <string>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/images/pixel-data.h>
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali
-{
-namespace Internal
-{
-class BitmapLoader;
-}
-
-class DALI_IMPORT_API BitmapLoader : public BaseHandle
-{
-public:
-
-  static BitmapLoader New( const std::string& url,
-                           ImageDimensions size = ImageDimensions( 0, 0 ),
-                           FittingMode::Type fittingMode = FittingMode::DEFAULT,
-                           SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
-                           bool orientationCorrection = true);
-  BitmapLoader();
-  ~BitmapLoader();
-  BitmapLoader(const BitmapLoader& handle);
-  BitmapLoader& operator=(const BitmapLoader& rhs);
-
-public:
-  void Load();
-  bool IsLoaded();
-  std::string GetUrl() const;
-  PixelData GetPixelData() const;
-
-  void WaitForLoading();
-  static BitmapLoader GetLatestCreated(); // return the latest created BitmapLoader
-  static void ResetLatestCreated();
-
-public: // Not intended for application developers
-
-  explicit DALI_INTERNAL BitmapLoader(Internal::BitmapLoader*);
-};
-
-} // Dali
-
-#endif // DALI_TOOLKIT_BITMAP_LOADER_H
index 5efd46d..8d8cefb 100644 (file)
@@ -23,9 +23,9 @@
 #include <dali-toolkit/devel-api/transition-effects/cube-transition-cross-effect.h>
 #include <dali-toolkit/devel-api/transition-effects/cube-transition-fold-effect.h>
 #include <dali-toolkit/devel-api/transition-effects/cube-transition-wave-effect.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
 #include <dali/public-api/images/buffer-image.h>
-
+#include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 
 
 using namespace Dali;
@@ -431,9 +431,8 @@ int UtcDaliCubeTransitionWaveEffectStartTransition(void)
 
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
 
-  BitmapLoader loader = BitmapLoader::New( "Image.jpg" );
-  loader.Load();
-  PixelData pixelData = loader.GetPixelData();
+  Devel::PixelBuffer pixelBuffer = LoadImageFromFile(TEST_RESOURCE_DIR "/gallery-small-1.jpg");
+  PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
   Texture texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
   texture.Upload( pixelData );
 
@@ -489,9 +488,8 @@ int UtcDaliCubeTransitionCrossEffectStartTransition(void)
 
   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
 
-  BitmapLoader loader = BitmapLoader::New( "Image.jpg" );
-  loader.Load();
-  PixelData pixelData = loader.GetPixelData();
+  Devel::PixelBuffer pixelBuffer = LoadImageFromFile(TEST_RESOURCE_DIR "/gallery-small-1.jpg");
+  PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
   Texture texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
   texture.Upload( pixelData );
 
index cca026f..848a282 100644 (file)
@@ -38,8 +38,8 @@ static const char* gImage_50_RGBA = TEST_RESOURCE_DIR "/icon-delete.png";
 // resolution: 128*128, pixel format: RGB888
 static const char* gImage_128_RGB = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
 
-// this is image is not exist, for negative test
-static const char* gImageNonExist = "non-exist.jpg";
+// Empty image, for testing broken image loading
+static const char* gEmptyImage = TEST_RESOURCE_DIR "/empty.bmp";
 
 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
 
@@ -194,26 +194,27 @@ int UtcDaliImageAtlasSetBrokenImage(void)
   unsigned int size = 200;
   ImageAtlas atlas = ImageAtlas::New( size, size );
 
-  Vector4 textureRect;
-  atlas.Upload( textureRect, gImageNonExist );
-  DALI_TEST_EQUALS( textureRect, Vector4::ZERO, TEST_LOCATION );
-
   // Set broken image
   TestPlatformAbstraction& platform = application.GetPlatform();
   platform.SetClosestImageSize(Vector2( 34, 34));
   atlas.SetBrokenImage( gImage_34_RGBA );
 
-  // the non-exit image will be replaced with the broken image
-  platform.SetClosestImageSize(Vector2( 0, 0));
-  atlas.Upload( textureRect, gImageNonExist );
+  Vector4 textureRect;
+
+  // the empty image will be replaced with the broken image
+  platform.SetClosestImageSize(Vector2( 20, 20));
+  atlas.Upload( textureRect, gEmptyImage );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   Rect<int> pixelArea = TextureCoordinateToPixelArea(textureRect, size);
-  DALI_TEST_EQUALS( pixelArea.width, 34, TEST_LOCATION );
-  DALI_TEST_EQUALS( pixelArea.height, 34, TEST_LOCATION );
+  DALI_TEST_EQUALS( pixelArea.width, 20, TEST_LOCATION );
+  DALI_TEST_EQUALS( pixelArea.height, 20, TEST_LOCATION );
 
   END_TEST;
 }
 
+
+
 int UtcDaliImageAtlasUploadP(void)
 {
   ToolkitTestApplication application;
index d1beb09..29b7a40 100644 (file)
@@ -18,7 +18,6 @@
 // Need to override adaptor classes for toolkit test harness, so include
 // test harness headers before dali headers.
 #include <dali-toolkit-test-suite-utils.h>
-#include <toolkit-bitmap-loader.h>
 #include <toolkit-event-thread-callback.h>
 
 #include <dali-toolkit/dali-toolkit.h>
@@ -29,6 +28,7 @@
 
 #include <test-native-image.h>
 #include <sstream>
+#include <unistd.h>
 
 using namespace Dali;
 using namespace Toolkit;
@@ -427,20 +427,28 @@ int UtcDaliImageViewPixelArea(void)
 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
 {
   ToolkitTestApplication application;
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+  const std::vector<GLuint>& textures = gl.GetBoundTextures();
+  size_t numTextures = textures.size();
 
   // Async loading, no atlasing for big size image
   ImageView imageView = ImageView::New( gImage_600_RGB );
 
   // By default, Aysnc loading is used
   Stage::GetCurrent().Add( imageView );
+  imageView.SetSize(100, 100);
+  imageView.SetParentOrigin( ParentOrigin::CENTER );
+
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
   application.SendNotification();
   application.Render(16);
-  application.Render(16);
   application.SendNotification();
 
-  // BitmapLoader is not used
-  BitmapLoader loader = BitmapLoader::GetLatestCreated();
-  DALI_TEST_CHECK( !loader );
+  const std::vector<GLuint>& textures2 = gl.GetBoundTextures();
+  DALI_TEST_GREATER( textures2.size(), numTextures, TEST_LOCATION );
+
+
 
   END_TEST;
 }
@@ -547,35 +555,22 @@ int UtcDaliImageViewSyncLoading(void)
     // Sync loading is used
     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
-
-
-    // BitmapLoader is used, and the loading is started immediately even the actor is not on stage.
-    BitmapLoader loader = BitmapLoader::GetLatestCreated();
-    DALI_TEST_CHECK( loader );
   }
 
   // Sync loading, automatic atlasing for small size image
   {
-    BitmapLoader::ResetLatestCreated();
     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
     callStack.Reset();
     callStack.Enable(true);
 
     ImageView imageView = ImageView::New( );
+
     // Sync loading is used
     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
     syncLoadingMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
     syncLoadingMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
 
-    // loading is started even if the actor is offStage
-    BitmapLoader loader = BitmapLoader::GetLatestCreated();
-    DALI_TEST_CHECK( loader );
-
-    loader.WaitForLoading();
-
-    DALI_TEST_CHECK( loader.IsLoaded() );
-
     Stage::GetCurrent().Add( imageView );
     application.SendNotification();
     application.Render(16);
@@ -598,7 +593,6 @@ int UtcDaliImageViewSyncLoading02(void)
 
   // Sync loading, automatic atlasing for small size image
   {
-    BitmapLoader::ResetLatestCreated();
     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
     callStack.Reset();
     callStack.Enable(true);
@@ -614,14 +608,6 @@ int UtcDaliImageViewSyncLoading02(void)
     syncLoadingMap[ "atlasing" ] = true;
     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
 
-    // loading is started even if the actor is offStage
-    BitmapLoader loader = BitmapLoader::GetLatestCreated();
-    DALI_TEST_CHECK( loader );
-
-    loader.WaitForLoading();
-
-    DALI_TEST_CHECK( loader.IsLoaded() );
-
     Stage::GetCurrent().Add( imageView );
     application.SendNotification();
     application.Render(16);
index f6d34b9..16f9fef 100644 (file)
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <toolkit-timer.h>
-#include <toolkit-bitmap-loader.h>
 #include <toolkit-event-thread-callback.h>
 #include <dali/public-api/rendering/renderer.h>
 #include <dali/public-api/rendering/texture-set.h>
@@ -451,11 +450,6 @@ int UtcDaliImageVisualCustomWrapModePixelArea(void)
   application.SendNotification();
   application.Render();
 
-  BitmapLoader loader = BitmapLoader::GetLatestCreated();
-  DALI_TEST_CHECK( loader );
-  loader.WaitForLoading();// waiting until the image to be loaded
-  DALI_TEST_CHECK( loader.IsLoaded() );
-
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
@@ -534,11 +528,6 @@ int UtcDaliImageVisualCustomWrapModeNoAtlas(void)
   application.SendNotification();
   application.Render();
 
-  BitmapLoader loader = BitmapLoader::GetLatestCreated();
-  DALI_TEST_CHECK( loader );
-  loader.WaitForLoading();// waiting until the image to be loaded
-  DALI_TEST_CHECK( loader.IsLoaded() );
-
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
   DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
index 2e7e268..337fb24 100644 (file)
@@ -18,7 +18,6 @@
 #include <stdlib.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <toolkit-timer.h>
-#include <toolkit-bitmap-loader.h>
 #include <toolkit-event-thread-callback.h>
 #include <dali/public-api/rendering/renderer.h>
 #include <dali/public-api/rendering/texture-set.h>
index fe8ef2b..64fbb88 100644 (file)
@@ -27,6 +27,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
   $(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
   $(devel_api_src_dir)/focus-manager/keyboard-focus-manager-devel.cpp \
+  $(devel_api_src_dir)/image-loader/async-image-loader-devel.cpp \
   $(devel_api_src_dir)/image-loader/atlas-upload-observer.cpp \
   $(devel_api_src_dir)/image-loader/image-atlas.cpp \
   $(devel_api_src_dir)/scripting/script.cpp \
@@ -112,6 +113,7 @@ devel_api_focus_manager_header_files = \
   $(devel_api_src_dir)/focus-manager/keyboard-focus-manager-devel.h
 
 devel_api_image_loader_header_files = \
+  $(devel_api_src_dir)/image-loader/async-image-loader-devel.h \
   $(devel_api_src_dir)/image-loader/atlas-upload-observer.h \
   $(devel_api_src_dir)/image-loader/image-atlas.h
 
diff --git a/dali-toolkit/devel-api/image-loader/async-image-loader-devel.cpp b/dali-toolkit/devel-api/image-loader/async-image-loader-devel.cpp
new file mode 100644 (file)
index 0000000..690f078
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
+#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace DevelAsyncImageLoader
+{
+
+PixelBufferLoadedSignalType& PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader )
+{
+  return GetImplementation( asyncImageLoader ).PixelBufferLoadedSignal();
+}
+
+} // Devel
+} // Toolkit
+} // Dali
diff --git a/dali-toolkit/devel-api/image-loader/async-image-loader-devel.h b/dali-toolkit/devel-api/image-loader/async-image-loader-devel.h
new file mode 100644 (file)
index 0000000..2af2be9
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/public-api/signals/dali-signal.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali-toolkit/public-api/image-loader/async-image-loader.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace DevelAsyncImageLoader
+{
+
+typedef Signal< void ( uint32_t, Devel::PixelBuffer ) > PixelBufferLoadedSignalType;
+
+/**
+ * Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
+ * @note Connecting to this signal prevents the emission of the ImageLoadedSignal.
+ */
+DALI_IMPORT_API PixelBufferLoadedSignalType&  PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader );
+
+}
+} // Toolkit
+} // Dali
+
+#endif
index 9c22982..3830f62 100644 (file)
@@ -27,7 +27,7 @@
 #include <dali-toolkit/public-api/controls/model3d-view/model3d-view.h>
 #include <dali/public-api/images/resource-image.h>
 #include <dali/devel-api/adaptor-framework/file-loader.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
@@ -60,12 +60,11 @@ enum TextureIndex
 Texture LoadTexture( const char* imageUrl )
 {
   Texture texture;
-  Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl );
-  loader.Load();
-  PixelData pixelData = loader.GetPixelData();
-  if( pixelData )
+  Devel::PixelBuffer pixelBuffer = LoadImageFromFile( imageUrl );
+  if( pixelBuffer )
   {
-    texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+    texture = Texture::New( TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight() );
+    PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
     texture.Upload( pixelData );
     texture.GenerateMipmaps();
   }
index 8454992..966da79 100644 (file)
@@ -71,6 +71,11 @@ Toolkit::AsyncImageLoader::ImageLoadedSignalType& AsyncImageLoader::ImageLoadedS
   return mLoadedSignal;
 }
 
+Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& AsyncImageLoader::PixelBufferLoadedSignal()
+{
+  return mPixelBufferLoadedSignal;
+}
+
 bool AsyncImageLoader::Cancel( uint32_t loadingTaskId )
 {
   return mLoadThread.CancelTask( loadingTaskId );
@@ -85,7 +90,20 @@ void AsyncImageLoader::ProcessLoadedImage()
 {
   while( LoadingTask *next = mLoadThread.NextCompletedTask() )
   {
-    mLoadedSignal.Emit( next->id, next->pixelData );
+    if( mPixelBufferLoadedSignal.GetConnectionCount() > 0 )
+    {
+      mPixelBufferLoadedSignal.Emit( next->id, next->pixelBuffer );
+    }
+    else if( mLoadedSignal.GetConnectionCount() > 0 )
+    {
+      PixelData pixelData;
+      if( next->pixelBuffer )
+      {
+        pixelData = Devel::PixelBuffer::Convert( next->pixelBuffer );
+      }
+      mLoadedSignal.Emit( next->id, pixelData );
+    }
+
     delete next;
   }
 }
index fe4c73b..ce40f5a 100644 (file)
@@ -23,6 +23,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
 #include <dali-toolkit/internal/image-loader/image-load-thread.h>
 
 namespace Dali
@@ -63,6 +64,11 @@ public:
   Toolkit::AsyncImageLoader::ImageLoadedSignalType& ImageLoadedSignal();
 
   /**
+   * @copydoc Toolkit::AsyncImageLoader::PixelBufferLoadedSignal
+   */
+  Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& PixelBufferLoadedSignal();
+
+  /**
    * @copydoc Toolkit::AsyncImageLoader::Cancel
    */
   bool Cancel( uint32_t loadingTaskId );
@@ -86,6 +92,7 @@ protected:
 
 private:
   Toolkit::AsyncImageLoader::ImageLoadedSignalType mLoadedSignal;
+  Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType mPixelBufferLoadedSignal;
 
   ImageLoadThread mLoadThread;
   uint32_t        mLoadTaskId;
index 30f1ba7..b69adbd 100644 (file)
@@ -22,7 +22,6 @@
 #include <string.h>
 #include <dali/public-api/signals/callback.h>
 #include <dali/devel-api/adaptor-framework/image-loading.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
 #include <dali/integration-api/debug.h>
 
 namespace Dali
@@ -262,10 +261,9 @@ void ImageAtlas::UploadToAtlas( uint32_t id, PixelData pixelData )
 
 void ImageAtlas::UploadBrokenImage( const Rect<unsigned int>& area )
 {
-  BitmapLoader loader = BitmapLoader::New(mBrokenImageUrl, ImageDimensions( area.width, area.height ) );
-  loader.Load();
-  SizeType loadedWidth = loader.GetPixelData().GetWidth();
-  SizeType loadedHeight = loader.GetPixelData().GetHeight();
+  Devel::PixelBuffer brokenBuffer = LoadImageFromFile( mBrokenImageUrl, ImageDimensions( area.width, area.height ) );
+  SizeType loadedWidth = brokenBuffer.GetWidth();
+  SizeType loadedHeight = brokenBuffer.GetHeight();
 
   bool needBackgroundClear = false;
   SizeType packX = area.x;
@@ -285,16 +283,18 @@ void ImageAtlas::UploadBrokenImage( const Rect<unsigned int>& area )
   if( needBackgroundClear )
   {
     SizeType size = area.width * area.height * Pixel::GetBytesPerPixel( mPixelFormat );
-    PixelBuffer* buffer = new PixelBuffer [size];
-    PixelData background = PixelData::New( buffer, size, area.width, area.height, mPixelFormat, PixelData::DELETE_ARRAY );
+    Devel::PixelBuffer background = Devel::PixelBuffer::New( area.width, area.height, mPixelFormat );
+    unsigned char* buffer = background.GetBuffer();
     for( SizeType idx = 0; idx < size; idx++ )
     {
       buffer[idx] = 0x00;
     }
-    mAtlas.Upload( background, 0u, 0u, area.x, area.y, area.width, area.height );
+    PixelData pixelData = Devel::PixelBuffer::Convert( background );
+    mAtlas.Upload( pixelData, 0u, 0u, area.x, area.y, area.width, area.height );
   }
 
-  mAtlas.Upload( loader.GetPixelData(), 0u, 0u, packX, packY, loadedWidth, loadedHeight );
+  PixelData brokenPixelData = Devel::PixelBuffer::Convert( brokenBuffer );
+  mAtlas.Upload( brokenPixelData, 0u, 0u, packX, packY, loadedWidth, loadedHeight );
 }
 
 } // namespace Internal
index a06953e..c1b4a91 100644 (file)
@@ -32,7 +32,7 @@ namespace Internal
 
 LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions,
                           FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
-: pixelData(),
+: pixelBuffer(),
   url( url ),
   id( id ),
   dimensions( dimensions ),
@@ -46,11 +46,11 @@ void LoadingTask::Load()
 {
   if( url.IsLocal() )
   {
-    pixelData = Dali::LoadImageFromFile( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
+    pixelBuffer = Dali::LoadImageFromFile( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
   }
   else
   {
-    pixelData = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
+    pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
   }
 }
 
index f3d9632..3d0ad24 100644 (file)
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/images/pixel-data.h>
 #include <dali/devel-api/threading/conditional-wait.h>
 #include <dali/devel-api/threading/mutex.h>
 #include <dali/devel-api/threading/thread.h>
 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
@@ -70,7 +70,7 @@ private:
 
 public:
 
-  PixelData          pixelData;     ///< pixelData handle after successfull load
+  Devel::PixelBuffer pixelBuffer;   ///< pixelBuffer handle after successful load
   VisualUrl          url;           ///< url of the image to load
   uint32_t           id;            ///< The unique id associated with this task.
   ImageDimensions    dimensions;    ///< dimensions to load
index e50edca..de7b3b8 100644 (file)
@@ -24,7 +24,6 @@
 #include <dali/public-api/images/resource-image.h>
 #include <dali/public-api/images/native-image.h>
 #include <dali/devel-api/images/texture-set-image.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
 #include <dali/devel-api/adaptor-framework/image-loading.h>
 #include <dali/devel-api/scripting/enum-helper.h>
 #include <dali/devel-api/scripting/scripting.h>
@@ -632,9 +631,12 @@ void ImageVisual::LoadResourceSynchronously()
 {
   if( mImageUrl.IsValid() )
   {
-    BitmapLoader loader = BitmapLoader::New( mImageUrl.GetUrl(), mDesiredSize, mFittingMode, mSamplingMode );
-    loader.Load();
-    mPixels = loader.GetPixelData();
+    Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mImageUrl.GetUrl(), mDesiredSize, mFittingMode, mSamplingMode );
+
+    if( pixelBuffer )
+    {
+      mPixels = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
+    }
     mTextureLoading = false;
   }
 }
index 76e8558..e6a7bf4 100644 (file)
@@ -21,7 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/common/stage.h>
-#include <dali/devel-api/adaptor-framework/bitmap-loader.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
 #include <dali/devel-api/adaptor-framework/file-loader.h>
 #include <dali/devel-api/scripting/enum-helper.h>
 #include <dali/devel-api/scripting/scripting.h>
@@ -46,12 +46,12 @@ namespace
   Texture LoadTexture( const char* imageUrl, bool generateMipmaps )
   {
     Texture texture;
-    Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl );
-    loader.Load();
-    PixelData pixelData = loader.GetPixelData();
-    if( pixelData )
+
+    Devel::PixelBuffer pixelBuffer = LoadImageFromFile( imageUrl );
+    if( pixelBuffer )
     {
-      texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+      texture = Texture::New( TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight() );
+      PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
       texture.Upload( pixelData );
 
       if( generateMipmaps )
index 2283f22..0c839ad 100644 (file)
 
 // EXTERNAL HEADERS
 #include <dali/devel-api/common/hash.h>
-#include <dali/devel-api/images/pixel-data-mask.h>
 #include <dali/devel-api/images/texture-set-image.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL HEADERS
 #include <dali/integration-api/debug.h>
-#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
 #include <dali-toolkit/internal/image-loader/image-atlas-impl.h>
+#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
 #include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
 
 
@@ -61,8 +62,8 @@ TextureManager::TextureManager()
   mAsyncRemoteLoader( Toolkit::AsyncImageLoader::New() ),
   mCurrentTextureId( 0 )
 {
-  mAsyncLocalLoader.ImageLoadedSignal().Connect( this, &TextureManager::AsyncLocalLoadComplete );
-  mAsyncRemoteLoader.ImageLoadedSignal().Connect( this, &TextureManager::AsyncRemoteLoadComplete );
+  DevelAsyncImageLoader::PixelBufferLoadedSignal(mAsyncLocalLoader).Connect( this, &TextureManager::AsyncLocalLoadComplete );
+  DevelAsyncImageLoader::PixelBufferLoadedSignal(mAsyncRemoteLoader).Connect( this, &TextureManager::AsyncRemoteLoadComplete );
 }
 
 TextureManager::TextureId TextureManager::RequestLoad(
@@ -73,7 +74,7 @@ TextureManager::TextureId TextureManager::RequestLoad(
   const UseAtlas           useAtlas,
   TextureUploadObserver*   observer )
 {
-  return RequestInternalLoad( url, INVALID_TEXTURE_ID, desiredSize, fittingMode, samplingMode, useAtlas, GPU_UPLOAD, observer );
+  return RequestLoadInternal( url, INVALID_TEXTURE_ID, desiredSize, fittingMode, samplingMode, useAtlas, UPLOAD_TO_TEXTURE, observer );
 }
 
 TextureManager::TextureId TextureManager::RequestLoad(
@@ -85,17 +86,17 @@ TextureManager::TextureId TextureManager::RequestLoad(
   const UseAtlas           useAtlas,
   TextureUploadObserver*   observer )
 {
-  return RequestInternalLoad( url, maskTextureId, desiredSize, fittingMode, samplingMode, useAtlas, GPU_UPLOAD, observer );
+  return RequestLoadInternal( url, maskTextureId, desiredSize, fittingMode, samplingMode, useAtlas, UPLOAD_TO_TEXTURE, observer );
 }
 
 TextureManager::TextureId TextureManager::RequestMaskLoad( const VisualUrl& maskUrl )
 {
   // Use the normal load procedure to get the alpha mask.
-  return RequestInternalLoad( maskUrl, INVALID_TEXTURE_ID, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, NO_ATLAS, CPU, NULL );
+  return RequestLoadInternal( maskUrl, INVALID_TEXTURE_ID, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, NO_ATLAS, KEEP_PIXEL_BUFFER, NULL );
 }
 
 
-TextureManager::TextureId TextureManager::RequestInternalLoad(
+TextureManager::TextureId TextureManager::RequestLoadInternal(
   const VisualUrl&         url,
   TextureId                maskTextureId,
   const ImageDimensions    desiredSize,
@@ -246,6 +247,15 @@ void TextureManager::Remove( const TextureManager::TextureId textureId )
   }
 }
 
+const VisualUrl& TextureManager::GetVisualUrl( TextureId textureId )
+{
+  int cacheIndex = GetCacheIndexFromId( textureId );
+  DALI_ASSERT_DEBUG( cacheIndex != INVALID_CACHE_INDEX && "TextureId out of range");
+
+  TextureInfo& cachedTextureInfo( mTextureInfoContainer[ cacheIndex ] );
+  return cachedTextureInfo.url;
+}
+
 TextureManager::LoadState TextureManager::GetTextureState( TextureId textureId )
 {
   LoadState loadState = TextureManager::NOT_STARTED;
@@ -314,17 +324,17 @@ void TextureManager::ObserveTexture( TextureInfo& textureInfo,
   }
 }
 
-void TextureManager::AsyncLocalLoadComplete( uint32_t id, PixelData pixelData )
+void TextureManager::AsyncLocalLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer )
 {
-  AsyncLoadComplete( mAsyncLocalLoadingInfoContainer, id, pixelData );
+  AsyncLoadComplete( mAsyncLocalLoadingInfoContainer, id, pixelBuffer );
 }
 
-void TextureManager::AsyncRemoteLoadComplete( uint32_t id, PixelData pixelData )
+void TextureManager::AsyncRemoteLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer )
 {
-  AsyncLoadComplete( mAsyncRemoteLoadingInfoContainer, id, pixelData );
+  AsyncLoadComplete( mAsyncRemoteLoadingInfoContainer, id, pixelBuffer );
 }
 
-void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingContainer, uint32_t id, PixelData pixelData )
+void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingContainer, uint32_t id, Devel::PixelBuffer pixelBuffer )
 {
   DALI_LOG_INFO( gTextureManagerLogFilter, Debug::Concise, "TextureManager::AsyncLoadComplete( id:%d )\n", id );
 
@@ -344,7 +354,7 @@ void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingCo
         if( textureInfo.loadState != CANCELLED )
         {
           // textureInfo can be invalidated after this call (as the mTextureInfoContainer may be modified)
-          PostLoad( textureInfo, pixelData );
+          PostLoad( textureInfo, pixelBuffer );
         }
         else
         {
@@ -357,15 +367,15 @@ void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingCo
   }
 }
 
-void TextureManager::PostLoad( TextureInfo& textureInfo, PixelData pixelData )
+void TextureManager::PostLoad( TextureInfo& textureInfo, Devel::PixelBuffer& pixelBuffer )
 {
   // Was the load successful?
-  if( pixelData && ( pixelData.GetWidth() != 0 ) && ( pixelData.GetHeight() != 0 ) )
+  if( pixelBuffer && ( pixelBuffer.GetWidth() != 0 ) && ( pixelBuffer.GetHeight() != 0 ) )
   {
     // No atlas support for now
     textureInfo.useAtlas = NO_ATLAS;
 
-    if( textureInfo.storageType == GPU_UPLOAD )
+    if( textureInfo.storageType == UPLOAD_TO_TEXTURE )
     {
       // If there is a mask texture ID associated with this texture, then apply the mask
       // if it's already loaded. If it hasn't, and the mask is still loading,
@@ -375,25 +385,25 @@ void TextureManager::PostLoad( TextureInfo& textureInfo, PixelData pixelData )
         LoadState maskLoadState = GetTextureState( textureInfo.maskTextureId );
         if( maskLoadState == LOADING )
         {
-          textureInfo.pixelData = pixelData; // Store the pixel data temporarily
+          textureInfo.pixelBuffer = pixelBuffer; // Store the pixel buffer temporarily
           textureInfo.loadState = WAITING_FOR_MASK;
         }
         else if( maskLoadState == LOAD_FINISHED )
         {
-          ApplyMask( pixelData, textureInfo.maskTextureId );
-          UploadTexture( pixelData, textureInfo );
+          ApplyMask( pixelBuffer, textureInfo.maskTextureId );
+          UploadTexture( pixelBuffer, textureInfo );
           NotifyObservers( textureInfo, true );
         }
       }
       else
       {
-        UploadTexture( pixelData, textureInfo );
+        UploadTexture( pixelBuffer, textureInfo );
         NotifyObservers( textureInfo, true );
       }
     }
-    else // currently, CPU textures are local to texture manager
+    else
     {
-      textureInfo.pixelData = pixelData; // Store the pixel data
+      textureInfo.pixelBuffer = pixelBuffer; // Store the pixel data
       textureInfo.loadState = LOAD_FINISHED;
 
       // Check if there was another texture waiting for this load to complete
@@ -423,13 +433,13 @@ void TextureManager::CheckForWaitingTexture( TextureInfo& maskTextureInfo )
         mTextureInfoContainer[cacheIndex].loadState == WAITING_FOR_MASK )
     {
       TextureInfo& textureInfo( mTextureInfoContainer[cacheIndex] );
-      PixelData pixelData = textureInfo.pixelData;
-      textureInfo.pixelData.Reset();
+      Devel::PixelBuffer pixelBuffer = textureInfo.pixelBuffer;
+      textureInfo.pixelBuffer.Reset();
 
       if( maskTextureInfo.loadState == LOAD_FINISHED )
       {
-        ApplyMask( pixelData, maskTextureInfo.textureId );
-        UploadTexture( pixelData, textureInfo );
+        ApplyMask( pixelBuffer, maskTextureInfo.textureId );
+        UploadTexture( pixelBuffer, textureInfo );
         NotifyObservers( textureInfo, true );
       }
       else
@@ -442,20 +452,21 @@ void TextureManager::CheckForWaitingTexture( TextureInfo& maskTextureInfo )
   }
 }
 
-void TextureManager::ApplyMask( PixelData pixelData, TextureId maskTextureId )
+void TextureManager::ApplyMask( Devel::PixelBuffer& pixelBuffer, TextureId maskTextureId )
 {
   int maskCacheIndex = GetCacheIndexFromId( maskTextureId );
-  PixelData maskPixelData = mTextureInfoContainer[maskCacheIndex].pixelData;
-  Dali::ApplyMask( pixelData, maskPixelData );
+  Devel::PixelBuffer maskPixelBuffer = mTextureInfoContainer[maskCacheIndex].pixelBuffer;
+  pixelBuffer.ApplyMask( maskPixelBuffer );
 }
 
-void TextureManager::UploadTexture( PixelData pixelData, TextureInfo& textureInfo )
+void TextureManager::UploadTexture( Devel::PixelBuffer& pixelBuffer, TextureInfo& textureInfo )
 {
   if( textureInfo.useAtlas != USE_ATLAS )
   {
     DALI_LOG_INFO( gTextureManagerLogFilter, Debug::Concise, "  TextureManager::UploadTexture() New Texture for textureId:%d\n", textureInfo.textureId );
 
-    Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+    Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight() );
+    PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
     texture.Upload( pixelData );
     textureInfo.textureSet = TextureSet::New();
     textureInfo.textureSet.SetTexture( 0u, texture );
index a650384..04faf46 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/devel-api/common/owner-container.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <deque>
 
 // INTERNAL INCLUDES
@@ -67,12 +68,12 @@ public:
   };
 
   /**
-   * Whether the texture should be stored in CPU memory, or uploaded to a GPU texture
+   * Whether the pixel data should be kept in TextureManager, or uploaded for rendering
    */
   enum StorageType
   {
-    CPU,
-    GPU_UPLOAD
+    KEEP_PIXEL_BUFFER,
+    UPLOAD_TO_TEXTURE
   };
 
   /**
@@ -140,8 +141,8 @@ public:
 
   /**
    * @brief Requests an image load of the given URL, when the texture has
-   * have loaded, it will perform a CPU blend with the image mask, and upload
-   * the blend texture.
+   * have loaded, it will perform a blend with the image mask, and upload
+   * the blended texture.
    *
    * The parameters are used to specify how the image is loaded.
    * The observer has the UploadComplete method called when the load is ready.
@@ -183,6 +184,11 @@ public:
   void Remove( const TextureManager::TextureId textureId );
 
   /**
+   * Get the visualUrl associated with the texture id
+   */
+  const VisualUrl& GetVisualUrl( TextureId textureId );
+
+  /**
    * @brief Get the current state of a texture
    * @param[in] textureId The texture id to query
    * @return The loading state if the texture is valid, or NOT_STARTED if the textureId
@@ -221,7 +227,7 @@ private:
    *                              This is called when an image load completes (or fails).
    * @return                      A TextureId to use as a handle to reference this Texture
    */
-  TextureId RequestInternalLoad(
+  TextureId RequestLoadInternal(
     const VisualUrl&         url,
     TextureId                maskTextureId,
     const ImageDimensions    desiredSize,
@@ -259,7 +265,7 @@ private:
       loadState( NOT_STARTED ),
       fittingMode( fittingMode ),
       samplingMode( samplingMode ),
-      storageType( GPU_UPLOAD ),
+      storageType( UPLOAD_TO_TEXTURE ),
       loadSynchronously( loadSynchronously ),
       useAtlas( useAtlas )
     {
@@ -272,7 +278,7 @@ private:
 
     ObserverListType observerList; ///< Container used to store all observer clients of this Texture
     Toolkit::ImageAtlas atlas;     ///< The atlas this Texture lays within (if any)
-    PixelData pixelData;           ///< The PixelData holding the image data (this is used if atlasing is deferred or CPU storage is required)
+    Devel::PixelBuffer pixelBuffer;///< The PixelBuffer holding the image data (May be empty after upload)
     TextureSet textureSet;         ///< The TextureSet holding the Texture
     VisualUrl url;                 ///< The URL of the image
     ImageDimensions desiredSize;   ///< The size requested
@@ -346,32 +352,32 @@ private:
   /**
    * @brief This signal handler is called when the async local loader finishes loading.
    * @param[in] id        This is the async image loaders Id
-   * @param[in] pixelData The loaded image data
+   * @param[in] pixelBuffer The loaded image data
    */
-  void AsyncLocalLoadComplete( uint32_t id, PixelData pixelData );
+  void AsyncLocalLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer );
 
   /**
    * @brief This signal handler is called when the async local loader finishes loading.
    * @param[in] id        This is the async image loaders Id
-   * @param[in] pixelData The loaded image data
+   * @param[in] pixelBuffer The loaded image data
    */
-  void AsyncRemoteLoadComplete( uint32_t id, PixelData pixelData );
+  void AsyncRemoteLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer );
 
   /**
    * Common method to handle loading completion
    * @param[in] container The Async loading container
    * @param[in] id        This is the async image loaders Id
-   * @param[in] pixelData The loaded image data
+   * @param[in] pixelBuffer The loaded image data
    */
-  void AsyncLoadComplete( AsyncLoadingInfoContainerType& container, uint32_t id, PixelData pixelData );
+  void AsyncLoadComplete( AsyncLoadingInfoContainerType& container, uint32_t id, Devel::PixelBuffer pixelBuffer );
 
   /**
    * @brief Performs Post-Load steps including atlasing.
    * @param[in] textureInfo The struct associated with this Texture
-   * @param[in] pixelData   The image pixelData
+   * @param[in] pixelBuffer The image pixelBuffer
    * @return    True if successful
    */
-  void PostLoad( TextureManager::TextureInfo& textureInfo, PixelData pixelData );
+  void PostLoad( TextureManager::TextureInfo& textureInfo, Devel::PixelBuffer& pixelBuffer );
 
   /**
    * Check if there is a texture waiting to be masked. If there
@@ -381,19 +387,19 @@ private:
   void CheckForWaitingTexture( TextureInfo& maskTextureInfo );
 
   /**
-   * Apply the mask texture to the image texture.
-   * @param[in] pixelData The image pixelData to apply the mask to
+   * Apply the mask to the pixelBuffer.
+   * @param[in] pixelBuffer The pixelBuffer to apply the mask to
    * @param[in] maskTextureId The texture id of the mask.
    */
-  void ApplyMask( PixelData pixelData, TextureId maskTextureId );
+  void ApplyMask( Devel::PixelBuffer& pixelBuffer, TextureId maskTextureId );
 
   /**
-   * Upload the texture specified in pixelData to the appropriate location
-   * @param[in] pixelData The image data to upload
+   * Upload the texture specified in pixelBuffer to the appropriate location
+   * @param[in] pixelBuffer The image data to upload
    * @param[in] textureInfo The texture info containing the location to
    * store the data to.
    */
-  void UploadTexture( PixelData pixelData, TextureInfo& textureInfo );
+  void UploadTexture( Devel::PixelBuffer& pixelBuffer, TextureInfo& textureInfo );
 
   /**
    * Mark the texture as complete, and inform observers
index 7a8ab3c..e8f8ad7 100644 (file)
@@ -46,7 +46,12 @@ PixelData Load( const std::string& url,
                 bool orientationCorrection )
 {
   // Load the image synchronously (block the thread here).
-  return Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
+  Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile( url, dimensions, fittingMode, samplingMode, orientationCorrection );
+  if( pixelBuffer )
+  {
+    return Devel::PixelBuffer::Convert( pixelBuffer );
+  }
+  return Dali::PixelData(); // return empty handle
 }