OLD | NEW |
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 "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkDevice.h" | 12 #include "SkDevice.h" |
13 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
14 #include "SkGraphics.h" | 14 #include "SkGraphics.h" |
15 #include "SkImageDecoder.h" | 15 #include "SkImageDecoder.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkRandom.h" | 17 #include "SkRandom.h" |
18 #include "SkRegion.h" | 18 #include "SkRegion.h" |
19 #include "SkShader.h" | 19 #include "SkShader.h" |
20 #include "SkUtils.h" | 20 #include "SkUtils.h" |
21 #include "SkXfermode.h" | 21 #include "SkXfermode.h" |
22 #include "SkColorPriv.h" | 22 #include "SkColorPriv.h" |
23 #include "SkColorFilter.h" | 23 #include "SkColorFilter.h" |
24 #include "SkTime.h" | 24 #include "SkTime.h" |
25 #include "SkTypeface.h" | 25 #include "SkTypeface.h" |
| 26 #include "SkView.h" |
26 | 27 |
27 #include "SkOSFile.h" | 28 #include "SkOSFile.h" |
28 #include "SkStream.h" | 29 #include "SkStream.h" |
29 | 30 |
30 static void check_for_nonwhite(const SkBitmap& bm, int alpha) { | 31 static void check_for_nonwhite(const SkBitmap& bm, int alpha) { |
31 if (bm.config() != SkBitmap::kRGB_565_Config) { | 32 if (bm.config() != SkBitmap::kRGB_565_Config) { |
32 return; | 33 return; |
33 } | 34 } |
34 | 35 |
35 for (int y = 0; y < bm.height(); y++) { | 36 for (int y = 0; y < bm.height(); y++) { |
(...skipping 26 matching lines...) Expand all Loading... |
62 virtual void onDrawContent(SkCanvas* canvas) { | 63 virtual void onDrawContent(SkCanvas* canvas) { |
63 const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 64 const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
64 SkPaint paint; | 65 SkPaint paint; |
65 SkScalar x = SkIntToScalar(10); | 66 SkScalar x = SkIntToScalar(10); |
66 SkScalar y = SkIntToScalar(20); | 67 SkScalar y = SkIntToScalar(20); |
67 | 68 |
68 paint.setFlags(0x105); | 69 paint.setFlags(0x105); |
69 | 70 |
70 paint.setARGB(fByte, 0xFF, 0xFF, 0xFF); | 71 paint.setARGB(fByte, 0xFF, 0xFF, 0xFF); |
71 | 72 |
72 paint.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3), | 73 paint.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_B
lurStyle, |
73 SkBlurMaskFilter::kNormal_BlurStyle)); | 74 SkBlurMask::ConvertRadiusToSigma(SkIntToScal
ar(3)))); |
74 paint.getMaskFilter()->unref(); | 75 paint.getMaskFilter()->unref(); |
75 | 76 |
76 SkRandom rand; | 77 SkRandom rand; |
77 | 78 |
78 for (int ps = 6; ps <= 35; ps++) { | 79 for (int ps = 6; ps <= 35; ps++) { |
79 paint.setColor(rand.nextU() | (0xFF << 24)); | 80 paint.setColor(rand.nextU() | (0xFF << 24)); |
80 paint.setTextSize(SkIntToScalar(ps)); | 81 paint.setTextSize(SkIntToScalar(ps)); |
81 paint.setTextSize(SkIntToScalar(24)); | 82 paint.setTextSize(SkIntToScalar(24)); |
82 canvas->drawText(str, strlen(str), x, y, paint); | 83 canvas->drawText(str, strlen(str), x, y, paint); |
83 y += paint.getFontMetrics(NULL); | 84 y += paint.getFontMetrics(NULL); |
(...skipping 29 matching lines...) Expand all Loading... |
113 private: | 114 private: |
114 int fByte; | 115 int fByte; |
115 | 116 |
116 typedef SampleView INHERITED; | 117 typedef SampleView INHERITED; |
117 }; | 118 }; |
118 | 119 |
119 ////////////////////////////////////////////////////////////////////////////// | 120 ////////////////////////////////////////////////////////////////////////////// |
120 | 121 |
121 static SkView* MyFactory() { return new TextAlphaView; } | 122 static SkView* MyFactory() { return new TextAlphaView; } |
122 static SkViewRegister reg(MyFactory); | 123 static SkViewRegister reg(MyFactory); |
OLD | NEW |