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: |
Robert Phillips | 67d52cf | 2017-06-05 13:38:13 -0400 | [diff] [blame] | 28 | static sk_sp<GrVkTextureRenderTarget> CreateNewTextureRenderTarget(GrVkGpu*, SkBudgeted, |
| 29 | const GrSurfaceDesc&, |
| 30 | const GrVkImage::ImageDesc&); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 31 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 32 | static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*, |
| 33 | const GrSurfaceDesc&, |
| 34 | GrWrapOwnership, |
| 35 | const GrVkImageInfo*); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 36 | |
egdaniel | 50ead53 | 2016-07-13 14:23:26 -0700 | [diff] [blame] | 37 | bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo); |
| 38 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 39 | protected: |
| 40 | void onAbandon() override { |
| 41 | GrVkRenderTarget::onAbandon(); |
| 42 | GrVkTexture::onAbandon(); |
| 43 | } |
| 44 | |
| 45 | void onRelease() override { |
| 46 | GrVkRenderTarget::onRelease(); |
| 47 | GrVkTexture::onRelease(); |
| 48 | } |
| 49 | |
| 50 | private: |
| 51 | GrVkTextureRenderTarget(GrVkGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 52 | SkBudgeted budgeted, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 53 | const GrSurfaceDesc& desc, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 54 | const GrVkImageInfo& info, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 55 | const GrVkImageView* texView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 56 | const GrVkImageInfo& msaaInfo, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 57 | const GrVkImageView* colorAttachmentView, |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame^] | 58 | const GrVkImageView* resolveAttachmentView); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 59 | |
| 60 | GrVkTextureRenderTarget(GrVkGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 61 | SkBudgeted budgeted, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 62 | const GrSurfaceDesc& desc, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 63 | const GrVkImageInfo& info, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 64 | const GrVkImageView* texView, |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame^] | 65 | const GrVkImageView* colorAttachmentView); |
| 66 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 67 | GrVkTextureRenderTarget(GrVkGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 68 | const GrSurfaceDesc& desc, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 69 | const GrVkImageInfo& info, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 70 | const GrVkImageView* texView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 71 | const GrVkImageInfo& msaaInfo, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 72 | const GrVkImageView* colorAttachmentView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 73 | const GrVkImageView* resolveAttachmentView, |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame^] | 74 | GrVkImage::Wrapped wrapped); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [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, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 79 | const GrVkImageView* texView, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 80 | const GrVkImageView* colorAttachmentView, |
Greg Daniel | 6ecc911 | 2017-06-16 16:17:03 +0000 | [diff] [blame^] | 81 | GrVkImage::Wrapped wrapped); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 82 | |
Robert Phillips | 67d52cf | 2017-06-05 13:38:13 -0400 | [diff] [blame] | 83 | static sk_sp<GrVkTextureRenderTarget> Make(GrVkGpu*, |
| 84 | const GrSurfaceDesc&, |
| 85 | const GrVkImageInfo&, |
| 86 | SkBudgeted budgeted, |
| 87 | GrVkImage::Wrapped wrapped); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 88 | |
| 89 | // 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] | 90 | size_t onGpuMemorySize() const override; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | #endif |