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 "include/gpu/vk/GrVkTypes.h" 13 #include "src/gpu/vk/GrVkRenderTarget.h" 14 #include "src/gpu/vk/GrVkTexture.h" 15 16 class GrVkGpu; 17 18 #ifdef SK_BUILD_FOR_WIN 19 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance. 20 #pragma warning(push) 21 #pragma warning(disable: 4250) 22 #endif 23 24 class GrVkImageView; 25 struct GrVkImageInfo; 26 27 class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget { 28 public: 29 static sk_sp<GrVkTextureRenderTarget> MakeNewTextureRenderTarget( 30 GrVkGpu* gpu, 31 SkBudgeted budgeted, 32 SkISize dimensions, 33 VkFormat format, 34 uint32_t mipLevels, 35 int sampleCnt, 36 GrMipmapStatus mipmapStatus, 37 GrProtected isProtected); 38 39 static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget( 40 GrVkGpu*, 41 SkISize dimensions, 42 int sampleCnt, 43 GrWrapOwnership, 44 GrWrapCacheable, 45 const GrVkImageInfo&, 46 sk_sp<GrBackendSurfaceMutableStateImpl>); 47 backendFormat()48 GrBackendFormat backendFormat() const override { return GrVkTexture::backendFormat(); } 49 50 protected: onAbandon()51 void onAbandon() override { 52 // In order to correctly handle calling texture idle procs, GrVkTexture must go first. 53 GrVkTexture::onAbandon(); 54 GrVkRenderTarget::onAbandon(); 55 } 56 onRelease()57 void onRelease() override { 58 // In order to correctly handle calling texture idle procs, GrVkTexture must go first. 59 GrVkTexture::onRelease(); 60 GrVkRenderTarget::onRelease(); 61 } 62 63 private: 64 GrVkTextureRenderTarget(GrVkGpu* gpu, 65 SkBudgeted budgeted, 66 SkISize dimensions, 67 sk_sp<GrVkImage> texture, 68 sk_sp<GrVkImage> colorAttachment, 69 sk_sp<GrVkImage> resolveAttachment, 70 GrMipmapStatus); 71 72 GrVkTextureRenderTarget(GrVkGpu* gpu, 73 SkISize dimensions, 74 sk_sp<GrVkImage> texture, 75 sk_sp<GrVkImage> colorAttachment, 76 sk_sp<GrVkImage> resolveAttachment, 77 GrMipmapStatus, 78 GrWrapCacheable); 79 80 size_t onGpuMemorySize() const override; 81 82 // In Vulkan we call the release proc after we are finished with the underlying 83 // GrVkImage::Resource object (which occurs after the GPU has finished all work on it). onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper)84 void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { 85 // Forward the release proc on to GrVkImage 86 GrVkTexture::onSetRelease(std::move(releaseHelper)); 87 } 88 }; 89 90 #ifdef SK_BUILD_FOR_WIN 91 #pragma warning(pop) 92 #endif 93 94 #endif 95