blob: 08d6799f62391519617d46e421ecf2cf4c4192a2 [file] [log] [blame]
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +00001/*
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
egdaniel8dc7c3a2015-04-16 11:22:42 -07009#ifndef GrStencilAttachment_DEFINED
10#define GrStencilAttachment_DEFINED
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000011
bsalomon6d3fe022014-07-25 08:35:45 -070012#include "GrGpuResource.h"
csmartdaltonc6f411e2016-08-05 22:32:12 -070013#include "SkClipStack.h"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000014
bsalomon@google.com558a75b2011-08-08 17:01:14 +000015class GrRenderTarget;
robertphillips@google.com46a86002012-08-08 10:42:44 +000016class GrResourceKey;
bsalomon@google.com558a75b2011-08-08 17:01:14 +000017
egdaniel8dc7c3a2015-04-16 11:22:42 -070018class GrStencilAttachment : public GrGpuResource {
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000019public:
halcanary9d524f22016-03-29 09:03:52 -070020
robertphillips@google.com46a86002012-08-08 10:42:44 +000021
egdaniel8dc7c3a2015-04-16 11:22:42 -070022 virtual ~GrStencilAttachment() {
bsalomon@google.com558a75b2011-08-08 17:01:14 +000023 // TODO: allow SB to be purged and detach itself from rts
bsalomon@google.com558a75b2011-08-08 17:01:14 +000024 }
25
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000026 int width() const { return fWidth; }
27 int height() const { return fHeight; }
28 int bits() const { return fBits; }
bsalomon@google.com558a75b2011-08-08 17:01:14 +000029 int numSamples() const { return fSampleCnt; }
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000030
bsalomon02a44a42015-02-19 09:09:00 -080031 // 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.
egdaniel8dc7c3a2015-04-16 11:22:42 -070033 static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt,
34 GrUniqueKey* key);
robertphillips@google.com46a86002012-08-08 10:42:44 +000035
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000036protected:
robertphillips55fdccc2016-06-06 06:16:20 -070037 GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleCnt)
kkinnunen2e6055b2016-04-22 01:48:29 -070038 : GrGpuResource(gpu)
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000039 , fWidth(width)
40 , fHeight(height)
41 , fBits(bits)
csmartdalton7cdda992016-11-01 07:03:03 -070042 , fSampleCnt(sampleCnt) {
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000043 }
44
45private:
bsalomon@google.comeefe6f12011-08-09 17:57:12 +000046
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000047 int fWidth;
48 int fHeight;
49 int fBits;
bsalomon@google.com558a75b2011-08-08 17:01:14 +000050 int fSampleCnt;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000051
bsalomon6d3fe022014-07-25 08:35:45 -070052 typedef GrGpuResource INHERITED;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000053};
54
55#endif