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