OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 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 "Checkerboard.h" |
| 9 #include "SkCanvas.h" |
| 10 #include "SkShader.h" |
| 11 |
| 12 SkShader* sk_tools::CreateCheckerboardShader( |
| 13 SkColor c1, SkColor c2, int size) { |
| 14 SkBitmap bm; |
| 15 bm.allocN32Pixels(2 * size, 2 * size); |
| 16 bm.eraseColor(c1); |
| 17 bm.eraseArea(SkIRect::MakeLTRB(0, 0, size, size), c2); |
| 18 bm.eraseArea(SkIRect::MakeLTRB(size, size, 2 * size, 2 * size), c2); |
| 19 return SkShader::CreateBitmapShader( |
| 20 bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); |
| 21 } |
| 22 |
| 23 void sk_tools::DrawCheckerboard(SkCanvas* canvas, |
| 24 SkColor c1, SkColor c2, int size) { |
| 25 SkPaint paint; |
| 26 paint.setShader(CreateCheckerboardShader(c1, c2, size))->unref(); |
| 27 canvas->drawPaint(paint); |
| 28 } |
OLD | NEW |