1f06c8dada3ed523ecc42728c69fc7b60718822b
[platform/core/uifw/dali-core.git] / dali / integration-api / graphics / graphics.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali/graphics/vulkan/vulkan-types.h>
19 #include <dali/graphics/vulkan/vulkan-graphics.h>
20 #include <dali/graphics/vulkan/vulkan-surface.h>
21
22 #include <dali/integration-api/graphics/graphics.h>
23
24 namespace Dali
25 {
26 /// fixme: substituting directly the vulkan implementation
27 namespace Graphics
28 {
29 using GraphicsImpl = Dali::Graphics::Vulkan::Graphics;
30 }
31
32 namespace Integration
33 {
34 namespace Graphics
35 {
36
37 Graphics::Graphics()
38 {
39   // create device
40   auto impl = Dali::Graphics::MakeUnique<Dali::Graphics::GraphicsImpl>();
41
42   impl->Create();
43
44   mGraphicsImpl = std::move(impl);
45 }
46
47 Graphics::~Graphics()
48 {
49
50 }
51
52 Dali::Graphics::FBID Graphics::Create(
53   std::unique_ptr<Dali::Integration::Graphics::SurfaceFactory> surfaceFactory)
54 {
55
56   // create surface
57   auto retval = mGraphicsImpl->CreateSurface(std::move(surfaceFactory));
58
59   // create device
60   mGraphicsImpl->CreateDevice();
61
62   return retval;
63 }
64
65 Dali::Graphics::FBID Graphics::CreateSurface(
66   std::unique_ptr<Dali::Integration::Graphics::SurfaceFactory> surfaceFactory)
67 {
68   return 0u;
69 }
70
71 void Graphics::PreRender(Dali::Graphics::FBID framebufferId)
72 {
73   assert(framebufferId != 0u && "Invalid FBID!");
74   auto &surface = mGraphicsImpl->GetSurface(framebufferId);
75   surface.AcquireNextImage();
76 }
77
78 /*
79  * Postrender
80  */
81 void Graphics::PostRender(Dali::Graphics::FBID framebufferId)
82 {
83   assert(framebufferId != 0u && "Invalid FBID!");
84   auto &surface = mGraphicsImpl->GetSurface(framebufferId);
85   surface.Present();
86 }
87
88 void IncludeThisLibrary()
89 {
90 // dummy function to create linker dependency
91 }
92
93 } // Namespace Graphics
94 } // Namespace Integration
95 } // Namespace Dali