Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: tools/Checkerboard.cpp

Issue 834303005: Factor out checkerboard function in gm and sampleapp into tools. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rename to sk_tools::DrawCheckerboard Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/Checkerboard.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « tools/Checkerboard.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698