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.

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

mercurial