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
--- /dev/null
+
+/*
+ * 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
--- /dev/null
+#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
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;
}
} // namespace
-int UtcDaliGraphicsAPI(void)
+int UtcDaliGraphicsAPITextures(void)
{
TestTexture testTexture;
*/
#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;
}
*/
#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;
}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#ifndef DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
+#define DALI_GRAPHICS_API_DYNAMIC_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.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for DynamicBuffer types in the graphics API.
+ */
+class DynamicBuffer
+{
+public:
+ // not copyable
+ DynamicBuffer(const DynamicBuffer&) = delete;
+ DynamicBuffer& operator=(const DynamicBuffer&) = delete;
+
+ virtual ~DynamicBuffer() = default;
+
+protected:
+ // derived types should not be moved direcly to prevent slicing
+ DynamicBuffer(DynamicBuffer&&) = default;
+ DynamicBuffer& operator=(DynamicBuffer&&) = default;
+
+ /**
+ * Objects of this type should not directly.
+ */
+ DynamicBuffer() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
+++ /dev/null
-#ifndef DALI_GRAPHICS_API_HANDLE_H
-#define DALI_GRAPHICS_API_HANDLE_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <memory>
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-template< typename T >
-class Handle
-{
-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;
- }
-
- T& operator()()
- {
- return mObject;
- }
-
- constexpr const T& operator()() const
- {
- return mObject;
- }
-
-private:
- T& mObject;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_HANDLE_H
+++ /dev/null
-#ifndef DALI_GRAPHICS_API_MANAGER_H
-#define DALI_GRAPHICS_API_MANAGER_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-texture.h>
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-/**
- * @brief Interface class for Manager types in the graphics API.
- */
-class Manager
-{
-public:
- /**
- * Dummy method
- */
- virtual int GetNumber() const = 0;
-
- // not copyable
- Manager(const Manager&) = delete;
- Manager& operator=(const Manager&) = delete;
-
- virtual ~Manager() = default;
-
-protected:
- // derived types should not be moved direcly to prevent slicing
- Manager(Manager&&) = default;
- Manager& operator=(Manager&&) = default;
-
- /**
- * Objects of this type should not directly.
- */
- Manager() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_MANAGER_H
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#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.
+ *
+ */
+
+#include <string>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+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
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#ifndef DALI_GRAPHICS_API_STATIC_BUFFER_H
+#define DALI_GRAPHICS_API_STATIC_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.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for Texture types in the graphics API.
+ */
+class StaticBuffer
+{
+public:
+ // not copyable
+ StaticBuffer(const StaticBuffer&) = delete;
+ StaticBuffer& operator=(const StaticBuffer&) = delete;
+
+ virtual ~StaticBuffer() = default;
+
+protected:
+ // derived types should not be moved directly to prevent slicing
+ StaticBuffer(StaticBuffer&&) = default;
+ StaticBuffer& operator=(StaticBuffer&&) = default;
+
+ /**
+ * Objects of this type should not directly.
+ */
+ StaticBuffer() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_STATIC_BUFFER_H
--- /dev/null
+#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
--- /dev/null
+#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
--- /dev/null
+#ifndef DALI_GRAPHICS_API_TEXTURE_SET_H
+#define DALI_GRAPHICS_API_TEXTURE_SET_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-texture.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for TextureSet types in the graphics API.
+ */
+class TextureSet
+{
+public:
+ virtual void AddTexture(const Accessor< Texture >& texture) = 0;
+
+ // not copyable
+ TextureSet(const TextureSet&) = delete;
+ TextureSet& operator=(const TextureSet&) = delete;
+
+ virtual ~TextureSet() = default;
+
+protected:
+ // derived types should not be moved direcly to prevent slicing
+ TextureSet(TextureSet&&) = default;
+ TextureSet& operator=(TextureSet&&) = default;
+
+ /**
+ * Objects of this type should not directly.
+ */
+ TextureSet() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_TEXTURE_SET_H
#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.
*
*/
-#include <dali/graphics-api/graphics-api-handle.h>
-
namespace Dali
{
namespace Graphics
class Texture
{
public:
+
// not copyable
Texture(const Texture&) = delete;
Texture& operator=(const Texture&) = delete;
Texture() = default;
};
-using TextureHandle = Handle< Texture >;
-
} // namespace API
} // namespace Graphics
} // namespace Dali
namespace API
{
+/**
+ * Structure that represents a rectangular size
+ */
+struct RectSize {
+ size_t width = 0;
+ size_t height = 0;
+};
+
} // namespace API
} // namespace Graphics
} // namespace Dali
# Add graphics source files here
graphics_src_files = \
- $(graphics_src_dir)/graphics-manager.cpp
+ $(graphics_src_dir)/graphics-controller.cpp
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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
+++ /dev/null
-/*
- * 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-manager.h>
-
-
-namespace Dali
-{
-namespace Graphics
-{
-
-int Manager::GetNumber() const
-{
- return 42;
-}
-
-
-} // namespace Graphics
-} // namespace Dali
-
+++ /dev/null
-#ifndef DALI_GRAPHICS_MANAGER_H
-#define DALI_GRAPHICS_MANAGER_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-manager.h>
-
-namespace Dali
-{
-namespace Graphics
-{
-
-/**
- * @brief Manager implementation of the graphics API
- */
-class Manager final : public API::Manager
-{
-public:
- Manager() = default;
-
- Manager(const Manager&) = delete;
- Manager& operator=(const Manager&) = delete;
-
- Manager(Manager&&) = default;
- Manager& operator=(Manager&&) = default;
-
- virtual ~Manager() = default;
-
- /**
- * Dummy method
- */
- int GetNumber() const;
-};
-
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_MANAGER_H
--- /dev/null
+#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
#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
renderTaskProcessor );
- Dali::Graphics::Manager gfxManager;
-
- DALI_LOG_ERROR("Created graphics manager! %d\n", gfxManager.GetNumber());
+ Dali::Graphics::Controller gfxController;
}
UpdateManager::~UpdateManager()