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 "GrVkTexture.h" | 8 #include "GrVkTexture.h" |
9 #include "GrVkGpu.h" | 9 #include "GrVkGpu.h" |
10 #include "GrVkImageView.h" | 10 #include "GrVkImageView.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const GrVkTextureInfo* info) { | 80 const GrVkTextureInfo* info) { |
81 SkASSERT(info); | 81 SkASSERT(info); |
82 // Wrapped textures require both image and allocation (because they can be m
apped) | 82 // Wrapped textures require both image and allocation (because they can be m
apped) |
83 SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc); | 83 SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc); |
84 | 84 |
85 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) | 85 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi
ling) |
86 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; | 86 ? Resource::kLinearTiling_Flag : Resource::
kNo_Flags; |
87 | 87 |
88 const GrVkImage::Resource* imageResource; | 88 const GrVkImage::Resource* imageResource; |
89 if (kBorrowed_LifeCycle == lifeCycle) { | 89 if (kBorrowed_LifeCycle == lifeCycle) { |
90 imageResource = new GrVkImage::BorrowedResource(info->fImage, info->fAll
oc, flags); | 90 imageResource = new GrVkImage::BorrowedResource(info->fImage, |
| 91 info->fAlloc, |
| 92 flags, |
| 93 info->fFormat); |
91 } else { | 94 } else { |
92 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s); | 95 imageResource = new GrVkImage::Resource(info->fImage, info->fAlloc, flag
s, info->fFormat); |
93 } | 96 } |
94 if (!imageResource) { | 97 if (!imageResource) { |
95 return nullptr; | 98 return nullptr; |
96 } | 99 } |
97 | 100 |
98 GrVkTexture* texture = Create(gpu, desc, lifeCycle, format, imageResource); | 101 GrVkTexture* texture = Create(gpu, desc, lifeCycle, format, imageResource); |
99 if (texture) { | 102 if (texture) { |
100 texture->fCurrentLayout = info->fImageLayout; | 103 texture->fCurrentLayout = info->fImageLayout; |
101 } | 104 } |
102 // Create() will increment the refCount of the image resource if it succeeds | 105 // Create() will increment the refCount of the image resource if it succeeds |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 141 |
139 GrBackendObject GrVkTexture::getTextureHandle() const { | 142 GrBackendObject GrVkTexture::getTextureHandle() const { |
140 // Currently just passing back the pointer to the Resource as the handle | 143 // Currently just passing back the pointer to the Resource as the handle |
141 return (GrBackendObject)&fResource; | 144 return (GrBackendObject)&fResource; |
142 } | 145 } |
143 | 146 |
144 GrVkGpu* GrVkTexture::getVkGpu() const { | 147 GrVkGpu* GrVkTexture::getVkGpu() const { |
145 SkASSERT(!this->wasDestroyed()); | 148 SkASSERT(!this->wasDestroyed()); |
146 return static_cast<GrVkGpu*>(this->getGpu()); | 149 return static_cast<GrVkGpu*>(this->getGpu()); |
147 } | 150 } |
OLD | NEW |