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

Side by Side Diff: gm/lighting.cpp

Issue 161733002: 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/imagefiltersscaled.cpp ('k') | gm/matrixconvolution.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 2012 Google Inc. 2 * Copyright 2012 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 "SkLightingImageFilter.h" 9 #include "SkLightingImageFilter.h"
10 10
11 #define WIDTH 330 11 #define WIDTH 330
12 #define HEIGHT 440 12 #define HEIGHT 440
13 13
14 namespace skiagm { 14 namespace skiagm {
15 15
16 class ImageLightingGM : public GM { 16 class ImageLightingGM : public GM {
17 public: 17 public:
18 ImageLightingGM() : fInitialized(false) { 18 ImageLightingGM() : fInitialized(false) {
19 this->setBGColor(0xFF000000); 19 this->setBGColor(0xFF000000);
20 } 20 }
21 21
22 protected: 22 protected:
23 virtual SkString onShortName() { 23 virtual SkString onShortName() {
24 return SkString("lighting"); 24 return SkString("lighting");
25 } 25 }
26 26
27 void make_bitmap() { 27 void make_bitmap() {
28 fBitmap.allocN32Pixels(100, 100); 28 fBitmap.allocN32Pixels(100, 100);
29 SkBitmapDevice device(fBitmap); 29 SkCanvas canvas(fBitmap);
30 SkCanvas canvas(&device);
31 canvas.clear(0x00000000); 30 canvas.clear(0x00000000);
32 SkPaint paint; 31 SkPaint paint;
33 paint.setAntiAlias(true); 32 paint.setAntiAlias(true);
34 paint.setColor(0xFFFFFFFF); 33 paint.setColor(0xFFFFFFFF);
35 paint.setTextSize(SkIntToScalar(96)); 34 paint.setTextSize(SkIntToScalar(96));
36 const char* str = "e"; 35 const char* str = "e";
37 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint); 36 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
38 } 37 }
39 38
40 virtual SkISize onISize() { 39 virtual SkISize onISize() {
41 return make_isize(WIDTH, HEIGHT); 40 return SkISize::Make(WIDTH, HEIGHT);
42 } 41 }
43 42
44 void drawClippedBitmap(SkCanvas* canvas, const SkPaint& paint, int x, int y) { 43 void drawClippedBitmap(SkCanvas* canvas, const SkPaint& paint, int x, int y) {
45 canvas->save(); 44 canvas->save();
46 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 45 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
47 canvas->clipRect(SkRect::MakeWH( 46 canvas->clipRect(SkRect::MakeWH(
48 SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height()))); 47 SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height())));
49 canvas->drawBitmap(fBitmap, 0, 0, &paint); 48 canvas->drawBitmap(fBitmap, 0, 0, &paint);
50 canvas->restore(); 49 canvas->restore();
51 } 50 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 SkBitmap fBitmap; 117 SkBitmap fBitmap;
119 bool fInitialized; 118 bool fInitialized;
120 }; 119 };
121 120
122 ////////////////////////////////////////////////////////////////////////////// 121 //////////////////////////////////////////////////////////////////////////////
123 122
124 static GM* MyFactory(void*) { return new ImageLightingGM; } 123 static GM* MyFactory(void*) { return new ImageLightingGM; }
125 static GMRegistry reg(MyFactory); 124 static GMRegistry reg(MyFactory);
126 125
127 } 126 }
OLDNEW
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | gm/matrixconvolution.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698