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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 this->createFramebuffer(gpu); | 113 this->createFramebuffer(gpu); |
114 } | 114 } |
115 | 115 |
116 GrVkRenderTarget* | 116 GrVkRenderTarget* |
117 GrVkRenderTarget::Create(GrVkGpu* gpu, | 117 GrVkRenderTarget::Create(GrVkGpu* gpu, |
118 const GrSurfaceDesc& desc, | 118 const GrSurfaceDesc& desc, |
119 GrGpuResource::LifeCycle lifeCycle, | 119 GrGpuResource::LifeCycle lifeCycle, |
120 const GrVkImage::Resource* imageResource) { | 120 const GrVkImage::Resource* imageResource) { |
121 VkFormat pixelFormat; | 121 VkFormat pixelFormat; |
122 GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat); | 122 GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat); |
123 | 123 |
124 VkImage colorImage; | 124 VkImage colorImage; |
125 | 125 |
126 // create msaa surface if necessary | 126 // create msaa surface if necessary |
127 const GrVkImage::Resource* msaaResource = nullptr; | 127 const GrVkImage::Resource* msaaResource = nullptr; |
128 const GrVkImageView* resolveAttachmentView = nullptr; | 128 const GrVkImageView* resolveAttachmentView = nullptr; |
129 if (desc.fSampleCnt) { | 129 if (desc.fSampleCnt) { |
130 GrVkImage::ImageDesc msImageDesc; | 130 GrVkImage::ImageDesc msImageDesc; |
131 msImageDesc.fImageType = VK_IMAGE_TYPE_2D; | 131 msImageDesc.fImageType = VK_IMAGE_TYPE_2D; |
132 msImageDesc.fFormat = pixelFormat; | 132 msImageDesc.fFormat = pixelFormat; |
133 msImageDesc.fWidth = desc.fWidth; | 133 msImageDesc.fWidth = desc.fWidth; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 GrVkRenderTarget* | 204 GrVkRenderTarget* |
205 GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu, | 205 GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu, |
206 const GrSurfaceDesc& desc, | 206 const GrSurfaceDesc& desc, |
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; | 217 const GrVkImage::Resource* imageResource; |
218 if (kBorrowed_LifeCycle == lifeCycle) { | 218 if (kBorrowed_LifeCycle == lifeCycle) { |
219 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); | 219 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); |
220 } else { | 220 } else { |
221 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); | 221 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); |
222 } | 222 } |
223 if (!imageResource) { | 223 if (!imageResource) { |
224 return nullptr; | 224 return nullptr; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 403 } |
404 | 404 |
405 return nullptr; | 405 return nullptr; |
406 } | 406 } |
407 | 407 |
408 | 408 |
409 GrVkGpu* GrVkRenderTarget::getVkGpu() const { | 409 GrVkGpu* GrVkRenderTarget::getVkGpu() const { |
410 SkASSERT(!this->wasDestroyed()); | 410 SkASSERT(!this->wasDestroyed()); |
411 return static_cast<GrVkGpu*>(this->getGpu()); | 411 return static_cast<GrVkGpu*>(this->getGpu()); |
412 } | 412 } |
413 | |
OLD | NEW |