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

Side by Side Diff: gm/imagefiltersscaled.cpp

Issue 163823002: Revert of 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/imagefiltersgraph.cpp ('k') | gm/lighting.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("imagefiltersscaled"); 29 return SkString("imagefiltersscaled");
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 SkCanvas canvas(fCheckerboard); 38 SkBitmapDevice device(fCheckerboard);
39 SkCanvas canvas(&device);
39 canvas.clear(0x00000000); 40 canvas.clear(0x00000000);
40 SkPaint darkPaint; 41 SkPaint darkPaint;
41 darkPaint.setColor(0xFF404040); 42 darkPaint.setColor(0xFF404040);
42 SkPaint lightPaint; 43 SkPaint lightPaint;
43 lightPaint.setColor(0xFFA0A0A0); 44 lightPaint.setColor(0xFFA0A0A0);
44 for (int y = 0; y < 64; y += 16) { 45 for (int y = 0; y < 64; y += 16) {
45 for (int x = 0; x < 64; x += 16) { 46 for (int x = 0; x < 64; x += 16) {
46 canvas.save(); 47 canvas.save();
47 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 48 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
48 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 49 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
49 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); 50 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
50 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); 51 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
51 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); 52 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
52 canvas.restore(); 53 canvas.restore();
53 } 54 }
54 } 55 }
55 } 56 }
56 57
57 void make_gradient_circle(int width, int height) { 58 void make_gradient_circle(int width, int height) {
58 SkScalar x = SkIntToScalar(width / 2); 59 SkScalar x = SkIntToScalar(width / 2);
59 SkScalar y = SkIntToScalar(height / 2); 60 SkScalar y = SkIntToScalar(height / 2);
60 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn tToScalar(5)); 61 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn tToScalar(5));
61 fGradientCircle.allocN32Pixels(width, height); 62 fGradientCircle.allocN32Pixels(width, height);
62 SkCanvas canvas(fGradientCircle); 63 SkBitmapDevice device(fGradientCircle);
64 SkCanvas canvas(&device);
63 canvas.clear(0x00000000); 65 canvas.clear(0x00000000);
64 SkColor colors[2]; 66 SkColor colors[2];
65 colors[0] = SK_ColorWHITE; 67 colors[0] = SK_ColorWHITE;
66 colors[1] = SK_ColorBLACK; 68 colors[1] = SK_ColorBLACK;
67 SkAutoTUnref<SkShader> shader( 69 SkAutoTUnref<SkShader> shader(
68 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, NULL, 2, 70 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, NULL, 2,
69 SkShader::kClamp_TileMode) 71 SkShader::kClamp_TileMode)
70 ); 72 );
71 SkPaint paint; 73 SkPaint paint;
72 paint.setShader(shader); 74 paint.setShader(shader);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 SkBitmap fGradientCircle; 145 SkBitmap fGradientCircle;
144 typedef GM INHERITED; 146 typedef GM INHERITED;
145 }; 147 };
146 148
147 ////////////////////////////////////////////////////////////////////////////// 149 //////////////////////////////////////////////////////////////////////////////
148 150
149 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; } 151 static GM* MyFactory(void*) { return new ImageFiltersScaledGM; }
150 static GMRegistry reg(MyFactory); 152 static GMRegistry reg(MyFactory);
151 153
152 } 154 }
OLDNEW
« no previous file with comments | « gm/imagefiltersgraph.cpp ('k') | gm/lighting.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698