OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrVkImage_DEFINED | 8 #ifndef GrVkImage_DEFINED |
9 #define GrVkImage_DEFINED | 9 #define GrVkImage_DEFINED |
10 | 10 |
11 #include "GrVkResource.h" | 11 #include "GrVkResource.h" |
| 12 |
| 13 #include "GrTypesPriv.h" |
12 #include "SkTypes.h" | 14 #include "SkTypes.h" |
13 | 15 |
14 #include "vk/GrVkDefines.h" | 16 #include "vk/GrVkDefines.h" |
15 | 17 |
16 class GrVkGpu; | 18 class GrVkGpu; |
17 | 19 |
18 class GrVkImage : SkNoncopyable { | 20 class GrVkImage : SkNoncopyable { |
19 public: | 21 public: |
20 // unlike GrVkBuffer, this needs to be public so GrVkStencilAttachment can u
se it | 22 // unlike GrVkBuffer, this needs to be public so GrVkStencilAttachment can u
se it |
21 class Resource : public GrVkResource { | 23 class Resource : public GrVkResource { |
22 public: | 24 public: |
23 enum Flags { | 25 enum Flags { |
24 kNo_Flags = 0, | 26 kNo_Flags = 0, |
25 kLinearTiling_Flag = 0x01 | 27 kLinearTiling_Flag = 0x01, |
| 28 kBorrowed_Flag = 0x02 |
26 }; | 29 }; |
27 | 30 |
28 VkImage fImage; | 31 VkImage fImage; |
29 VkDeviceMemory fAlloc; | 32 VkDeviceMemory fAlloc; |
30 Flags fFlags; | 33 VkFormat fFormat; |
31 VkFormat fFormat; | 34 uint32_t fFlags; |
32 | 35 |
33 Resource() | 36 Resource() |
34 : INHERITED() | 37 : INHERITED() |
35 , fImage(VK_NULL_HANDLE) | 38 , fImage(VK_NULL_HANDLE) |
36 , fAlloc(VK_NULL_HANDLE) | 39 , fAlloc(VK_NULL_HANDLE) |
37 , fFlags(kNo_Flags) | 40 , fFlags(kNo_Flags) |
38 , fFormat(VK_FORMAT_UNDEFINED) {} | 41 , fFormat(VK_FORMAT_UNDEFINED) {} |
39 | 42 |
40 Resource(VkImage image, VkDeviceMemory alloc, Flags flags, VkFormat form
at) | 43 Resource(VkImage image, VkDeviceMemory alloc, uint32_t flags, VkFormat f
ormat) |
41 : fImage(image), fAlloc(alloc), fFlags(flags), fFormat(format) {} | 44 : fImage(image), fAlloc(alloc), fFlags(flags), fFormat(format) {} |
42 | 45 |
43 ~Resource() override {} | 46 ~Resource() override {} |
| 47 |
44 private: | 48 private: |
45 void freeGPUData(const GrVkGpu* gpu) const override; | 49 void freeGPUData(const GrVkGpu* gpu) const override; |
46 | 50 |
47 typedef GrVkResource INHERITED; | 51 typedef GrVkResource INHERITED; |
48 }; | 52 }; |
49 | 53 |
50 // for wrapped textures | 54 // for wrapped textures |
51 class BorrowedResource : public Resource { | 55 class BorrowedResource : public Resource { |
52 public: | 56 public: |
53 BorrowedResource(VkImage image, VkDeviceMemory alloc, Flags flags, VkFor
mat format) | 57 BorrowedResource(VkImage image, VkDeviceMemory alloc, uint32_t flags, Vk
Format format) |
54 : Resource(image, alloc, flags, format) {} | 58 : Resource(image, alloc, (flags | kBorrowed_Flag), format) { |
| 59 } |
55 private: | 60 private: |
56 void freeGPUData(const GrVkGpu* gpu) const override; | 61 void freeGPUData(const GrVkGpu* gpu) const override; |
57 }; | 62 }; |
58 | 63 |
59 GrVkImage(const Resource* imageResource) : fResource(imageResource) { | 64 GrVkImage(const Resource* imageResource) : fResource(imageResource) { |
60 if (imageResource->fFlags & Resource::kLinearTiling_Flag) { | 65 if (imageResource->fFlags & Resource::kLinearTiling_Flag) { |
61 fCurrentLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | 66 fCurrentLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
62 } else { | 67 } else { |
63 fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED; | 68 fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
64 } | 69 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void releaseImage(const GrVkGpu* gpu); | 119 void releaseImage(const GrVkGpu* gpu); |
115 void abandonImage(); | 120 void abandonImage(); |
116 | 121 |
117 const Resource* fResource; | 122 const Resource* fResource; |
118 | 123 |
119 VkImageLayout fCurrentLayout; | 124 VkImageLayout fCurrentLayout; |
120 | 125 |
121 }; | 126 }; |
122 | 127 |
123 #endif | 128 #endif |
OLD | NEW |