1/* 2 * Copyright 2015 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#ifndef GrVkTexture_DEFINED 9#define GrVkTexture_DEFINED 10 11#include "GrTexture.h" 12#include "GrVkImage.h" 13 14class GrVkGpu; 15class GrVkImageView; 16struct GrVkImageInfo; 17 18class GrVkTexture : public GrTexture, public virtual GrVkImage { 19public: 20 static sk_sp<GrVkTexture> CreateNewTexture(GrVkGpu*, 21 SkBudgeted budgeted, 22 const GrSurfaceDesc&, 23 const GrVkImage::ImageDesc&, 24 GrMipMapsStatus); 25 26 static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&, 27 GrWrapOwnership, const GrVkImageInfo*); 28 29 ~GrVkTexture() override; 30 31 GrBackendObject getTextureHandle() const override; 32 GrBackendTexture getBackendTexture() const override; 33 34 void textureParamsModified() override {} 35 36 const GrVkImageView* textureView(bool allowSRGB); 37 38 bool reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels); 39 40 // In Vulkan we call the release proc after we are finished with the underlying 41 // GrVkImage::Resource object (which occurs after the GPU has finsihed all work on it). 42 void setRelease(sk_sp<GrReleaseProcHelper> releaseHelper) override { 43 // Forward the release proc on to GrVkImage 44 this->setResourceRelease(std::move(releaseHelper)); 45 } 46 47protected: 48 GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, const GrVkImageView*, 49 GrMipMapsStatus, GrBackendObjectOwnership); 50 51 GrVkGpu* getVkGpu() const; 52 53 void onAbandon() override; 54 void onRelease() override; 55 56 bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { 57 return false; 58 } 59 60private: 61 enum Wrapped { kWrapped }; 62 GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&, 63 const GrVkImageInfo&, const GrVkImageView* imageView, 64 GrMipMapsStatus); 65 GrVkTexture(GrVkGpu*, Wrapped, const GrSurfaceDesc&, 66 const GrVkImageInfo&, const GrVkImageView* imageView, GrMipMapsStatus, 67 GrBackendObjectOwnership); 68 69 const GrVkImageView* fTextureView; 70 const GrVkImageView* fLinearTextureView; 71 72 typedef GrTexture INHERITED; 73}; 74 75#endif 76