Added Graphics API classes and helper types.
authorFrancisco Santos <f1.santos@samsung.com>
Thu, 16 Mar 2017 19:03:21 +0000 (19:03 +0000)
committerFrancisco Santos <f1.santos@samsung.com>
Thu, 6 Apr 2017 13:18:07 +0000 (14:18 +0100)
Change-Id: I4e4077a956831738ace63ce819992b1079aea134

32 files changed:
automated-tests/src/dali-graphics/CMakeLists.txt
automated-tests/src/dali-graphics/graphics-test-implementation/graphics-test-implementation.cpp [new file with mode: 0644]
automated-tests/src/dali-graphics/graphics-test-implementation/graphics-test-implementation.h [new file with mode: 0644]
automated-tests/src/dali-graphics/utc-Dali-Graphics-API-texture.cpp
automated-tests/src/dali-graphics/utc-Dali-Graphics-API.cpp
automated-tests/src/dali-graphics/utc-Dali-Graphics-Manager.cpp
automated-tests/src/dali-graphics/utc-Dali-Graphics-object-owner.cpp [new file with mode: 0644]
dali/graphics-api/graphics-api-accessor.h [new file with mode: 0644]
dali/graphics-api/graphics-api-base-factory.h [new file with mode: 0644]
dali/graphics-api/graphics-api-base-object-owner.h [new file with mode: 0644]
dali/graphics-api/graphics-api-controller.h [new file with mode: 0644]
dali/graphics-api/graphics-api-dynamic-buffer.h [moved from dali/graphics-api/graphics-api-handle.h with 52% similarity]
dali/graphics-api/graphics-api-framebuffer-factory.h [new file with mode: 0644]
dali/graphics-api/graphics-api-framebuffer.h [new file with mode: 0644]
dali/graphics-api/graphics-api-generic-buffer.h [new file with mode: 0644]
dali/graphics-api/graphics-api-render-item-list.h [new file with mode: 0644]
dali/graphics-api/graphics-api-render-list.h [new file with mode: 0644]
dali/graphics-api/graphics-api-sampler.h [new file with mode: 0644]
dali/graphics-api/graphics-api-shader-details.h [moved from dali/graphics/graphics-manager.cpp with 54% similarity]
dali/graphics-api/graphics-api-shader-factory.h [new file with mode: 0644]
dali/graphics-api/graphics-api-shader.h [new file with mode: 0644]
dali/graphics-api/graphics-api-static-buffer.h [moved from dali/graphics/graphics-manager.h with 53% similarity]
dali/graphics-api/graphics-api-texture-details.h [new file with mode: 0644]
dali/graphics-api/graphics-api-texture-factory.h [new file with mode: 0644]
dali/graphics-api/graphics-api-texture-set.h [moved from dali/graphics-api/graphics-api-manager.h with 65% similarity]
dali/graphics-api/graphics-api-texture.h
dali/graphics-api/graphics-api-utility.h
dali/graphics/file.list
dali/graphics/graphics-controller.cpp [new file with mode: 0644]
dali/graphics/graphics-controller.h [new file with mode: 0644]
dali/graphics/graphics-object-owner.h [new file with mode: 0644]
dali/internal/update/manager/update-manager.cpp

index 309769b..2e7a919 100644 (file)
@@ -7,6 +7,11 @@ SET(CAPI_LIB "dali-internal")
 
 SET(TC_SOURCES
   utc-Dali-Graphics-API.cpp
+  utc-Dali-Graphics-object-owner.cpp
+)
+
+LIST(APPEND TC_SOURCES
+  graphics-test-implementation/graphics-test-implementation.cpp
 )
 
 LIST(APPEND TC_SOURCES
diff --git a/automated-tests/src/dali-graphics/graphics-test-implementation/graphics-test-implementation.cpp b/automated-tests/src/dali-graphics/graphics-test-implementation/graphics-test-implementation.cpp
new file mode 100644 (file)
index 0000000..41281b7
--- /dev/null
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include "graphics-test-implementation.h"
+
+namespace Dali
+{
+
+namespace Graphics
+{
+namespace Test
+{
+
+API::Accessor< API::Shader > Controller::CreateShader(
+    const API::BaseFactory< API::Shader >& factory)
+{
+  auto handle = mShaders.CreateObject(factory);
+  return API::Accessor< API::Shader >{mShaders, handle};
+}
+
+API::Accessor< API::Texture > Controller::CreateTexture(
+    const API::BaseFactory< API::Texture >& factory)
+{
+  auto handle = mTextures.CreateObject(factory);
+  return API::Accessor< API::Texture >{mTextures, handle};
+}
+
+API::Accessor< API::TextureSet > Controller::CreateTextureSet(
+    const API::BaseFactory< API::TextureSet >& factory)
+{
+  auto handle = mTextureSets.CreateObject(factory);
+  return API::Accessor< API::TextureSet >{mTextureSets, handle};
+}
+
+API::Accessor< API::DynamicBuffer > Controller::CreateDynamicBuffer(
+    const API::BaseFactory< API::DynamicBuffer >& factory)
+{
+  auto handle = mDynamicBuffers.CreateObject(factory);
+  return API::Accessor< API::DynamicBuffer >{mDynamicBuffers, handle};
+}
+
+API::Accessor< API::StaticBuffer > Controller::CreateStaticBuffer(
+    const API::BaseFactory< API::StaticBuffer >& factory)
+{
+  auto handle = mStaticBuffers.CreateObject(factory);
+  return API::Accessor< API::StaticBuffer >{mStaticBuffers, handle};
+}
+
+API::Accessor< API::Sampler > Controller::CreateSampler(
+    const API::BaseFactory< API::Sampler >& factory)
+{
+  auto handle = mSamplers.CreateObject(factory);
+  return API::Accessor< API::Sampler >{mSamplers, handle};
+}
+
+API::Accessor< API::Framebuffer > Controller::CreateFramebuffer(
+    const API::BaseFactory< API::Framebuffer >& factory)
+{
+  auto handle = mFramebuffers.CreateObject(factory);
+  return API::Accessor< API::Framebuffer >{mFramebuffers, handle};
+}
+
+void Controller::GetRenderItemList()
+{
+}
+
+} // namespace Test
+} // namespace Graphics
+} // namespace Dali
diff --git a/automated-tests/src/dali-graphics/graphics-test-implementation/graphics-test-implementation.h b/automated-tests/src/dali-graphics/graphics-test-implementation/graphics-test-implementation.h
new file mode 100644 (file)
index 0000000..36f5a2e
--- /dev/null
@@ -0,0 +1,129 @@
+#ifndef DALI_GRAPHICS_TEST_IMPLEMENTATION_H
+#define DALI_GRAPHICS_TEST_IMPLEMENTATION_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/graphics-api/graphics-api-base-factory.h>
+#include <dali/graphics-api/graphics-api-controller.h>
+#include <dali/graphics/graphics-object-owner.h>
+
+namespace Dali
+{
+
+namespace Graphics
+{
+namespace Test
+{
+
+template< typename T, typename BaseT >
+struct FactoryImpl : public API::BaseFactory< BaseT >
+{
+  FactoryImpl() = default;
+
+  virtual typename API::BaseFactory< BaseT >::PointerType Create() const override
+  {
+    return typename API::BaseFactory< BaseT >::PointerType{new T{}};
+  }
+
+  FactoryImpl(const FactoryImpl&) = delete;
+  FactoryImpl& operator=(const FactoryImpl&) = delete;
+
+  FactoryImpl(FactoryImpl&&) = default;
+  FactoryImpl& operator=(FactoryImpl&&) = default;
+
+  virtual ~FactoryImpl() = default;
+};
+
+struct Shader final : public API::Shader
+{
+};
+using ShaderFactory = FactoryImpl< Shader, API::Shader >;
+
+struct Texture final : public API::Texture
+{
+};
+using TextureFactory = FactoryImpl< Texture, API::Texture >;
+
+struct TextureSet final : public API::TextureSet
+{
+  virtual void AddTexture(const API::Accessor<API::Texture>& ) override {}
+};
+using TextureSetFactory = FactoryImpl< TextureSet, API::TextureSet >;
+
+struct DynamicBuffer final : public API::DynamicBuffer
+{
+};
+using DynamicBufferFactory = FactoryImpl< DynamicBuffer, API::DynamicBuffer >;
+
+struct StaticBuffer final : public API::StaticBuffer
+{
+};
+using StaticBufferFactory = FactoryImpl< StaticBuffer, API::StaticBuffer >;
+
+struct Sampler final : public API::Sampler
+{
+};
+using SamplerFactory = FactoryImpl< Sampler, API::Sampler >;
+
+struct Framebuffer final : public API::Framebuffer
+{
+};
+using FramebufferFactory = FactoryImpl< Framebuffer, API::Framebuffer >;
+
+class Controller final : public API::Controller
+{
+public:
+  virtual API::Accessor< API::Shader > CreateShader(
+      const API::BaseFactory< API::Shader >& factory) override;
+
+  virtual API::Accessor< API::Texture > CreateTexture(
+      const API::BaseFactory< API::Texture >& factory) override;
+
+  virtual API::Accessor< API::TextureSet > CreateTextureSet(
+      const API::BaseFactory< API::TextureSet >& factory) override;
+
+  virtual API::Accessor< API::DynamicBuffer > CreateDynamicBuffer(
+      const API::BaseFactory< API::DynamicBuffer >& factory) override;
+
+  virtual API::Accessor< API::StaticBuffer > CreateStaticBuffer(
+      const API::BaseFactory< API::StaticBuffer >& factory) override;
+
+  virtual API::Accessor< API::Sampler > CreateSampler(
+      const API::BaseFactory< API::Sampler >& factory) override;
+
+  virtual API::Accessor< API::Framebuffer > CreateFramebuffer(
+      const API::BaseFactory< API::Framebuffer >& factory) override;
+
+  virtual void GetRenderItemList() override;
+
+private:
+  ObjectOwner< API::Shader >        mShaders;
+  ObjectOwner< API::Texture >       mTextures;
+  ObjectOwner< API::TextureSet >    mTextureSets;
+  ObjectOwner< API::DynamicBuffer > mDynamicBuffers;
+  ObjectOwner< API::StaticBuffer >  mStaticBuffers;
+  ObjectOwner< API::Sampler >       mSamplers;
+  ObjectOwner< API::Framebuffer >   mFramebuffers;
+};
+
+} // namespace Test
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_TEST_IMPLEMENTATION_H
index 7f4cee5..213172a 100644 (file)
 
 using Dali::Graphics::API::Texture;
 
-void utc_dali_internal_memorypoolobjectallocator_startup(void)
+void utc_dali_graphics_api_textures_startup(void)
 {
   test_return_value = TET_UNDEF;
 }
 
-void utc_dali_internal_memorypoolobjectallocator_cleanup(void)
+void utc_dali_graphics_api_textures_cleanup(void)
 {
   test_return_value = TET_PASS;
 }
@@ -46,7 +46,7 @@ public:
 
 } // namespace
 
-int UtcDaliGraphicsAPI(void)
+int UtcDaliGraphicsAPITextures(void)
 {
   TestTexture testTexture;
 
index 361fd2d..24a5906 100644 (file)
  */
 
 #include <dali-test-suite-utils.h>
-#include <dali/graphics-api/graphics-api-manager.h>
 
-using Dali::Graphics::API::Manager;
+#include "graphics-test-implementation/graphics-test-implementation.h"
 
-void utc_dali_internal_memorypoolobjectallocator_startup(void)
+using namespace Dali::Graphics::Test;
+
+void utc_dali_graphics_api_startup(void)
 {
   test_return_value = TET_UNDEF;
 }
 
-void utc_dali_internal_memorypoolobjectallocator_cleanup(void)
+void utc_dali_graphics_api_cleanup(void)
 {
   test_return_value = TET_PASS;
 }
 
-namespace
+int UtcDaliGraphicsAPI(void)
 {
+  auto controller = Controller{};
+
+  // Just test construction of controller
+  DALI_TEST_CHECK(true);
+
+  END_TEST;
+}
 
-class TestManager : public Manager
+int UtcDaliGraphicsAPICreateShader(void)
 {
-public:
-  virtual int GetNumber() const override
-  {
-    return 42;
-  }
-};
+  auto controller = Controller {};
 
-} // namespace
+  auto factory = ShaderFactory {};
+  auto accessor = controller.CreateShader(factory);
+  DALI_TEST_CHECK(accessor.Exists());
 
-int UtcDaliGraphicsAPI(void)
+  END_TEST;
+}
+
+int UtcDaliGraphicsAPICreateTexture(void)
 {
-  TestManager testManager;
+  auto controller = Controller {};
+
+  auto factory = TextureFactory {};
+  auto accessor = controller.CreateTexture(factory);
+  DALI_TEST_CHECK(accessor.Exists());
+
+  END_TEST;
+}
+
+int UtcDaliGraphicsAPICreateTextureSet(void)
+{
+  auto controller = Controller {};
+
+  auto factory = TextureSetFactory {};
+  auto accessor = controller.CreateTextureSet(factory);
+  DALI_TEST_CHECK(accessor.Exists());
+
+  END_TEST;
+}
 
-  auto n = testManager.GetNumber();
+int UtcDaliGraphicsAPICreateDynamicBuffer(void)
+{
+  auto controller = Controller {};
+
+  auto factory = DynamicBufferFactory {};
+  auto accessor = controller.CreateDynamicBuffer(factory);
+  DALI_TEST_CHECK(accessor.Exists());
+
+  END_TEST;
+}
+
+int UtcDaliGraphicsAPICreateStaticBuffer(void)
+{
+  auto controller = Controller {};
+
+  auto factory = StaticBufferFactory {};
+  auto accessor = controller.CreateStaticBuffer(factory);
+  DALI_TEST_CHECK(accessor.Exists());
+
+  END_TEST;
+}
+
+int UtcDaliGraphicsAPICreateSampler(void)
+{
+  auto controller = Controller {};
+
+  auto factory = SamplerFactory {};
+  auto accessor = controller.CreateSampler(factory);
+  DALI_TEST_CHECK(accessor.Exists());
+
+  END_TEST;
+}
+
+int UtcDaliGraphicsAPICreateFramebuffer(void)
+{
+  auto controller = Controller {};
 
-  DALI_TEST_EQUALS(n, 42, TEST_LOCATION);
+  auto factory = FramebufferFactory {};
+  auto accessor = controller.CreateFramebuffer(factory);
+  DALI_TEST_CHECK(accessor.Exists());
 
   END_TEST;
 }
index 1920e2c..36ddbce 100644 (file)
  */
 
 #include <dali-test-suite-utils.h>
-#include <dali/graphics/graphics-manager.h>
+#include <dali/graphics/graphics-controller.h>
 
 using Dali::Graphics::Manager;
 
-void utc_dali_internal_memorypoolobjectallocator_startup(void)
+void utc_dali_graphics_manager_startup(void)
 {
   test_return_value = TET_UNDEF;
 }
 
-void utc_dali_internal_memorypoolobjectallocator_cleanup(void)
+void utc_dali_graphics_manager_cleanup(void)
 {
   test_return_value = TET_PASS;
 }
diff --git a/automated-tests/src/dali-graphics/utc-Dali-Graphics-object-owner.cpp b/automated-tests/src/dali-graphics/utc-Dali-Graphics-object-owner.cpp
new file mode 100644 (file)
index 0000000..0f73dbe
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <memory>
+
+#include <dali-test-suite-utils.h>
+#include <dali/graphics/graphics-object-owner.h>
+
+using namespace Dali::Graphics;
+
+void utc_dali_graphics_api_handle_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_graphics_api_handle_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+struct TestType final
+{
+  /**
+   * @brief default conmstructor
+   */
+  TestType() = default;
+
+  /**
+   * @brief constructor
+   */
+  constexpr TestType(int value) : mValue(value)
+  {
+  }
+
+  //data
+  int mValue = 0;
+};
+
+struct TestTypeFactory final : public API::BaseFactory< TestType >
+{
+  virtual typename API::BaseFactory< TestType >::PointerType Create() const override
+  {
+    return typename API::BaseFactory< TestType >::PointerType{new TestType{42}};
+  }
+};
+
+} // namespace
+
+int UtcDaliGraphicsAPIHandle(void)
+{
+  ObjectOwner< TestType > objectOwner;
+
+  auto handle = objectOwner.CreateObject(TestTypeFactory{});
+  DALI_TEST_EQUALS(handle, 0, TEST_LOCATION);
+
+  auto value = objectOwner[handle].mValue;
+
+  DALI_TEST_CHECK(value == 42);
+
+  END_TEST;
+}
diff --git a/dali/graphics-api/graphics-api-accessor.h b/dali/graphics-api/graphics-api-accessor.h
new file mode 100644 (file)
index 0000000..8f69225
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef DALI_GRAPHICS_API_ACCESSOR_H
+#define DALI_GRAPHICS_API_ACCESSOR_H
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+#include <dali/graphics/graphics-object-owner.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+template< typename T >
+class Accessor
+{
+public:
+  Accessor(ObjectOwner< T >& owner, typename ObjectOwner< T >::Handle handle)
+  : mOwner(owner),  // save owner to access object
+    mHandle(handle) // handle to the object
+  {
+  }
+
+  bool Exists() const
+  {
+    return mOwner.Contains(mHandle);
+  }
+  operator bool() const
+  {
+    return Exists();
+  }
+
+  T& Get()
+  {
+    return mOwner[mHandle];
+  }
+
+  const T& Get() const
+  {
+    return mOwner[mHandle];
+  }
+
+  Accessor(const Accessor&) = default;
+  Accessor& operator=(const Accessor&) = default;
+
+  Accessor(Accessor&&) = default;
+  Accessor& operator=(Accessor&&) = default;
+
+private:
+  ObjectOwner< T >&                 mOwner;
+  typename ObjectOwner< T >::Handle mHandle;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_ACCESSOR_H
diff --git a/dali/graphics-api/graphics-api-base-factory.h b/dali/graphics-api/graphics-api-base-factory.h
new file mode 100644 (file)
index 0000000..f9cb189
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef DALI_GRAPHICS_API_BASE_FACTORY_H
+#define DALI_GRAPHICS_API_BASE_FACTORY_H
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+#include <tuple>
+#include <utility>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+template< typename T, typename... Params >
+class BaseFactory
+{
+public:
+  using Type        = T;
+  using PointerType = std::unique_ptr< T >;
+
+  BaseFactory(Params&&... params) : mParams(std::forward< Params >(params)...)
+  {
+  }
+  virtual ~BaseFactory() = default;
+
+  virtual PointerType Create(const Params&...) const = 0;
+
+protected:
+  BaseFactory(const BaseFactory&) = delete;
+  BaseFactory& operator=(const BaseFactory&) = delete;
+
+  BaseFactory(BaseFactory&&) = default;
+  BaseFactory& operator=(BaseFactory&&) = default;
+
+private:
+  std::tuple< Params... > mParams;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_BASE_FACTORY_H
diff --git a/dali/graphics-api/graphics-api-base-object-owner.h b/dali/graphics-api/graphics-api-base-object-owner.h
new file mode 100644 (file)
index 0000000..e51f267
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef DALI_GRAPHICS_API_BASE_OBJECT_OWNER_H
+#define DALI_GRAPHICS_API_BASE_OBJECT_OWNER_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cassert>
+#include <memory>
+#include <unordered_map>
+#include <utility>
+
+#include <dali/graphics-api/graphics-api-base-factory.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+template< typename T >
+class ObjectOwnerBase
+{
+public:
+  using Handle = size_t;
+
+  /**
+   * @brief Create an new object using the provided factory and store it.
+   *
+   * @param[in] factory Factory that will be used to create the object\
+   * @return Handle that identifies the object
+   */
+  virtual Handle CreateObject(const BaseFactory< T >& factory) = 0;
+
+  // @brief default constructor
+  ObjectOwnerBase() = default;
+
+  // @brief virtual destructor
+  virtual ~ObjectOwnerBase() = default;
+
+  // delete copy constructor/assignment
+  ObjectOwnerBase(const ObjectOwnerBase&) = delete;
+  ObjectOwnerBase& operator=(const ObjectOwnerBase&) = delete;
+
+protected:
+  // protected move constructor/assignment
+  ObjectOwnerBase(ObjectOwnerBase&&) = default;
+  ObjectOwnerBase& operator=(ObjectOwnerBase&&) = default;
+};
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_BASE_OBJECT_OWNER_H
diff --git a/dali/graphics-api/graphics-api-controller.h b/dali/graphics-api/graphics-api-controller.h
new file mode 100644 (file)
index 0000000..cfb48d0
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef DALI_GRAPHICS_API_CONTROLLER_H
+#define DALI_GRAPHICS_API_CONTROLLER_H
+
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/graphics-api/graphics-api-accessor.h>
+#include <dali/graphics-api/graphics-api-base-factory.h>
+#include <dali/graphics-api/graphics-api-dynamic-buffer.h>
+#include <dali/graphics-api/graphics-api-framebuffer.h>
+#include <dali/graphics-api/graphics-api-sampler.h>
+#include <dali/graphics-api/graphics-api-shader.h>
+#include <dali/graphics-api/graphics-api-static-buffer.h>
+#include <dali/graphics-api/graphics-api-texture-set.h>
+#include <dali/graphics-api/graphics-api-texture.h>
+#include <dali/graphics-api/graphics-api-texture-factory.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for Manager types in the graphics API.
+ */
+class Controller
+{
+public:
+  /**
+   * @brief Create a new object
+   */
+  virtual Accessor< Shader > CreateShader(const BaseFactory< Shader >& factory) = 0;
+
+  /**
+   * @brief Create a new object
+   */
+  virtual Accessor< Texture > CreateTexture(const BaseFactory< Texture >& factory) = 0;
+
+  /**
+   * @brief Create a new object
+   */
+  virtual Accessor< TextureSet > CreateTextureSet(const BaseFactory< TextureSet >& factory) = 0;
+
+  /**
+   * @brief Create a new object
+   */
+  virtual Accessor< DynamicBuffer > CreateDynamicBuffer(
+      const BaseFactory< DynamicBuffer >& factory) = 0;
+
+  /**
+   * @brief Create a new object
+   */
+  virtual Accessor< StaticBuffer > CreateStaticBuffer(
+      const BaseFactory< StaticBuffer >& factory) = 0;
+
+  /**
+   * @brief Create a new object
+   */
+  virtual Accessor< Sampler > CreateSampler(const BaseFactory< Sampler >& factory) = 0;
+
+  /**
+   * @brief Create a new object
+   */
+  virtual Accessor< Framebuffer > CreateFramebuffer(const BaseFactory< Framebuffer >& factory) = 0;
+
+  /**
+   * @brief Get a render list
+   */
+  virtual void GetRenderItemList() = 0;
+
+public:
+  // not copyable
+  Controller(const Controller&) = delete;
+  Controller& operator=(const Controller&) = delete;
+
+  virtual ~Controller() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  Controller(Controller&&) = default;
+  Controller& operator=(Controller&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  Controller() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_CONTROLLER_H
similarity index 52%
rename from dali/graphics-api/graphics-api-handle.h
rename to dali/graphics-api/graphics-api-dynamic-buffer.h
index 13d3722..d276609 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef DALI_GRAPHICS_API_HANDLE_H
-#define DALI_GRAPHICS_API_HANDLE_H
+#ifndef DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
+#define DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
 
 /*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -18,9 +18,6 @@
  *
  */
 
-// EXTERNAL INCLUDES
-#include <memory>
-
 namespace Dali
 {
 namespace Graphics
@@ -28,48 +25,31 @@ namespace Graphics
 namespace API
 {
 
-template< typename T >
-class Handle
+/**
+ * @brief Interface class for DynamicBuffer types in the graphics API.
+ */
+class DynamicBuffer
 {
 public:
-  constexpr Handle(T& reference) : mObject(reference)
-  {
-  }
-
-  Handle(const Handle&) = default;
-  Handle& operator=(const Handle&) = default;
-
-  Handle(Handle&&) = default;
-  Handle& operator=(Handle&&) = default;
-
-  ~Handle() = default;
-
-  T* operator->()
-  {
-    return &mObject;
-  }
-
-  constexpr const T* operator->() const
-  {
-    return &mObject;
-  }
+  // not copyable
+  DynamicBuffer(const DynamicBuffer&) = delete;
+  DynamicBuffer& operator=(const DynamicBuffer&) = delete;
 
-  T& operator()()
-  {
-    return mObject;
-  }
+  virtual ~DynamicBuffer() = default;
 
-  constexpr const T& operator()() const
-  {
-    return mObject;
-  }
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  DynamicBuffer(DynamicBuffer&&) = default;
+  DynamicBuffer& operator=(DynamicBuffer&&) = default;
 
-private:
-  T& mObject;
+  /**
+   * Objects of this type should not directly.
+   */
+  DynamicBuffer() = default;
 };
 
 } // namespace API
 } // namespace Graphics
 } // namespace Dali
 
-#endif // DALI_GRAPHICS_API_HANDLE_H
+#endif // DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
diff --git a/dali/graphics-api/graphics-api-framebuffer-factory.h b/dali/graphics-api/graphics-api-framebuffer-factory.h
new file mode 100644 (file)
index 0000000..011f6b1
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef DALI_GRAPHICS_API_FRAMEBUFFER_FACTORY_H
+#define DALI_GRAPHICS_API_FRAMEBUFFER_FACTORY_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/graphics-api/graphics-api-base-factory.h>
+#include <dali/graphics-api/graphics-api-texture-details.h>
+#include <dali/graphics-api/graphics-api-texture.h>
+#include <dali/graphics-api/graphics-api-utility.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for FramebufferFactory types in the graphics API.
+ */
+class FramebufferFactory : BaseFactory< Framebuffer >
+{
+public:
+  /**
+   * @brief Set the size of framebuffer
+   */
+  virtual void SetSize(const RectSize& size) = 0;
+
+  /**
+   *@brief Set a color attachment texture on the framebuffer
+   */
+  virtual void SetColorAttachment(TextureDetails::AttachmentId attachment,
+                                  const Texture&               texture,
+                                  TextureDetails::LayerId      layer,
+                                  TextureDetails::LevelId      level) = 0;
+
+  /**
+   * @brief Set the depth stencil flags on the framebuffer
+   */
+  virtual void SetDepthStencilFlag(TextureDetails::DepthStencilFlag depthStencilFlag) = 0;
+
+  // not copyable
+  FramebufferFactory(const FramebufferFactory&) = delete;
+  FramebufferFactory& operator=(const FramebufferFactory&) = delete;
+
+  virtual ~FramebufferFactory() = default;
+
+protected:
+  /// @brief default constructor
+  FramebufferFactory() = default;
+
+  // derived types should not be moved direcly to prevent slicing
+  FramebufferFactory(FramebufferFactory&&) = default;
+  FramebufferFactory& operator=(FramebufferFactory&&) = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_FRAMEBUFFER_FACTORY_H
diff --git a/dali/graphics-api/graphics-api-framebuffer.h b/dali/graphics-api/graphics-api-framebuffer.h
new file mode 100644 (file)
index 0000000..1f710d0
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef DALI_GRAPHICS_API_FRAMEBUFFER_H
+#define DALI_GRAPHICS_API_FRAMEBUFFER_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for Framebuffer types in the graphics API.
+ */
+class Framebuffer
+{
+public:
+  // not copyable
+  Framebuffer(const Framebuffer&) = delete;
+  Framebuffer& operator=(const Framebuffer&) = delete;
+
+  virtual ~Framebuffer() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  Framebuffer(Framebuffer&&) = default;
+  Framebuffer& operator=(Framebuffer&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  Framebuffer() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_FRAMEBUFFER_H
diff --git a/dali/graphics-api/graphics-api-generic-buffer.h b/dali/graphics-api/graphics-api-generic-buffer.h
new file mode 100644 (file)
index 0000000..65b11d8
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef DALI_GRAPHICS_API_GENERIC_BUFFER_H
+#define DALI_GRAPHICS_API_GENERIC_BUFFER_H
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <vector>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for GenericBuffer types in the graphics API.
+ */
+template< typename Base, typename Structure >
+class GenericBuffer final : public Base
+{
+public:
+  GenericBuffer(size_t size) = default;
+
+  // not copyable
+  GenericBuffer(const GenericBuffer&) = delete;
+  GenericBuffer& operator=(const GenericBuffer&) = delete;
+
+  virtual ~GenericBuffer() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  GenericBuffer(GenericBuffer&&) = default;
+  GenericBuffer& operator=(GenericBuffer&&) = default;
+
+private:
+
+  std::vector< Structure > mData;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_GENERIC_BUFFER_H
diff --git a/dali/graphics-api/graphics-api-render-item-list.h b/dali/graphics-api/graphics-api-render-item-list.h
new file mode 100644 (file)
index 0000000..d7a6ed8
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
+#define DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Class that represents a list of RenderItems
+ */
+class RenderItemList
+{
+public:
+  template< typename Structure >
+  void CreateInstanceBuffer();
+
+  // not copyable
+  RenderItemList(const RenderItemList&) = delete;
+  RenderItemList& operator=(const RenderItemList&) = delete;
+
+  virtual ~RenderItemList() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  RenderItemList(RenderItemList&&) = default;
+  RenderItemList& operator=(RenderItemList&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  RenderItemList() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
diff --git a/dali/graphics-api/graphics-api-render-list.h b/dali/graphics-api/graphics-api-render-list.h
new file mode 100644 (file)
index 0000000..b62feff
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef DALI_GRAPHICS_API_RENDER_LIST_H
+#define DALI_GRAPHICS_API_RENDER_LIST_H
+
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for RenderList types in the graphics API.
+ */
+class RenderList
+{
+public:
+  using Handle = size_t;
+
+  virtual void SetRenderItemData(size_t index) = 0;
+
+  // not copyable
+  RenderList(const RenderList&) = delete;
+  RenderList& operator=(const RenderList&) = delete;
+
+  virtual ~RenderList() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  RenderList(RenderList&&) = default;
+  RenderList& operator=(RenderList&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  RenderList() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_RENDER_LIST_H
diff --git a/dali/graphics-api/graphics-api-sampler.h b/dali/graphics-api/graphics-api-sampler.h
new file mode 100644 (file)
index 0000000..c270a4c
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef DALI_GRAPHICS_API_SAMPLER_H
+#define DALI_GRAPHICS_API_SAMPLER_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for Sampler types in the graphics API.
+ */
+class Sampler
+{
+public:
+  // not copyable
+  Sampler(const Sampler&) = delete;
+  Sampler& operator=(const Sampler&) = delete;
+
+  virtual ~Sampler() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  Sampler(Sampler&&) = default;
+  Sampler& operator=(Sampler&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  Sampler() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_SAMPLER_H
similarity index 54%
rename from dali/graphics/graphics-manager.cpp
rename to dali/graphics-api/graphics-api-shader-details.h
index aa44675..3940c5d 100644 (file)
@@ -1,5 +1,8 @@
+#ifndef DALI_GRAPHICS_API_TEXTURE_DETAILS_H
+#define DALI_GRAPHICS_API_TEXTURE_DETAILS_H
+
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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 <dali/graphics/graphics-manager.h>
-
+#include <string>
 
 namespace Dali
 {
 namespace Graphics
 {
-
-int Manager::GetNumber() const
+namespace API
 {
-  return 42;
-}
+namespace ShaderDetails
+{
+
+using ShaderSource = std::string;
+
+enum class Language {
+  GLSL_1,
+  GLSL_3_1,
+  GLSL_3_2,
+  SPIRV_1_0,
+  SPIRV_1_1,
+};
 
+enum class PipelineStage {
+  VERTEX,
+  GEOMETRY,
+  FRAGMENT,
+  COMPUTE,
+  TESSELATION_CONTROL,
+  TESSELATION_EVALUATION,
+};
 
+} // namespace TextureDetails
+} // namespace API
 } // namespace Graphics
 } // namespace Dali
 
+#endif // DALI_GRAPHICS_API_TEXTURE_DETAILS_H
diff --git a/dali/graphics-api/graphics-api-shader-factory.h b/dali/graphics-api/graphics-api-shader-factory.h
new file mode 100644 (file)
index 0000000..fd8011c
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef DALI_GRAPHICS_API_SHADER_FACTORY_H
+#define DALI_GRAPHICS_API_SHADER_FACTORY_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/graphics-api/graphics-api-base-factory.h>
+#include <dali/graphics-api/graphics-api-shader-details.h>
+#include <dali/graphics-api/graphics-api-shader.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for ShaderFactory types in the graphics API.
+ */
+class ShaderFactory : BaseFactory< Shader >
+{
+public:
+  /**
+   * @brief Set the source for a pipeline stage
+   */
+  virtual void SetSize(ShaderDetails::PipelineStage       pipelineStage,
+                       ShaderDetails::Language            language,
+                       const ShaderDetails::ShaderSource& source) = 0;
+
+  // not copyable
+  ShaderFactory(const ShaderFactory&) = delete;
+  ShaderFactory& operator=(const ShaderFactory&) = delete;
+
+  virtual ~ShaderFactory() = default;
+
+protected:
+  /// @brief default constructor
+  ShaderFactory() = default;
+
+  // derived types should not be moved direcly to prevent slicing
+  ShaderFactory(ShaderFactory&&) = default;
+  ShaderFactory& operator=(ShaderFactory&&) = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_SHADER_FACTORY_H
diff --git a/dali/graphics-api/graphics-api-shader.h b/dali/graphics-api/graphics-api-shader.h
new file mode 100644 (file)
index 0000000..5e93086
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef DALI_GRAPHICS_API_SHADER_H
+#define DALI_GRAPHICS_API_SHADER_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for Shader types in the graphics API.
+ */
+class Shader
+{
+public:
+  // not copyable
+  Shader(const Shader&) = delete;
+  Shader& operator=(const Shader&) = delete;
+
+  virtual ~Shader() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  Shader(Shader&&) = default;
+  Shader& operator=(Shader&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  Shader() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_SHADER_H
similarity index 53%
rename from dali/graphics/graphics-manager.h
rename to dali/graphics-api/graphics-api-static-buffer.h
index 32610c7..65ca04a 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef DALI_GRAPHICS_MANAGER_H
-#define DALI_GRAPHICS_MANAGER_H
+#ifndef DALI_GRAPHICS_API_STATIC_BUFFER_H
+#define DALI_GRAPHICS_API_STATIC_BUFFER_H
 
 /*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  */
 
-#include <dali/graphics-api/graphics-api-manager.h>
-
 namespace Dali
 {
 namespace Graphics
 {
+namespace API
+{
 
 /**
- * @brief Manager implementation of the graphics API
+ * @brief Interface class for Texture types in the graphics API.
  */
-class Manager final : public API::Manager
+class StaticBuffer
 {
 public:
-  Manager() = default;
-
-  Manager(const Manager&) = delete;
-  Manager& operator=(const Manager&) = delete;
+  // not copyable
+  StaticBuffer(const StaticBuffer&) = delete;
+  StaticBuffer& operator=(const StaticBuffer&) = delete;
 
-  Manager(Manager&&) = default;
-  Manager& operator=(Manager&&) = default;
+  virtual ~StaticBuffer() = default;
 
-  virtual ~Manager() = default;
+protected:
+  // derived types should not be moved directly to prevent slicing
+  StaticBuffer(StaticBuffer&&) = default;
+  StaticBuffer& operator=(StaticBuffer&&) = default;
 
   /**
-   * Dummy method
+   * Objects of this type should not directly.
    */
-  int GetNumber() const;
+  StaticBuffer() = default;
 };
 
+} // namespace API
 } // namespace Graphics
 } // namespace Dali
 
-#endif // DALI_GRAPHICS_MANAGER_H
+#endif // DALI_GRAPHICS_API_STATIC_BUFFER_H
diff --git a/dali/graphics-api/graphics-api-texture-details.h b/dali/graphics-api/graphics-api-texture-details.h
new file mode 100644 (file)
index 0000000..2110a38
--- /dev/null
@@ -0,0 +1,82 @@
+#ifndef DALI_GRAPHICS_API_TEXTURE_DETAILS_H
+#define DALI_GRAPHICS_API_TEXTURE_DETAILS_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+namespace TextureDetails
+{
+
+using AttachmentId = size_t;
+using LayerId = size_t;
+using LevelId = size_t;
+
+enum class Type {
+  TEXTURE_2D,
+  TEXTURE_3D,
+  TEXTURE_CUBEMAP,
+};
+
+enum class Format {
+
+  // texture color formats
+  RGBA8,
+  ETC2_RGBA8,
+
+  // compressed color formats
+  ETC2,
+  ASTC_4x4,
+  ASTC_5x5,
+  ASTC_6x6,
+  ASTC_8x8,
+  ASTC_10x10,
+  ASTC_12x12,
+
+  // depth /stencil formats
+  D16_UNORM,
+  D16_UNORM_S8_UINT,
+  D32_SFLOAT,
+  D32_SFLOAT_S8_UINT,
+  D24_UNORM_S8_UINT,
+
+  // TODO: copy
+};
+
+enum class MipMapFlag {
+  ENABLED,
+  DISABLED,
+};
+
+enum class DepthStencilFlag {
+  NONE,
+  DEPTH,
+  STENCIL,
+  DEPTH_STENCIL,
+};
+
+} // namespace TextureDetails
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_TEXTURE_DETAILS_H
diff --git a/dali/graphics-api/graphics-api-texture-factory.h b/dali/graphics-api/graphics-api-texture-factory.h
new file mode 100644 (file)
index 0000000..1c2a604
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef DALI_GRAPHICS_API_TEXTURE_FACTORY_H
+#define DALI_GRAPHICS_API_TEXTURE_FACTORY_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/graphics-api/graphics-api-base-factory.h>
+#include <dali/graphics-api/graphics-api-texture-details.h>
+#include <dali/graphics-api/graphics-api-texture.h>
+#include <dali/graphics-api/graphics-api-utility.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for TextureFactory types in the graphics API.
+ */
+class TextureFactory : BaseFactory< Texture >
+{
+public:
+  virtual void SetType(TextureDetails::Type type)             = 0;
+  virtual void SetSize(const RectSize& size)                  = 0;
+  virtual void SetFormat(TextureDetails::Format format)       = 0;
+  virtual void SetMipMapFlag(TextureDetails::MipMapFlag mipMSapFlag) = 0;
+
+  // not copyable
+  TextureFactory(const TextureFactory&) = delete;
+  TextureFactory& operator=(const TextureFactory&) = delete;
+
+  virtual ~TextureFactory() = default;
+
+protected:
+  /// @brief default constructor
+  TextureFactory() = default;
+
+  // derived types should not be moved direcly to prevent slicing
+  TextureFactory(TextureFactory&&) = default;
+  TextureFactory& operator=(TextureFactory&&) = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_TEXTURE_FACTORY_H
similarity index 65%
rename from dali/graphics-api/graphics-api-manager.h
rename to dali/graphics-api/graphics-api-texture-set.h
index dc22664..e039808 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef DALI_GRAPHICS_API_MANAGER_H
-#define DALI_GRAPHICS_API_MANAGER_H
+#ifndef DALI_GRAPHICS_API_TEXTURE_SET_H
+#define DALI_GRAPHICS_API_TEXTURE_SET_H
 
 /*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
@@ -28,35 +28,32 @@ namespace API
 {
 
 /**
- * @brief Interface class for Manager types in the graphics API.
+ * @brief Interface class for TextureSet types in the graphics API.
  */
-class Manager
+class TextureSet
 {
 public:
-  /**
-   * Dummy method
-   */
-  virtual int GetNumber() const = 0;
+  virtual void AddTexture(const Accessor< Texture >& texture) = 0;
 
   // not copyable
-  Manager(const Manager&) = delete;
-  Manager& operator=(const Manager&) = delete;
+  TextureSet(const TextureSet&) = delete;
+  TextureSet& operator=(const TextureSet&) = delete;
 
-  virtual ~Manager() = default;
+  virtual ~TextureSet() = default;
 
 protected:
   // derived types should not be moved direcly to prevent slicing
-  Manager(Manager&&) = default;
-  Manager& operator=(Manager&&) = default;
+  TextureSet(TextureSet&&) = default;
+  TextureSet& operator=(TextureSet&&) = default;
 
   /**
    * Objects of this type should not directly.
    */
-  Manager() = default;
+  TextureSet() = default;
 };
 
 } // namespace API
 } // namespace Graphics
 } // namespace Dali
 
-#endif // DALI_GRAPHICS_API_MANAGER_H
+#endif // DALI_GRAPHICS_API_TEXTURE_SET_H
index b6905f9..f1b66f9 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_API_TEXTURE_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -18,8 +18,6 @@
  *
  */
 
-#include <dali/graphics-api/graphics-api-handle.h>
-
 namespace Dali
 {
 namespace Graphics
@@ -33,6 +31,7 @@ namespace API
 class Texture
 {
 public:
+
   // not copyable
   Texture(const Texture&) = delete;
   Texture& operator=(const Texture&) = delete;
@@ -50,8 +49,6 @@ protected:
   Texture() = default;
 };
 
-using TextureHandle = Handle< Texture >;
-
 } // namespace API
 } // namespace Graphics
 } // namespace Dali
index 873a724..f2906f3 100644 (file)
@@ -28,6 +28,14 @@ namespace Graphics
 namespace API
 {
 
+/**
+ * Structure that represents a rectangular size
+ */
+struct RectSize {
+  size_t width = 0;
+  size_t height = 0;
+};
+
 } // namespace API
 } // namespace Graphics
 } // namespace Dali
index 2bcc083..666ef14 100644 (file)
@@ -1,4 +1,4 @@
 # Add graphics source files here
 
 graphics_src_files = \
-  $(graphics_src_dir)/graphics-manager.cpp
+  $(graphics_src_dir)/graphics-controller.cpp
diff --git a/dali/graphics/graphics-controller.cpp b/dali/graphics/graphics-controller.cpp
new file mode 100644 (file)
index 0000000..dcc9c8f
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/graphics/graphics-controller.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+
+API::Accessor< API::Shader > Controller::CreateShader(
+    const API::BaseFactory< API::Shader >& factory)
+{
+  auto handle = mShaders.CreateObject(factory);
+  return API::Accessor< API::Shader >{mShaders, handle};
+}
+
+API::Accessor< API::Texture > Controller::CreateTexture(
+    const API::BaseFactory< API::Texture >& factory)
+{
+  auto handle = mTextures.CreateObject(factory);
+  return API::Accessor< API::Texture >{mTextures, handle};
+}
+
+API::Accessor< API::TextureSet > Controller::CreateTextureSet(
+    const API::BaseFactory< API::TextureSet >& factory)
+{
+  auto handle = mTextureSets.CreateObject(factory);
+  return API::Accessor< API::TextureSet >{mTextureSets, handle};
+}
+
+API::Accessor< API::DynamicBuffer > Controller::CreateDynamicBuffer(
+    const API::BaseFactory< API::DynamicBuffer >& factory)
+{
+  auto handle = mDynamicBuffers.CreateObject(factory);
+  return API::Accessor< API::DynamicBuffer >{mDynamicBuffers, handle};
+}
+
+API::Accessor< API::StaticBuffer > Controller::CreateStaticBuffer(
+    const API::BaseFactory< API::StaticBuffer >& factory)
+{
+  auto handle = mStaticBuffers.CreateObject(factory);
+  return API::Accessor< API::StaticBuffer >{mStaticBuffers, handle};
+}
+
+API::Accessor< API::Sampler > Controller::CreateSampler(
+    const API::BaseFactory< API::Sampler >& factory)
+{
+  auto handle = mSamplers.CreateObject(factory);
+  return API::Accessor< API::Sampler >{mSamplers, handle};
+}
+
+API::Accessor< API::Framebuffer > Controller::CreateFramebuffer(
+    const API::BaseFactory< API::Framebuffer >& factory)
+{
+  auto handle = mFramebuffers.CreateObject(factory);
+  return API::Accessor< API::Framebuffer >{mFramebuffers, handle};
+}
+
+void Controller::GetRenderItemList()
+{
+}
+
+} // namespace Graphics
+} // namespace Dali
diff --git a/dali/graphics/graphics-controller.h b/dali/graphics/graphics-controller.h
new file mode 100644 (file)
index 0000000..00637ad
--- /dev/null
@@ -0,0 +1,82 @@
+#ifndef DALI_GRAPHICS_CONTROLLER_H
+#define DALI_GRAPHICS_CONTROLLER_H
+
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/graphics-api/graphics-api-controller.h>
+#include <dali/graphics/graphics-object-owner.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+
+/**
+ * @brief Controller implementation of the graphics API
+ */
+class Controller final : public API::Controller
+{
+public:
+  virtual API::Accessor< API::Shader > CreateShader(
+      const API::BaseFactory< API::Shader >& factory) override;
+
+  virtual API::Accessor< API::Texture > CreateTexture(
+      const API::BaseFactory< API::Texture >& factory) override;
+
+  virtual API::Accessor< API::TextureSet > CreateTextureSet(
+      const API::BaseFactory< API::TextureSet >& factory) override;
+
+  virtual API::Accessor< API::DynamicBuffer > CreateDynamicBuffer(
+      const API::BaseFactory< API::DynamicBuffer >& factory) override;
+
+  virtual API::Accessor< API::StaticBuffer > CreateStaticBuffer(
+      const API::BaseFactory< API::StaticBuffer >& factory) override;
+
+  virtual API::Accessor< API::Sampler > CreateSampler(
+      const API::BaseFactory< API::Sampler >& factory) override;
+
+  virtual API::Accessor< API::Framebuffer > CreateFramebuffer(
+      const API::BaseFactory< API::Framebuffer >& factory) override;
+
+  virtual void GetRenderItemList() override;
+
+public:
+  Controller() = default;
+
+  Controller(const Controller&) = delete;
+  Controller& operator=(const Controller&) = delete;
+
+  Controller(Controller&&) = default;
+  Controller& operator=(Controller&&) = default;
+
+  virtual ~Controller() = default;
+
+private:
+  ObjectOwner< API::Shader >        mShaders;
+  ObjectOwner< API::Texture >       mTextures;
+  ObjectOwner< API::TextureSet >    mTextureSets;
+  ObjectOwner< API::DynamicBuffer > mDynamicBuffers;
+  ObjectOwner< API::StaticBuffer >  mStaticBuffers;
+  ObjectOwner< API::Sampler >       mSamplers;
+  ObjectOwner< API::Framebuffer >   mFramebuffers;
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_CONTROLLER_H
diff --git a/dali/graphics/graphics-object-owner.h b/dali/graphics/graphics-object-owner.h
new file mode 100644 (file)
index 0000000..ed61a89
--- /dev/null
@@ -0,0 +1,88 @@
+#ifndef DALI_GRAPHICS_OBJECT_OWNER_H
+#define DALI_GRAPHICS_OBJECT_OWNER_H
+
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cassert>
+#include <memory>
+#include <unordered_map>
+#include <utility>
+
+#include <dali/graphics-api/graphics-api-base-object-owner.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+template< typename T >
+class ObjectOwner final : public API::ObjectOwnerBase< T >
+{
+public:
+  using Type   = T;
+  using Handle = size_t;
+
+  constexpr ObjectOwner()
+  : mObjects{},      // Initialise without objects
+    mNextObjecId{0u} // Initialize to zero
+  {
+  }
+
+  Handle CreateObject(const API::BaseFactory< T >& factory)
+  {
+    auto id = mNextObjecId++;
+
+    auto&& object = factory.Create();
+    auto   it     = mObjects.emplace(std::make_pair(id, std::move(object)));
+    assert(it.second);
+
+    return Handle{id};
+  }
+
+  T& operator[](Handle handle)
+  {
+    return *mObjects[handle];
+  }
+
+  const T& operator[](Handle handle) const
+  {
+    return *mObjects[handle];
+  }
+
+  bool Contains(Handle handle) const
+  {
+    return mObjects.end() != mObjects.find(handle);
+  }
+
+  ObjectOwner(const ObjectOwner&) = delete;
+  ObjectOwner& operator=(const ObjectOwner&) = delete;
+
+  ObjectOwner(ObjectOwner&&) = default;
+  ObjectOwner& operator=(ObjectOwner&&) = default;
+
+  virtual ~ObjectOwner() = default;
+
+private:
+  std::unordered_map< size_t, std::unique_ptr< T > > mObjects;
+  size_t mNextObjecId;
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_OBJECT_OWNER_H
index d821cf0..ebc3df3 100644 (file)
@@ -63,7 +63,7 @@
 #include <dali/internal/render/queue/render-queue.h>
 #include <dali/internal/render/shaders/scene-graph-shader.h>
 
-#include <dali/graphics/graphics-manager.h>
+#include <dali/graphics/graphics-controller.h>
 
 // Un-comment to enable node tree debug logging
 //#define NODE_TREE_LOGGING 1
@@ -291,9 +291,7 @@ UpdateManager::UpdateManager( NotificationManager& notificationManager,
                     renderTaskProcessor );
 
 
-  Dali::Graphics::Manager gfxManager;
-
-  DALI_LOG_ERROR("Created graphics manager! %d\n", gfxManager.GetNumber());
+  Dali::Graphics::Controller gfxController;
 }
 
 UpdateManager::~UpdateManager()