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

Side by Side Diff: gm/tileimagefilter.cpp

Issue 1320673011: Minor code cleanup (left over from prior CL) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 | « gm/repeated_bitmap.cpp ('k') | gm/xfermodeimagefilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkColorFilterImageFilter.h" 10 #include "SkColorFilterImageFilter.h"
11 #include "SkColorMatrixFilter.h" 11 #include "SkColorMatrixFilter.h"
12 #include "SkTileImageFilter.h" 12 #include "SkTileImageFilter.h"
13 #include "gm.h" 13 #include "gm.h"
14 14
15 #define WIDTH 400 15 #define WIDTH 400
16 #define HEIGHT 100 16 #define HEIGHT 100
17 #define MARGIN 12 17 #define MARGIN 12
18 18
19 static SkBitmap make_bitmap() {
20 SkBitmap bitmap;
21 bitmap.allocN32Pixels(50, 50);
22 SkCanvas canvas(bitmap);
23 canvas.clear(0xFF000000);
24 SkPaint paint;
25 paint.setAntiAlias(true);
26 sk_tool_utils::set_portable_typeface(&paint);
27 paint.setColor(0xD000D000);
28 paint.setTextSize(SkIntToScalar(50));
29 const char* str = "e";
30 canvas.drawText(str, strlen(str), SkIntToScalar(10), SkIntToScalar(45), pain t);
31 return bitmap;
32 }
33
34
35 namespace skiagm { 19 namespace skiagm {
36 20
37 class TileImageFilterGM : public GM { 21 class TileImageFilterGM : public GM {
38 public: 22 public:
39 TileImageFilterGM() { 23 TileImageFilterGM() {
40 this->setBGColor(0xFF000000); 24 this->setBGColor(0xFF000000);
41 } 25 }
42 26
43 protected: 27 protected:
44 SkString onShortName() override { 28 SkString onShortName() override {
45 return SkString("tileimagefilter"); 29 return SkString("tileimagefilter");
46 } 30 }
47 31
48 SkISize onISize() override{ 32 SkISize onISize() override{
49 return SkISize::Make(WIDTH, HEIGHT); 33 return SkISize::Make(WIDTH, HEIGHT);
50 } 34 }
51 35
52 void onOnceBeforeDraw() override { 36 void onOnceBeforeDraw() override {
53 fBitmap = make_bitmap(); 37 fBitmap = sk_tool_utils::create_string_bitmap(50, 50, 0xD000D000, 10, 45 , 50, "e");
54 38
55 fCheckerboard.allocN32Pixels(80, 80); 39 fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(
56 SkCanvas checkerboardCanvas(fCheckerboard); 40 80, 80,
57 sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 41 sk_tool_utils::color_to_ 565(0xFFA0A0A0),
58 sk_tool_utils::color_to_565(0xFFA0A0A0), 42 sk_tool_utils::color_to_ 565(0xFF404040),
59 sk_tool_utils::color_to_565(0xFF404040), 8); 43 8);
60 } 44 }
61 45
62 void onDraw(SkCanvas* canvas) override { 46 void onDraw(SkCanvas* canvas) override {
63 canvas->clear(SK_ColorBLACK); 47 canvas->clear(SK_ColorBLACK);
64 48
65 int x = 0, y = 0; 49 int x = 0, y = 0;
66 for (size_t i = 0; i < 4; i++) { 50 for (size_t i = 0; i < 4; i++) {
67 SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; 51 SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap;
68 SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(bitmap->width()/4), 52 SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(bitmap->width()/4),
69 SkIntToScalar(bitmap->height()/4), 53 SkIntToScalar(bitmap->height()/4),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 SkBitmap fBitmap; 100 SkBitmap fBitmap;
117 SkBitmap fCheckerboard; 101 SkBitmap fCheckerboard;
118 102
119 typedef GM INHERITED; 103 typedef GM INHERITED;
120 }; 104 };
121 105
122 ////////////////////////////////////////////////////////////////////////////// 106 //////////////////////////////////////////////////////////////////////////////
123 107
124 DEF_GM(return new TileImageFilterGM;) 108 DEF_GM(return new TileImageFilterGM;)
125 } 109 }
OLDNEW
« no previous file with comments | « gm/repeated_bitmap.cpp ('k') | gm/xfermodeimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698