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 #include "vk/GrVkTypes.h" 14 15 class GrVkGpu; 16 class GrVkImageView; 17 struct GrVkImageInfo; 18 19 class GrVkTexture : public GrTexture, public virtual GrVkImage { 20 public: 21 static sk_sp<GrVkTexture> MakeNewTexture(GrVkGpu*, 22 SkBudgeted budgeted, 23 const GrSurfaceDesc&, 24 const GrVkImage::ImageDesc&, 25 GrMipMapsStatus); 26 27 static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&, GrWrapOwnership, 28 GrWrapCacheable, GrIOType, const GrVkImageInfo&, 29 sk_sp<GrVkImageLayout>); 30 31 ~GrVkTexture() override; 32 33 GrBackendTexture getBackendTexture() const override; 34 backendFormat()35 GrBackendFormat backendFormat() const override { return this->getBackendFormat(); } 36 textureParamsModified()37 void textureParamsModified() override {} 38 39 const GrVkImageView* textureView(); 40 41 // In Vulkan we call the release proc after we are finished with the underlying 42 // GrVkImage::Resource object (which occurs after the GPU has finsihed all work on it). setRelease(sk_sp<GrReleaseProcHelper> releaseHelper)43 void setRelease(sk_sp<GrReleaseProcHelper> releaseHelper) override { 44 // Forward the release proc on to GrVkImage 45 this->setResourceRelease(std::move(releaseHelper)); 46 } 47 48 void setIdleProc(IdleProc, void* context) override; idleContext()49 void* idleContext() const override { return fIdleProcContext; } 50 51 protected: 52 GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>, 53 const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership); 54 55 GrVkGpu* getVkGpu() const; 56 57 void onAbandon() override; 58 void onRelease() override; 59 onStealBackendTexture(GrBackendTexture *,SkImage::BackendTextureReleaseProc *)60 bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override { 61 return false; 62 } 63 64 private: 65 GrVkTexture(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&, const GrVkImageInfo&, 66 sk_sp<GrVkImageLayout> layout, const GrVkImageView* imageView, 67 GrMipMapsStatus); 68 GrVkTexture(GrVkGpu*, const GrSurfaceDesc&, const GrVkImageInfo&, sk_sp<GrVkImageLayout>, 69 const GrVkImageView*, GrMipMapsStatus, GrBackendObjectOwnership, GrWrapCacheable, 70 GrIOType); 71 72 void removedLastRefOrPendingIO() override; 73 74 const GrVkImageView* fTextureView; 75 GrTexture::IdleProc* fIdleProc = nullptr; 76 void* fIdleProcContext = nullptr; 77 78 typedef GrTexture INHERITED; 79 }; 80 81 #endif 82