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

Side by Side Diff: gm/displacement.cpp

Issue 159723006: add peekPixels to canvas (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
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 "SkDisplacementMapEffect.h" 9 #include "SkDisplacementMapEffect.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 15 matching lines...) Expand all
26 make_bitmap(); 26 make_bitmap();
27 make_checkerboard(&fCheckerboard, 80, 80); 27 make_checkerboard(&fCheckerboard, 80, 80);
28 make_checkerboard(&fSmall, 64, 64); 28 make_checkerboard(&fSmall, 64, 64);
29 make_checkerboard(&fLarge, 96, 96); 29 make_checkerboard(&fLarge, 96, 96);
30 make_checkerboard(&fLargeW, 96, 64); 30 make_checkerboard(&fLargeW, 96, 64);
31 make_checkerboard(&fLargeH, 64, 96); 31 make_checkerboard(&fLargeH, 64, 96);
32 } 32 }
33 33
34 void make_bitmap() { 34 void make_bitmap() {
35 fBitmap.allocN32Pixels(80, 80); 35 fBitmap.allocN32Pixels(80, 80);
36 SkBitmapDevice device(fBitmap); 36 SkCanvas canvas(fBitmap);
37 SkCanvas canvas(&device);
38 canvas.clear(0x00000000); 37 canvas.clear(0x00000000);
39 SkPaint paint; 38 SkPaint paint;
40 paint.setAntiAlias(true); 39 paint.setAntiAlias(true);
41 paint.setColor(0xFF884422); 40 paint.setColor(0xFF884422);
42 paint.setTextSize(SkIntToScalar(96)); 41 paint.setTextSize(SkIntToScalar(96));
43 const char* str = "g"; 42 const char* str = "g";
44 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint); 43 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint);
45 } 44 }
46 45
47 void make_checkerboard(SkBitmap* bitmap, int w, int h) { 46 void make_checkerboard(SkBitmap* bitmap, int w, int h) {
48 bitmap->allocN32Pixels(w, h); 47 bitmap->allocN32Pixels(w, h);
49 SkBitmapDevice device(*bitmap); 48 SkCanvas canvas(*bitmap);
50 SkCanvas canvas(&device);
51 canvas.clear(0x00000000); 49 canvas.clear(0x00000000);
52 SkPaint darkPaint; 50 SkPaint darkPaint;
53 darkPaint.setColor(0xFF804020); 51 darkPaint.setColor(0xFF804020);
54 SkPaint lightPaint; 52 SkPaint lightPaint;
55 lightPaint.setColor(0xFF244484); 53 lightPaint.setColor(0xFF244484);
56 for (int y = 0; y < h; y += 16) { 54 for (int y = 0; y < h; y += 16) {
57 for (int x = 0; x < w; x += 16) { 55 for (int x = 0; x < w; x += 16) {
58 canvas.save(); 56 canvas.save();
59 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 57 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
60 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 58 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; 220 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH;
223 bool fInitialized; 221 bool fInitialized;
224 }; 222 };
225 223
226 ////////////////////////////////////////////////////////////////////////////// 224 //////////////////////////////////////////////////////////////////////////////
227 225
228 static GM* MyFactory(void*) { return new DisplacementMapGM; } 226 static GM* MyFactory(void*) { return new DisplacementMapGM; }
229 static GMRegistry reg(MyFactory); 227 static GMRegistry reg(MyFactory);
230 228
231 } 229 }
OLDNEW
« no previous file with comments | « gm/deviceproperties.cpp ('k') | gm/gammatext.cpp » ('j') | include/core/SkCanvas.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698