1 #ifndef DALI_GRAPHICS_API_CONTROLLER_H
2 #define DALI_GRAPHICS_API_CONTROLLER_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/graphics-api/graphics-api-accessor.h>
23 #include <dali/graphics-api/graphics-api-base-factory.h>
24 #include <dali/graphics-api/graphics-api-dynamic-buffer.h>
25 #include <dali/graphics-api/graphics-api-frame.h>
26 #include <dali/graphics-api/graphics-api-framebuffer.h>
27 #include <dali/graphics-api/graphics-api-generic-buffer.h>
28 #include <dali/graphics-api/graphics-api-render-command.h>
29 #include <dali/graphics-api/graphics-api-sampler.h>
30 #include <dali/graphics-api/graphics-api-shader.h>
31 #include <dali/graphics-api/graphics-api-shader-details.h>
32 #include <dali/graphics-api/graphics-api-shader-factory.h>
33 #include <dali/graphics-api/graphics-api-static-buffer.h>
34 #include <dali/graphics-api/graphics-api-texture-factory.h>
35 #include <dali/graphics-api/graphics-api-texture-set.h>
36 #include <dali/graphics-api/graphics-api-texture.h>
37 #include <dali/graphics-api/graphics-api-buffer.h>
38 #include <dali/graphics-api/graphics-api-buffer-factory.h>
39 #include <dali/graphics-api/utility/utility-builder.h>
49 * @brief Interface class for Manager types in the graphics API.
55 virtual ~Controller() = default;
58 * @brief Create a new object
60 virtual Accessor<Shader> CreateShader( const BaseFactory<Shader>& factory ) = 0;
63 * @brief Create a new object
65 virtual Accessor<Texture> CreateTexture( const BaseFactory<Texture>& factory ) = 0;
68 * @brief Create a new object
70 virtual Accessor<TextureSet> CreateTextureSet( const BaseFactory<TextureSet>& factory ) = 0;
73 * @brief Create a new object
75 virtual Accessor<DynamicBuffer> CreateDynamicBuffer( const BaseFactory<DynamicBuffer>& factory ) = 0;
78 * @brief Create a new object
80 virtual Accessor<Buffer> CreateBuffer( const BaseFactory<Buffer>& factory ) = 0;
83 * @brief Create a new object
85 virtual Accessor<StaticBuffer> CreateStaticBuffer( const BaseFactory<StaticBuffer>& factory ) = 0;
88 * @brief Create a new object
90 virtual Accessor<Sampler> CreateSampler( const BaseFactory<Sampler>& factory ) = 0;
93 * @brief Create a new object
95 virtual Accessor<Framebuffer> CreateFramebuffer( const BaseFactory<Framebuffer>& factory ) = 0;
98 * @brief Get a render list
100 virtual void GetRenderItemList() = 0;
103 * @brief Returns texture factory
106 virtual TextureFactory& GetTextureFactory() const = 0;
109 * @brief Returns shader factory
112 virtual ShaderFactory& GetShaderFactory() const = 0;
115 * @brief Returns shader factory
118 virtual BufferFactory& GetBufferFactory() const = 0;
121 * @brief Create a buffer
124 std::unique_ptr<GenericBuffer<T>> CreateBuffer( size_t numberOfElements );
127 * @brief Submit a render command
129 virtual void SubmitCommand( API::RenderCommand&& command ) = 0;
132 * @brief alAllocates render command ( depends on implementation );
135 virtual std::unique_ptr<API::RenderCommand> AllocateRenderCommand() = 0;
138 * @brief Submits a list of commands
141 virtual void SubmitCommands( std::vector<API::RenderCommand*> commands ) = 0;
144 * @brief Mark the beginning of a frame
146 virtual void BeginFrame() = 0;
149 * @brief Mark the end of a frame
151 virtual void EndFrame() = 0;
155 Controller( const Controller& ) = delete;
156 Controller& operator=( const Controller& ) = delete;
159 // derived types should not be moved direcly to prevent slicing
160 Controller( Controller&& ) = default;
161 Controller& operator=( Controller&& ) = default;
164 * Objects of this type should not directly.
166 Controller() = default;
171 * @brief create an element for the given number of elements and element size
173 virtual std::unique_ptr<char> CreateBuffer( size_t numberOfElements, size_t elementSize ) = 0;
179 std::unique_ptr<GenericBuffer<T>> Controller::CreateBuffer( size_t numberOfElements )
181 return std::make_unique<GenericBuffer<T>>(numberOfElements, std::move(CreateBuffer( numberOfElements, sizeof( T ) )));
185 } // namespace Graphics
188 #endif // DALI_GRAPHICS_API_CONTROLLER_H