gfx/skia/trunk/src/gpu/GrStencilBuffer.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2011 Google Inc.
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef GrStencilBuffer_DEFINED
michael@0 11 #define GrStencilBuffer_DEFINED
michael@0 12
michael@0 13 #include "GrClipData.h"
michael@0 14 #include "GrResource.h"
michael@0 15
michael@0 16 class GrRenderTarget;
michael@0 17 class GrResourceEntry;
michael@0 18 class GrResourceKey;
michael@0 19
michael@0 20 class GrStencilBuffer : public GrResource {
michael@0 21 public:
michael@0 22 SK_DECLARE_INST_COUNT(GrStencilBuffer);
michael@0 23
michael@0 24 virtual ~GrStencilBuffer() {
michael@0 25 // TODO: allow SB to be purged and detach itself from rts
michael@0 26 }
michael@0 27
michael@0 28 int width() const { return fWidth; }
michael@0 29 int height() const { return fHeight; }
michael@0 30 int bits() const { return fBits; }
michael@0 31 int numSamples() const { return fSampleCnt; }
michael@0 32
michael@0 33 // called to note the last clip drawn to this buffer.
michael@0 34 void setLastClip(int32_t clipStackGenID,
michael@0 35 const SkIRect& clipSpaceRect,
michael@0 36 const SkIPoint clipSpaceToStencilOffset) {
michael@0 37 fLastClipStackGenID = clipStackGenID;
michael@0 38 fLastClipStackRect = clipSpaceRect;
michael@0 39 fLastClipSpaceOffset = clipSpaceToStencilOffset;
michael@0 40 }
michael@0 41
michael@0 42 // called to determine if we have to render the clip into SB.
michael@0 43 bool mustRenderClip(int32_t clipStackGenID,
michael@0 44 const SkIRect& clipSpaceRect,
michael@0 45 const SkIPoint clipSpaceToStencilOffset) const {
michael@0 46 return fLastClipStackGenID != clipStackGenID ||
michael@0 47 fLastClipSpaceOffset != clipSpaceToStencilOffset ||
michael@0 48 !fLastClipStackRect.contains(clipSpaceRect);
michael@0 49 }
michael@0 50
michael@0 51 // Places the sb in the cache. The cache takes a ref of the stencil buffer.
michael@0 52 void transferToCache();
michael@0 53
michael@0 54 static GrResourceKey ComputeKey(int width, int height, int sampleCnt);
michael@0 55
michael@0 56 protected:
michael@0 57 GrStencilBuffer(GrGpu* gpu, bool isWrapped, int width, int height, int bits, int sampleCnt)
michael@0 58 : GrResource(gpu, isWrapped)
michael@0 59 , fWidth(width)
michael@0 60 , fHeight(height)
michael@0 61 , fBits(bits)
michael@0 62 , fSampleCnt(sampleCnt)
michael@0 63 , fLastClipStackGenID(SkClipStack::kInvalidGenID) {
michael@0 64 fLastClipStackRect.setEmpty();
michael@0 65 }
michael@0 66
michael@0 67 private:
michael@0 68
michael@0 69 int fWidth;
michael@0 70 int fHeight;
michael@0 71 int fBits;
michael@0 72 int fSampleCnt;
michael@0 73
michael@0 74 int32_t fLastClipStackGenID;
michael@0 75 SkIRect fLastClipStackRect;
michael@0 76 SkIPoint fLastClipSpaceOffset;
michael@0 77
michael@0 78 typedef GrResource INHERITED;
michael@0 79 };
michael@0 80
michael@0 81 #endif

mercurial