OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "CanvasStateHelpers.h" | 8 #include "CanvasStateHelpers.h" |
9 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 9 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 complex_layers_draw(canvas, left, top, right, bottom, spacer); | 34 complex_layers_draw(canvas, left, top, right, bottom, spacer); |
35 canvas->unref(); | 35 canvas->unref(); |
36 return true; | 36 return true; |
37 } | 37 } |
38 | 38 |
39 void complex_clips_draw(SkCanvas* canvas, int32_t left, int32_t top, | 39 void complex_clips_draw(SkCanvas* canvas, int32_t left, int32_t top, |
40 int32_t right, int32_t bottom, int32_t clipOp, const SkRegion& localRegi
on) { | 40 int32_t right, int32_t bottom, int32_t clipOp, const SkRegion& localRegi
on) { |
41 canvas->save(); | 41 canvas->save(); |
42 SkRect clipRect = SkRect::MakeLTRB(SkIntToScalar(left), SkIntToScalar(top), | 42 SkRect clipRect = SkRect::MakeLTRB(SkIntToScalar(left), SkIntToScalar(top), |
43 SkIntToScalar(right), SkIntToScalar(botto
m)); | 43 SkIntToScalar(right), SkIntToScalar(botto
m)); |
44 canvas->clipRect(clipRect, (SkRegion::Op) clipOp); | 44 canvas->legacyClipRect(clipRect, (SkRegion::Op) clipOp); |
45 canvas->drawColor(SK_ColorBLUE); | 45 canvas->drawColor(SK_ColorBLUE); |
46 canvas->restore(); | 46 canvas->restore(); |
47 | 47 |
48 canvas->clipRegion(localRegion, (SkRegion::Op) clipOp); | 48 canvas->legacyClipRegion(localRegion, (SkRegion::Op) clipOp); |
49 canvas->drawColor(SK_ColorBLUE); | 49 canvas->drawColor(SK_ColorBLUE); |
50 } | 50 } |
51 | 51 |
52 extern "C" bool complex_clips_draw_from_canvas_state(SkCanvasState* state, | 52 extern "C" bool complex_clips_draw_from_canvas_state(SkCanvasState* state, |
53 int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t clipOp
, | 53 int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t clipOp
, |
54 int32_t regionRects, int32_t* rectCoords) { | 54 int32_t regionRects, int32_t* rectCoords) { |
55 SkCanvas* canvas = SkCanvasStateUtils::CreateFromCanvasState(state); | 55 SkCanvas* canvas = SkCanvasStateUtils::CreateFromCanvasState(state); |
56 if (!canvas) { | 56 if (!canvas) { |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 SkRegion localRegion; | 60 SkRegion localRegion; |
61 for (int32_t i = 0; i < regionRects; ++i) { | 61 for (int32_t i = 0; i < regionRects; ++i) { |
62 localRegion.op(rectCoords[0], rectCoords[1], rectCoords[2], rectCoords[3
], | 62 localRegion.op(rectCoords[0], rectCoords[1], rectCoords[2], rectCoords[3
], |
63 SkRegion::kUnion_Op); | 63 SkRegion::kUnion_Op); |
64 rectCoords += 4; | 64 rectCoords += 4; |
65 } | 65 } |
66 | 66 |
67 complex_clips_draw(canvas, left, top, right, bottom, clipOp, localRegion); | 67 complex_clips_draw(canvas, left, top, right, bottom, clipOp, localRegion); |
68 canvas->unref(); | 68 canvas->unref(); |
69 return true; | 69 return true; |
70 } | 70 } |
71 #endif // SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 71 #endif // SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
OLD | NEW |