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

Side by Side Diff: samplecode/SampleLayerMask.cpp

Issue 169063002: use SkColorType instead of SkBitmap::Config in samplecode (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 | « samplecode/SampleHairline.cpp ('k') | samplecode/SampleMipMap.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 void drawMask(SkCanvas* canvas, const SkRect& r) { 31 void drawMask(SkCanvas* canvas, const SkRect& r) {
32 SkPaint paint; 32 SkPaint paint;
33 paint.setAntiAlias(true); 33 paint.setAntiAlias(true);
34 34
35 if (true) { 35 if (true) {
36 SkBitmap mask; 36 SkBitmap mask;
37 int w = SkScalarRoundToInt(r.width()); 37 int w = SkScalarRoundToInt(r.width());
38 int h = SkScalarRoundToInt(r.height()); 38 int h = SkScalarRoundToInt(r.height());
39 mask.setConfig(SkBitmap::kARGB_8888_Config, w, h); 39 mask.allocN32Pixels(w, h);
40 mask.allocPixels();
41 mask.eraseColor(SK_ColorTRANSPARENT); 40 mask.eraseColor(SK_ColorTRANSPARENT);
42 SkCanvas c(mask); 41 SkCanvas c(mask);
43 SkRect bounds = r; 42 SkRect bounds = r;
44 bounds.offset(-bounds.fLeft, -bounds.fTop); 43 bounds.offset(-bounds.fLeft, -bounds.fTop);
45 c.drawOval(bounds, paint); 44 c.drawOval(bounds, paint);
46 45
47 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); 46 paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
48 canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint); 47 canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint);
49 } else { 48 } else {
50 SkPath p; 49 SkPath p;
(...skipping 14 matching lines...) Expand all
65 } 64 }
66 65
67 private: 66 private:
68 typedef SampleView INHERITED; 67 typedef SampleView INHERITED;
69 }; 68 };
70 69
71 /////////////////////////////////////////////////////////////////////////////// 70 ///////////////////////////////////////////////////////////////////////////////
72 71
73 static SkView* MyFactory() { return new LayerMaskView; } 72 static SkView* MyFactory() { return new LayerMaskView; }
74 static SkViewRegister reg(MyFactory); 73 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleHairline.cpp ('k') | samplecode/SampleMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698