NPatch rendering optimization 57/243057/3
authoradam.b <adam.b@samsung.com>
Wed, 2 Sep 2020 21:27:52 +0000 (22:27 +0100)
committeradam.b <adam.b@samsung.com>
Thu, 3 Sep 2020 10:32:15 +0000 (11:32 +0100)
Change-Id: I6d2b95e8141c7e22d326e2f736c98f4783b829ab

automated-tests/src/dali-toolkit-internal/utc-Dali-AddOns.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/rendering-addon.h

index 195656d..bc82cac 100644 (file)
@@ -30,7 +30,7 @@ namespace
 
 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR "/application-icon-20.png";
 const char* TEST_IMAGE_FILE_NAME_9 =  TEST_RESOURCE_DIR "/heartsframe.9.png";
 
 const char* TEST_IMAGE_FILE_NAME =  TEST_RESOURCE_DIR "/application-icon-20.png";
 const char* TEST_IMAGE_FILE_NAME_9 =  TEST_RESOURCE_DIR "/heartsframe.9.png";
-
+const char* TEST_IMAGE_FILE_NAME2_9 =  TEST_RESOURCE_DIR "/button-up.9.png";
 int CountFunctionCalls( const std::vector<std::string>& callstack, const std::string& function )
 {
   int counter = 0;
 int CountFunctionCalls( const std::vector<std::string>& callstack, const std::string& function )
 {
   int counter = 0;
@@ -72,13 +72,20 @@ int UtcRenderingAddOnTestP(void)
   imageView2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
   imageView2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
   imageView2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
   imageView2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
 
+  // Load npatch image view
+  auto imageView3 = Dali::Toolkit::ImageView::New( TEST_IMAGE_FILE_NAME2_9 );
+  imageView3.SetProperty( Actor::Property::SIZE, Vector2( 400.f, 60.f ) );
+  imageView3.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  imageView3.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
   application.GetScene().Add( imageView );
   application.GetScene().Add( imageView2 );
   application.GetScene().Add( imageView );
   application.GetScene().Add( imageView2 );
+  application.GetScene().Add( imageView3 );
 
   application.SendNotification();
   application.Render();
 
 
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( ::Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
+  DALI_TEST_EQUALS( ::Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
 
   application.SendNotification();
   application.Render();
 
   application.SendNotification();
   application.Render();
@@ -87,8 +94,8 @@ int UtcRenderingAddOnTestP(void)
 
   DALI_TEST_EQUALS( CountFunctionCalls( callstack, "GetGeometry" ), 2, TEST_LOCATION);
   DALI_TEST_EQUALS( CountFunctionCalls( callstack, "CreateGeometry" ), 1, TEST_LOCATION);
 
   DALI_TEST_EQUALS( CountFunctionCalls( callstack, "GetGeometry" ), 2, TEST_LOCATION);
   DALI_TEST_EQUALS( CountFunctionCalls( callstack, "CreateGeometry" ), 1, TEST_LOCATION);
-  DALI_TEST_EQUALS( CountFunctionCalls( callstack, "CreateGeometryGrid" ), 1, TEST_LOCATION);
-  DALI_TEST_EQUALS( CountFunctionCalls( callstack, "BuildNPatch" ), 1, TEST_LOCATION);
+  DALI_TEST_EQUALS( CountFunctionCalls( callstack, "CreateGeometryGrid" ), 2, TEST_LOCATION);
+  DALI_TEST_EQUALS( CountFunctionCalls( callstack, "BuildNPatch" ), 2, TEST_LOCATION);
 
   delete addOnManager;
 
 
   delete addOnManager;
 
index 6f3231d..b8abd9b 100644 (file)
@@ -518,10 +518,10 @@ void ImageVisual::CreateRenderer( TextureSet& textureSet )
   {
     TextureManager& textureManager = mFactoryCache.GetTextureManager();
 
   {
     TextureManager& textureManager = mFactoryCache.GetTextureManager();
 
-    uint32_t opaqueElementsCount {0u};
-    uint32_t transparentElementsCount {0u};
-    geometry = textureManager.GetRenderGeometry(mTextureId, opaqueElementsCount, transparentElementsCount);
-    if(!opaqueElementsCount && !transparentElementsCount)
+    uint32_t firstElementCount {0u};
+    uint32_t secondElementCount {0u};
+    geometry = textureManager.GetRenderGeometry(mTextureId, firstElementCount, secondElementCount);
+    if(!firstElementCount && !secondElementCount)
     {
       geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
     }
     {
       geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
     }
@@ -863,28 +863,28 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur
   // use geometry if needed
   if( loadingSuccess )
   {
   // use geometry if needed
   if( loadingSuccess )
   {
-    uint32_t opaqueElements{0u};
-    uint32_t transparentElements{0u};
-    auto geometry = mFactoryCache.GetTextureManager().GetRenderGeometry(mTextureId, opaqueElements, transparentElements);
+    uint32_t firstElementCount{0u};
+    uint32_t secondElementCount{0u};
+    auto geometry = mFactoryCache.GetTextureManager().GetRenderGeometry(mTextureId, firstElementCount, secondElementCount);
     if (mImpl->mRenderer && geometry)
     {
       mImpl->mRenderer.SetGeometry(geometry);
       Dali::DevelRenderer::DrawCommand drawCommand{};
       drawCommand.drawType = DevelRenderer::DrawType::INDEXED;
 
     if (mImpl->mRenderer && geometry)
     {
       mImpl->mRenderer.SetGeometry(geometry);
       Dali::DevelRenderer::DrawCommand drawCommand{};
       drawCommand.drawType = DevelRenderer::DrawType::INDEXED;
 
-      if (opaqueElements)
+      if (firstElementCount)
       {
         drawCommand.firstIndex = 0;
       {
         drawCommand.firstIndex = 0;
-        drawCommand.elementCount = opaqueElements;
-        drawCommand.queue = 0;
+        drawCommand.elementCount = firstElementCount;
+        drawCommand.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
         DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
       }
 
         DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
       }
 
-      if (transparentElements)
+      if (secondElementCount)
       {
       {
-        drawCommand.firstIndex = opaqueElements;
-        drawCommand.elementCount = transparentElements;
-        drawCommand.queue = 1;
+        drawCommand.firstIndex = firstElementCount;
+        drawCommand.elementCount = secondElementCount;
+        drawCommand.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT;
         DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
       }
     }
         DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand);
       }
     }
index c18bddf..b954c8c 100644 (file)
@@ -496,6 +496,10 @@ Geometry NPatchVisual::CreateGeometry()
         {
           uint32_t elementCount[2];
           geometry = RenderingAddOn::Get().CreateGeometryGrid(data->renderingMap, Uint16Pair(3, 3), elementCount );
         {
           uint32_t elementCount[2];
           geometry = RenderingAddOn::Get().CreateGeometryGrid(data->renderingMap, Uint16Pair(3, 3), elementCount );
+          if( mImpl->mRenderer )
+          {
+            RenderingAddOn::Get().SubmitRenderTask(mImpl->mRenderer, data->renderingMap);
+          }
         }
         else
         {
         }
         else
         {
@@ -515,6 +519,10 @@ Geometry NPatchVisual::CreateGeometry()
         uint32_t elementCount[2];
         geometry = !mBorderOnly ?
                    RenderingAddOn::Get().CreateGeometryGrid(data->renderingMap, gridSize, elementCount ) : CreateBorderGeometry(gridSize );
         uint32_t elementCount[2];
         geometry = !mBorderOnly ?
                    RenderingAddOn::Get().CreateGeometryGrid(data->renderingMap, gridSize, elementCount ) : CreateBorderGeometry(gridSize );
+        if( mImpl->mRenderer )
+        {
+          RenderingAddOn::Get().SubmitRenderTask(mImpl->mRenderer, data->renderingMap);
+        }
       }
     }
   }
       }
     }
   }
index 5d39f97..95e3e86 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef DALI_CMAKE_RENDERING_ADDON_H
-#define DALI_CMAKE_RENDERING_ADDON_H
+#ifndef DALI_RENDERING_ADDON_H
+#define DALI_RENDERING_ADDON_H
 
 /*
 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
 
 /*
 * Copyright (c) 2020 Samsung Electronics Co., Ltd.