diff options
author | 2015-04-16 11:22:42 -0700 | |
---|---|---|
committer | 2015-04-16 11:22:42 -0700 | |
commit | 8dc7c3a839b38b73af34cc2674a06f49eb1ce527 (patch) | |
tree | 8e0b5386124df537472c66769a73a276351d95f0 /src/gpu/GrStencilAttachment.h | |
parent | 9c798207b7c710148d7f2989e877a7ece62edd5e (diff) |
Rename GrStencilBuffer to GrStencilAttachment
BUG=skia:
Review URL: https://codereview.chromium.org/1083133002
Diffstat (limited to 'src/gpu/GrStencilAttachment.h')
-rw-r--r-- | src/gpu/GrStencilAttachment.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/gpu/GrStencilAttachment.h b/src/gpu/GrStencilAttachment.h new file mode 100644 index 0000000000..ba9781d4ce --- /dev/null +++ b/src/gpu/GrStencilAttachment.h @@ -0,0 +1,81 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#ifndef GrStencilAttachment_DEFINED +#define GrStencilAttachment_DEFINED + +#include "GrClip.h" +#include "GrGpuResource.h" + +class GrRenderTarget; +class GrResourceKey; + +class GrStencilAttachment : public GrGpuResource { +public: + SK_DECLARE_INST_COUNT(GrStencilAttachment); + + virtual ~GrStencilAttachment() { + // TODO: allow SB to be purged and detach itself from rts + } + + int width() const { return fWidth; } + int height() const { return fHeight; } + int bits() const { return fBits; } + int numSamples() const { return fSampleCnt; } + + // called to note the last clip drawn to this buffer. + void setLastClip(int32_t clipStackGenID, + const SkIRect& clipSpaceRect, + const SkIPoint clipSpaceToStencilOffset) { + fLastClipStackGenID = clipStackGenID; + fLastClipStackRect = clipSpaceRect; + fLastClipSpaceOffset = clipSpaceToStencilOffset; + } + + // called to determine if we have to render the clip into SB. + bool mustRenderClip(int32_t clipStackGenID, + const SkIRect& clipSpaceRect, + const SkIPoint clipSpaceToStencilOffset) const { + return fLastClipStackGenID != clipStackGenID || + fLastClipSpaceOffset != clipSpaceToStencilOffset || + !fLastClipStackRect.contains(clipSpaceRect); + } + + // We create a unique stencil buffer at each width, height and sampleCnt and share it for + // all render targets that require a stencil with those params. + static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt, + GrUniqueKey* key); + +protected: + GrStencilAttachment(GrGpu* gpu, LifeCycle lifeCycle, int width, int height, int bits, + int sampleCnt) + : GrGpuResource(gpu, lifeCycle) + , fWidth(width) + , fHeight(height) + , fBits(bits) + , fSampleCnt(sampleCnt) + , fLastClipStackGenID(SkClipStack::kInvalidGenID) { + fLastClipStackRect.setEmpty(); + } + +private: + + int fWidth; + int fHeight; + int fBits; + int fSampleCnt; + + int32_t fLastClipStackGenID; + SkIRect fLastClipStackRect; + SkIPoint fLastClipSpaceOffset; + + typedef GrGpuResource INHERITED; +}; + +#endif |