OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrClip.h" | 8 #include "GrClip.h" |
9 | 9 |
10 #include "GrSurface.h" | 10 #include "GrSurface.h" |
11 #include "SkRect.h" | 11 #include "SkRect.h" |
12 | 12 |
13 /////////////////////////////////////////////////////////////////////////////// | 13 /////////////////////////////////////////////////////////////////////////////// |
14 | 14 |
15 /** | 15 /** |
16 * getConservativeBounds returns the conservative bounding box of the clip | 16 * getConservativeBounds returns the conservative bounding box of the clip |
17 * in device (as opposed to canvas) coordinates. If the bounding box is | 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) | 18 * the result of purely intersections of rects (with an initial replace) |
19 * isIntersectionOfRects will be set to true. | 19 * isIntersectionOfRects will be set to true. |
20 */ | 20 */ |
21 void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult, | 21 void GrClip::getConservativeBounds(int width, int height, SkIRect* devResult, |
22 bool* isIntersectionOfRects) const { | 22 bool* isIntersectionOfRects) const { |
23 switch (fClipType) { | 23 switch (fClipType) { |
24 default: | |
25 SkFAIL("incomplete switch\n"); | |
26 case kWideOpen_ClipType: { | 24 case kWideOpen_ClipType: { |
27 devResult->setLTRB(0, 0, width, height); | 25 devResult->setLTRB(0, 0, width, height); |
28 if (isIntersectionOfRects) { | 26 if (isIntersectionOfRects) { |
29 *isIntersectionOfRects = true; | 27 *isIntersectionOfRects = true; |
30 } | 28 } |
31 } break; | 29 } break; |
32 case kIRect_ClipType: { | 30 case kIRect_ClipType: { |
33 *devResult = this->irect(); | 31 *devResult = this->irect(); |
34 if (isIntersectionOfRects) { | 32 if (isIntersectionOfRects) { |
35 *isIntersectionOfRects = true; | 33 *isIntersectionOfRects = true; |
36 } | 34 } |
37 } break; | 35 } break; |
| 36 case kRect_ClipType: { |
| 37 devResult->setLTRB(SkScalarCeilToInt(this->rect().fLeft), |
| 38 SkScalarCeilToInt(this->rect().fTop), |
| 39 SkScalarCeilToInt(this->rect().fRight), |
| 40 SkScalarCeilToInt(this->rect().fBottom)); |
| 41 if (isIntersectionOfRects) { |
| 42 *isIntersectionOfRects = true; |
| 43 } |
| 44 } break; |
38 case kClipStack_ClipType: { | 45 case kClipStack_ClipType: { |
39 SkRect devBounds; | 46 SkRect devBounds; |
40 this->clipStack()->getConservativeBounds(-this->origin().fX, | 47 this->clipStack()->getConservativeBounds(-this->origin().fX, |
41 -this->origin().fY, | 48 -this->origin().fY, |
42 width, | 49 width, |
43 height, | 50 height, |
44 &devBounds, | 51 &devBounds, |
45 isIntersectionOfRects); | 52 isIntersectionOfRects); |
46 devBounds.roundOut(devResult); | 53 devBounds.roundOut(devResult); |
47 } break; | 54 } break; |
48 | 55 |
49 } | 56 } |
50 } | 57 } |
51 | 58 |
52 const GrClip& GrClip::WideOpen() { | 59 const GrClip& GrClip::WideOpen() { |
53 static const GrClip clip; | 60 static const GrClip clip; |
54 return clip; | 61 return clip; |
55 } | 62 } |
OLD | NEW |