[Vulkan] Support for clear color in Swapchain
[platform/core/uifw/dali-core.git] / dali / graphics / vulkan / vulkan-swapchain.h
1 #ifndef DALI_GRAPHICS_VULKAN_SWAPCHAIN_H
2 #define DALI_GRAPHICS_VULKAN_SWAPCHAIN_H
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/graphics/vulkan/vulkan-types.h>
23
24 namespace Dali
25 {
26 namespace Graphics
27 {
28 namespace Vulkan
29 {
30 class Surface;
31 class Queue;
32
33 /**
34  * Creates swapchain for given surface and queue
35  */
36 class Swapchain : public VkManaged
37 {
38 public:
39
40   static SwapchainRef New( Graphics& graphics, Queue& presentationQueue, SurfaceRef surface, uint8_t bufferCount, uint32_t flags );
41
42 public:
43
44   Swapchain( const Swapchain& ) = delete;
45   Swapchain& operator=( const Swapchain& ) = delete;
46
47   /**
48    * Returns current framebuffer ( the one which is rendering to )
49    * @return
50    */
51   FramebufferRef GetCurrentFramebuffer() const;
52
53   /**
54    * Returns any framebuffer from the queue
55    * @param index
56    * @return
57    */
58   FramebufferRef GetFramebuffer( uint32_t index ) const;
59
60   /**
61    * Requests for next framebuffer
62    * @return
63    */
64   FramebufferRef AcquireNextFramebuffer();
65
66   /**
67    * Returns primary command buffer associated with currently
68    * being recorded frame
69    * @return
70    */
71   CommandBufferRef GetPrimaryCommandBuffer() const;
72
73   /**
74    * Begins primary render pass, must be called after acquiring new image
75    */
76   void BeginPrimaryRenderPass();
77
78   /**
79    * Begins primary render pass, must be called after acquiring new image
80    * @param beginInfo custom initialisation structure
81    */
82   void BeginPrimaryRenderPass( std::vector<std::array<float,4>> colors );
83
84   /**
85    * Presents using default present queue, asynchronously
86    */
87   void Present();
88
89   /**
90    * Presents using default queue, synchronized with supplied semaphores
91    * @param waitSemaphores
92    */
93   void Present( std::vector<vk::Semaphore> waitSemaphores );
94
95 private:
96
97   Swapchain();
98   Swapchain( Graphics& graphics, Queue& presentationQueue, SurfaceRef surface, uint8_t bufferCount, uint32_t flags );
99   ~Swapchain() override;
100
101 private:
102
103   struct Impl;
104   std::unique_ptr<Impl> mImpl;
105 };
106
107 } // namespace Vulkan
108 } // namespace Graphics
109 } // namespace Dali
110 #endif //DALI_GRAPHICS_VULKAN_SWAPCHAIN_H