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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 const GrVkImage::ImageDesc&
imageDesc) { | 122 const GrVkImage::ImageDesc&
imageDesc) { |
123 SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); | 123 SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); |
124 SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT); | 124 SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT); |
125 | 125 |
126 const GrVkImage::Resource* imageRsrc = GrVkImage::CreateResource(gpu, imageD
esc); | 126 const GrVkImage::Resource* imageRsrc = GrVkImage::CreateResource(gpu, imageD
esc); |
127 | 127 |
128 if (!imageRsrc) { | 128 if (!imageRsrc) { |
129 return nullptr; | 129 return nullptr; |
130 } | 130 } |
131 | 131 |
132 GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, li
feCycle, | 132 GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, li
feCycle, |
133 imageDesc.fFo
rmat, imageRsrc); | 133 imageDesc.fFo
rmat, imageRsrc); |
134 // Create() will increment the refCount of the image resource if it succeeds | 134 // Create() will increment the refCount of the image resource if it succeeds |
135 imageRsrc->unref(gpu); | 135 imageRsrc->unref(gpu); |
136 | 136 |
137 return trt; | 137 return trt; |
138 } | 138 } |
139 | 139 |
140 GrVkTextureRenderTarget* | 140 GrVkTextureRenderTarget* |
141 GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu, | 141 GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu, |
142 const GrSurfaceDesc& d
esc, | 142 const GrSurfaceDesc& d
esc, |
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; | 153 const GrVkImage::Resource* imageResource; |
154 if (kBorrowed_LifeCycle == lifeCycle) { | 154 if (kBorrowed_LifeCycle == lifeCycle) { |
155 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); | 155 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); |
156 } else { | 156 } else { |
157 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); | 157 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); |
158 } | 158 } |
159 if (!imageResource) { | 159 if (!imageResource) { |
160 return nullptr; | 160 return nullptr; |
161 } | 161 } |
162 | 162 |
163 GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, li
feCycle, | 163 GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, li
feCycle, |
164 format, image
Resource); | 164 format, image
Resource); |
165 if (trt) { | 165 if (trt) { |
166 trt->fCurrentLayout = info->fImageLayout; | 166 trt->fCurrentLayout = info->fImageLayout; |
167 } | 167 } |
168 // 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 |
169 imageResource->unref(gpu); | 169 imageResource->unref(gpu); |
170 | 170 |
171 return trt; | 171 return trt; |
172 } | 172 } |
173 | |
OLD | NEW |