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

Side by Side Diff: gm/imagefiltersclipped.cpp

Issue 163603003: add peekPixels to SkCanvas and SkSurface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « gm/gm.h ('k') | gm/imagefiltersgraph.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 2014 Google Inc. 2 * Copyright 2014 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 "SkColor.h" 9 #include "SkColor.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 17 matching lines...) Expand all
28 virtual SkString onShortName() { 28 virtual SkString onShortName() {
29 return SkString("imagefiltersclipped"); 29 return SkString("imagefiltersclipped");
30 } 30 }
31 31
32 virtual SkISize onISize() { 32 virtual SkISize onISize() {
33 return make_isize(860, 500); 33 return make_isize(860, 500);
34 } 34 }
35 35
36 void make_checkerboard() { 36 void make_checkerboard() {
37 fCheckerboard.allocN32Pixels(64, 64); 37 fCheckerboard.allocN32Pixels(64, 64);
38 SkBitmapDevice device(fCheckerboard); 38 SkCanvas canvas(fCheckerboard);
39 SkCanvas canvas(&device);
40 canvas.clear(0x00000000); 39 canvas.clear(0x00000000);
41 SkPaint darkPaint; 40 SkPaint darkPaint;
42 darkPaint.setColor(0xFF404040); 41 darkPaint.setColor(0xFF404040);
43 SkPaint lightPaint; 42 SkPaint lightPaint;
44 lightPaint.setColor(0xFFA0A0A0); 43 lightPaint.setColor(0xFFA0A0A0);
45 for (int y = 0; y < 64; y += 16) { 44 for (int y = 0; y < 64; y += 16) {
46 for (int x = 0; x < 64; x += 16) { 45 for (int x = 0; x < 64; x += 16) {
47 canvas.save(); 46 canvas.save();
48 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 47 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
49 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 48 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
50 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); 49 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
51 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); 50 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
52 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); 51 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
53 canvas.restore(); 52 canvas.restore();
54 } 53 }
55 } 54 }
56 } 55 }
57 56
58 void make_gradient_circle(int width, int height) { 57 void make_gradient_circle(int width, int height) {
59 SkScalar x = SkIntToScalar(width / 2); 58 SkScalar x = SkIntToScalar(width / 2);
60 SkScalar y = SkIntToScalar(height / 2); 59 SkScalar y = SkIntToScalar(height / 2);
61 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn tToScalar(5)); 60 SkScalar radius = SkMinScalar(x, y) * 0.8f;
62 fGradientCircle.allocN32Pixels(width, height); 61 fGradientCircle.allocN32Pixels(width, height);
63 SkBitmapDevice device(fGradientCircle); 62 SkCanvas canvas(fGradientCircle);
64 SkCanvas canvas(&device);
65 canvas.clear(0x00000000); 63 canvas.clear(0x00000000);
66 SkColor colors[2]; 64 SkColor colors[2];
67 colors[0] = SK_ColorWHITE; 65 colors[0] = SK_ColorWHITE;
68 colors[1] = SK_ColorBLACK; 66 colors[1] = SK_ColorBLACK;
69 SkAutoTUnref<SkShader> shader( 67 SkAutoTUnref<SkShader> shader(
70 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, NULL, 2, 68 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, NULL, 2,
71 SkShader::kClamp_TileMode) 69 SkShader::kClamp_TileMode)
72 ); 70 );
73 SkPaint paint; 71 SkPaint paint;
74 paint.setShader(shader); 72 paint.setShader(shader);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 SkBitmap fGradientCircle; 136 SkBitmap fGradientCircle;
139 typedef GM INHERITED; 137 typedef GM INHERITED;
140 }; 138 };
141 139
142 ////////////////////////////////////////////////////////////////////////////// 140 //////////////////////////////////////////////////////////////////////////////
143 141
144 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } 142 static GM* MyFactory(void*) { return new ImageFiltersClippedGM; }
145 static GMRegistry reg(MyFactory); 143 static GMRegistry reg(MyFactory);
146 144
147 } 145 }
OLDNEW
« no previous file with comments | « gm/gm.h ('k') | gm/imagefiltersgraph.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698