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

Side by Side Diff: gm/tileimagefilter.cpp

Issue 140593005: add legacy/helper allocN32Pixels, and convert gm to use it (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gm/tablecolorfilter.cpp ('k') | gm/tilemodes.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 "gm.h" 8 #include "gm.h"
9 #include "SkTileImageFilter.h" 9 #include "SkTileImageFilter.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
11 11
12 #define WIDTH 400 12 #define WIDTH 400
13 #define HEIGHT 100 13 #define HEIGHT 100
14 #define MARGIN 12 14 #define MARGIN 12
15 15
16 namespace skiagm { 16 namespace skiagm {
17 17
18 class TileImageFilterGM : public GM { 18 class TileImageFilterGM : public GM {
19 public: 19 public:
20 TileImageFilterGM() : fInitialized(false) { 20 TileImageFilterGM() : fInitialized(false) {
21 this->setBGColor(0xFF000000); 21 this->setBGColor(0xFF000000);
22 } 22 }
23 23
24 protected: 24 protected:
25 virtual SkString onShortName() { 25 virtual SkString onShortName() {
26 return SkString("tileimagefilter"); 26 return SkString("tileimagefilter");
27 } 27 }
28 28
29 void make_bitmap() { 29 void make_bitmap() {
30 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); 30 fBitmap.allocN32Pixels(80, 80);
31 fBitmap.allocPixels();
32 SkBitmapDevice device(fBitmap); 31 SkBitmapDevice device(fBitmap);
33 SkCanvas canvas(&device); 32 SkCanvas canvas(&device);
34 canvas.clear(0xFF000000); 33 canvas.clear(0xFF000000);
35 SkPaint paint; 34 SkPaint paint;
36 paint.setAntiAlias(true); 35 paint.setAntiAlias(true);
37 paint.setColor(0xD000D000); 36 paint.setColor(0xD000D000);
38 paint.setTextSize(SkIntToScalar(96)); 37 paint.setTextSize(SkIntToScalar(96));
39 const char* str = "e"; 38 const char* str = "e";
40 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(65), paint); 39 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(65), paint);
41 } 40 }
42 41
43 void make_checkerboard() { 42 void make_checkerboard() {
44 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); 43 fCheckerboard.allocN32Pixels(80, 80);
45 fCheckerboard.allocPixels();
46 SkBitmapDevice device(fCheckerboard); 44 SkBitmapDevice device(fCheckerboard);
47 SkCanvas canvas(&device); 45 SkCanvas canvas(&device);
48 canvas.clear(0x00000000); 46 canvas.clear(0x00000000);
49 SkPaint darkPaint; 47 SkPaint darkPaint;
50 darkPaint.setColor(0xFF404040); 48 darkPaint.setColor(0xFF404040);
51 SkPaint lightPaint; 49 SkPaint lightPaint;
52 lightPaint.setColor(0xFFA0A0A0); 50 lightPaint.setColor(0xFFA0A0A0);
53 for (int y = 0; y < 80; y += 16) { 51 for (int y = 0; y < 80; y += 16) {
54 for (int x = 0; x < 80; x += 16) { 52 for (int x = 0; x < 80; x += 16) {
55 canvas.save(); 53 canvas.save();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 SkBitmap fBitmap, fCheckerboard; 105 SkBitmap fBitmap, fCheckerboard;
108 bool fInitialized; 106 bool fInitialized;
109 }; 107 };
110 108
111 ////////////////////////////////////////////////////////////////////////////// 109 //////////////////////////////////////////////////////////////////////////////
112 110
113 static GM* MyFactory(void*) { return new TileImageFilterGM; } 111 static GM* MyFactory(void*) { return new TileImageFilterGM; }
114 static GMRegistry reg(MyFactory); 112 static GMRegistry reg(MyFactory);
115 113
116 } 114 }
OLDNEW
« no previous file with comments | « gm/tablecolorfilter.cpp ('k') | gm/tilemodes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698