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 | #ifndef GrVkStencil_DEFINED |
| 9 | #define GrVkStencil_DEFINED |
| 10 | |
| 11 | #include "GrStencilAttachment.h" |
| 12 | #include "GrVkImage.h" |
Greg Daniel | 487132b | 2018-12-20 14:09:36 -0500 | [diff] [blame] | 13 | #include "vk/GrVkTypes.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 14 | |
| 15 | class GrVkImageView; |
| 16 | class GrVkGpu; |
| 17 | |
egdaniel | e015c26 | 2016-02-26 13:12:00 -0800 | [diff] [blame] | 18 | class GrVkStencilAttachment : public GrStencilAttachment, public GrVkImage { |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 19 | public: |
| 20 | struct Format { |
| 21 | VkFormat fInternalFormat; |
| 22 | int fStencilBits; |
| 23 | int fTotalBits; |
| 24 | bool fPacked; |
| 25 | }; |
| 26 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 27 | static GrVkStencilAttachment* Create(GrVkGpu* gpu, int width, int height, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 28 | int sampleCnt, const Format& format); |
| 29 | |
| 30 | ~GrVkStencilAttachment() override; |
| 31 | |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 32 | const GrVkResource* imageResource() const { return this->resource(); } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 33 | const GrVkImageView* stencilView() const { return fStencilView; } |
| 34 | |
| 35 | VkFormat vkFormat() const { return fFormat.fInternalFormat; } |
| 36 | |
| 37 | protected: |
| 38 | void onRelease() override; |
| 39 | void onAbandon() override; |
| 40 | |
| 41 | private: |
| 42 | size_t onGpuMemorySize() const override; |
| 43 | |
| 44 | GrVkStencilAttachment(GrVkGpu* gpu, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 45 | const Format& format, |
| 46 | const GrVkImage::ImageDesc&, |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 47 | const GrVkImageInfo&, |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 48 | sk_sp<GrVkImageLayout> layout, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 49 | const GrVkImageView* stencilView); |
| 50 | |
| 51 | GrVkGpu* getVkGpu() const; |
| 52 | |
| 53 | Format fFormat; |
| 54 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 55 | const GrVkImageView* fStencilView; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #endif |