joshualitt | 44701df | 2015-02-23 14:44:57 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrClip.h" |
| 9 | |
| 10 | #include "GrSurface.h" |
| 11 | #include "SkRect.h" |
| 12 | |
| 13 | /////////////////////////////////////////////////////////////////////////////// |
| 14 | |
| 15 | /** |
| 16 | * getConservativeBounds returns the conservative bounding box of the clip |
| 17 | * in device (as opposed to canvas) coordinates. If the bounding box is |
| 18 | * the result of purely intersections of rects (with an initial replace) |
| 19 | * isIntersectionOfRects will be set to true. |
| 20 | */ |
| 21 | void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult, |
| 22 | bool* isIntersectionOfRects) const { |
| 23 | switch (fClipType) { |
joshualitt | 44701df | 2015-02-23 14:44:57 -0800 | [diff] [blame] | 24 | case kWideOpen_ClipType: { |
| 25 | devResult->setLTRB(0, 0, width, height); |
| 26 | if (isIntersectionOfRects) { |
| 27 | *isIntersectionOfRects = true; |
| 28 | } |
| 29 | } break; |
| 30 | case kIRect_ClipType: { |
| 31 | *devResult = this->irect(); |
| 32 | if (isIntersectionOfRects) { |
| 33 | *isIntersectionOfRects = true; |
| 34 | } |
| 35 | } break; |
| 36 | case kClipStack_ClipType: { |
| 37 | SkRect devBounds; |
| 38 | this->clipStack()->getConservativeBounds(-this->origin().fX, |
| 39 | -this->origin().fY, |
| 40 | width, |
| 41 | height, |
| 42 | &devBounds, |
| 43 | isIntersectionOfRects); |
| 44 | devBounds.roundOut(devResult); |
| 45 | } break; |
| 46 | |
| 47 | } |
| 48 | } |
joshualitt | 9ece6a9 | 2015-02-23 17:03:33 -0800 | [diff] [blame] | 49 | |
| 50 | const GrClip& GrClip::WideOpen() { |
joshualitt | ab2f44c | 2015-02-24 06:47:14 -0800 | [diff] [blame] | 51 | static const GrClip clip; |
joshualitt | 9ece6a9 | 2015-02-23 17:03:33 -0800 | [diff] [blame] | 52 | return clip; |
| 53 | } |