Chromium Code Reviews| Index: src/gpu/GrClip.cpp |
| diff --git a/src/gpu/GrClip.cpp b/src/gpu/GrClip.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..761c065460af4c9b0adecaf7a54cf26801000148 |
| --- /dev/null |
| +++ b/src/gpu/GrClip.cpp |
| @@ -0,0 +1,50 @@ |
| +/* |
| + * Copyright 2010 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "GrClip.h" |
| + |
| +#include "GrSurface.h" |
| +#include "SkRect.h" |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +/** |
| + * 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) { |
| + default: |
| + SkFAIL("incomplete switch\n"); |
| + case kWideOpen_ClipType: { |
| + devResult->setLTRB(0, 0, SkIntToScalar(width), SkIntToScalar(height)); |
| + if (isIntersectionOfRects) { |
| + *isIntersectionOfRects = false; |
|
bsalomon
2015/02/23 19:31:29
I think we should say true here... it is effective
|
| + } |
| + } break; |
| + case kIRect_ClipType: { |
| + *devResult = this->irect(); |
| + if (isIntersectionOfRects) { |
| + *isIntersectionOfRects = false; |
|
bsalomon
2015/02/23 19:31:29
true
|
| + } |
| + } break; |
| + case kClipStack_ClipType: { |
| + SkRect devBounds; |
| + this->clipStack()->getConservativeBounds(-this->origin().fX, |
| + -this->origin().fY, |
| + width, |
| + height, |
| + &devBounds, |
| + isIntersectionOfRects); |
| + devBounds.roundOut(devResult); |
| + } break; |
| + |
| + } |
| +} |