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"); |
24 case kWideOpen_ClipType: { | 26 case kWideOpen_ClipType: { |
25 devResult->setLTRB(0, 0, width, height); | 27 devResult->setLTRB(0, 0, width, height); |
26 if (isIntersectionOfRects) { | 28 if (isIntersectionOfRects) { |
27 *isIntersectionOfRects = true; | 29 *isIntersectionOfRects = true; |
28 } | 30 } |
29 } break; | 31 } break; |
30 case kIRect_ClipType: { | 32 case kIRect_ClipType: { |
31 *devResult = this->irect(); | 33 *devResult = this->irect(); |
32 if (isIntersectionOfRects) { | 34 if (isIntersectionOfRects) { |
33 *isIntersectionOfRects = true; | 35 *isIntersectionOfRects = true; |
34 } | 36 } |
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; | 37 } break; |
45 case kClipStack_ClipType: { | 38 case kClipStack_ClipType: { |
46 SkRect devBounds; | 39 SkRect devBounds; |
47 this->clipStack()->getConservativeBounds(-this->origin().fX, | 40 this->clipStack()->getConservativeBounds(-this->origin().fX, |
48 -this->origin().fY, | 41 -this->origin().fY, |
49 width, | 42 width, |
50 height, | 43 height, |
51 &devBounds, | 44 &devBounds, |
52 isIntersectionOfRects); | 45 isIntersectionOfRects); |
53 devBounds.roundOut(devResult); | 46 devBounds.roundOut(devResult); |
54 } break; | 47 } break; |
55 | 48 |
56 } | 49 } |
57 } | 50 } |
58 | 51 |
59 const GrClip& GrClip::WideOpen() { | 52 const GrClip& GrClip::WideOpen() { |
60 static const GrClip clip; | 53 static const GrClip clip; |
61 return clip; | 54 return clip; |
62 } | 55 } |
OLD | NEW |