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 |
26 }; | 28 }; |
27 | 29 |
28 VkImage fImage; | 30 VkImage fImage; |
29 VkDeviceMemory fAlloc; | 31 VkDeviceMemory fAlloc; |
30 Flags fFlags; | 32 Flags fFlags; |
31 VkFormat fFormat; | 33 VkFormat fFormat; |
34 GrBackendObjectOwnership fOwnership; | |
jvanverth1
2016/04/29 13:44:14
I added this here rather than the texture because
| |
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, Flags flags, VkFormat form at, |
41 : fImage(image), fAlloc(alloc), fFlags(flags), fFormat(format) {} | 44 GrBackendObjectOwnership ownership = GrBackendObjectOwnership:: kOwned) |
45 : fImage(image), fAlloc(alloc), fFlags(flags), fFormat(format) | |
46 , fOwnership(ownership) {} | |
42 | 47 |
43 ~Resource() override {} | 48 ~Resource() override {} |
49 | |
44 private: | 50 private: |
45 void freeGPUData(const GrVkGpu* gpu) const override; | 51 void freeGPUData(const GrVkGpu* gpu) const override; |
46 | 52 |
47 typedef GrVkResource INHERITED; | 53 typedef GrVkResource INHERITED; |
48 }; | 54 }; |
49 | 55 |
50 // for wrapped textures | 56 // for wrapped textures |
51 class BorrowedResource : public Resource { | 57 class BorrowedResource : public Resource { |
52 public: | 58 public: |
53 BorrowedResource(VkImage image, VkDeviceMemory alloc, Flags flags, VkFor mat format) | 59 BorrowedResource(VkImage image, VkDeviceMemory alloc, Flags flags, VkFor mat format) |
54 : Resource(image, alloc, flags, format) {} | 60 : Resource(image, alloc, flags, format, GrBackendObjectOwnership::kB orrowed) { |
61 } | |
55 private: | 62 private: |
56 void freeGPUData(const GrVkGpu* gpu) const override; | 63 void freeGPUData(const GrVkGpu* gpu) const override; |
57 }; | 64 }; |
58 | 65 |
59 GrVkImage(const Resource* imageResource) : fResource(imageResource) { | 66 GrVkImage(const Resource* imageResource) : fResource(imageResource) { |
60 if (imageResource->fFlags & Resource::kLinearTiling_Flag) { | 67 if (imageResource->fFlags & Resource::kLinearTiling_Flag) { |
61 fCurrentLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | 68 fCurrentLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
62 } else { | 69 } else { |
63 fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED; | 70 fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
64 } | 71 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 void releaseImage(const GrVkGpu* gpu); | 121 void releaseImage(const GrVkGpu* gpu); |
115 void abandonImage(); | 122 void abandonImage(); |
116 | 123 |
117 const Resource* fResource; | 124 const Resource* fResource; |
118 | 125 |
119 VkImageLayout fCurrentLayout; | 126 VkImageLayout fCurrentLayout; |
120 | 127 |
121 }; | 128 }; |
122 | 129 |
123 #endif | 130 #endif |
OLD | NEW |