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

Side by Side Diff: gm/dropshadowimagefilter.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/drawbitmaprect.cpp ('k') | gm/extractbitmap.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 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 "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 canvas->restore(); 47 canvas->restore();
48 } 48 }
49 49
50 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { 50 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
51 SkPaint paint; 51 SkPaint paint;
52 52
53 SkIRect bounds; 53 SkIRect bounds;
54 r.roundOut(&bounds); 54 r.roundOut(&bounds);
55 55
56 SkBitmap bm; 56 SkBitmap bm;
57 bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()); 57 bm.allocN32Pixels(bounds.width(), bounds.height());
58 bm.allocPixels();
59 bm.eraseColor(SK_ColorTRANSPARENT); 58 bm.eraseColor(SK_ColorTRANSPARENT);
60 SkCanvas c(bm); 59 SkCanvas c(bm);
61 draw_path(&c, r, NULL); 60 draw_path(&c, r, NULL);
62 61
63 paint.setImageFilter(imf); 62 paint.setImageFilter(imf);
64 canvas->save(); 63 canvas->save();
65 canvas->clipRect(r); 64 canvas->clipRect(r);
66 canvas->drawBitmap(bm, 0, 0, &paint); 65 canvas->drawBitmap(bm, 0, 0, &paint);
67 canvas->restore(); 66 canvas->restore();
68 } 67 }
69 68
70 static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { 69 static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
71 SkPaint paint; 70 SkPaint paint;
72 71
73 SkIRect bounds; 72 SkIRect bounds;
74 r.roundOut(&bounds); 73 r.roundOut(&bounds);
75 74
76 SkBitmap bm; 75 SkBitmap bm;
77 bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()); 76 bm.allocN32Pixels(bounds.width(), bounds.height());
78 bm.allocPixels();
79 bm.eraseColor(SK_ColorRED); 77 bm.eraseColor(SK_ColorRED);
80 SkCanvas c(bm); 78 SkCanvas c(bm);
81 79
82 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44); 80 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44);
83 paint.setColor(SK_ColorGREEN); 81 paint.setColor(SK_ColorGREEN);
84 c.drawRect(SkRect::Make(cropRect), paint); 82 c.drawRect(SkRect::Make(cropRect), paint);
85 83
86 paint.setImageFilter(imf); 84 paint.setImageFilter(imf);
87 SkPoint loc = { r.fLeft, r.fTop }; 85 SkPoint loc = { r.fLeft, r.fTop };
88 canvas->getTotalMatrix().mapPoints(&loc, 1); 86 canvas->getTotalMatrix().mapPoints(&loc, 1);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 163 }
166 164
167 private: 165 private:
168 typedef GM INHERITED; 166 typedef GM INHERITED;
169 }; 167 };
170 168
171 /////////////////////////////////////////////////////////////////////////////// 169 ///////////////////////////////////////////////////////////////////////////////
172 170
173 static skiagm::GM* MyFactory(void*) { return new DropShadowImageFilterGM; } 171 static skiagm::GM* MyFactory(void*) { return new DropShadowImageFilterGM; }
174 static skiagm::GMRegistry reg(MyFactory); 172 static skiagm::GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/drawbitmaprect.cpp ('k') | gm/extractbitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698