Added VisualRenderer (for visual default properties)
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / dali-test-suite-utils / test-graphics-buffer.cpp
index 55c7dc4..8f9b9fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
  */
 
 #include "test-graphics-buffer.h"
-#include "test-graphics-program.h"
-#include "test-graphics-reflection.h"
 #include <sstream>
 #include "dali-test-suite-utils.h"
+#include "test-graphics-program.h"
+#include "test-graphics-reflection.h"
 
 namespace Dali
 {
@@ -27,8 +27,8 @@ TestGraphicsBuffer::TestGraphicsBuffer(TraceCallStack& callStack, TestGlAbstract
   mGl(glAbstraction),
   mUsage(usage)
 {
-  memory.reserve(size);
-  mGl.GetBufferTrace().EnableLogging(true);
+  memory.resize(size);
+  mGl.GetBufferTrace().EnableLogging(false);
 }
 
 void TestGraphicsBuffer::Bind()
@@ -65,7 +65,7 @@ void TestGraphicsBuffer::Upload(uint32_t offset, uint32_t size)
   }
   else
   {
-    mGl.BufferData(GetTarget(), size, &memory[0], GL_STATIC_DRAW); //@todo Query - do we need other usages?
+    mGl.BufferData(GetTarget(), GLsizeiptr(size), &memory[0], GL_STATIC_DRAW); //@todo Query - do we need other usages?
     mCreated = true;
   }
 }
@@ -80,71 +80,70 @@ GLenum TestGraphicsBuffer::GetTarget()
   return target;
 }
 
-void TestGraphicsBuffer::BindAsUniformBuffer( const TestGraphicsProgram* program ) const
+void TestGraphicsBuffer::BindAsUniformBuffer(const TestGraphicsProgram* program, const Dali::UniformBufferBindingDescriptor& uboBinding) const
 {
   auto* reflection = static_cast<const TestGraphicsReflection*>(&program->GetReflection());
 
   Graphics::UniformBlockInfo uboInfo{};
   reflection->GetUniformBlock(0, uboInfo);
 
-  auto* data = memory.data();
+  auto  offset = uboBinding.offset;
+  auto* data   = memory.data() + offset;
 
-  for( const auto& member : uboInfo.members )
+  for(const auto& member : uboInfo.members)
   {
-    auto type = reflection->GetMemberType( 0, member.location );
+    auto type = reflection->GetMemberType(0, member.location);
     switch(type)
     {
       case Property::VECTOR4:
       {
-        auto value = *reinterpret_cast<const Dali::Vector4*>(data+member.offset);
-        mGl.Uniform4f( member.location, value.x, value.y, value.z, value.w );
+        auto value = *reinterpret_cast<const Dali::Vector4*>(data + member.offset);
+        mGl.Uniform4f(member.location, value.x, value.y, value.z, value.w);
         break;
       }
       case Property::VECTOR3:
       {
-        auto value = *reinterpret_cast<const Dali::Vector3*>(data+member.offset);
-        mGl.Uniform3f( member.location, value.x, value.y, value.z );
+        auto value = *reinterpret_cast<const Dali::Vector3*>(data + member.offset);
+        mGl.Uniform3f(member.location, value.x, value.y, value.z);
         break;
       }
       case Property::VECTOR2:
       {
-        auto value = *reinterpret_cast<const Dali::Vector2*>(data+member.offset);
-        mGl.Uniform2f( member.location, value.x, value.y );
+        auto value = *reinterpret_cast<const Dali::Vector2*>(data + member.offset);
+        mGl.Uniform2f(member.location, value.x, value.y);
         break;
       }
       case Property::FLOAT:
       {
-        auto value = *reinterpret_cast<const float*>(data+member.offset);
-        mGl.Uniform1f( member.location, value );
+        auto value = *reinterpret_cast<const float*>(data + member.offset);
+        mGl.Uniform1f(member.location, value);
         break;
       }
       case Property::INTEGER:
       {
-        auto ptr = reinterpret_cast<const GLint*>(data+member.offset);
+        auto ptr   = reinterpret_cast<const GLint*>(data + member.offset);
         auto value = *ptr;
-        mGl.Uniform1i( member.location, value );
+        mGl.Uniform1i(member.location, value);
         break;
       }
       case Property::MATRIX:
       {
-        auto value = reinterpret_cast<const float*>(data+member.offset);
-        mGl.UniformMatrix4fv( member.location, 1, GL_FALSE, value );
+        auto value = reinterpret_cast<const float*>(data + member.offset);
+        mGl.UniformMatrix4fv(member.location, 1, GL_FALSE, value);
         break;
       }
       case Property::MATRIX3:
       {
-        auto value = reinterpret_cast<const float*>(data+member.offset);
-        mGl.UniformMatrix3fv( member.location, 1, GL_FALSE, value );
+        auto value = reinterpret_cast<const float*>(data + member.offset);
+        mGl.UniformMatrix3fv(member.location, 1, GL_FALSE, value);
         break;
       }
       default:
       {
-
+        fprintf(stderr, "\n%s type not found\n", member.name.c_str());
       }
     }
   }
-
-
 }
 
 } // namespace Dali