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 GrGLStencilAttachment_DEFINED |
| 10 | #define GrGLStencilAttachment_DEFINED |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 11 | |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 12 | #include "gl/GrGLInterface.h" |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 13 | #include "GrStencilAttachment.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 14 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 15 | class GrGLStencilAttachment : public GrStencilAttachment { |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 16 | public: |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 17 | static const GrGLenum kUnknownInternalFormat = ~0U; |
| 18 | static const GrGLuint kUnknownBitCount = ~0U; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 19 | struct Format { |
| 20 | GrGLenum fInternalFormat; |
| 21 | GrGLuint fStencilBits; |
| 22 | GrGLuint fTotalBits; |
| 23 | bool fPacked; |
| 24 | }; |
| 25 | |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 26 | struct IDDesc { |
bsalomon | 02a44a4 | 2015-02-19 09:09:00 -0800 | [diff] [blame] | 27 | IDDesc() : fRenderbufferID(0), fLifeCycle(kCached_LifeCycle) {} |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 28 | GrGLuint fRenderbufferID; |
| 29 | GrGpuResource::LifeCycle fLifeCycle; |
| 30 | }; |
| 31 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 32 | GrGLStencilAttachment(GrGpu* gpu, |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 33 | const IDDesc& idDesc, |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 34 | int width, int height, |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 35 | int sampleCnt, |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 36 | const Format& format) |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 37 | : GrStencilAttachment(gpu, idDesc.fLifeCycle, width, height, format.fStencilBits, sampleCnt) |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 38 | , fFormat(format) |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 39 | , fRenderbufferID(idDesc.fRenderbufferID) { |
bsalomon | 1696126 | 2014-08-26 14:01:07 -0700 | [diff] [blame] | 40 | this->registerWithCache(); |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 41 | } |
| 42 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 43 | GrGLuint renderbufferID() const { |
| 44 | return fRenderbufferID; |
| 45 | } |
| 46 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 47 | const Format& format() const { return fFormat; } |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 48 | |
| 49 | protected: |
robertphillips@google.com | d6bbbf8 | 2012-09-05 15:46:34 +0000 | [diff] [blame] | 50 | // overrides of GrResource |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 51 | void onRelease() override; |
| 52 | void onAbandon() override; |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 53 | void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 54 | const SkString& dumpName) const override; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 55 | |
| 56 | private: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 57 | size_t onGpuMemorySize() const override; |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 58 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 59 | Format fFormat; |
| 60 | // may be zero for external SBs associated with external RTs |
| 61 | // (we don't require the client to give us the id, just tell |
| 62 | // us how many bits of stencil there are). |
| 63 | GrGLuint fRenderbufferID; |
| 64 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 65 | typedef GrStencilAttachment INHERITED; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | #endif |