-
-int UtcDaliImageDiscard02(void)
-{
- TestApplication application;
- application.GetGlAbstraction().EnableTextureCallTrace( true );
- tet_infoline("UtcDaliImageDiscard02 - one actor, tests TextureCache::DiscardTexture");
-
- {
- {
- Actor actor;
- {
- Image image = ResourceImage::New(gTestImageFilename, ImageDimensions( 40, 30 ) );
- actor = CreateRenderableActor(image);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
-
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
- TestPlatformAbstraction& platform = application.GetPlatform();
- LoadBitmapResource( platform );
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK( application.GetGlAbstraction().GetTextureTrace().FindMethod("BindTexture") );
- } // lose image handle, actor should still keep one
- application.SendNotification();
- application.Render(16);
-
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(16);
- } // lose actor
- application.SendNotification();
- application.Render(16);
- }
-
- // Cleanup
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- // texture should have been removed:
- DALI_TEST_CHECK( application.GetGlAbstraction().CheckTextureDeleted( 23 ));
- END_TEST;
-}
-
-int UtcDaliImageDiscard03(void)
-{
- TestApplication application;
- tet_infoline("UtcDaliImageDiscard03 - one actor, tests TextureCache::RemoveObserver");
-
- const Vector2 closestImageSize( 1, 1);
- application.GetPlatform().SetClosestImageSize(closestImageSize);
-
- Image image = ResourceImage::New(gTestImageFilename);
- Actor actor = CreateRenderableActor(image);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
-
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
- TestPlatformAbstraction& platform = application.GetPlatform();
- LoadBitmapResource( platform );
- application.Render(16);
- application.SendNotification();
- application.SendNotification();
- application.Render(16);
-
- const std::vector<GLuint>& texIds = application.GetGlAbstraction().GetNextTextureIds();
- DALI_TEST_CHECK( texIds.size() == 0 );
- const std::vector<GLuint>& boundTexIds = application.GetGlAbstraction().GetBoundTextures();
- DALI_TEST_CHECK( boundTexIds[0] == 23 );
-
- Stage::GetCurrent().Remove(actor);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16); // Should remove image renderer
-
- END_TEST;
-}
-
-int UtcDaliImageContextLoss(void)
-{
- TestApplication application; // Default config: DALI_DISCARDS_ALL_DATA
-
- const Vector2 closestImageSize( 80, 80 );
- TestPlatformAbstraction& platform = application.GetPlatform();
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-
- platform.SetClosestImageSize(closestImageSize);
-
- tet_infoline("UtcDaliImageContextLoss - Load image with LoadPolicy::Immediate, ReleasePolicy::Never, bitmap discard. Check that the image is re-requested on context regain\n");
-
- Image image = ResourceImage::New("image.png", ResourceImage::IMMEDIATE, Image::NEVER);
-
- DALI_TEST_CHECK( image );
-
- application.SendNotification();
- application.Render(16);
-
- // request file loading immediately
-
- DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
- Actor actor = CreateRenderableActor(image);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render(16);
-
- TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
- textureTrace.Enable(true);
-
- std::vector<GLuint> ids;
- ids.push_back( 23 );
- glAbstraction.SetNextTextureIds( ids );
-
- LoadBitmapResource(platform);
-
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( textureTrace.FindMethod("GenTextures") );
-
- textureTrace.Reset();
- textureTrace.Enable(true);
- platform.ResetTrace();
- platform.EnableTrace(true);
-
- // Lose & regain context (in render 'thread')
- application.ResetContext();
-
- application.GetCore().RecoverFromContextLoss(); // start the recovery process
- application.SendNotification();
-
- // Run update/render loop
- application.Render(16);
- application.SendNotification();
-
- // Expect new load request
- DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
- // Finish loading image
- LoadBitmapResource(platform);
- ids.clear();
- ids.push_back( 57 );
- glAbstraction.SetNextTextureIds(ids);
-
- // Run update/render loop
- application.Render(16);
- application.SendNotification();
-
- // Expect new GenTextures
- DALI_TEST_CHECK( textureTrace.FindMethod("GenTextures") );
-
- END_TEST;
-}