OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 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 "CanvasStateHelpers.h" |
| 9 #include "SkCanvas.h" |
| 10 #include "SkCanvasStateUtils.h" |
| 11 #include "SkPaint.h" |
| 12 #include "SkRect.h" |
| 13 #include "SkRegion.h" |
| 14 |
| 15 void complex_layers_draw(SkCanvas* canvas, float left, float top, |
| 16 float right, float bottom, int32_t spacer) { |
| 17 SkPaint bluePaint; |
| 18 bluePaint.setColor(SK_ColorBLUE); |
| 19 bluePaint.setStyle(SkPaint::kFill_Style); |
| 20 |
| 21 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom); |
| 22 canvas->drawRect(rect, bluePaint); |
| 23 canvas->translate(0, rect.height() + spacer); |
| 24 canvas->drawRect(rect, bluePaint); |
| 25 } |
| 26 |
| 27 extern "C" bool complex_layers_draw_from_canvas_state(SkCanvasState* state, |
| 28 float left, float top, float right, float bottom, int32_t spacer) { |
| 29 SkCanvas* canvas = SkCanvasStateUtils::CreateFromCanvasState(state); |
| 30 if (!canvas) { |
| 31 return false; |
| 32 } |
| 33 complex_layers_draw(canvas, left, top, right, bottom, spacer); |
| 34 canvas->unref(); |
| 35 return true; |
| 36 } |
| 37 |
| 38 void test_complex_clips_draw(SkCanvas* canvas, int32_t left, int32_t top, |
| 39 // FIXME: Don't use SkRegion... |
| 40 int32_t right, int32_t bottom, int32_t clipOp, const SkRegion& localRegi
on) { |
| 41 canvas->save(); |
| 42 SkRect clipRect = SkRect::MakeLTRB(SkIntToScalar(left), SkIntToScalar(top), |
| 43 SkIntToScalar(right), SkIntToScalar(botto
m)); |
| 44 canvas->clipRect(clipRect, (SkRegion::Op) clipOp); |
| 45 canvas->drawColor(SK_ColorBLUE); |
| 46 canvas->restore(); |
| 47 |
| 48 canvas->clipRegion(localRegion, (SkRegion::Op) clipOp); |
| 49 canvas->drawColor(SK_ColorBLUE); |
| 50 } |
| 51 |
| 52 extern "C" bool test_complex_clips_draw_from_canvas_state(SkCanvasState* state,
int32_t left, |
| 53 int32_t top, int32_t right, int32_t bottom, int32_t clipOp, const SkRegi
on* localRegion) { |
| 54 SkCanvas* canvas = SkCanvasStateUtils::CreateFromCanvasState(state); |
| 55 if (!canvas) { |
| 56 return false; |
| 57 } |
| 58 test_complex_clips_draw(canvas, left, top, right, bottom, clipOp, *localRegi
on); |
| 59 canvas->unref(); |
| 60 return true; |
| 61 } |
| 62 |
OLD | NEW |