[Vulkan] Basic Vulkan backend
[platform/core/uifw/dali-core.git] / dali / graphics / vulkan / vulkan-image.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-graphics.h>
19 #include <dali/graphics/vulkan/vulkan-image.h>
20
21 namespace Dali
22 {
23 namespace Graphics
24 {
25 namespace Vulkan
26 {
27
28 Image::Image(Graphics& graphics, const vk::ImageCreateInfo& createInfo) : mGraphics(graphics)
29 {
30 }
31
32 Image::Image(Graphics& graphics, vk::Image externalImage)
33 : mGraphics(graphics), mImage(externalImage)
34 {
35 }
36
37 vk::ImageView Image::CreateUnmanagedView(const vk::ImageViewCreateInfo& info)
38 {
39   NotImplemented();
40   return nullptr;
41 }
42
43 ImageViewRef Image::CreateView(const vk::ImageViewCreateInfo& info)
44 {
45   return MakeRef< ImageView >(mGraphics, *this, info);
46 }
47
48 ImageView::ImageView(Graphics& graphics, Image& image) : mGraphics(graphics), mImageRef(&image)
49 {
50 }
51
52 ImageView::ImageView(Graphics& graphics, Image& image, const VkImageViewCreateInfo& createInfo)
53 : mGraphics(graphics), mImageRef(&image)
54 {
55   mImageView =
56       VkAssert(mGraphics.GetDevice().createImageView(createInfo, mGraphics.GetAllocator()));
57 }
58
59 ImageView::~ImageView()
60 {
61   if(mImageView)
62   {
63     mGraphics.GetDevice().destroyImageView( mImageView, mGraphics.GetAllocator());
64   }
65 }
66
67 } // namespace Vulkan
68
69 } // namespace Graphics
70
71 } // namespace Dali