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 #include "GrVkTexture.h" | 8 #include "GrVkTexture.h" |
9 #include "GrVkGpu.h" | 9 #include "GrVkGpu.h" |
10 #include "GrVkImageView.h" | 10 #include "GrVkImageView.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 GrGpuResource::LifeCycle lifeCycl
e, | 78 GrGpuResource::LifeCycle lifeCycl
e, |
79 VkFormat format, | 79 VkFormat format, |
80 const GrVkTextureInfo* info) { | 80 const GrVkTextureInfo* info) { |
81 SkASSERT(info); | 81 SkASSERT(info); |
82 // Wrapped textures require both image and allocation (because they can be m
apped) | 82 // Wrapped textures require both image and allocation (because they can be m
apped) |
83 SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc); | 83 SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc); |
84 | 84 |
85 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) | 85 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) |
86 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; | 86 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; |
87 | 87 |
88 const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fIm
age, | 88 const GrVkImage::Resource* imageResource; |
89 info->fAl
loc, | 89 if (kBorrowed_LifeCycle == lifeCycle) { |
90 flags); | 90 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); |
| 91 } else { |
| 92 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); |
| 93 } |
91 if (!imageResource) { | 94 if (!imageResource) { |
92 return nullptr; | 95 return nullptr; |
93 } | 96 } |
94 | 97 |
95 GrVkTexture* texture = Create(gpu, desc, lifeCycle, format, imageResource); | 98 GrVkTexture* texture = Create(gpu, desc, lifeCycle, format, imageResource); |
96 if (texture) { | 99 if (texture) { |
97 texture->fCurrentLayout = info->fImageLayout; | 100 texture->fCurrentLayout = info->fImageLayout; |
98 } | 101 } |
99 // Create() will increment the refCount of the image resource if it succeeds | 102 // Create() will increment the refCount of the image resource if it succeeds |
100 imageResource->unref(gpu); | 103 imageResource->unref(gpu); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 GrBackendObject GrVkTexture::getTextureHandle() const { | 139 GrBackendObject GrVkTexture::getTextureHandle() const { |
137 // Currently just passing back the pointer to the Resource as the handle | 140 // Currently just passing back the pointer to the Resource as the handle |
138 return (GrBackendObject)&fResource; | 141 return (GrBackendObject)&fResource; |
139 } | 142 } |
140 | 143 |
141 GrVkGpu* GrVkTexture::getVkGpu() const { | 144 GrVkGpu* GrVkTexture::getVkGpu() const { |
142 SkASSERT(!this->wasDestroyed()); | 145 SkASSERT(!this->wasDestroyed()); |
143 return static_cast<GrVkGpu*>(this->getGpu()); | 146 return static_cast<GrVkGpu*>(this->getGpu()); |
144 } | 147 } |
145 | 148 |
OLD | NEW |