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 "GrVkRenderTarget.h" | 8 #include "GrVkRenderTarget.h" |
9 | 9 |
10 #include "GrRenderTargetPriv.h" | 10 #include "GrRenderTargetPriv.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 GrGpuResource::LifeCycle lifeCycle, | 207 GrGpuResource::LifeCycle lifeCycle, |
208 const GrVkTextureInfo* info) { | 208 const GrVkTextureInfo* info) { |
209 SkASSERT(info); | 209 SkASSERT(info); |
210 // We can wrap a rendertarget without its allocation, as long as we don't ta
ke ownership | 210 // We can wrap a rendertarget without its allocation, as long as we don't ta
ke ownership |
211 SkASSERT(VK_NULL_HANDLE != info->fImage); | 211 SkASSERT(VK_NULL_HANDLE != info->fImage); |
212 SkASSERT(VK_NULL_HANDLE != info->fAlloc || kAdopted_LifeCycle != lifeCycle); | 212 SkASSERT(VK_NULL_HANDLE != info->fAlloc || kAdopted_LifeCycle != lifeCycle); |
213 | 213 |
214 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) | 214 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) |
215 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; | 215 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; |
216 | 216 |
217 const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fIm
age, | 217 const GrVkImage::Resource* imageResource; |
218 info->fAl
loc, | 218 if (kBorrowed_LifeCycle == lifeCycle) { |
219 flags); | 219 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); |
| 220 } else { |
| 221 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); |
| 222 } |
220 if (!imageResource) { | 223 if (!imageResource) { |
221 return nullptr; | 224 return nullptr; |
222 } | 225 } |
223 | 226 |
224 GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageR
esource); | 227 GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageR
esource); |
225 if (rt) { | 228 if (rt) { |
226 rt->fCurrentLayout = info->fImageLayout; | 229 rt->fCurrentLayout = info->fImageLayout; |
227 } | 230 } |
228 // Create() will increment the refCount of the image resource if it succeeds | 231 // Create() will increment the refCount of the image resource if it succeeds |
229 imageResource->unref(gpu); | 232 imageResource->unref(gpu); |
| 233 |
230 return rt; | 234 return rt; |
231 } | 235 } |
232 | 236 |
233 bool GrVkRenderTarget::completeStencilAttachment() { | 237 bool GrVkRenderTarget::completeStencilAttachment() { |
234 this->createFramebuffer(this->getVkGpu()); | 238 this->createFramebuffer(this->getVkGpu()); |
235 return true; | 239 return true; |
236 } | 240 } |
237 | 241 |
238 void GrVkRenderTarget::createFramebuffer(GrVkGpu* gpu) { | 242 void GrVkRenderTarget::createFramebuffer(GrVkGpu* gpu) { |
239 if (fFramebuffer) { | 243 if (fFramebuffer) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 404 |
401 return nullptr; | 405 return nullptr; |
402 } | 406 } |
403 | 407 |
404 | 408 |
405 GrVkGpu* GrVkRenderTarget::getVkGpu() const { | 409 GrVkGpu* GrVkRenderTarget::getVkGpu() const { |
406 SkASSERT(!this->wasDestroyed()); | 410 SkASSERT(!this->wasDestroyed()); |
407 return static_cast<GrVkGpu*>(this->getGpu()); | 411 return static_cast<GrVkGpu*>(this->getGpu()); |
408 } | 412 } |
409 | 413 |
OLD | NEW |