Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 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" |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame] | 14 | |
| 15 | class GrVkGpu; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 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; |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 24 | struct GrVkImageInfo; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 25 | |
| 26 | class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget { |
| 27 | public: |
Greg Daniel | f18c297 | 2018-09-25 19:16:43 +0000 | [diff] [blame] | 28 | static sk_sp<GrVkTextureRenderTarget> CreateNewTextureRenderTarget(GrVkGpu*, SkBudgeted, |
| 29 | const GrSurfaceDesc&, |
| 30 | const GrVkImage::ImageDesc&, |
| 31 | GrMipMapsStatus); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 32 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 33 | static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*, |
| 34 | const GrSurfaceDesc&, |
| 35 | GrWrapOwnership, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 36 | const GrVkImageInfo&, |
| 37 | sk_sp<GrVkImageLayout>); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 38 | |
egdaniel | 50ead53 | 2016-07-13 14:23:26 -0700 | [diff] [blame] | 39 | bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo); |
| 40 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 41 | protected: |
| 42 | void onAbandon() override { |
| 43 | GrVkRenderTarget::onAbandon(); |
| 44 | GrVkTexture::onAbandon(); |
| 45 | } |
| 46 | |
| 47 | void onRelease() override { |
| 48 | GrVkRenderTarget::onRelease(); |
| 49 | GrVkTexture::onRelease(); |
| 50 | } |
| 51 | |
| 52 | private: |
| 53 | GrVkTextureRenderTarget(GrVkGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 54 | SkBudgeted budgeted, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 55 | const GrSurfaceDesc& desc, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 56 | const GrVkImageInfo& info, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 57 | sk_sp<GrVkImageLayout> layout, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 58 | const GrVkImageView* texView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 59 | const GrVkImageInfo& msaaInfo, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 60 | sk_sp<GrVkImageLayout> msaaLayout, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 61 | const GrVkImageView* colorAttachmentView, |
Greg Daniel | 1591c38 | 2017-08-17 15:37:20 -0400 | [diff] [blame] | 62 | const GrVkImageView* resolveAttachmentView, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 63 | GrMipMapsStatus, |
| 64 | GrBackendObjectOwnership); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 65 | |
| 66 | GrVkTextureRenderTarget(GrVkGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 67 | SkBudgeted budgeted, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 68 | const GrSurfaceDesc& desc, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 69 | const GrVkImageInfo& info, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 70 | sk_sp<GrVkImageLayout> layout, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 71 | const GrVkImageView* texView, |
Greg Daniel | 1591c38 | 2017-08-17 15:37:20 -0400 | [diff] [blame] | 72 | const GrVkImageView* colorAttachmentView, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 73 | GrMipMapsStatus, |
| 74 | GrBackendObjectOwnership); |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame] | 75 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 76 | GrVkTextureRenderTarget(GrVkGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 77 | const GrSurfaceDesc& desc, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 78 | const GrVkImageInfo& info, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 79 | sk_sp<GrVkImageLayout> layout, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 80 | const GrVkImageView* texView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 81 | const GrVkImageInfo& msaaInfo, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 82 | sk_sp<GrVkImageLayout> msaaLayout, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 83 | const GrVkImageView* colorAttachmentView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 84 | const GrVkImageView* resolveAttachmentView, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 85 | GrMipMapsStatus, |
Greg Daniel | 1591c38 | 2017-08-17 15:37:20 -0400 | [diff] [blame] | 86 | GrBackendObjectOwnership); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 87 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 88 | GrVkTextureRenderTarget(GrVkGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 89 | const GrSurfaceDesc& desc, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 90 | const GrVkImageInfo& info, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 91 | sk_sp<GrVkImageLayout> layout, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 92 | const GrVkImageView* texView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 93 | const GrVkImageView* colorAttachmentView, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 94 | GrMipMapsStatus, |
Greg Daniel | 1591c38 | 2017-08-17 15:37:20 -0400 | [diff] [blame] | 95 | GrBackendObjectOwnership); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 96 | |
Robert Phillips | 67d52cf | 2017-06-05 13:38:13 -0400 | [diff] [blame] | 97 | static sk_sp<GrVkTextureRenderTarget> Make(GrVkGpu*, |
| 98 | const GrSurfaceDesc&, |
| 99 | const GrVkImageInfo&, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 100 | sk_sp<GrVkImageLayout>, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 101 | GrMipMapsStatus, |
Robert Phillips | 67d52cf | 2017-06-05 13:38:13 -0400 | [diff] [blame] | 102 | SkBudgeted budgeted, |
Greg Daniel | 1591c38 | 2017-08-17 15:37:20 -0400 | [diff] [blame] | 103 | GrBackendObjectOwnership, |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 104 | bool isWrapped); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 105 | |
| 106 | // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory. |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 107 | size_t onGpuMemorySize() const override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | #endif |