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

Side by Side Diff: gm/imagefilterscropped.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/imagefiltersbase.cpp ('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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 canvas->restore(); 53 canvas->restore();
54 } 54 }
55 55
56 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { 56 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
57 SkPaint paint; 57 SkPaint paint;
58 58
59 SkIRect bounds; 59 SkIRect bounds;
60 r.roundOut(&bounds); 60 r.roundOut(&bounds);
61 61
62 SkBitmap bm; 62 SkBitmap bm;
63 bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()); 63 bm.allocN32Pixels(bounds.width(), bounds.height());
64 bm.allocPixels();
65 bm.eraseColor(SK_ColorTRANSPARENT); 64 bm.eraseColor(SK_ColorTRANSPARENT);
66 SkCanvas c(bm); 65 SkCanvas c(bm);
67 draw_path(&c, r, NULL); 66 draw_path(&c, r, NULL);
68 67
69 paint.setImageFilter(imf); 68 paint.setImageFilter(imf);
70 canvas->save(); 69 canvas->save();
71 canvas->clipRect(r); 70 canvas->clipRect(r);
72 canvas->drawBitmap(bm, 0, 0, &paint); 71 canvas->drawBitmap(bm, 0, 0, &paint);
73 canvas->restore(); 72 canvas->restore();
74 } 73 }
75 74
76 static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { 75 static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
77 SkPaint paint; 76 SkPaint paint;
78 77
79 SkIRect bounds; 78 SkIRect bounds;
80 r.roundOut(&bounds); 79 r.roundOut(&bounds);
81 80
82 SkBitmap bm; 81 SkBitmap bm;
83 bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()); 82 bm.allocN32Pixels(bounds.width(), bounds.height());
84 bm.allocPixels();
85 bm.eraseColor(SK_ColorRED); 83 bm.eraseColor(SK_ColorRED);
86 SkCanvas c(bm); 84 SkCanvas c(bm);
87 85
88 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44); 86 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44);
89 paint.setColor(SK_ColorGREEN); 87 paint.setColor(SK_ColorGREEN);
90 c.drawRect(SkRect::Make(cropRect), paint); 88 c.drawRect(SkRect::Make(cropRect), paint);
91 89
92 paint.setImageFilter(imf); 90 paint.setImageFilter(imf);
93 SkPoint loc = { r.fLeft, r.fTop }; 91 SkPoint loc = { r.fLeft, r.fTop };
94 canvas->getTotalMatrix().mapPoints(&loc, 1); 92 canvas->getTotalMatrix().mapPoints(&loc, 1);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 173 }
176 174
177 private: 175 private:
178 typedef GM INHERITED; 176 typedef GM INHERITED;
179 }; 177 };
180 178
181 /////////////////////////////////////////////////////////////////////////////// 179 ///////////////////////////////////////////////////////////////////////////////
182 180
183 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; } 181 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; }
184 static skiagm::GMRegistry reg(MyFactory); 182 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/imagefiltersbase.cpp ('k') | gm/imagefiltersgraph.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698