utc-Dali-Any.cpp
utc-Dali-Atlas.cpp
utc-Dali-BaseHandle.cpp
- utc-Dali-BitmapImage.cpp
+ utc-Dali-BufferImage.cpp
utc-Dali-CameraActor.cpp
utc-Dali-Character.cpp
utc-Dali-Constraint.cpp
}
}
-BitmapImage CreateBitmapImage()
+BufferImage CreateBufferImage()
{
- BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);
+ BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
PixelBuffer* pixbuf = image.GetBuffer();
};
-// Helper to Create bitmap image
-BitmapImage CreateBitmapImage();
+// Helper to Create buffer image
+BufferImage CreateBufferImage();
#endif // __DALI_TEST_SUITE_UTILS_H__
ids.push_back( 10 ); // third rendered actor
app.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage imageA = BitmapImage::New(16, 16);
- BitmapImage imageB = BitmapImage::New(16, 16);
- BitmapImage imageC = BitmapImage::New(16, 16);
+ BufferImage imageA = BufferImage::New(16, 16);
+ BufferImage imageB = BufferImage::New(16, 16);
+ BufferImage imageC = BufferImage::New(16, 16);
ImageActor a = ImageActor::New( imageA );
ImageActor b = ImageActor::New( imageB );
ImageActor c = ImageActor::New( imageC );
TestApplication app;
tet_infoline(" UtcDaliActorSetDrawModeOverlayHitTest");
- BitmapImage imageA = BitmapImage::New(16, 16);
- BitmapImage imageB = BitmapImage::New(16, 16);
+ BufferImage imageA = BufferImage::New(16, 16);
+ BufferImage imageB = BufferImage::New(16, 16);
ImageActor a = ImageActor::New( imageA );
ImageActor b = ImageActor::New( imageB );
// Using correct pixel format
PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
// Using INCORRECT pixel format
PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New( buffer, 16, 16, Pixel::A8 );
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::A8 );
DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
// Using image too big for atlas
PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
// Using valid offsets
PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
DALI_TEST_CHECK( atlas.Upload( image, 16, 0 ) );
// Using invalid offsets
PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New( buffer, 16, 16, Pixel::RGBA8888 );
+ BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
DALI_TEST_CHECK( !atlas.Upload( image, 0, 17 ) );
DALI_TEST_CHECK( !atlas.Upload( image, 17, 0 ) );
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <algorithm>
-
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-
-using std::max;
-using namespace Dali;
-
-void utc_dali_bitmap_image_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_bitmap_image_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliBitmapImageNew01(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageNew01 - BitmapImage::New(unsigned int, unsigned int, Pixel::Format)");
-
- // invoke default handle constructor
- BitmapImage image;
-
- // initialise handle
- image = BitmapImage::New(16, 16);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( image.GetWidth() == 16);
- END_TEST;
-}
-
-int UtcDaliBitmapImageNew02(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageNew02 - BitmapImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int)");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( image.GetWidth() == 16);
-
- delete [] buffer;
- END_TEST;
-}
-
-int UtcDaliBitmapImageNewWithPolicy01(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageNewWithPolicy01 - BitmapImage::New(unsigned int, unsigned int, Pixel::Format, LoadPolicy, ReleasePolicy)");
-
- // Force texture id's
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
- // invoke default handle constructor
- BitmapImage image;
-
- // initialise handle
- image = BitmapImage::New(16, 16, Pixel::A8, Image::UNUSED);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( image.GetWidth() == 16);
- ImageActor actor = ImageActor::New(image);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
- // testing ReleasePolicy::Unused
- // fake loading image
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // discard texture when actor comes off stage
- Stage::GetCurrent().Remove(actor);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
- END_TEST;
-}
-
-int UtcDaliBitmapImageNewWithPolicy02(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageNewWithPolicy02 - BitmapImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int, ReleasePolicy)");
-
- // Force texture id's
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8, 16, Image::UNUSED);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( image.GetWidth() == 16);
- ImageActor actor = ImageActor::New(image);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
- // testing ReleasePolicy::Unused
- // fake loading image
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
- // discard texture when actor comes off stage
- Stage::GetCurrent().Remove(actor);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
- END_TEST;
-}
-
-int UtcDaliBitmapImageDownCast(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::BitmapImage::DownCast()");
-
- BitmapImage bitmap = BitmapImage::New(1, 1, Dali::Pixel::BGRA8888);
- ImageActor imageActor = ImageActor::New(bitmap);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- Image image = imageActor.GetImage();
- BitmapImage bitmapImage = BitmapImage::DownCast( image );
-
- DALI_TEST_CHECK(bitmapImage);
- END_TEST;
-}
-
-int UtcDaliBitmapImageDownCast2(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::BitmapImage::DownCast()");
-
- Image image = ResourceImage::New("IncorrectImageName");
- ImageActor imageActor = ImageActor::New(image);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- Image image1 = imageActor.GetImage();
-
- BitmapImage bitmapImage = BitmapImage::DownCast( image1 );
- DALI_TEST_CHECK(!bitmapImage);
-
- Actor unInitialzedActor;
- bitmapImage = BitmapImage::DownCast( unInitialzedActor );
- DALI_TEST_CHECK(!bitmapImage);
- END_TEST;
-}
-
-int UtcDaliBitmapImageWHITE(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageWHITE - BitmapImage::WHITE()");
-
- BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- PixelBuffer* buffer = image.GetBuffer();
-
- DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide
- buffer != NULL && // valid buffer
- *buffer == 0xff); // r component is 255
- END_TEST;
-}
-
-int UtcDaliBitmapImageGetBuffer(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageGetBuffer");
-
- BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel
-
- PixelBuffer* buffer = image.GetBuffer();
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide
- buffer != NULL && // valid buffer
- *((unsigned int*)buffer) == 0xffffffff); // all component are 255
- END_TEST;
-}
-
-int UtcDaliBitmapImageGetBufferSize(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageGetBufferSize");
-
- BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- PixelBuffer* buffer = image.GetBuffer();
- unsigned int bufferSize = image.GetBufferSize();
- unsigned int pixelSize = Pixel::GetBytesPerPixel(image.GetPixelFormat());
-
- DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide
- buffer != NULL && // valid buffer
- bufferSize == pixelSize); // r component is 255
- END_TEST;
-}
-
-int UtcDaliBitmapImageGetBufferStride(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageGetBufferStride");
-
- BitmapImage image = BitmapImage::WHITE(); // creates a 1x1 RGBA white pixel
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- unsigned int pixelSize = Pixel::GetBytesPerPixel(image.GetPixelFormat());
- unsigned int bufferStride = image.GetBufferStride();
- DALI_TEST_CHECK( bufferStride == pixelSize );
- DALI_TEST_CHECK( !image.IsDataExternal() );
-
- PixelBuffer* buffer = new PixelBuffer[20 * 16];
- image = BitmapImage::New(buffer, 16, 16, Pixel::A8, 20);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- bufferStride = image.GetBufferStride();
-
- DALI_TEST_CHECK( bufferStride == 20);
- DALI_TEST_CHECK( image.IsDataExternal() );
-
- delete [] buffer;
- END_TEST;
-}
-
-int UtcDaliBitmapImageGetPixelFormat(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageGetPixelFormat");
-
- // Set pixel format to a non-default
- BitmapImage image = BitmapImage::New( 16, 16, Pixel::A8 );
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( image.GetPixelFormat() == Pixel::A8 );
- END_TEST;
-}
-
-
-int UtcDaliBitmapImageIsDataExternal(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageIsDataExternal - BitmapImage::IsDataExternal()");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8);
- application.SendNotification();
- application.Render();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_CHECK( image.IsDataExternal() );
- END_TEST;
-}
-
-namespace
-{
-
-static bool SignalReceived;
-static void ImageUploaded(Image image)
-{
- tet_infoline("Received image uploaded signal");
- SignalReceived = true;
-}
-}
-
-int UtcDaliBitmapImageUpdate01(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageUpdate01 - single empty rect");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
-
- BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8);
- ImageActor actor = ImageActor::New(image);
- Stage::GetCurrent().Add(actor);
- actor.SetVisible(true);
-
- SignalReceived = false;
- image.UploadedSignal().Connect( ImageUploaded );
-
- std::vector<GLuint> ids;
- ids.push_back(200);
- ids.push_back(201);
- ids.push_back(202);
- application.GetGlAbstraction().SetNextTextureIds(ids);
-
- // Allow actor to be staged and rendered
- application.SendNotification();
- application.Render(0);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( image.IsDataExternal() );
- application.GetGlAbstraction().EnableTextureCallTrace(true);
-
- image.Update();//(RectArea()); // notify Core that the image has been updated
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
-
- const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "0, 0, 16, 16"), true, TEST_LOCATION);
-
- DALI_TEST_CHECK( SignalReceived == true );
- SignalReceived = false;
- END_TEST;
-}
-
-int UtcDaliBitmapImageUpdate02(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageUpdate02 - Multiple rects");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8);
- ImageActor actor = ImageActor::New(image);
- Stage::GetCurrent().Add(actor);
- actor.SetVisible(true);
-
- SignalReceived = false;
- image.UploadedSignal().Connect( ImageUploaded );
-
- std::vector<GLuint> ids;
- ids.push_back(200);
- ids.push_back(201);
- ids.push_back(202);
- application.GetGlAbstraction().SetNextTextureIds(ids);
-
- application.SendNotification();
- application.Render(0);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( image.IsDataExternal() );
- application.GetGlAbstraction().EnableTextureCallTrace(true);
-
- image.Update(RectArea(9,9,5,5)); // notify Core that the image has been updated
-
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
-
- const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "9, 9, 5, 1"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", "9, 10, 5, 1"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", "9, 11, 5, 1"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(3, "TexSubImage2D", "9, 12, 5, 1"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(4, "TexSubImage2D", "9, 13, 5, 1"), true, TEST_LOCATION);
-
- DALI_TEST_CHECK( SignalReceived == true );
- SignalReceived = false;
- END_TEST;
-}
-
-int UtcDaliBitmapImageUploadedSignal01(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageUploadedSignal - Test that Uploaded signal is sent when image is staged");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8);
- SignalReceived = false;
- image.UploadedSignal().Connect( ImageUploaded );
-
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- Dali::ImageActor imageActor = ImageActor::New(image);
- Stage::GetCurrent().Add(imageActor);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( SignalReceived == true );
- END_TEST;
-}
-
-int UtcDaliBitmapImageUploadedSignal02(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBitmapImageUploadedSignal - Test that Uploaded signal is sent after Update");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BitmapImage image = BitmapImage::New(buffer, 16, 16, Pixel::A8);
- SignalReceived = false;
- //ScopedConnection connection =
- image.UploadedSignal().Connect( ImageUploaded );
-
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- Dali::ImageActor imageActor = ImageActor::New(image);
- Stage::GetCurrent().Add(imageActor);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK( SignalReceived == true );
- SignalReceived = false;
-
- image.Update(RectArea()); // notify Core that the whole image has been updated
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK( SignalReceived == true );
- END_TEST;
-}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 <algorithm>
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using std::max;
+using namespace Dali;
+
+void utc_dali_buffer_image_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_buffer_image_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliBufferImageNew01(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageNew01 - BufferImage::New(unsigned int, unsigned int, Pixel::Format)");
+
+ // invoke default handle constructor
+ BufferImage image;
+
+ // initialise handle
+ image = BufferImage::New(16, 16);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.GetWidth() == 16);
+ END_TEST;
+}
+
+int UtcDaliBufferImageNew02(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageNew02 - BufferImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int)");
+
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.GetWidth() == 16);
+
+ delete [] buffer;
+ END_TEST;
+}
+
+int UtcDaliBufferImageNewWithPolicy01(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageNewWithPolicy01 - BufferImage::New(unsigned int, unsigned int, Pixel::Format, LoadPolicy, ReleasePolicy)");
+
+ // Force texture id's
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+
+ // invoke default handle constructor
+ BufferImage image;
+
+ // initialise handle
+ image = BufferImage::New(16, 16, Pixel::A8, Image::UNUSED);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.GetWidth() == 16);
+ ImageActor actor = ImageActor::New(image);
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+ // testing ReleasePolicy::Unused
+ // fake loading image
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // discard texture when actor comes off stage
+ Stage::GetCurrent().Remove(actor);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
+ END_TEST;
+}
+
+int UtcDaliBufferImageNewWithPolicy02(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageNewWithPolicy02 - BufferImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int, ReleasePolicy)");
+
+ // Force texture id's
+ std::vector<GLuint> ids;
+ ids.push_back( 23 );
+ application.GetGlAbstraction().SetNextTextureIds( ids );
+
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8, 16, Image::UNUSED);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.GetWidth() == 16);
+ ImageActor actor = ImageActor::New(image);
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(16);
+ // testing ReleasePolicy::Unused
+ // fake loading image
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
+
+ // discard texture when actor comes off stage
+ Stage::GetCurrent().Remove(actor);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
+ END_TEST;
+}
+
+int UtcDaliBufferImageDownCast(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::BufferImage::DownCast()");
+
+ BufferImage bitmap = BufferImage::New(1, 1, Dali::Pixel::BGRA8888);
+ ImageActor imageActor = ImageActor::New(bitmap);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ Image image = imageActor.GetImage();
+ BufferImage bufferImage = BufferImage::DownCast( image );
+
+ DALI_TEST_CHECK(bufferImage);
+ END_TEST;
+}
+
+int UtcDaliBufferImageDownCast2(void)
+{
+ TestApplication application;
+ tet_infoline("Testing Dali::BufferImage::DownCast()");
+
+ Image image = ResourceImage::New("IncorrectImageName");
+ ImageActor imageActor = ImageActor::New(image);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ Image image1 = imageActor.GetImage();
+
+ BufferImage bufferImage = BufferImage::DownCast( image1 );
+ DALI_TEST_CHECK(!bufferImage);
+
+ Actor unInitialzedActor;
+ bufferImage = BufferImage::DownCast( unInitialzedActor );
+ DALI_TEST_CHECK(!bufferImage);
+ END_TEST;
+}
+
+int UtcDaliBufferImageWHITE(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageWHITE - BufferImage::WHITE()");
+
+ BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ PixelBuffer* buffer = image.GetBuffer();
+
+ DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide
+ buffer != NULL && // valid buffer
+ *buffer == 0xff); // r component is 255
+ END_TEST;
+}
+
+int UtcDaliBufferImageGetBuffer(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageGetBuffer");
+
+ BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel
+
+ PixelBuffer* buffer = image.GetBuffer();
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide
+ buffer != NULL && // valid buffer
+ *((unsigned int*)buffer) == 0xffffffff); // all component are 255
+ END_TEST;
+}
+
+int UtcDaliBufferImageGetBufferSize(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageGetBufferSize");
+
+ BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ PixelBuffer* buffer = image.GetBuffer();
+ unsigned int bufferSize = image.GetBufferSize();
+ unsigned int pixelSize = Pixel::GetBytesPerPixel(image.GetPixelFormat());
+
+ DALI_TEST_CHECK( image.GetWidth() == 1 && // 1 pixel wide
+ buffer != NULL && // valid buffer
+ bufferSize == pixelSize); // r component is 255
+ END_TEST;
+}
+
+int UtcDaliBufferImageGetBufferStride(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageGetBufferStride");
+
+ BufferImage image = BufferImage::WHITE(); // creates a 1x1 RGBA white pixel
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ unsigned int pixelSize = Pixel::GetBytesPerPixel(image.GetPixelFormat());
+ unsigned int bufferStride = image.GetBufferStride();
+ DALI_TEST_CHECK( bufferStride == pixelSize );
+ DALI_TEST_CHECK( !image.IsDataExternal() );
+
+ PixelBuffer* buffer = new PixelBuffer[20 * 16];
+ image = BufferImage::New(buffer, 16, 16, Pixel::A8, 20);
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ bufferStride = image.GetBufferStride();
+
+ DALI_TEST_CHECK( bufferStride == 20);
+ DALI_TEST_CHECK( image.IsDataExternal() );
+
+ delete [] buffer;
+ END_TEST;
+}
+
+int UtcDaliBufferImageGetPixelFormat(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageGetPixelFormat");
+
+ // Set pixel format to a non-default
+ BufferImage image = BufferImage::New( 16, 16, Pixel::A8 );
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.GetPixelFormat() == Pixel::A8 );
+ END_TEST;
+}
+
+
+int UtcDaliBufferImageIsDataExternal(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageIsDataExternal - BufferImage::IsDataExternal()");
+
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
+ application.SendNotification();
+ application.Render();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.IsDataExternal() );
+ END_TEST;
+}
+
+namespace
+{
+
+static bool SignalReceived;
+static void ImageUploaded(Image image)
+{
+ tet_infoline("Received image uploaded signal");
+ SignalReceived = true;
+}
+}
+
+int UtcDaliBufferImageUpdate01(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageUpdate01 - single empty rect");
+
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+
+ BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
+ ImageActor actor = ImageActor::New(image);
+ Stage::GetCurrent().Add(actor);
+ actor.SetVisible(true);
+
+ SignalReceived = false;
+ image.UploadedSignal().Connect( ImageUploaded );
+
+ std::vector<GLuint> ids;
+ ids.push_back(200);
+ ids.push_back(201);
+ ids.push_back(202);
+ application.GetGlAbstraction().SetNextTextureIds(ids);
+
+ // Allow actor to be staged and rendered
+ application.SendNotification();
+ application.Render(0);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.IsDataExternal() );
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+ image.Update();//(RectArea()); // notify Core that the image has been updated
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+
+ const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "0, 0, 16, 16"), true, TEST_LOCATION);
+
+ DALI_TEST_CHECK( SignalReceived == true );
+ SignalReceived = false;
+ END_TEST;
+}
+
+int UtcDaliBufferImageUpdate02(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageUpdate02 - Multiple rects");
+
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
+ ImageActor actor = ImageActor::New(image);
+ Stage::GetCurrent().Add(actor);
+ actor.SetVisible(true);
+
+ SignalReceived = false;
+ image.UploadedSignal().Connect( ImageUploaded );
+
+ std::vector<GLuint> ids;
+ ids.push_back(200);
+ ids.push_back(201);
+ ids.push_back(202);
+ application.GetGlAbstraction().SetNextTextureIds(ids);
+
+ application.SendNotification();
+ application.Render(0);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( image.IsDataExternal() );
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+ image.Update(RectArea(9,9,5,5)); // notify Core that the image has been updated
+
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+
+ const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "9, 9, 5, 1"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", "9, 10, 5, 1"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", "9, 11, 5, 1"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(3, "TexSubImage2D", "9, 12, 5, 1"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(4, "TexSubImage2D", "9, 13, 5, 1"), true, TEST_LOCATION);
+
+ DALI_TEST_CHECK( SignalReceived == true );
+ SignalReceived = false;
+ END_TEST;
+}
+
+int UtcDaliBufferImageUploadedSignal01(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageUploadedSignal - Test that Uploaded signal is sent when image is staged");
+
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
+ SignalReceived = false;
+ image.UploadedSignal().Connect( ImageUploaded );
+
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ Dali::ImageActor imageActor = ImageActor::New(image);
+ Stage::GetCurrent().Add(imageActor);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+
+ DALI_TEST_CHECK( SignalReceived == true );
+ END_TEST;
+}
+
+int UtcDaliBufferImageUploadedSignal02(void)
+{
+ TestApplication application;
+
+ tet_infoline("UtcDaliBufferImageUploadedSignal - Test that Uploaded signal is sent after Update");
+
+ PixelBuffer* buffer = new PixelBuffer[16 * 16];
+ BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
+ SignalReceived = false;
+ //ScopedConnection connection =
+ image.UploadedSignal().Connect( ImageUploaded );
+
+ application.SendNotification();
+ application.Render(16);
+ application.Render(16);
+ application.SendNotification();
+
+ Dali::ImageActor imageActor = ImageActor::New(image);
+ Stage::GetCurrent().Add(imageActor);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK( SignalReceived == true );
+ SignalReceived = false;
+
+ image.Update(RectArea()); // notify Core that the whole image has been updated
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ application.Render(16);
+ application.SendNotification();
+ DALI_TEST_CHECK( SignalReceived == true );
+ END_TEST;
+}
TestApplication application;
tet_infoline("Testing Dali::CameraActor Test view application");
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
application.Render(0);
application.Render();
application.SendNotification();
- Image image = CreateBitmapImage();
+ Image image = CreateBufferImage();
ImageActor imageActor = ImageActor::New( image );
imageActor.SetSize(100.0f, 100.0f);
Stage::GetCurrent().Add(imageActor);
};
// Create bitmap image
-static BitmapImage CreateBitmapImage()
+static BufferImage CreateBufferImage()
{
- BitmapImage image = BitmapImage::New(4,4,Pixel::RGBA8888);
+ BufferImage image = BufferImage::New(4,4,Pixel::RGBA8888);
return image;
}
static ImageActor CreateImageActor()
{
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
actor.SetName("Test ImageActor");
stage.Add( layer );
// Create a stencil and add that to the layer
- Actor stencil = ImageActor::New(Dali::BitmapImage::WHITE() );
+ Actor stencil = ImageActor::New(Dali::BufferImage::WHITE() );
stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
stencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
stencil.SetSize( 50.0f, 50.0f );
TestApplication application;
tet_infoline("Positive test for Dali::ImageActor::UtcDaliImageActorPixelArea");
- BitmapImage img = BitmapImage::New( 10, 10 );
+ BufferImage img = BufferImage::New( 10, 10 );
ImageActor actor = ImageActor::New( img );
DALI_TEST_CHECK( actor.IsPixelAreaSet() == false );
{
TestApplication application;
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
ShaderEffect effect = ShaderEffect::New( " ", " ", " ", " ", ShaderEffect::HINT_GRID );
tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize");
Vector2 initialImageSize(100, 50);
- BitmapImage image = BitmapImage::New( initialImageSize.width, initialImageSize.height );
+ BufferImage image = BufferImage::New( initialImageSize.width, initialImageSize.height );
ImageActor actor = ImageActor::New( image );
Stage::GetCurrent().Add(actor);
TestApplication application;
tet_infoline("Testing Dali::ImageActor DefaultProperties");
- BitmapImage img = BitmapImage::New( 10, 10 );
+ BufferImage img = BufferImage::New( 10, 10 );
ImageActor actor = ImageActor::New( img );
std::vector<Property::Index> indices;
tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
- BitmapImage image = BitmapImage::New( 100, 50 );
+ BufferImage image = BufferImage::New( 100, 50 );
ImageActor actor = ImageActor::New( image );
actor.SetBlendMode( BlendingMode::ON );
actor.SetSize(100, 50);
tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
- BitmapImage image = BitmapImage::New( 100, 50 );
+ BufferImage image = BufferImage::New( 100, 50 );
ImageActor actor = ImageActor::New( image );
actor.SetBlendMode( BlendingMode::OFF );
actor.SetSize(100, 50);
tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
- BitmapImage image = BitmapImage::New( 100, 50 );
+ BufferImage image = BufferImage::New( 100, 50 );
ImageActor actor = ImageActor::New( image );
actor.SetBlendMode( BlendingMode::AUTO );
actor.SetColor(Vector4(1.0, 1.0, 1.0, 0.5));
tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
- BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 );
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
ImageActor actor = ImageActor::New( image );
actor.SetBlendMode( BlendingMode::AUTO );
actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0));
{
TestApplication application;
- BitmapImage img = BitmapImage::New( 10, 10 );
+ BufferImage img = BufferImage::New( 10, 10 );
ImageActor actor = ImageActor::New( img );
DALI_TEST_CHECK( actor.IsPixelAreaSet() == false );
TestApplication application;
// Standard image
- BitmapImage img = BitmapImage::New( 10, 10 );
+ BufferImage img = BufferImage::New( 10, 10 );
ImageActor actor = ImageActor::New( img );
DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == Vector2( 10, 10 ) );
{
tet_infoline("Testing Dali::Layer::SetSortFunction()");
TestApplication application;
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
// create two transparent actors so there is something to sort
ImageActor actor = ImageActor::New( img );
ImageActor actor2 = ImageActor::New( img );
tet_infoline("Testing Dali::MeshActor::Blend04()");
Material material = ConstructMaterial(1.0f, 1.0f);
- BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
material.SetDiffuseTexture( image );
application.SendNotification();
application.Render(0);
tet_infoline("Testing Dali::MeshActor::Blend05()");
Material material = ConstructMaterial(1.0f, 1.0f);
- BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
material.SetDiffuseTexture( image );
application.SendNotification();
application.Render(0);
tet_infoline("Testing Dali::MeshActor::Blend()");
Material material = ConstructMaterial(1.0f, 1.0f);
- BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 );
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
material.SetDiffuseTexture( image );
application.SendNotification();
application.Render(0);
tet_infoline("Testing Dali::MeshActor::Blend08()");
Material material = ConstructMaterial(1.0f, 1.0f);
- BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGBA8888 );
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGBA8888 );
material.SetDiffuseTexture( image );
application.SendNotification();
application.Render(0);
tet_infoline("Testing Dali::MeshActor::Blend08()");
Material material = ConstructMaterial(0.5f, 1.0f);
- BitmapImage image = BitmapImage::New( 100, 50, Pixel::RGB888 );
+ BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
material.SetDiffuseTexture( image );
application.SendNotification();
application.Render(0);
branch.SetPosition(Vector3(10.0f, 100.0f, 0.0f));
branch.SetRotation(Quaternion(M_PI*0.2f, Vector3::YAXIS));
- Actor twig = ImageActor::New(CreateBitmapImage());
+ Actor twig = ImageActor::New(CreateBufferImage());
twig.SetName("twig");
branch.SetPosition(Vector3(20.0f, 30.0f, 40.0f));
ids.push_back( 7 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor newActor = ImageActor::New( img );
newActor.SetSize(1,1);
stage.Add( newActor );
ids.push_back( expectedTextureId );
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor newActor = ImageActor::New( img );
newActor.SetSize(1,1);
task.SetSourceActor( newActor );
ids.push_back( expectedTextureId );
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor newActor = ImageActor::New( img );
newActor.SetSize(1,1);
stage.Add( newActor );
ids.push_back( 10 ); // 10 = actor3
application.GetGlAbstraction().SetNextTextureIds( ids );
- BitmapImage img1 = BitmapImage::New( 1,1 );
+ BufferImage img1 = BufferImage::New( 1,1 );
ImageActor actor1 = ImageActor::New( img1 );
actor1.SetSize(1,1);
Stage::GetCurrent().Add( actor1 );
DALI_TEST_EQUALS( boundTextures[0], 8u/*unique to actor1*/, TEST_LOCATION );
}
- BitmapImage img2 = BitmapImage::New( 1,1 );
+ BufferImage img2 = BufferImage::New( 1,1 );
ImageActor actor2 = ImageActor::New( img2 );
actor2.SetSize(1,1);
DALI_TEST_EQUALS( boundTextures[1], 8u/*unique to actor1*/, TEST_LOCATION );
}
- BitmapImage img3 = BitmapImage::New( 1,1 );
+ BufferImage img3 = BufferImage::New( 1,1 );
ImageActor actor3 = ImageActor::New( img3 );
actor3.SetSize(1,1);
Stage::GetCurrent().Add( offscreenCameraActor );
- BitmapImage image = BitmapImage::New( 10, 10 );
+ BufferImage image = BufferImage::New( 10, 10 );
ImageActor rootActor = ImageActor::New( image );
rootActor.SetSize( 10, 10 );
Stage::GetCurrent().Add( rootActor );
//Verify through layer SetSortFunction
gIsActor1SortModifierCorrect = false;
gIsActor2SortModifierCorrect = false;
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
// create two transparent actors so there is something to sort
ImageActor actor1 = ImageActor::New( img );
ImageActor actor2 = ImageActor::New( img );
tet_infoline("Testing Dali::RenderableActor::SetCullFace()");
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
ImageActor actor2 = ImageActor::New( img );
tet_infoline("Testing Dali::RenderableActor::UtcDaliRenderableActorSetGetBlendFunc()");
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
Stage::GetCurrent().Add( actor );
application.SendNotification();
tet_infoline("Testing Dali::RenderableActor::SetBlendEquation()");
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
Stage::GetCurrent().Add( actor );
application.SendNotification();
tet_infoline("Testing Dali::RenderableActor::SetBlendColor()");
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
Stage::GetCurrent().Add( actor );
application.SendNotification();
tet_infoline("Testing Dali::RenderableActor::SetGetAlpha()");
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
Stage::GetCurrent().Add( actor );
application.SendNotification();
tet_infoline("Testing Dali::RenderableActor::SetFilterMode()");
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
actor.SetSize(100.0f, 100.0f);
int UtcDaliRenderableActorSetShaderEffect(void)
{
TestApplication application;
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
Stage::GetCurrent().Add( actor );
* actor3 textactor
* imageactor
*/
- BitmapImage img = BitmapImage::New( 1,1 );
+ BufferImage img = BufferImage::New( 1,1 );
ImageActor actor1 = ImageActor::New( img );
Actor actor2 = Actor::New();
actor1.Add( actor2 );
}
/// Helper method to create ResourceImage using property
-BitmapImage NewBitmapImage( const Property::Value& map )
+BufferImage NewBufferImage( const Property::Value& map )
{
- BitmapImage image = BitmapImage::DownCast( NewImage( map ) );
+ BufferImage image = BufferImage::DownCast( NewImage( map ) );
return image;
}
Image image = NewImage( map );
DALI_TEST_CHECK( FrameBufferImage::DownCast( image ) );
}
- // type BitMapImage
- map[ "type" ] = "BitmapImage";
+ // type BufferImage
+ map[ "type" ] = "BufferImage";
{
Image image = NewImage( map );
- DALI_TEST_CHECK( BitmapImage::DownCast( image ) );
- DALI_TEST_CHECK((BitmapImage::DownCast( image )).GetPixelFormat()== Pixel::RGBA8888);
+ DALI_TEST_CHECK( BufferImage::DownCast( image ) );
+ DALI_TEST_CHECK((BufferImage::DownCast( image )).GetPixelFormat()== Pixel::RGBA8888);
}
// pixel-format
{ "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC },
{ "COMPRESSED_RGB8_ETC1", Pixel::COMPRESSED_RGB8_ETC1 },
{ "COMPRESSED_RGB_PVRTC_4BPPV1", Pixel::COMPRESSED_RGB_PVRTC_4BPPV1 },*/
- // BitmapImage doesnot support compressed format
+ // BufferImage doesnot support compressed format
};
- TestEnumStrings< Pixel::Format, BitmapImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &BitmapImage::GetPixelFormat, &NewBitmapImage );
+ TestEnumStrings< Pixel::Format, BufferImage >( map, values, ( sizeof( values ) / sizeof ( values[0] ) ), &BufferImage::GetPixelFormat, &NewBufferImage );
}
// type Image
- map[ "type" ] = "Image";
+ map[ "type" ] = "ResourceImage";
{
Image image = NewImage( map );
DALI_TEST_CHECK( ResourceImage::DownCast( image ) );
DALI_TEST_CHECK( !FrameBufferImage::DownCast( image ) );
- DALI_TEST_CHECK( !BitmapImage::DownCast( image ) );
+ DALI_TEST_CHECK( !BufferImage::DownCast( image ) );
}
END_TEST;
}
DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION );
}
- // BitmapImage
+ // BufferImage
{
- Image image = BitmapImage::New( 200, 300, Pixel::A8 );
+ Image image = BufferImage::New( 200, 300, Pixel::A8 );
Property::Map map;
CreatePropertyMap( image, map );
Property::Value value( map );
DALI_TEST_CHECK( value.HasKey( "type" ) );
- DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BitmapImage", TEST_LOCATION );
+ DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BufferImage", TEST_LOCATION );
DALI_TEST_CHECK( value.HasKey( "pixel-format") );
DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION );
}
fragmentShaderPrefix, FragmentSourceUsingExtensions,
GEOMETRY_TYPE_IMAGE, ShaderEffect::HINT_NONE );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
actor.SetName("TestImageFilenameActor");
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uFloat", 1.0f );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec2", Vector2( 2.0f, 3.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec3", Vector3( 4.0f, 5.0f, 6.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec4", Vector4( 7.0f, 8.0f, 9.0f, 10.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uModelView", Matrix::IDENTITY );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
Matrix3 matIdentity(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
effect.SetUniform( "uMatrix3", matIdentity );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetEffectImage(image);
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
- BitmapImage effectImage = CreateBitmapImage();
+ BufferImage effectImage = CreateBufferImage();
effect.SetEffectImage(effectImage);
ImageActor actor = ImageActor::New();
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec3", Vector3( 50.0f, 25.0f, 0.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec3", Vector3( 50.0f, 25.0f, 0.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
effect.SetUniform( "uFloat", 1.0f );
ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
DALI_TEST_CHECK( effect );
- BitmapImage image = CreateBitmapImage();
+ BufferImage image = CreateBufferImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
actor.SetName("TestImageFilenameActor");
TestPlatformAbstraction& platform = application.GetPlatform();
platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resourcePtr);
- BitmapImage image(CreateBitmapImage());
+ BufferImage image(CreateBufferImage());
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
actor.SetName("TestImageFilenameActor");
NinePatchImage* ninePatchImage = NinePatchImage::DownCast( image.Get() );
if( ninePatchImage )
{
- newImage = ninePatchImage->CreateCroppedBitmapImage();
+ newImage = ninePatchImage->CreateCroppedBufferImage();
SetStyle( Dali::ImageActor::STYLE_NINE_PATCH );
SetNinePatchBorder( ninePatchImage->GetStretchBorders(), true );
}
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/images/bitmap-image-impl.h>
+#include <dali/internal/event/images/buffer-image-impl.h>
#include <dali/internal/event/resources/resource-client.h>
#include <dali/integration-api/bitmap.h>
return new Atlas( width, height, pixelFormat );
}
-bool Atlas::Upload( const BitmapImage& bitmapImage,
+bool Atlas::Upload( const BufferImage& bufferImage,
std::size_t xOffset,
std::size_t yOffset )
{
AllocateAtlas();
- if( IsWithin(bitmapImage, xOffset, yOffset) )
+ if( IsWithin(bufferImage, xOffset, yOffset) )
{
ResourceId destId = GetResourceId();
- ResourceId srcId = bitmapImage.GetResourceId();
+ ResourceId srcId = bufferImage.GetResourceId();
if( destId && srcId )
{
}
}
-bool Atlas::IsWithin( const BitmapImage& bitmapImage,
+bool Atlas::IsWithin( const BufferImage& bufferImage,
std::size_t xOffset,
std::size_t yOffset )
{
bool within(false);
- if( mPixelFormat != bitmapImage.GetPixelFormat() )
+ if( mPixelFormat != bufferImage.GetPixelFormat() )
{
- DALI_LOG_ERROR( "Pixel format %d does not match Atlas format %d\n", bitmapImage.GetPixelFormat(), mPixelFormat );
+ DALI_LOG_ERROR( "Pixel format %d does not match Atlas format %d\n", bufferImage.GetPixelFormat(), mPixelFormat );
}
else
{
- const unsigned int width = bitmapImage.GetWidth();
- const unsigned int height = bitmapImage.GetHeight();
+ const unsigned int width = bufferImage.GetWidth();
+ const unsigned int height = bufferImage.GetHeight();
if( xOffset < mWidth &&
yOffset < mHeight &&
Pixel::Format pixelFormat = Pixel::RGBA8888 );
/**
- * @brief Upload a bitmap to the atlas.
+ * @brief Upload a buffer image to the atlas.
*
* @pre The bitmap pixel format must match the Atlas format.
- * @param [in] bitmap The bitmap to upload.
+ * @param [in] bufferImage The buffer image to upload.
* @param [in] xOffset Specifies an offset in the x direction within the atlas.
* @param [in] yOffset Specifies an offset in the y direction within the atlas.
* @return True if the bitmap fits within the atlas at the specified offset.
*/
- bool Upload( const BitmapImage& bitmap,
+ bool Upload( const BufferImage& bufferImage,
std::size_t xOffset,
std::size_t yOffset );
* Helper for Upload methods
* @return True if the bitmap fits within the atlas at the specified offset
*/
- bool IsWithin( const BitmapImage& bitmapImage,
+ bool IsWithin( const BufferImage& bufferImage,
std::size_t xOffset,
std::size_t yOffset );
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <dali/internal/event/images/bitmap-image-impl.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/internal/event/images/bitmap-external.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/resources/resource-client.h>
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/internal/event/images/image-factory.h>
-
-namespace Dali
-{
-namespace Internal
-{
-
-namespace
-{
-TypeRegistration mType( typeid( Dali::BitmapImage ), typeid( Dali::Image ), NULL );
-} // unnamed namespace
-
-BitmapImagePtr BitmapImage::New( unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol )
-{
- BitmapImagePtr internal = new BitmapImage( width, height, pixelformat, releasePol );
- internal->Initialize();
- return internal;
-}
-
-BitmapImagePtr BitmapImage::New( PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol )
-{
- BitmapImagePtr internal = new BitmapImage( pixBuf, width, height, pixelformat, stride, releasePol );
- internal->Initialize();
- return internal;
-}
-
-BitmapImage::BitmapImage(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol)
-: Image(releasePol),
- mIsDataExternal(false)
-{
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
- mResourceClient = &tls.GetResourceClient();
- mWidth = width;
- mHeight = height;
-
- const ImageTicketPtr& t = mResourceClient->AllocateBitmapImage(width, height, width, height, pixelformat);
- mTicket = t.Get();
-
- mTicket->AddObserver(*this);
-}
-
-BitmapImage::BitmapImage(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol)
-: Image(releasePol),
- mIsDataExternal(true)
-{
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
- mResourceClient = &tls.GetResourceClient();
- mWidth = width;
- mHeight = height;
- Integration::Bitmap* bitmap = new BitmapExternal(pixBuf, width, height, pixelformat, stride);
- const ImageTicketPtr& t = mResourceClient->AddBitmapImage(bitmap);
- mTicket = t.Get();
-
- mTicket->AddObserver(*this);
-}
-
-BitmapImage::~BitmapImage()
-{
-}
-
-void BitmapImage::Update( RectArea& updateArea )
-{
- if (mTicket)
- {
- // TODO:
- // If updateArea is empty or same as image size, then pass on.
- // If updateArea is larger than image size, throw exception
- // Otherwise, copy updateArea window of pixelBuffer into newly
- // allocated buffer and pass that to resource client. (it will
- // tramp through to BitmapTexture eventually!)
- mResourceClient->UpdateBitmapArea( mTicket, updateArea );
- }
- else if (mIsDataExternal && mBitmapCached)
- {
- // previously freed up resource memory, dali was informed about external BitmapImage put back on screen
- Integration::Bitmap* bitmap = mBitmapCached.Get();
- mTicket.Reset((mResourceClient->AddBitmapImage(bitmap)).Get());
-
- mTicket->AddObserver(*this);
- }
-}
-
-bool BitmapImage::IsDataExternal() const
-{
- return mIsDataExternal;
-}
-
-PixelBuffer* BitmapImage::GetBuffer()
-{
- PixelBuffer* buffer = NULL;
-
- Integration::Bitmap* const bitmap = GetBitmap();
-
- if(bitmap)
- {
- buffer = bitmap->GetBuffer();
- }
- return buffer;
-}
-
-unsigned int BitmapImage::GetBufferSize() const
-{
- unsigned int bufferSize = 0;
-
- Integration::Bitmap* const bitmap = GetBitmap();
-
- if(bitmap)
- {
- bufferSize = bitmap->GetBufferSize();
- }
- return bufferSize;
-}
-
-unsigned int BitmapImage::GetBufferStride() const
-{
- unsigned int bufferStride = 0;
-
- Integration::Bitmap* const bitmap = GetBitmap();
-
- if(bitmap)
- {
- Integration::Bitmap::PackedPixelsProfile* packedBitmap = bitmap->GetPackedPixelsProfile();
- DALI_ASSERT_DEBUG(packedBitmap);
- bufferStride = packedBitmap->GetBufferStride();
- }
-
- return bufferStride;
-}
-
-Pixel::Format BitmapImage::GetPixelFormat() const
-{
- Pixel::Format format( Pixel::RGBA8888 );
-
- Integration::Bitmap* const bitmap = GetBitmap();
-
- if( bitmap )
- {
- format = bitmap->GetPixelFormat();
- }
-
- return format;
-}
-
-void BitmapImage::Connect()
-{
- ++mConnectionCount;
-
- // application owns bitmap buffer, don't do anything. BufferUpdated() has to be called manually.
- if (mIsDataExternal)
- {
- return;
- }
-
- if (mConnectionCount == 1)
- {
- if (!mTicket && mBitmapCached)
- {
- const ImageTicketPtr& t = mResourceClient->AddBitmapImage(mBitmapCached.Get());
- mTicket = t.Get();
- mTicket->AddObserver(*this);
- }
- }
-}
-
-void BitmapImage::Disconnect()
-{
- if (!mTicket)
- {
- return;
- }
-
- --mConnectionCount;
-
- if (mConnectionCount == 0 && mReleasePolicy == Dali::Image::UNUSED)
- {
- mBitmapCached = mResourceClient->GetBitmap(mTicket);
- // release image memory when it's not visible anymore (decrease ref. count of texture)
- mTicket->RemoveObserver(*this);
- mTicket.Reset();
- }
-}
-
-Integration::Bitmap * BitmapImage::GetBitmap() const
-{
- Integration::Bitmap* bitmap = NULL;
-
- if (mTicket)
- {
- bitmap = mResourceClient->GetBitmap(mTicket);
- }
- else
- {
- // off screen and freeing memory was requested
- bitmap = mBitmapCached.Get();
- }
-
- DALI_ASSERT_DEBUG(bitmap);
-
- return bitmap;
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_BITMAP_IMAGE_H__
-#define __DALI_INTERNAL_BITMAP_IMAGE_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/internal/event/images/image-impl.h>
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/bitmap-image.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class BitmapImage;
-typedef IntrusivePtr<BitmapImage> BitmapImagePtr;
-
-class ResourceClient;
-class ResourceManager;
-
-/**
- * BitmapImage represents an image resource that can be added to actors etc.
- * Its pixel buffer data is provided by the application developer.
- * Pixel buffer memory allocation can be handled by dali or application.
- */
-class BitmapImage : public Image
-{
-public:
- /**
- * Create a new BitmapImage.
- * Also a pixel buffer for image data is allocated.
- * Dali has ownership of the buffer.
- * For better performance and portability use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- * @param [in] width image width in pixels
- * @param [in] height image height in pixels
- * @param [in] pixelformat the pixel format (rgba 32 bit by default)
- * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
- */
- static BitmapImagePtr New( unsigned int width,
- unsigned int height,
- Pixel::Format pixelformat,
- ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT );
-
- /**
- * Create a new BitmapImage, which uses external data source.
- * Pixel buffer has to be allocated by application.
- * Application holds ownership of the buffer.
- * For better performance and portability use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- * @note in case releasePol is "OffStage", application has to call Image::BufferUpdated() whenever image is re-added to the stage
- * @param [in] pixBuf pixel buffer. has to be allocated by application.
- * @param [in] width image width in pixels
- * @param [in] height image height in pixels
- * @param [in] pixelformat the pixel format (rgba 32 bit by default)
- * @param [in] stride the internal stride of the pixelbuffer in pixels
- * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
- */
- static BitmapImagePtr New( PixelBuffer* pixBuf,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelformat,
- unsigned int stride,
- ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT );
-
- /**
- * Create a new BitmapImage.
- * Also a pixel buffer for image data is allocated.
- * Dali has ownership of the buffer.
- * For better performance use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- * @param [in] width image width in pixels
- * @param [in] height image height in pixels
- * @param [in] pixelformat the pixel format (rgba 32 bit by default)
- * @param [in] releasePol optionally release memory when image is not visible on screen (default: keep image data until Image object is alive).
- */
- BitmapImage(unsigned int width,
- unsigned int height,
- Pixel::Format pixelformat,
- ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT);
-
- /**
- * Create a new BitmapImage, which uses external data source.
- * Pixel buffer has to be allocated by application.
- * Application holds ownership of the buffer.
- * For better performance and portability use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- * @note in case releasePol is "OffStage", application has to call Image::BufferUpdated() whenever image is re-added to the stage
- * @param [in] pixBuf pixel buffer. has to be allocated by application.
- * @param [in] width image width in pixels
- * @param [in] height image height in pixels
- * @param [in] pixelformat the pixel format (rgba 32 bit by default)
- * @param [in] stride the internal stride of the pixelbuffer in pixels
- * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
- */
- BitmapImage(PixelBuffer* pixBuf,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelformat,
- unsigned int stride,
- ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT);
-
-protected:
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~BitmapImage();
-
-public:
- /**
- * Notify Dali that the contents of the buffer have changed.
- * @param [in] updateArea area that has changed in buffer. An empty rect means the whole buffer has changed.
- */
- void Update (RectArea& updateArea);
-
- /**
- * @copydoc Dali::BitmapImage::IsDataExternal
- */
- bool IsDataExternal() const;
-
- /**
- * Returns the pixel buffer of the Image.
- * The application developer can write to the buffer.
- * Upload the modified contents with BufferUpdated.
- * @return the pixel buffer
- */
- PixelBuffer* GetBuffer();
-
- /**
- * Returns buffer size in bytes.
- * @return the buffer size in bytes
- */
- unsigned int GetBufferSize() const;
-
- /**
- * Returns buffer stride (in bytes).
- * @return the buffer stride
- */
- unsigned int GetBufferStride() const;
-
- /**
- * Get the pixel format
- * @return The pixel format
- */
- Pixel::Format GetPixelFormat() const;
-
-protected: // From Resource
- /**
- * @copydoc Dali::Internal::Image::Connect
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Image::Disconnect
- */
- virtual void Disconnect();
-
- /**
- * Get the bitmap from local cache or ticket.
- **/
- Integration::Bitmap * GetBitmap() const;
-
-private:
- bool mIsDataExternal; ///< whether application holds ownership of pixel buffer or not
-
- ResourceClient* mResourceClient;
-
-protected:
- Integration::BitmapPtr mBitmapCached;
-};
-
-} // namespace Internal
-
-/**
- * Helper methods for public API.
- */
-inline Internal::BitmapImage& GetImplementation(Dali::BitmapImage& image)
-{
- DALI_ASSERT_ALWAYS( image && "BitmapImage handle is empty" );
-
- BaseObject& handle = image.GetBaseObject();
-
- return static_cast<Internal::BitmapImage&>(handle);
-}
-
-inline const Internal::BitmapImage& GetImplementation(const Dali::BitmapImage& image)
-{
- DALI_ASSERT_ALWAYS( image && "BitmapImage handle is empty" );
-
- const BaseObject& handle = image.GetBaseObject();
-
- return static_cast<const Internal::BitmapImage&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_BITMAP_IMAGE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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 <dali/internal/event/images/buffer-image-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <dali/integration-api/bitmap.h>
+#include <dali/internal/event/images/bitmap-external.h>
+#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/event/resources/resource-client.h>
+#include <dali/internal/update/manager/update-manager.h>
+#include <dali/internal/event/images/image-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+
+namespace
+{
+TypeRegistration mType( typeid( Dali::BufferImage ), typeid( Dali::Image ), NULL );
+} // unnamed namespace
+
+BufferImagePtr BufferImage::New( unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol )
+{
+ BufferImagePtr internal = new BufferImage( width, height, pixelformat, releasePol );
+ internal->Initialize();
+ return internal;
+}
+
+BufferImagePtr BufferImage::New( PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol )
+{
+ BufferImagePtr internal = new BufferImage( pixBuf, width, height, pixelformat, stride, releasePol );
+ internal->Initialize();
+ return internal;
+}
+
+BufferImage::BufferImage(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol)
+: Image(releasePol),
+ mIsDataExternal(false)
+{
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ mResourceClient = &tls.GetResourceClient();
+ mWidth = width;
+ mHeight = height;
+
+ const ImageTicketPtr& t = mResourceClient->AllocateBitmapImage(width, height, width, height, pixelformat);
+ mTicket = t.Get();
+
+ mTicket->AddObserver(*this);
+}
+
+BufferImage::BufferImage(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol)
+: Image(releasePol),
+ mIsDataExternal(true)
+{
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ mResourceClient = &tls.GetResourceClient();
+ mWidth = width;
+ mHeight = height;
+ Integration::Bitmap* bitmap = new BitmapExternal(pixBuf, width, height, pixelformat, stride);
+ const ImageTicketPtr& t = mResourceClient->AddBitmapImage(bitmap);
+ mTicket = t.Get();
+
+ mTicket->AddObserver(*this);
+}
+
+BufferImage::~BufferImage()
+{
+}
+
+void BufferImage::Update( RectArea& updateArea )
+{
+ if (mTicket)
+ {
+ // TODO:
+ // If updateArea is empty or same as image size, then pass on.
+ // If updateArea is larger than image size, throw exception
+ // Otherwise, copy updateArea window of pixelBuffer into newly
+ // allocated buffer and pass that to resource client. (it will
+ // tramp through to BitmapTexture eventually!)
+ mResourceClient->UpdateBitmapArea( mTicket, updateArea );
+ }
+ else if (mIsDataExternal && mBitmapCached)
+ {
+ // previously freed up resource memory, dali was informed about external BufferImage put back on screen
+ Integration::Bitmap* bitmap = mBitmapCached.Get();
+ mTicket.Reset((mResourceClient->AddBitmapImage(bitmap)).Get());
+
+ mTicket->AddObserver(*this);
+ }
+}
+
+bool BufferImage::IsDataExternal() const
+{
+ return mIsDataExternal;
+}
+
+PixelBuffer* BufferImage::GetBuffer()
+{
+ PixelBuffer* buffer = NULL;
+
+ Integration::Bitmap* const bitmap = GetBitmap();
+
+ if(bitmap)
+ {
+ buffer = bitmap->GetBuffer();
+ }
+ return buffer;
+}
+
+unsigned int BufferImage::GetBufferSize() const
+{
+ unsigned int bufferSize = 0;
+
+ Integration::Bitmap* const bitmap = GetBitmap();
+
+ if(bitmap)
+ {
+ bufferSize = bitmap->GetBufferSize();
+ }
+ return bufferSize;
+}
+
+unsigned int BufferImage::GetBufferStride() const
+{
+ unsigned int bufferStride = 0;
+
+ Integration::Bitmap* const bitmap = GetBitmap();
+
+ if(bitmap)
+ {
+ Integration::Bitmap::PackedPixelsProfile* packedBitmap = bitmap->GetPackedPixelsProfile();
+ DALI_ASSERT_DEBUG(packedBitmap);
+ bufferStride = packedBitmap->GetBufferStride();
+ }
+
+ return bufferStride;
+}
+
+Pixel::Format BufferImage::GetPixelFormat() const
+{
+ Pixel::Format format( Pixel::RGBA8888 );
+
+ Integration::Bitmap* const bitmap = GetBitmap();
+
+ if( bitmap )
+ {
+ format = bitmap->GetPixelFormat();
+ }
+
+ return format;
+}
+
+void BufferImage::Connect()
+{
+ ++mConnectionCount;
+
+ // application owns bitmap buffer, don't do anything. Update() has to be called manually.
+ if (mIsDataExternal)
+ {
+ return;
+ }
+
+ if (mConnectionCount == 1)
+ {
+ if (!mTicket && mBitmapCached)
+ {
+ const ImageTicketPtr& t = mResourceClient->AddBitmapImage(mBitmapCached.Get());
+ mTicket = t.Get();
+ mTicket->AddObserver(*this);
+ }
+ }
+}
+
+void BufferImage::Disconnect()
+{
+ if (!mTicket)
+ {
+ return;
+ }
+
+ --mConnectionCount;
+
+ if (mConnectionCount == 0 && mReleasePolicy == Dali::Image::UNUSED)
+ {
+ mBitmapCached = mResourceClient->GetBitmap(mTicket);
+ // release image memory when it's not visible anymore (decrease ref. count of texture)
+ mTicket->RemoveObserver(*this);
+ mTicket.Reset();
+ }
+}
+
+Integration::Bitmap * BufferImage::GetBitmap() const
+{
+ Integration::Bitmap* bitmap = NULL;
+
+ if (mTicket)
+ {
+ bitmap = mResourceClient->GetBitmap(mTicket);
+ }
+ else
+ {
+ // off screen and freeing memory was requested
+ bitmap = mBitmapCached.Get();
+ }
+
+ DALI_ASSERT_DEBUG(bitmap);
+
+ return bitmap;
+}
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_BUFFER_IMAGE_H__
+#define __DALI_INTERNAL_BUFFER_IMAGE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/ref-object.h>
+#include <dali/internal/event/images/image-impl.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/images/buffer-image.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+class BufferImage;
+typedef IntrusivePtr<BufferImage> BufferImagePtr;
+
+class ResourceClient;
+class ResourceManager;
+
+/**
+ * BufferImage represents an image resource that can be added to actors etc.
+ * Its pixel buffer data is provided by the application developer.
+ * Pixel buffer memory allocation can be handled by dali or application.
+ */
+class BufferImage : public Image
+{
+public:
+ /**
+ * Create a new BufferImage.
+ * Also a pixel buffer for image data is allocated.
+ * Dali has ownership of the buffer.
+ * For better performance and portability use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ * @param [in] width image width in pixels
+ * @param [in] height image height in pixels
+ * @param [in] pixelformat the pixel format (rgba 32 bit by default)
+ * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
+ */
+ static BufferImagePtr New( unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelformat,
+ ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT );
+
+ /**
+ * Create a new BufferImage, which uses external data source.
+ * Pixel buffer has to be allocated by application.
+ * Application holds ownership of the buffer.
+ * For better performance and portability use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ * @note in case releasePol is "OffStage", application has to call Update() whenever image is re-added to the stage
+ * @param [in] pixBuf pixel buffer. has to be allocated by application.
+ * @param [in] width image width in pixels
+ * @param [in] height image height in pixels
+ * @param [in] pixelformat the pixel format (rgba 32 bit by default)
+ * @param [in] stride the internal stride of the pixelbuffer in pixels
+ * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
+ */
+ static BufferImagePtr New( PixelBuffer* pixBuf,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelformat,
+ unsigned int stride,
+ ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT );
+
+ /**
+ * Create a new BufferImage.
+ * Also a pixel buffer for image data is allocated.
+ * Dali has ownership of the buffer.
+ * For better performance use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ * @param [in] width image width in pixels
+ * @param [in] height image height in pixels
+ * @param [in] pixelformat the pixel format (rgba 32 bit by default)
+ * @param [in] releasePol optionally release memory when image is not visible on screen (default: keep image data until Image object is alive).
+ */
+ BufferImage(unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelformat,
+ ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT);
+
+ /**
+ * Create a new BufferImage, which uses external data source.
+ * Pixel buffer has to be allocated by application.
+ * Application holds ownership of the buffer.
+ * For better performance and portability use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ * @note in case releasePol is "OffStage", application has to call Update() whenever image is re-added to the stage
+ * @param [in] pixBuf pixel buffer. has to be allocated by application.
+ * @param [in] width image width in pixels
+ * @param [in] height image height in pixels
+ * @param [in] pixelformat the pixel format (rgba 32 bit by default)
+ * @param [in] stride the internal stride of the pixelbuffer in pixels
+ * @param [in] releasePol optionally relase memory when image is not visible on screen (default: keep image data until Image object is alive).
+ */
+ BufferImage(PixelBuffer* pixBuf,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelformat,
+ unsigned int stride,
+ ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT);
+
+protected:
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~BufferImage();
+
+public:
+ /**
+ * Notify Dali that the contents of the buffer have changed.
+ * @param [in] updateArea area that has changed in buffer. An empty rect means the whole buffer has changed.
+ */
+ void Update (RectArea& updateArea);
+
+ /**
+ * @copydoc Dali::BufferImage::IsDataExternal
+ */
+ bool IsDataExternal() const;
+
+ /**
+ * Returns the pixel buffer of the Image.
+ * The application developer can write to the buffer.
+ * Upload the modified contents with Update().
+ * @return the pixel buffer
+ */
+ PixelBuffer* GetBuffer();
+
+ /**
+ * Returns buffer size in bytes.
+ * @return the buffer size in bytes
+ */
+ unsigned int GetBufferSize() const;
+
+ /**
+ * Returns buffer stride (in bytes).
+ * @return the buffer stride
+ */
+ unsigned int GetBufferStride() const;
+
+ /**
+ * Get the pixel format
+ * @return The pixel format
+ */
+ Pixel::Format GetPixelFormat() const;
+
+protected: // From Resource
+ /**
+ * @copydoc Dali::Internal::Image::Connect
+ */
+ virtual void Connect();
+
+ /**
+ * @copydoc Dali::Internal::Image::Disconnect
+ */
+ virtual void Disconnect();
+
+ /**
+ * Get the bitmap from local cache or ticket.
+ **/
+ Integration::Bitmap * GetBitmap() const;
+
+private:
+ bool mIsDataExternal; ///< whether application holds ownership of pixel buffer or not
+
+ ResourceClient* mResourceClient;
+
+protected:
+ Integration::BitmapPtr mBitmapCached;
+};
+
+} // namespace Internal
+
+/**
+ * Helper methods for public API.
+ */
+inline Internal::BufferImage& GetImplementation(Dali::BufferImage& image)
+{
+ DALI_ASSERT_ALWAYS( image && "BufferImage handle is empty" );
+
+ BaseObject& handle = image.GetBaseObject();
+
+ return static_cast<Internal::BufferImage&>(handle);
+}
+
+inline const Internal::BufferImage& GetImplementation(const Dali::BufferImage& image)
+{
+ DALI_ASSERT_ALWAYS( image && "BufferImage handle is empty" );
+
+ const BaseObject& handle = image.GetBaseObject();
+
+ return static_cast<const Internal::BufferImage&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_BUFFER_IMAGE_H__
return mChildRectangle;
}
-Internal::BitmapImagePtr NinePatchImage::CreateCroppedBitmapImage()
+Internal::BufferImagePtr NinePatchImage::CreateCroppedBufferImage()
{
- BitmapImagePtr cropped;
+ BufferImagePtr cropped;
if( ! mBitmap )
{
{
Pixel::Format pixelFormat = mBitmap->GetPixelFormat();
- cropped = BitmapImage::New( mWidth-2, mHeight-2, pixelFormat, Dali::Image::NEVER );
+ cropped = BufferImage::New( mWidth-2, mHeight-2, pixelFormat, Dali::Image::NEVER );
Integration::Bitmap::PackedPixelsProfile* srcProfile = mBitmap->GetPackedPixelsProfile();
DALI_ASSERT_DEBUG( srcProfile && "Wrong profile for source bitmap");
// INTERNAL INCLUDES
#include <dali/public-api/images/nine-patch-image.h>
#include <dali/internal/event/images/resource-image-impl.h>
-#include <dali/internal/event/images/bitmap-image-impl.h>
+#include <dali/internal/event/images/buffer-image-impl.h>
namespace Dali
{
*
* @return the cropped bitmap.
*/
- BitmapImagePtr CreateCroppedBitmapImage();
+ BufferImagePtr CreateCroppedBufferImage();
protected: // From Resource
$(internal_src_dir)/event/images/bitmap-packed-pixel.cpp \
$(internal_src_dir)/event/images/bitmap-compressed.cpp \
$(internal_src_dir)/event/images/image-impl.cpp \
- $(internal_src_dir)/event/images/bitmap-image-impl.cpp \
+ $(internal_src_dir)/event/images/buffer-image-impl.cpp \
$(internal_src_dir)/event/images/frame-buffer-image-impl.cpp \
$(internal_src_dir)/event/images/encoded-buffer-image-impl.cpp \
$(internal_src_dir)/event/images/image-connector.cpp \
// INTERNAL INCLUDES
#include <dali/public-api/images/native-image-interface.h>
-#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/images/pixel.h>
#include <dali/internal/common/message.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <stdint.h>
// INTERNAL INCLUDES
-#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/buffer-image.h>
#include <dali/internal/common/message.h>
#include <dali/internal/render/gl-resources/texture.h>
#include <dali/internal/render/gl-resources/texture-cache.h>
// INTERNAL INCLUDES
#include <dali/public-api/images/image.h>
#include <dali/public-api/images/native-image-interface.h>
-#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/common/ref-counted-dali-vector.h>
#include <dali/integration-api/bitmap.h>
#include <dali/public-api/geometry/spline.h>
#include <dali/public-api/images/atlas.h>
-#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/images/distance-field.h>
#include <dali/public-api/images/encoded-buffer-image.h>
#include <dali/public-api/images/frame-buffer-image.h>
$(public_api_src_dir)/images/image.cpp \
$(public_api_src_dir)/images/image-attributes.cpp \
$(public_api_src_dir)/images/pixel.cpp \
- $(public_api_src_dir)/images/bitmap-image.cpp \
+ $(public_api_src_dir)/images/buffer-image.cpp \
$(public_api_src_dir)/images/frame-buffer-image.cpp \
$(public_api_src_dir)/images/encoded-buffer-image.cpp \
$(public_api_src_dir)/images/nine-patch-image.cpp \
public_api_core_images_header_files = \
$(public_api_src_dir)/images/atlas.h \
- $(public_api_src_dir)/images/bitmap-image.h \
+ $(public_api_src_dir)/images/buffer-image.h \
$(public_api_src_dir)/images/distance-field.h \
$(public_api_src_dir)/images/encoded-buffer-image.h \
$(public_api_src_dir)/images/frame-buffer-image.h \
// INTERNAL INCLUDES
#include <dali/internal/event/images/atlas-impl.h>
-#include <dali/internal/event/images/bitmap-image-impl.h>
+#include <dali/internal/event/images/buffer-image-impl.h>
namespace Dali
{
{
}
-bool Atlas::Upload( const BitmapImage& bitmap,
+bool Atlas::Upload( const BufferImage& bufferImage,
std::size_t xOffset,
std::size_t yOffset )
{
- return GetImplementation(*this).Upload( GetImplementation(bitmap), xOffset, yOffset );
+ return GetImplementation(*this).Upload( GetImplementation(bufferImage), xOffset, yOffset );
}
Atlas Atlas::DownCast( BaseHandle handle )
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/buffer-image.h>
namespace Dali
{
* @brief Upload a bitmap to the atlas.
*
* @pre The bitmap pixel format must match the Atlas format.
- * @param [in] bitmap The bitmap to upload.
+ * @param [in] bufferImage The buffer image to upload.
* @param [in] xOffset Specifies an offset in the x direction within the atlas.
* @param [in] yOffset Specifies an offset in the y direction within the atlas.
* @return True if the bitmap fits within the atlas at the specified offset.
*/
- bool Upload( const BitmapImage& bitmap,
+ bool Upload( const BufferImage& bufferImage,
std::size_t xOffset,
std::size_t yOffset );
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <dali/public-api/images/bitmap-image.h>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/internal/event/images/bitmap-image-impl.h>
-
-namespace Dali
-{
-
-BitmapImage::BitmapImage()
-{
-}
-
-BitmapImage::BitmapImage(Internal::BitmapImage* internal)
- : Image(internal)
-{
-}
-
-BitmapImage BitmapImage::DownCast( BaseHandle handle )
-{
- return BitmapImage( dynamic_cast<Dali::Internal::BitmapImage*>(handle.GetObjectPtr()) );
-}
-
-BitmapImage::~BitmapImage()
-{
-}
-
-BitmapImage::BitmapImage(const BitmapImage& handle)
-: Image(handle)
-{
-}
-
-BitmapImage& BitmapImage::operator=(const BitmapImage& rhs)
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-
-const BitmapImage BitmapImage::WHITE()
-{
- Internal::BitmapImage* internal = new Internal::BitmapImage(1,1,Pixel::RGBA8888, Dali::Image::NEVER);
- PixelBuffer* pBuf = internal->GetBuffer();
- pBuf[0] = pBuf[1] = pBuf[2] = pBuf[3] = 0xFF;
- return BitmapImage(internal);
-}
-
-BitmapImage BitmapImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat)
-{
- DALI_ASSERT_ALWAYS( 0u != width && "Invalid BitmapImage width requested" );
- DALI_ASSERT_ALWAYS( 0u != height && "Invalid BitmapImage height requested" );
-
- Internal::BitmapImagePtr internal = Internal::BitmapImage::New(width, height, pixelformat);
- return BitmapImage(internal.Get());
-}
-
-BitmapImage BitmapImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol)
-{
- DALI_ASSERT_ALWAYS( 0u != width && "Invalid BitmapImage width requested" );
- DALI_ASSERT_ALWAYS( 0u != height && "Invalid BitmapImage height requested" );
-
- Internal::BitmapImagePtr internal = Internal::BitmapImage::New(width, height, pixelformat, releasePol);
- return BitmapImage(internal.Get());
-}
-
-BitmapImage BitmapImage::New(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride)
-{
- DALI_ASSERT_ALWAYS( 0u != width && "Invalid BitmapImage width requested" );
- DALI_ASSERT_ALWAYS( 0u != height && "Invalid BitmapImage height requested" );
-
- Internal::BitmapImagePtr internal = Internal::BitmapImage::New(pixBuf, width, height, pixelformat, stride);
- return BitmapImage(internal.Get());
-}
-
-BitmapImage BitmapImage::New(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol)
-{
- DALI_ASSERT_ALWAYS( 0u != width && "Invalid BitmapImage width requested" );
- DALI_ASSERT_ALWAYS( 0u != height && "Invalid BitmapImage height requested" );
- Internal::BitmapImagePtr internal = Internal::BitmapImage::New(pixBuf, width, height, pixelformat, stride, releasePol);
- return BitmapImage(internal.Get());
-}
-
-PixelBuffer* BitmapImage::GetBuffer()
-{
- return GetImplementation(*this).GetBuffer();
-}
-
-unsigned int BitmapImage::GetBufferSize() const
-{
- return GetImplementation(*this).GetBufferSize();
-}
-
-unsigned int BitmapImage::GetBufferStride() const
-{
- return GetImplementation(*this).GetBufferStride();
-}
-
-Pixel::Format BitmapImage::GetPixelFormat() const
-{
- return GetImplementation(*this).GetPixelFormat();
-}
-
-void BitmapImage::Update ()
-{
- RectArea area;
- GetImplementation(*this).Update(area);
-}
-
-void BitmapImage::Update (RectArea updateArea)
-{
- GetImplementation(*this).Update(updateArea);
-}
-
-bool BitmapImage::IsDataExternal() const
-{
- return GetImplementation(*this).IsDataExternal();
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_BITMAP_IMAGE_H__
-#define __DALI_BITMAP_IMAGE_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/math/rect.h>
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class BitmapImage;
-}
-
-typedef unsigned char PixelBuffer; ///< pixel data buffer
-typedef Rect<unsigned int> RectArea; ///< rectangular area (x,y,w,h)
-
-
-/**
- * @brief BitmapImage represents an image resource that can be added to ImageActors.
- * Its pixel buffer data is provided by the application developer.
- *
- * Care should be taken with pixel data allocated by the application,
- * as the data is copied to GL both when the image is added to the
- * stage and after a call to Update(). In both of these cases, a
- * SignalUploaded will be sent to the application confirming that the
- * operation has completed.
- *
- * The application can free the pixel data after receiving a
- * SignalUploaded.
- *
- * Similarly, once the image is on stage (i.e. it's being used by an
- * ImageActor that is on stage), the application should only write to
- * the buffer after receiving a SignalUploaded, then call Update()
- * once the write is finished. This avoids the pixel data being changed
- * whilst it's being copied to GL. Writing to the buffer without waiting
- * for the signal will likely result in visible tearing.
- *
- * If the pixel format of the pixel buffer contains an alpha channel,
- * then the image is considered to be have transparent pixels without
- * regard for the actual content of the channel, and will be blended.
- *
- * If the image is opaque and blending is not required, then the user
- * should call ImageActor::SetUseImageAlpha(false) on the containing actor.
- */
-class DALI_IMPORT_API BitmapImage : public Image
-{
-public:
- /**
- * @brief Constructor which creates an uninitialized BitmapImage object.
- *
- * Use BitmapImage::New(...) to create an initialised object.
- */
- BitmapImage();
-
- /**
- * @brief Create a new BitmapImage.
- *
- * Also a pixel buffer for image data is allocated.
- * Dali has ownership of the buffer.
- * For better performance and portability use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- * @note: default resource management policies are Immediate and Never
- *
- * @pre width & height are greater than zero
- * @param [in] width image width in pixels
- * @param [in] height image height in pixels
- * @param [in] pixelformat the pixel format (rgba 32 bit by default)
- * @return a handle to a new instance of BitmapImage
- */
- static BitmapImage New(unsigned int width,
- unsigned int height,
- Pixel::Format pixelformat=Pixel::RGBA8888);
-
- /**
- * @brief Create a new BitmapImage.
- *
- * Also a pixel buffer for image data is allocated.
- * Dali has ownership of the buffer.
- * For better performance and portability use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- *
- * @pre width & height are greater than zero
- * @param [in] width Image width in pixels
- * @param [in] height Image height in pixels
- * @param [in] pixelFormat The pixel format
- * @param [in] releasePolicy Optionally release memory when image is not visible on screen.
- * @return a handle to a new instance of BitmapImage
- */
- static BitmapImage New(unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- ReleasePolicy releasePolicy);
-
- /**
- * @brief Create a new BitmapImage, which uses an external data source.
- *
- * The PixelBuffer has to be allocated by application.
- *
- * The application holds ownership of the buffer. It must not
- * destroy the PixelBuffer on a staged image if it has called
- * Update() and hasn't received a SignalUploaded, or if it has just
- * added it to the stage and has not received a SignalUploaded.
- *
- * For better performance and portability use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- *
- * @pre width & height are greater than zero
- * @param [in] pixelBuffer pixel buffer. has to be allocated by application.
- * @param [in] width image width in pixels
- * @param [in] height image height in pixels
- * @param [in] pixelFormat the pixel format (rgba 32 bit by default)
- * @param [in] stride the internal stride of the pixelbuffer in pixels
- * @return a handle to a new instance of BitmapImage
- */
- static BitmapImage New(PixelBuffer* pixelBuffer,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat=Pixel::RGBA8888,
- unsigned int stride=0);
-
- /**
- * @brief Create a new BitmapImage, which uses an external data source.
- *
- * The PixelBuffer has to be allocated by application.
- *
- * The application holds ownership of the buffer. It must not
- * destroy the PixelBuffer on a staged image if it has called
- * Update() and hasn't received a SignalUploaded, or if it has just
- * added it to the stage and has not received a SignalUploaded.
- *
- * For better performance and portability use power of two dimensions.
- * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
- *
- * @note in case releasePolicy is "Unused", application has to call
- * BitmapImage::Update() whenever image is re-added to the stage
- *
- * @pre width & height are greater than zero
- * @param [in] pixelBuffer pixel buffer. has to be allocated by application.
- * @param [in] width image width in pixels
- * @param [in] height image height in pixels
- * @param [in] pixelFormat the pixel format
- * @param [in] stride the internal stride of the pixelbuffer in pixels
- * @param [in] releasePolicy optionally relase memory when image is not visible on screen.
- * @return a handle to a new instance of BitmapImage
- */
- static BitmapImage New(PixelBuffer* pixelBuffer,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- unsigned int stride,
- ReleasePolicy releasePolicy);
-
- /**
- * @brief Downcast an Object handle to BitmapImage.
- *
- * If handle points to a BitmapImage the downcast produces valid
- * handle. If not the returned handle is left uninitialized.
- *
- * @param[in] handle to An object
- * @return handle to a BitmapImage or an uninitialized handle
- */
- static BitmapImage DownCast( BaseHandle handle );
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~BitmapImage();
-
- /**
- * @brief This copy constructor is required for (smart) pointer semantics.
- *
- * @param [in] handle A reference to the copied handle
- */
- BitmapImage(const BitmapImage& handle);
-
- /**
- * @brief This assignment operator is required for (smart) pointer semantics.
- *
- * @param [in] rhs A reference to the copied handle
- * @return A reference to this
- */
- BitmapImage& operator=(const BitmapImage& rhs);
-
- /**
- * @brief White pixel as image data.
- *
- * Can be used to create solid color actors.
- * @return 1 white pixel with 32 bit colordepth
- */
- static const BitmapImage WHITE();
-
-public:
- /**
- * @brief Returns the pixel buffer of the Image.
- *
- * The application can write to the buffer to modify its contents.
- *
- * Whilst the image is on stage, after writing to the buffer the
- * application should call Update() and wait for the
- * SignalUploaded() method before writing again.
- *
- * @return the pixel buffer
- */
- PixelBuffer* GetBuffer();
-
- /**
- * @brief Returns buffer size in bytes.
- *
- * @return the buffer size in bytes
- */
- unsigned int GetBufferSize() const;
-
- /**
- * @brief Returns buffer stride (in bytes).
- *
- * @return the buffer stride
- */
- unsigned int GetBufferStride() const;
-
- /**
- * @brief Returns the pixel format of the contained bitmap
- *
- * @return the pixel format
- */
- Pixel::Format GetPixelFormat() const;
-
- /**
- * @brief Inform Dali that the contents of the buffer have changed.
- *
- * SignalUploaded will be sent in response if the image is on stage
- * and the image data has been successfully copied to graphics
- * memory. To avoid visual tearing, the application should wait for
- * the SignalUploaded before modifying the data.
- *
- * The application must not destroy an external PixelBuffer on a staged
- * image after calling this method until the SignalUploaded has been
- * successfully received.
- *
- * @note: BitmapImage::Update might not work with BGR/BGRA formats!
- * @note: Some GPUs may not support Non power of two buffer updates (for
- * example C110/SGX540)
- */
- void Update();
-
- /**
- * @copydoc Update()
- * @param [in] updateArea area that has changed in buffer
- */
- void Update( RectArea updateArea );
-
- /**
- * @brief Returns whether BitmapImage uses external data source or not.
- *
- * If not, dali holds ownership of the PixelBuffer, otherwise the application
- * is responsible for freeing it.
- *
- * The application must not destroy an external PixelBuffer on a staged image
- * if it has called Update() and hasn't received a SignalUploaded.
- *
- * @return true if application owns data, false otherwise
- */
- bool IsDataExternal() const;
-
-public: // Not intended for application developers
-
- explicit DALI_INTERNAL BitmapImage(Internal::BitmapImage*);
-};
-
-} // namespace Dali
-
-#endif // __DALI_BITMAP_IMAGE_H__
--- /dev/null
+/*
+ * Copyright (c) 2014 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 <dali/public-api/images/buffer-image.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/internal/event/images/buffer-image-impl.h>
+
+namespace Dali
+{
+
+BufferImage::BufferImage()
+{
+}
+
+BufferImage::BufferImage(Internal::BufferImage* internal)
+ : Image(internal)
+{
+}
+
+BufferImage BufferImage::DownCast( BaseHandle handle )
+{
+ return BufferImage( dynamic_cast<Dali::Internal::BufferImage*>(handle.GetObjectPtr()) );
+}
+
+BufferImage::~BufferImage()
+{
+}
+
+BufferImage::BufferImage(const BufferImage& handle)
+: Image(handle)
+{
+}
+
+BufferImage& BufferImage::operator=(const BufferImage& rhs)
+{
+ BaseHandle::operator=(rhs);
+ return *this;
+}
+
+const BufferImage BufferImage::WHITE()
+{
+ Internal::BufferImage* internal = new Internal::BufferImage(1,1,Pixel::RGBA8888, Dali::Image::NEVER);
+ PixelBuffer* pBuf = internal->GetBuffer();
+ pBuf[0] = pBuf[1] = pBuf[2] = pBuf[3] = 0xFF;
+ return BufferImage(internal);
+}
+
+BufferImage BufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat)
+{
+ DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" );
+ DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
+
+ Internal::BufferImagePtr internal = Internal::BufferImage::New(width, height, pixelformat);
+ return BufferImage(internal.Get());
+}
+
+BufferImage BufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol)
+{
+ DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" );
+ DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
+
+ Internal::BufferImagePtr internal = Internal::BufferImage::New(width, height, pixelformat, releasePol);
+ return BufferImage(internal.Get());
+}
+
+BufferImage BufferImage::New(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride)
+{
+ DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" );
+ DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
+
+ Internal::BufferImagePtr internal = Internal::BufferImage::New(pixBuf, width, height, pixelformat, stride);
+ return BufferImage(internal.Get());
+}
+
+BufferImage BufferImage::New(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol)
+{
+ DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" );
+ DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
+ Internal::BufferImagePtr internal = Internal::BufferImage::New(pixBuf, width, height, pixelformat, stride, releasePol);
+ return BufferImage(internal.Get());
+}
+
+PixelBuffer* BufferImage::GetBuffer()
+{
+ return GetImplementation(*this).GetBuffer();
+}
+
+unsigned int BufferImage::GetBufferSize() const
+{
+ return GetImplementation(*this).GetBufferSize();
+}
+
+unsigned int BufferImage::GetBufferStride() const
+{
+ return GetImplementation(*this).GetBufferStride();
+}
+
+Pixel::Format BufferImage::GetPixelFormat() const
+{
+ return GetImplementation(*this).GetPixelFormat();
+}
+
+void BufferImage::Update ()
+{
+ RectArea area;
+ GetImplementation(*this).Update(area);
+}
+
+void BufferImage::Update (RectArea updateArea)
+{
+ GetImplementation(*this).Update(updateArea);
+}
+
+bool BufferImage::IsDataExternal() const
+{
+ return GetImplementation(*this).IsDataExternal();
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_BUFFER_IMAGE_H__
+#define __DALI_BUFFER_IMAGE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/images/image.h>
+#include <dali/public-api/images/pixel.h>
+#include <dali/public-api/math/rect.h>
+
+namespace Dali
+{
+
+namespace Internal DALI_INTERNAL
+{
+class BufferImage;
+}
+
+typedef unsigned char PixelBuffer; ///< pixel data buffer
+typedef Rect<unsigned int> RectArea; ///< rectangular area (x,y,w,h)
+
+
+/**
+ * @brief BufferImage represents an image resource that can be added to ImageActors.
+ * Its pixel buffer data is provided by the application developer.
+ *
+ * Care should be taken with pixel data allocated by the application,
+ * as the data is copied to GL both when the image is added to the
+ * stage and after a call to Update(). In both of these cases, a
+ * SignalUploaded will be sent to the application confirming that the
+ * operation has completed.
+ *
+ * The application can free the pixel data after receiving a
+ * SignalUploaded.
+ *
+ * Similarly, once the image is on stage (i.e. it's being used by an
+ * ImageActor that is on stage), the application should only write to
+ * the buffer after receiving a SignalUploaded, then call Update()
+ * once the write is finished. This avoids the pixel data being changed
+ * whilst it's being copied to GL. Writing to the buffer without waiting
+ * for the signal will likely result in visible tearing.
+ *
+ * If the pixel format of the pixel buffer contains an alpha channel,
+ * then the image is considered to be have transparent pixels without
+ * regard for the actual content of the channel, and will be blended.
+ *
+ * If the image is opaque and blending is not required, then the user
+ * should call ImageActor::SetUseImageAlpha(false) on the containing actor.
+ */
+class DALI_IMPORT_API BufferImage : public Image
+{
+public:
+ /**
+ * @brief Constructor which creates an uninitialized BufferImage object.
+ *
+ * Use BufferImage::New(...) to create an initialised object.
+ */
+ BufferImage();
+
+ /**
+ * @brief Create a new BufferImage.
+ *
+ * Also a pixel buffer for image data is allocated.
+ * Dali has ownership of the buffer.
+ * For better performance and portability use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ * @note: default resource management policies are Immediate and Never
+ *
+ * @pre width & height are greater than zero
+ * @param [in] width image width in pixels
+ * @param [in] height image height in pixels
+ * @param [in] pixelformat the pixel format (rgba 32 bit by default)
+ * @return a handle to a new instance of BufferImage
+ */
+ static BufferImage New(unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelformat=Pixel::RGBA8888);
+
+ /**
+ * @brief Create a new BufferImage.
+ *
+ * Also a pixel buffer for image data is allocated.
+ * Dali has ownership of the buffer.
+ * For better performance and portability use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ *
+ * @pre width & height are greater than zero
+ * @param [in] width Image width in pixels
+ * @param [in] height Image height in pixels
+ * @param [in] pixelFormat The pixel format
+ * @param [in] releasePolicy Optionally release memory when image is not visible on screen.
+ * @return a handle to a new instance of BufferImage
+ */
+ static BufferImage New(unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ ReleasePolicy releasePolicy);
+
+ /**
+ * @brief Create a new BufferImage, which uses an external data source.
+ *
+ * The PixelBuffer has to be allocated by application.
+ *
+ * The application holds ownership of the buffer. It must not
+ * destroy the PixelBuffer on a staged image if it has called
+ * Update() and hasn't received a SignalUploaded, or if it has just
+ * added it to the stage and has not received a SignalUploaded.
+ *
+ * For better performance and portability use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ *
+ * @pre width & height are greater than zero
+ * @param [in] pixelBuffer pixel buffer. has to be allocated by application.
+ * @param [in] width image width in pixels
+ * @param [in] height image height in pixels
+ * @param [in] pixelFormat the pixel format (rgba 32 bit by default)
+ * @param [in] stride the internal stride of the pixelbuffer in pixels
+ * @return a handle to a new instance of BufferImage
+ */
+ static BufferImage New(PixelBuffer* pixelBuffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat=Pixel::RGBA8888,
+ unsigned int stride=0);
+
+ /**
+ * @brief Create a new BufferImage, which uses an external data source.
+ *
+ * The PixelBuffer has to be allocated by application.
+ *
+ * The application holds ownership of the buffer. It must not
+ * destroy the PixelBuffer on a staged image if it has called
+ * Update() and hasn't received a SignalUploaded, or if it has just
+ * added it to the stage and has not received a SignalUploaded.
+ *
+ * For better performance and portability use power of two dimensions.
+ * The maximum size of the image is limited by GL_MAX_TEXTURE_SIZE.
+ *
+ * @note in case releasePolicy is "Unused", application has to call
+ * BufferImage::Update() whenever image is re-added to the stage
+ *
+ * @pre width & height are greater than zero
+ * @param [in] pixelBuffer pixel buffer. has to be allocated by application.
+ * @param [in] width image width in pixels
+ * @param [in] height image height in pixels
+ * @param [in] pixelFormat the pixel format
+ * @param [in] stride the internal stride of the pixelbuffer in pixels
+ * @param [in] releasePolicy optionally relase memory when image is not visible on screen.
+ * @return a handle to a new instance of BufferImage
+ */
+ static BufferImage New(PixelBuffer* pixelBuffer,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat,
+ unsigned int stride,
+ ReleasePolicy releasePolicy);
+
+ /**
+ * @brief Downcast an Object handle to BufferImage.
+ *
+ * If handle points to a BufferImage the downcast produces valid
+ * handle. If not the returned handle is left uninitialized.
+ *
+ * @param[in] handle to An object
+ * @return handle to a BufferImage or an uninitialized handle
+ */
+ static BufferImage DownCast( BaseHandle handle );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~BufferImage();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param [in] handle A reference to the copied handle
+ */
+ BufferImage(const BufferImage& handle);
+
+ /**
+ * @brief This assignment operator is required for (smart) pointer semantics.
+ *
+ * @param [in] rhs A reference to the copied handle
+ * @return A reference to this
+ */
+ BufferImage& operator=(const BufferImage& rhs);
+
+ /**
+ * @brief White pixel as image data.
+ *
+ * Can be used to create solid color actors.
+ * @return 1 white pixel with 32 bit colordepth
+ */
+ static const BufferImage WHITE();
+
+public:
+ /**
+ * @brief Returns the pixel buffer of the Image.
+ *
+ * The application can write to the buffer to modify its contents.
+ *
+ * Whilst the image is on stage, after writing to the buffer the
+ * application should call Update() and wait for the
+ * SignalUploaded() method before writing again.
+ *
+ * @return the pixel buffer
+ */
+ PixelBuffer* GetBuffer();
+
+ /**
+ * @brief Returns buffer size in bytes.
+ *
+ * @return the buffer size in bytes
+ */
+ unsigned int GetBufferSize() const;
+
+ /**
+ * @brief Returns buffer stride (in bytes).
+ *
+ * @return the buffer stride
+ */
+ unsigned int GetBufferStride() const;
+
+ /**
+ * @brief Returns the pixel format of the contained buffer
+ *
+ * @return the pixel format
+ */
+ Pixel::Format GetPixelFormat() const;
+
+ /**
+ * @brief Inform Dali that the contents of the buffer have changed.
+ *
+ * SignalUploaded will be sent in response if the image is on stage
+ * and the image data has been successfully copied to graphics
+ * memory. To avoid visual tearing, the application should wait for
+ * the SignalUploaded before modifying the data.
+ *
+ * The application must not destroy an external PixelBuffer on a staged
+ * image after calling this method until the SignalUploaded has been
+ * successfully received.
+ *
+ * @note: BufferImage::Update might not work with BGR/BGRA formats!
+ * @note: Some GPUs may not support Non power of two buffer updates (for
+ * example C110/SGX540)
+ */
+ void Update();
+
+ /**
+ * @copydoc Update()
+ * @param [in] updateArea area that has changed in buffer
+ */
+ void Update( RectArea updateArea );
+
+ /**
+ * @brief Returns whether BufferImage uses external data source or not.
+ *
+ * If not, dali holds ownership of the PixelBuffer, otherwise the application
+ * is responsible for freeing it.
+ *
+ * The application must not destroy an external PixelBuffer on a staged image
+ * if it has called Update() and hasn't received a SignalUploaded.
+ *
+ * @return true if application owns data, false otherwise
+ */
+ bool IsDataExternal() const;
+
+public: // Not intended for application developers
+
+ explicit DALI_INTERNAL BufferImage(Internal::BufferImage*);
+};
+
+} // namespace Dali
+
+#endif // __DALI_BUFFER_IMAGE_H__
#include <dali/public-api/images/glyph-image.h>
// INTERNAL INCLUDES
-#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/text/text-style.h>
#include <dali/integration-api/platform-abstraction.h>
// TODO: support more text decoration features: outline, glow, shadow, underline, ...
const std::size_t width = bitmapPtr->GetImageWidth();
const std::size_t height = bitmapPtr->GetImageHeight();
- BitmapImage bitmapImage = BitmapImage::New( width, height, Pixel::RGBA8888 );
+ BufferImage bufferImage = BufferImage::New( width, height, Pixel::RGBA8888 );
// Point the source bitmap buffer.
unsigned char* src = bitmapPtr->GetBuffer();
// Point the destination image buffer.
- unsigned char* dst = bitmapImage.GetBuffer();
+ unsigned char* dst = bufferImage.GetBuffer();
//Retrieve the color from the text style.
const Vector4& color = style.GetTextColor();
}
}
- bitmapImage.Update();
+ bufferImage.Update();
- image = bitmapImage;
+ image = bufferImage;
}
}
*
* It Will be sent after an actor using the image is added to
* the stage, when such a staged image is reloaded, or when a staged
- * BitmapImage calls Update().
+ * BufferImage calls Update().
* @return A signal object to Connect() with.
*/
ImageSignalType& UploadedSignal();
return GetImplementation(*this).GetChildRectangle();
}
-BitmapImage NinePatchImage::CreateCroppedBitmapImage()
+BufferImage NinePatchImage::CreateCroppedBufferImage()
{
- Internal::BitmapImagePtr internal = GetImplementation(*this).CreateCroppedBitmapImage();
- return BitmapImage(internal.Get());
+ Internal::BufferImagePtr internal = GetImplementation(*this).CreateCroppedBufferImage();
+ return BufferImage(internal.Get());
}
// INTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/images/resource-image.h>
-#include <dali/public-api/images/bitmap-image.h>
+#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/math/rect.h>
namespace Dali
* area.
*
* The class offers an API to read the stretch area and child area, but it does not
- * remove the border from it's bitmap. An API can be used to obtain a BitmapImage with
+ * remove the border from it's bitmap. An API can be used to obtain a BufferImage with
* the border removed.
*
* Adding this image to an ImageActor using an Image handle will automatically convert
- * to use the cropped BitmapImage - if you don't retain a handle to this object, it will
+ * to use the cropped BufferImage - if you don't retain a handle to this object, it will
* be automatically destroyed.
*/
class DALI_IMPORT_API NinePatchImage : public ResourceImage
Rect<int> GetChildRectangle();
/**
- * Creates a bitmap image from the bitmap with the 1 pixel border cropped off.
+ * Creates a buffer image from the bitmap with the 1 pixel border cropped off.
* This does not change the internal bitmap.
*
- * @return The cropped BitmapImage
+ * @return The cropped BufferImage
*/
- BitmapImage CreateCroppedBitmapImage();
+ BufferImage CreateCroppedBufferImage();
public: // Not intended for application developers
/**
* @brief Pixel formats
*
- * @note: BitmapImage::Update might not work with BGR/BGRA formats!
+ * @note: BufferImage::Update might not work with BGR/BGRA formats!
*/
enum Format ///< pixel format, default color depth is RGBA 32 bit with alpha
{
#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/images/resource-image-impl.h>
#include <dali/internal/event/images/frame-buffer-image-impl.h>
-#include <dali/internal/event/images/bitmap-image-impl.h>
+#include <dali/internal/event/images/buffer-image-impl.h>
#include <dali/internal/event/effects/shader-effect-impl.h>
namespace Dali
pixelFormat,
releasePolicy);
}
- else if("BitmapImage" == s)
+ else if("BufferImage" == s)
{
- ret = BitmapImage::New(attributes.GetWidth(),
+ ret = BufferImage::New(attributes.GetWidth(),
attributes.GetHeight(),
pixelFormat,
releasePolicy);
}
- else if("Image" == s || "ResourceImage" == s)
+ else if("ResourceImage" == s)
{
ret = ResourceImage::New(filename, attributes, loadPolicy, releasePolicy);
}
std::string imageType( "ResourceImage" );
// Get Type - cannot use TypeRegistry as Image is not an Object and thus, not registered
- BitmapImage bitmapImage = BitmapImage::DownCast( image );
- if ( bitmapImage )
+ BufferImage bufferImage = BufferImage::DownCast( image );
+ if ( bufferImage )
{
- imageType = "BitmapImage";
- map[ "pixel-format" ] = GetEnumerationName< Pixel::Format >( bitmapImage.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
+ imageType = "BufferImage";
+ map[ "pixel-format" ] = GetEnumerationName< Pixel::Format >( bufferImage.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
}
else if ( FrameBufferImage::DownCast( image ) )
{
* "height" type FLOAT
* "pixel-format" type STRING (enum)
* "scaling-mode" type STRING (enum)
- * "type" type STRING (FrameBufferImage|BitMapImage|Image(default))
+ * "type" type STRING (FrameBufferImage|BufferImage|ResourceImage(default))
* @endcode
* Some fields are optional and some only pertain to a specific type.
*