| 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" |
| 11 #include "GrTexturePriv.h" | 11 #include "GrTexturePriv.h" |
| 12 #include "GrVkUtil.h" | 12 #include "GrVkUtil.h" |
| 13 | 13 |
| 14 #include "vk/GrVkTypes.h" | 14 #include "vk/GrVkTypes.h" |
| 15 | 15 |
| 16 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) | 16 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) |
| 17 | 17 |
| 18 // Because this class is virtually derived from GrSurface we must explicitly cal
l its constructor. | 18 // Because this class is virtually derived from GrSurface we must explicitly cal
l its constructor. |
| 19 GrVkTexture::GrVkTexture(GrVkGpu* gpu, | 19 GrVkTexture::GrVkTexture(GrVkGpu* gpu, |
| 20 SkBudgeted budgeted, | 20 SkBudgeted budgeted, |
| 21 const GrSurfaceDesc& desc, | 21 const GrSurfaceDesc& desc, |
| 22 const GrVkImageInfo& info, | 22 const GrVkImageInfo& info, |
| 23 const GrVkImageView* view) | 23 const GrVkImageView* view) |
| 24 : GrSurface(gpu, desc) | 24 : GrSurface(gpu, desc) |
| 25 , GrVkImage(info, GrVkImage::kNot_Wrapped) | 25 , GrVkImage(info, GrVkImage::kNot_Wrapped) |
| 26 , INHERITED(gpu, desc, kSampler2D_GrSLType, desc.fIsMipMapped) | 26 , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped) |
| 27 , fTextureView(view) | 27 , fTextureView(view) |
| 28 , fLinearTextureView(nullptr) { | 28 , fLinearTextureView(nullptr) { |
| 29 this->registerWithCache(budgeted); | 29 this->registerWithCache(budgeted); |
| 30 } | 30 } |
| 31 | 31 |
| 32 GrVkTexture::GrVkTexture(GrVkGpu* gpu, | 32 GrVkTexture::GrVkTexture(GrVkGpu* gpu, |
| 33 Wrapped, | 33 Wrapped, |
| 34 const GrSurfaceDesc& desc, | 34 const GrSurfaceDesc& desc, |
| 35 const GrVkImageInfo& info, | 35 const GrVkImageInfo& info, |
| 36 const GrVkImageView* view, | 36 const GrVkImageView* view, |
| 37 GrVkImage::Wrapped wrapped) | 37 GrVkImage::Wrapped wrapped) |
| 38 : GrSurface(gpu, desc) | 38 : GrSurface(gpu, desc) |
| 39 , GrVkImage(info, wrapped) | 39 , GrVkImage(info, wrapped) |
| 40 , INHERITED(gpu, desc, kSampler2D_GrSLType, desc.fIsMipMapped) | 40 , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped) |
| 41 , fTextureView(view) | 41 , fTextureView(view) |
| 42 , fLinearTextureView(nullptr) { | 42 , fLinearTextureView(nullptr) { |
| 43 this->registerWithCacheWrapped(); | 43 this->registerWithCacheWrapped(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Because this class is virtually derived from GrSurface we must explicitly cal
l its constructor. | 46 // Because this class is virtually derived from GrSurface we must explicitly cal
l its constructor. |
| 47 GrVkTexture::GrVkTexture(GrVkGpu* gpu, | 47 GrVkTexture::GrVkTexture(GrVkGpu* gpu, |
| 48 const GrSurfaceDesc& desc, | 48 const GrSurfaceDesc& desc, |
| 49 const GrVkImageInfo& info, | 49 const GrVkImageInfo& info, |
| 50 const GrVkImageView* view, | 50 const GrVkImageView* view, |
| 51 GrVkImage::Wrapped wrapped) | 51 GrVkImage::Wrapped wrapped) |
| 52 : GrSurface(gpu, desc) | 52 : GrSurface(gpu, desc) |
| 53 , GrVkImage(info, wrapped) | 53 , GrVkImage(info, wrapped) |
| 54 , INHERITED(gpu, desc, kSampler2D_GrSLType, desc.fIsMipMapped) | 54 , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped) |
| 55 , fTextureView(view) | 55 , fTextureView(view) |
| 56 , fLinearTextureView(nullptr) { | 56 , fLinearTextureView(nullptr) { |
| 57 } | 57 } |
| 58 | 58 |
| 59 GrVkTexture* GrVkTexture::CreateNewTexture(GrVkGpu* gpu, SkBudgeted budgeted, | 59 GrVkTexture* GrVkTexture::CreateNewTexture(GrVkGpu* gpu, SkBudgeted budgeted, |
| 60 const GrSurfaceDesc& desc, | 60 const GrSurfaceDesc& desc, |
| 61 const GrVkImage::ImageDesc& imageDesc
) { | 61 const GrVkImage::ImageDesc& imageDesc
) { |
| 62 SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT); | 62 SkASSERT(imageDesc.fUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT); |
| 63 | 63 |
| 64 GrVkImageInfo info; | 64 GrVkImageInfo info; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 fLinearTextureView = nullptr; | 216 fLinearTextureView = nullptr; |
| 217 } | 217 } |
| 218 | 218 |
| 219 this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling); | 219 this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling); |
| 220 fTextureView = textureView; | 220 fTextureView = textureView; |
| 221 fInfo = info; | 221 fInfo = info; |
| 222 this->texturePriv().setMaxMipMapLevel(mipLevels); | 222 this->texturePriv().setMaxMipMapLevel(mipLevels); |
| 223 | 223 |
| 224 return true; | 224 return true; |
| 225 } | 225 } |
| OLD | NEW |