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 "GrVkTextureRenderTarget.h" | 8 #include "GrVkTextureRenderTarget.h" |
9 | 9 |
10 #include "GrRenderTargetPriv.h" | 10 #include "GrRenderTargetPriv.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 GrGpuResource::LifeCyc
le lifeCycle, | 143 GrGpuResource::LifeCyc
le lifeCycle, |
144 VkFormat format, | 144 VkFormat format, |
145 const GrVkTextureInfo*
info) { | 145 const GrVkTextureInfo*
info) { |
146 SkASSERT(info); | 146 SkASSERT(info); |
147 // Wrapped textures require both image and allocation (because they can be m
apped) | 147 // Wrapped textures require both image and allocation (because they can be m
apped) |
148 SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc); | 148 SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc); |
149 | 149 |
150 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) | 150 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) |
151 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; | 151 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; |
152 | 152 |
153 const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fIm
age, | 153 const GrVkImage::Resource* imageResource; |
154 info->fAl
loc, | 154 if (kBorrowed_LifeCycle == lifeCycle) { |
155 flags); | 155 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); |
| 156 } else { |
| 157 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); |
| 158 } |
156 if (!imageResource) { | 159 if (!imageResource) { |
157 return nullptr; | 160 return nullptr; |
158 } | 161 } |
159 | 162 |
160 GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, li
feCycle, | 163 GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, li
feCycle, |
161 format, image
Resource); | 164 format, image
Resource); |
162 if (trt) { | 165 if (trt) { |
163 trt->fCurrentLayout = info->fImageLayout; | 166 trt->fCurrentLayout = info->fImageLayout; |
164 } | 167 } |
165 // Create() will increment the refCount of the image resource if it succeeds | 168 // Create() will increment the refCount of the image resource if it succeeds |
166 imageResource->unref(gpu); | 169 imageResource->unref(gpu); |
167 | 170 |
168 return trt; | 171 return trt; |
169 | |
170 } | 172 } |
171 | 173 |
OLD | NEW |