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

Side by Side Diff: samplecode/SampleDash.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/SampleColorFilter.cpp ('k') | samplecode/SampleDither.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 "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkGraphics.h" 11 #include "SkGraphics.h"
12 #include "SkRandom.h" 12 #include "SkRandom.h"
13 #include "SkDashPathEffect.h" 13 #include "SkDashPathEffect.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 15
16 static void setBitmapDash(SkPaint* paint, int width) { 16 static void setBitmapDash(SkPaint* paint, int width) {
17 SkColor c = paint->getColor(); 17 SkColor c = paint->getColor();
18 18
19 SkBitmap bm; 19 SkBitmap bm;
20 bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 1); 20 bm.allocN32Pixels(2, 1);
21 bm.allocPixels();
22 bm.lockPixels(); 21 bm.lockPixels();
23 *bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c), 22 *bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c),
24 SkColorGetG(c), SkColorGetB(c)); 23 SkColorGetG(c), SkColorGetB(c));
25 *bm.getAddr32(1, 0) = 0; 24 *bm.getAddr32(1, 0) = 0;
26 bm.unlockPixels(); 25 bm.unlockPixels();
27 26
28 SkMatrix matrix; 27 SkMatrix matrix;
29 matrix.setScale(SkIntToScalar(width), SK_Scalar1); 28 matrix.setScale(SkIntToScalar(width), SK_Scalar1);
30 29
31 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, 30 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 84 }
86 85
87 private: 86 private:
88 typedef SampleView INHERITED; 87 typedef SampleView INHERITED;
89 }; 88 };
90 89
91 ////////////////////////////////////////////////////////////////////////////// 90 //////////////////////////////////////////////////////////////////////////////
92 91
93 static SkView* MyFactory() { return new DashView; } 92 static SkView* MyFactory() { return new DashView; }
94 static SkViewRegister reg(MyFactory); 93 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleColorFilter.cpp ('k') | samplecode/SampleDither.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698