#include <dali/dali.h>
#include <dali-toolkit-test-suite-utils.h>
#include <toolkit-event-thread-callback.h>
-#include <dali/devel-api/images/atlas.h>
-#include <dali-toolkit/devel-api/image-atlas/image-atlas.h>
+#include <dali-toolkit/devel-api/image-loader/image-atlas.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
using namespace Dali;
&& rect2.y < rect1.y+rect1.height;
}
-}
+} // anonymous namespace
void dali_image_atlas_startup(void)
{
ToolkitTestApplication application;
ImageAtlas atlas = ImageAtlas::New( 32, 32 );
- Image image = atlas.GetAtlas();
+ Texture image = atlas.GetAtlas();
// test the atlas created
DALI_TEST_EQUALS( (bool)image, true, TEST_LOCATION );
DALI_TEST_CHECK( image.GetHeight() == 32u );
DALI_TEST_CHECK( image.GetWidth() == 32u );
- Atlas coreAtlas = Atlas::DownCast( image );
- DALI_TEST_EQUALS( (bool)coreAtlas, true, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliImageAtlasGetOccupancyRate(void)
+{
+ ToolkitTestApplication application;
+
+ ImageAtlas atlas = ImageAtlas::New( 100, 100 );
+
+ DALI_TEST_EQUALS( atlas.GetOccupancyRate(), 0.f, TEST_LOCATION );
+
+ Vector4 textureRect1;
+ atlas.Upload( textureRect1, gImage_34_RGBA, ImageDimensions(34, 34) );
+ DALI_TEST_EQUALS( atlas.GetOccupancyRate(), 34.f*34.f/10000.f, 0.001f, TEST_LOCATION );
+
+ Vector4 textureRect2;
+ atlas.Upload( textureRect2, gImage_50_RGBA, ImageDimensions(50, 50) );
+ DALI_TEST_EQUALS( atlas.GetOccupancyRate(), (34.f*34.f+50.f*50.f)/10000.f, 0.001f, TEST_LOCATION );
END_TEST;
}
atlas.Upload( textureRect, gImageNonExist );
Rect<int> pixelArea = TextureCoordinateToPixelArea(textureRect, size);
- DALI_TEST_EQUALS( pixelArea.width, 34.f, TEST_LOCATION );
- DALI_TEST_EQUALS( pixelArea.height, 34.f, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.width, 34, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.height, 34, TEST_LOCATION );
END_TEST;
}
unsigned int size = 200;
ImageAtlas atlas = ImageAtlas::New( size, size );
- EventThreadCallback* eventTrigger = EventThreadCallback::Get();
- CallbackBase* callback = eventTrigger->GetCallback();
-
TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
callStack.Reset();
callStack.Enable(true);
Vector4 textureRect3;
atlas.Upload( textureRect3, gImage_128_RGB, ImageDimensions(128, 128) );
+ EventThreadCallback* eventTrigger = EventThreadCallback::Get();
+ CallbackBase* callback = eventTrigger->GetCallback();
+
eventTrigger->WaitingForTrigger( 3 );// waiting until all three images are loaded
CallbackBase::Execute( *callback );
Rect<int> pixelArea1 = TextureCoordinateToPixelArea(textureRect1, size);
DALI_TEST_EQUALS( pixelArea1.width, 34, TEST_LOCATION );
DALI_TEST_EQUALS( pixelArea1.height, 34, TEST_LOCATION );
- std::stringstream out;
- out<<pixelArea1.x<<", "<<pixelArea1.y<<", "<<pixelArea1.width<<", "<<pixelArea1.height;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str()) );
+
+ TraceCallStack::NamedParams params;
+ params["width"] = ToString(pixelArea1.width);
+ params["height"] = ToString(pixelArea1.height);
+ params["xoffset"] = ToString(pixelArea1.x);
+ params["yoffset"] = ToString(pixelArea1.y);
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ));
Rect<int> pixelArea2 = TextureCoordinateToPixelArea(textureRect2, size);
DALI_TEST_EQUALS( pixelArea2.width, 50, TEST_LOCATION );
DALI_TEST_EQUALS( pixelArea2.height, 50, TEST_LOCATION );
- out.str("");
- out<<pixelArea2.x<<", "<<pixelArea2.y<<", "<<pixelArea2.width<<", "<<pixelArea2.height;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str()) );
+
+ params["width"] = ToString(pixelArea2.width);
+ params["height"] = ToString(pixelArea2.height);
+ params["xoffset"] = ToString(pixelArea2.x);
+ params["yoffset"] = ToString(pixelArea2.y);
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ) );
Rect<int> pixelArea3 = TextureCoordinateToPixelArea(textureRect3, size);
DALI_TEST_EQUALS( pixelArea3.width, 128, TEST_LOCATION );
DALI_TEST_EQUALS( pixelArea3.height, 128, TEST_LOCATION );
- out.str("");
- out<<pixelArea3.x<<", "<<pixelArea3.y<<", "<<pixelArea3.width<<", "<<pixelArea3.height;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str()) );
+
+ params["width"] = ToString(pixelArea3.width);
+ params["height"] = ToString(pixelArea3.height);
+ params["xoffset"] = ToString(pixelArea3.x);
+ params["yoffset"] = ToString(pixelArea3.y);
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", params ) );
DALI_TEST_CHECK( ! IsOverlap(pixelArea1, pixelArea2) );
DALI_TEST_CHECK( ! IsOverlap(pixelArea1, pixelArea3) );
// one pixel gap
Rect<int> pixelArea = TextureCoordinateToPixelArea(textureRect2, size);
- DALI_TEST_EQUALS( pixelArea.x, 0.f, TEST_LOCATION );
- DALI_TEST_EQUALS( pixelArea.y, 0.f, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.x, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( pixelArea.y, 0, TEST_LOCATION );
END_TEST;
}
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 34, 34" ) );
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 34, 50, 50" ) );
+ TraceCallStack::NamedParams params1;
+ params1["width"] = "34";
+ params1["height"] = "34";
+ params1["xoffset"] = "0";
+ params1["yoffset"] = "0";
+
+ TraceCallStack::NamedParams params2;
+ params2["width"] = "50";
+ params2["height"] = "50";
+ params2["xoffset"] = "0";
+ params2["yoffset"] = "34";
+
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams("TexSubImage2D", params1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams("TexSubImage2D", params2 ), true, TEST_LOCATION );
callStack.Reset();
callStack.Enable(true);
application.Render(RENDER_FRAME_INTERVAL);
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 34, 100, 100" ) );
+
+ TraceCallStack::NamedParams params3;
+ params3["width"] = "100";
+ params3["height"] = "100";
+ params3["xoffset"] = "0";
+ params3["yoffset"] = "34";
+
+ DALI_TEST_EQUALS( callStack.FindMethodAndParams("TexSubImage2D", params3 ), true, TEST_LOCATION );
END_TEST;
}