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

Unified Diff: gm/tileimagefilter.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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/offsetimagefilter.cpp ('k') | gm/xfermodeimagefilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/tileimagefilter.cpp
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index 7d1a3f08c3dd39a0ff47d3ea1ccd6fe81b5fcf4b..1d58def66bdcf25945ded8eb685186a0d1bd8dd7 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -5,11 +5,12 @@
* found in the LICENSE file.
*/
-#include "gm.h"
-#include "SkColorMatrixFilter.h"
+#include "Checkerboard.h"
+#include "SkBitmapSource.h"
#include "SkColorFilterImageFilter.h"
+#include "SkColorMatrixFilter.h"
#include "SkTileImageFilter.h"
-#include "SkBitmapSource.h"
+#include "gm.h"
#define WIDTH 400
#define HEIGHT 100
@@ -41,27 +42,6 @@ protected:
canvas.drawText(str, strlen(str), SkIntToScalar(10), SkIntToScalar(45), paint);
}
- void make_checkerboard() {
- fCheckerboard.allocN32Pixels(80, 80);
- SkCanvas canvas(fCheckerboard);
- canvas.clear(0x00000000);
- SkPaint darkPaint;
- darkPaint.setColor(0xFF404040);
- SkPaint lightPaint;
- lightPaint.setColor(0xFFA0A0A0);
- for (int y = 0; y < 80; y += 16) {
- for (int x = 0; x < 80; x += 16) {
- canvas.save();
- canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
- canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
- canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
- canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
- canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
- canvas.restore();
- }
- }
- }
-
virtual SkISize onISize() {
return SkISize::Make(WIDTH, HEIGHT);
}
@@ -69,7 +49,11 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
make_bitmap();
- make_checkerboard();
+
+ fCheckerboard.allocN32Pixels(80, 80);
+ SkCanvas checkerboardCanvas(fCheckerboard);
+ sk_tools::DrawCheckerboard(&checkerboardCanvas, 0xFFA0A0A0, 0xFF404040, 8);
+
fInitialized = true;
}
canvas->clear(0x00000000);
« no previous file with comments | « gm/offsetimagefilter.cpp ('k') | gm/xfermodeimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698