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 9 #ifndef GrVkTextureRenderTarget_DEFINED 10 #define GrVkTextureRenderTarget_DEFINED 11 12 #include "GrVkTexture.h" 13 #include "GrVkRenderTarget.h" 14 15 class GrVkGpu; 16 17 #ifdef SK_BUILD_FOR_WIN 18 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance. 19 #pragma warning(push) 20 #pragma warning(disable: 4250) 21 #endif 22 23 class GrVkImageView; 24 struct GrVkImageInfo; 25 26 class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget { 27 public: 28 static sk_sp<GrVkTextureRenderTarget> CreateNewTextureRenderTarget(GrVkGpu*, SkBudgeted, 29 const GrSurfaceDesc&, 30 const GrVkImage::ImageDesc&); 31 32 static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*, 33 const GrSurfaceDesc&, 34 GrWrapOwnership, 35 const GrVkImageInfo*); 36 37 bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo); 38 39 protected: onAbandon()40 void onAbandon() override { 41 GrVkRenderTarget::onAbandon(); 42 GrVkTexture::onAbandon(); 43 } 44 onRelease()45 void onRelease() override { 46 GrVkRenderTarget::onRelease(); 47 GrVkTexture::onRelease(); 48 } 49 50 private: 51 GrVkTextureRenderTarget(GrVkGpu* gpu, 52 SkBudgeted budgeted, 53 const GrSurfaceDesc& desc, 54 const GrVkImageInfo& info, 55 const GrVkImageView* texView, 56 const GrVkImageInfo& msaaInfo, 57 const GrVkImageView* colorAttachmentView, 58 const GrVkImageView* resolveAttachmentView); 59 60 GrVkTextureRenderTarget(GrVkGpu* gpu, 61 SkBudgeted budgeted, 62 const GrSurfaceDesc& desc, 63 const GrVkImageInfo& info, 64 const GrVkImageView* texView, 65 const GrVkImageView* colorAttachmentView); 66 67 GrVkTextureRenderTarget(GrVkGpu* gpu, 68 const GrSurfaceDesc& desc, 69 const GrVkImageInfo& info, 70 const GrVkImageView* texView, 71 const GrVkImageInfo& msaaInfo, 72 const GrVkImageView* colorAttachmentView, 73 const GrVkImageView* resolveAttachmentView, 74 GrVkImage::Wrapped wrapped); 75 76 GrVkTextureRenderTarget(GrVkGpu* gpu, 77 const GrSurfaceDesc& desc, 78 const GrVkImageInfo& info, 79 const GrVkImageView* texView, 80 const GrVkImageView* colorAttachmentView, 81 GrVkImage::Wrapped wrapped); 82 83 static sk_sp<GrVkTextureRenderTarget> Make(GrVkGpu*, 84 const GrSurfaceDesc&, 85 const GrVkImageInfo&, 86 SkBudgeted budgeted, 87 GrVkImage::Wrapped wrapped); 88 89 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory. 90 size_t onGpuMemorySize() const override; 91 }; 92 93 #endif 94