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" |
11 #include "GrVkGpu.h" | 11 #include "GrVkGpu.h" |
12 #include "GrVkImageView.h" | 12 #include "GrVkImageView.h" |
13 #include "GrVkUtil.h" | 13 #include "GrVkUtil.h" |
14 | 14 |
| 15 #include "vk/GrVkTypes.h" |
| 16 |
15 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) | 17 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) |
16 | 18 |
17 GrVkTextureRenderTarget* | 19 GrVkTextureRenderTarget* |
18 GrVkTextureRenderTarget::Create(GrVkGpu* gpu, | 20 GrVkTextureRenderTarget::Create(GrVkGpu* gpu, |
19 const GrSurfaceDesc& desc, | 21 const GrSurfaceDesc& desc, |
20 GrGpuResource::LifeCycle lifeCycle, | 22 GrGpuResource::LifeCycle lifeCycle, |
21 VkFormat format, | 23 VkFormat format, |
22 const GrVkImage::Resource* imageResource) { | 24 const GrVkImage::Resource* imageResource) { |
23 | 25 |
24 VkImage image = imageResource->fImage; | 26 VkImage image = imageResource->fImage; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 imageRsrc->unref(gpu); | 135 imageRsrc->unref(gpu); |
134 | 136 |
135 return trt; | 137 return trt; |
136 } | 138 } |
137 | 139 |
138 GrVkTextureRenderTarget* | 140 GrVkTextureRenderTarget* |
139 GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu, | 141 GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(GrVkGpu* gpu, |
140 const GrSurfaceDesc& d
esc, | 142 const GrSurfaceDesc& d
esc, |
141 GrGpuResource::LifeCyc
le lifeCycle, | 143 GrGpuResource::LifeCyc
le lifeCycle, |
142 VkFormat format, | 144 VkFormat format, |
143 GrVkImage::Resource* i
mageRsrc) { | 145 const GrVkTextureInfo*
info) { |
144 SkASSERT(imageRsrc); | 146 SkASSERT(info); |
| 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); |
145 | 149 |
146 // Note: we assume the caller will unref the imageResource | 150 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) |
147 // Create() will increment the refCount, and we'll unref when we're done wit
h it | 151 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; |
148 return GrVkTextureRenderTarget::Create(gpu, desc, lifeCycle, format, imageRs
rc); | 152 |
| 153 const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fIm
age, |
| 154 info->fAl
loc, |
| 155 flags); |
| 156 if (!imageResource) { |
| 157 return nullptr; |
| 158 } |
| 159 |
| 160 GrVkTextureRenderTarget* trt = GrVkTextureRenderTarget::Create(gpu, desc, li
feCycle, |
| 161 format, image
Resource); |
| 162 if (trt) { |
| 163 trt->fCurrentLayout = info->fImageLayout; |
| 164 } |
| 165 // Create() will increment the refCount of the image resource if it succeeds |
| 166 imageResource->unref(gpu); |
| 167 |
| 168 return trt; |
| 169 |
149 } | 170 } |
150 | 171 |
OLD | NEW |