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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 Resource(VkImage image, VkDeviceMemory alloc, Flags flags) | 34 Resource(VkImage image, VkDeviceMemory alloc, Flags flags) |
35 : fImage(image), fAlloc(alloc), fFlags(flags) {} | 35 : fImage(image), fAlloc(alloc), fFlags(flags) {} |
36 | 36 |
37 ~Resource() override {} | 37 ~Resource() override {} |
38 private: | 38 private: |
39 void freeGPUData(const GrVkGpu* gpu) const override; | 39 void freeGPUData(const GrVkGpu* gpu) const override; |
40 | 40 |
41 typedef GrVkResource INHERITED; | 41 typedef GrVkResource INHERITED; |
42 }; | 42 }; |
43 | 43 |
| 44 // for wrapped textures |
| 45 class BorrowedResource : public Resource { |
| 46 public: |
| 47 BorrowedResource(VkImage image, VkDeviceMemory alloc, Flags flags) |
| 48 : Resource(image, alloc, flags) {} |
| 49 private: |
| 50 void freeGPUData(const GrVkGpu* gpu) const override; |
| 51 }; |
44 | 52 |
45 GrVkImage(const Resource* imageResource) : fResource(imageResource) { | 53 GrVkImage(const Resource* imageResource) : fResource(imageResource) { |
46 if (imageResource->fFlags & Resource::kLinearTiling_Flag) { | 54 if (imageResource->fFlags & Resource::kLinearTiling_Flag) { |
47 fCurrentLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | 55 fCurrentLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
48 } else { | 56 } else { |
49 fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED; | 57 fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
50 } | 58 } |
51 imageResource->ref(); | 59 imageResource->ref(); |
52 } | 60 } |
53 | 61 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void releaseImage(const GrVkGpu* gpu); | 107 void releaseImage(const GrVkGpu* gpu); |
100 void abandonImage(); | 108 void abandonImage(); |
101 | 109 |
102 const Resource* fResource; | 110 const Resource* fResource; |
103 | 111 |
104 VkImageLayout fCurrentLayout; | 112 VkImageLayout fCurrentLayout; |
105 | 113 |
106 }; | 114 }; |
107 | 115 |
108 #endif | 116 #endif |
OLD | NEW |