| Index: src/gpu/GrClip.cpp
|
| diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp
|
| index 5c4a27ccadb0453e73720084e454a6e29c7ee45b..15065aa4849fbd76a724634d3bb70f028684a5a9 100644
|
| --- a/src/gpu/GrClip.cpp
|
| +++ b/src/gpu/GrClip.cpp
|
| @@ -7,47 +7,83 @@
|
|
|
| #include "GrClip.h"
|
|
|
| -#include "GrSurface.h"
|
| -#include "SkRect.h"
|
| +#include "GrClipMaskManager.h"
|
|
|
| -///////////////////////////////////////////////////////////////////////////////
|
| +void GrNoClip::getConservativeBounds(int width, int height, SkIRect* devResult,
|
| + bool* isIntersectionOfRects) const {
|
| + devResult->setXYWH(0, 0, width, height);
|
| + if (isIntersectionOfRects) {
|
| + *isIntersectionOfRects = true;
|
| + }
|
| +}
|
|
|
| -/**
|
| - * getConservativeBounds returns the conservative bounding box of the clip
|
| - * in device (as opposed to canvas) coordinates. If the bounding box is
|
| - * the result of purely intersections of rects (with an initial replace)
|
| - * isIntersectionOfRects will be set to true.
|
| - */
|
| -void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult,
|
| - bool* isIntersectionOfRects) const {
|
| - switch (fClipType) {
|
| - case kWideOpen_ClipType: {
|
| - devResult->setLTRB(0, 0, width, height);
|
| - if (isIntersectionOfRects) {
|
| - *isIntersectionOfRects = true;
|
| - }
|
| - } break;
|
| - case kIRect_ClipType: {
|
| - *devResult = this->irect();
|
| - if (isIntersectionOfRects) {
|
| - *isIntersectionOfRects = true;
|
| - }
|
| - } break;
|
| - case kClipStack_ClipType: {
|
| - SkRect devBounds;
|
| - this->clipStack()->getConservativeBounds(-this->origin().fX,
|
| - -this->origin().fY,
|
| - width,
|
| - height,
|
| - &devBounds,
|
| - isIntersectionOfRects);
|
| - devBounds.roundOut(devResult);
|
| - } break;
|
| +bool GrFixedClip::quickContains(const SkRect& rect) const {
|
| + if (fHasStencilClip) {
|
| + return false;
|
| + }
|
| + if (!fScissorState.enabled()) {
|
| + return true;
|
| + }
|
| + return fScissorState.rect().contains(rect);
|
| +}
|
| +
|
| +void GrFixedClip::getConservativeBounds(int width, int height, SkIRect* devResult,
|
| + bool* isIntersectionOfRects) const {
|
| + devResult->setXYWH(0, 0, width, height);
|
| + if (fScissorState.enabled()) {
|
| + if (!devResult->intersect(fScissorState.rect())) {
|
| + devResult->setEmpty();
|
| + }
|
| + }
|
| + if (isIntersectionOfRects) {
|
| + *isIntersectionOfRects = true;
|
| + }
|
| +}
|
| +
|
| +bool GrFixedClip::apply(GrClipMaskManager*, const GrPipelineBuilder& pipelineBuilder,
|
| + const SkRect* devBounds, GrAppliedClip* out) const {
|
| + if (fScissorState.enabled()) {
|
| + const GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
|
| + SkIRect tightScissor;
|
| + if (!tightScissor.intersect(fScissorState.rect(),
|
| + SkIRect::MakeWH(rt->width(), rt->height()))) {
|
| + return false;
|
| + }
|
| + if (devBounds && !devBounds->intersects(SkRect::Make(tightScissor))) {
|
| + return false;
|
| + }
|
| + out->fScissorState.set(tightScissor);
|
| + }
|
| + out->fHasStencilClip = fHasStencilClip;
|
| + return true;
|
| +}
|
| +
|
| +bool GrClipStackClip::quickContains(const SkRect& rect) const {
|
| + if (!fStack) {
|
| + return true;
|
| + }
|
| + return fStack->quickContains(rect.makeOffset(SkIntToScalar(fOrigin.x()),
|
| + SkIntToScalar(fOrigin.y())));
|
| +}
|
|
|
| +void GrClipStackClip::getConservativeBounds(int width, int height, SkIRect* devResult,
|
| + bool* isIntersectionOfRects) const {
|
| + if (!fStack) {
|
| + devResult->setXYWH(0, 0, width, height);
|
| + if (isIntersectionOfRects) {
|
| + *isIntersectionOfRects = true;
|
| + }
|
| + return;
|
| }
|
| + SkRect devBounds;
|
| + fStack->getConservativeBounds(-fOrigin.x(), -fOrigin.y(), width, height, &devBounds,
|
| + isIntersectionOfRects);
|
| + devBounds.roundOut(devResult);
|
| }
|
|
|
| -const GrClip& GrClip::WideOpen() {
|
| - static const GrClip clip;
|
| - return clip;
|
| +bool GrClipStackClip::apply(GrClipMaskManager* clipMaskManager,
|
| + const GrPipelineBuilder& pipelineBuilder, const SkRect* devBounds,
|
| + GrAppliedClip* out) const {
|
| + // TODO: Collapse ClipMaskManager into this class.(?)
|
| + return clipMaskManager->setupClipping(pipelineBuilder, *this, devBounds, out);
|
| }
|
|
|