Texture mipmap support
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-controller.h
index 9179a39..1c62119 100644 (file)
@@ -21,6 +21,8 @@
 #include "test-gl-abstraction.h"
 #include "test-gl-context-helper-abstraction.h"
 #include "test-gl-sync-abstraction.h"
+#include "test-graphics-command-buffer.h"
+#include "test-graphics-program.h"
 #include "test-graphics-reflection.h"
 
 namespace Dali
@@ -35,6 +37,54 @@ std::ostream& operator<<(std::ostream& o, Graphics::SamplerFilter filterMode);
 std::ostream& operator<<(std::ostream& o, Graphics::SamplerMipmapMode mipmapMode);
 std::ostream& operator<<(std::ostream& o, const Graphics::SamplerCreateInfo& createInfo);
 
+template<typename T>
+T* Uncast(const Graphics::CommandBuffer* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Texture* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Sampler* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Buffer* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Shader* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Framebuffer* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Pipeline* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::RenderTarget* object)
+{
+  return const_cast<T*>(static_cast<const T*>(object));
+}
+
 class TestGraphicsController : public Dali::Graphics::Controller
 {
 public:
@@ -86,6 +136,16 @@ public:
   void Resume() override;
 
   /**
+   * @brief Lifecycle shutdown event
+   */
+  void Shutdown() override;
+
+  /**
+   * @brief Lifecycle destroy event
+   */
+  void Destroy() override;
+
+  /**
    * @brief Executes batch update of textures
    *
    * This function may perform full or partial update of many textures.
@@ -102,6 +162,12 @@ public:
                       const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList) override;
 
   /**
+   * Auto generates mipmaps for the texture
+   * @param[in] texture The texture
+   */
+  void GenerateTextureMipmaps(const Graphics::Texture& texture) override;
+
+  /**
    * TBD: do we need those functions in the new implementation?
    */
   bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) override;
@@ -298,6 +364,11 @@ public: // Test Functions
     mVertexFormats = vfs;
   }
 
+  void AddCustomUniforms(std::vector<UniformData>& customUniforms)
+  {
+    mCustomUniforms = customUniforms;
+  }
+
   void ClearSubmitStack()
   {
     mSubmitStack.clear();
@@ -313,11 +384,16 @@ public: // Test Functions
    * @param[out] outData Pointer to output memory
    * @return True on success
    */
-  bool GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData ) override;
+  bool GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData) override;
+
+  void ProcessCommandBuffer(TestGraphicsCommandBuffer& commandBuffer);
+
+  void BindPipeline(TestGraphicsPipeline* pipeline);
 
 public:
   mutable TraceCallStack                    mCallStack;
   mutable TraceCallStack                    mCommandBufferCallStack;
+  mutable TraceCallStack                    mFrameBufferCallStack;
   mutable std::vector<Graphics::SubmitInfo> mSubmitStack;
 
   TestGlAbstraction              mGl;
@@ -328,6 +404,19 @@ public:
   bool isDrawOnResumeRequiredResult{true};
 
   Property::Array mVertexFormats;
+
+  struct ProgramCache
+  {
+    std::map<Graphics::PipelineStage, std::vector<uint8_t>> shaders;
+    TestGraphicsProgramImpl*                                programImpl;
+  };
+  std::vector<ProgramCache> mProgramCache;
+
+  struct PipelineCache
+  {
+  };
+
+  std::vector<UniformData> mCustomUniforms;
 };
 
 } // namespace Dali