bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 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 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 9 | #ifndef GrStencilAttachment_DEFINED |
| 10 | #define GrStencilAttachment_DEFINED |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 11 | |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 12 | #include "GrGpuResource.h" |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 13 | #include "SkClipStack.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 14 | |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 15 | class GrRenderTarget; |
robertphillips@google.com | 46a8600 | 2012-08-08 10:42:44 +0000 | [diff] [blame] | 16 | class GrResourceKey; |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 17 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 18 | class GrStencilAttachment : public GrGpuResource { |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 19 | public: |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 20 | ~GrStencilAttachment() override { |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 21 | // TODO: allow SB to be purged and detach itself from rts |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 22 | } |
| 23 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 24 | int width() const { return fWidth; } |
| 25 | int height() const { return fHeight; } |
| 26 | int bits() const { return fBits; } |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 27 | int numSamples() const { return fSampleCnt; } |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 28 | bool isDirty() const { return fIsDirty; } |
| 29 | |
| 30 | void cleared() { fIsDirty = false; } |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 31 | |
bsalomon | 02a44a4 | 2015-02-19 09:09:00 -0800 | [diff] [blame] | 32 | // We create a unique stencil buffer at each width, height and sampleCnt and share it for |
| 33 | // all render targets that require a stencil with those params. |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 34 | static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt, |
| 35 | GrUniqueKey* key); |
robertphillips@google.com | 46a8600 | 2012-08-08 10:42:44 +0000 | [diff] [blame] | 36 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 37 | protected: |
robertphillips | 55fdccc | 2016-06-06 06:16:20 -0700 | [diff] [blame] | 38 | GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleCnt) |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 39 | : INHERITED(gpu) |
| 40 | , fWidth(width) |
| 41 | , fHeight(height) |
| 42 | , fBits(bits) |
| 43 | , fSampleCnt(sampleCnt) |
| 44 | , fIsDirty(true) { |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | private: |
bsalomon@google.com | eefe6f1 | 2011-08-09 17:57:12 +0000 | [diff] [blame] | 48 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 49 | int fWidth; |
| 50 | int fHeight; |
| 51 | int fBits; |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 52 | int fSampleCnt; |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 53 | bool fIsDirty; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 54 | |
bsalomon | 6d3fe02 | 2014-07-25 08:35:45 -0700 | [diff] [blame] | 55 | typedef GrGpuResource INHERITED; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #endif |