OLD | NEW |
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 | 9 |
| 10 #include "Checkerboard.h" |
10 #include "Resources.h" | 11 #include "Resources.h" |
11 #include "SampleCode.h" | 12 #include "SampleCode.h" |
12 #include "SkBlurMask.h" | 13 #include "SkBlurMask.h" |
13 #include "SkBlurDrawLooper.h" | 14 #include "SkBlurDrawLooper.h" |
14 #include "SkCanvas.h" | 15 #include "SkCanvas.h" |
15 #include "SkColorPriv.h" | 16 #include "SkColorPriv.h" |
16 #include "SkForceLinking.h" | 17 #include "SkForceLinking.h" |
17 #include "SkImageDecoder.h" | 18 #include "SkImageDecoder.h" |
18 #include "SkOSFile.h" | 19 #include "SkOSFile.h" |
19 #include "SkStream.h" | 20 #include "SkStream.h" |
20 #include "SkString.h" | 21 #include "SkString.h" |
21 #include "SkSystemEventTypes.h" | 22 #include "SkSystemEventTypes.h" |
22 #include "SkTypes.h" | 23 #include "SkTypes.h" |
23 #include "SkUtils.h" | 24 #include "SkUtils.h" |
24 #include "SkView.h" | 25 #include "SkView.h" |
25 | 26 |
26 __SK_FORCE_IMAGE_DECODER_LINKING; | 27 __SK_FORCE_IMAGE_DECODER_LINKING; |
27 | 28 |
28 // Defined in SampleColorFilter.cpp | |
29 extern SkShader* createChecker(); | |
30 | |
31 /** | 29 /** |
32 * Interprets c as an unpremultiplied color, and returns the | 30 * Interprets c as an unpremultiplied color, and returns the |
33 * premultiplied equivalent. | 31 * premultiplied equivalent. |
34 */ | 32 */ |
35 static SkPMColor premultiply_unpmcolor(SkPMColor c) { | 33 static SkPMColor premultiply_unpmcolor(SkPMColor c) { |
36 U8CPU a = SkGetPackedA32(c); | 34 U8CPU a = SkGetPackedA32(c); |
37 U8CPU r = SkGetPackedR32(c); | 35 U8CPU r = SkGetPackedR32(c); |
38 U8CPU g = SkGetPackedG32(c); | 36 U8CPU g = SkGetPackedG32(c); |
39 U8CPU b = SkGetPackedB32(c); | 37 U8CPU b = SkGetPackedB32(c); |
40 return SkPreMultiplyARGB(a, r, g, b); | 38 return SkPreMultiplyARGB(a, r, g, b); |
(...skipping 30 matching lines...) Expand all Loading... |
71 return true; | 69 return true; |
72 default: | 70 default: |
73 break; | 71 break; |
74 } | 72 } |
75 } | 73 } |
76 } | 74 } |
77 return this->INHERITED::onQuery(evt); | 75 return this->INHERITED::onQuery(evt); |
78 } | 76 } |
79 | 77 |
80 void onDrawBackground(SkCanvas* canvas) SK_OVERRIDE { | 78 void onDrawBackground(SkCanvas* canvas) SK_OVERRIDE { |
81 SkPaint paint; | 79 sk_tools::DrawCheckerboard(canvas, 0xFFCCCCCC, 0xFFFFFFFF, 12); |
82 SkAutoTUnref<SkShader> shader(createChecker()); | |
83 paint.setShader(shader.get()); | |
84 canvas->drawPaint(paint); | |
85 } | 80 } |
86 | 81 |
87 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 82 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
88 SkPaint paint; | 83 SkPaint paint; |
89 paint.setAntiAlias(true); | 84 paint.setAntiAlias(true); |
90 paint.setTextSize(SkIntToScalar(24)); | 85 paint.setTextSize(SkIntToScalar(24)); |
91 SkAutoTUnref<SkBlurDrawLooper> looper( | 86 SkAutoTUnref<SkBlurDrawLooper> looper( |
92 SkBlurDrawLooper::Create(SK_ColorBLUE, | 87 SkBlurDrawLooper::Create(SK_ColorBLUE, |
93 SkBlurMask::ConvertRadiusToSigma(SkIntToSca
lar(2)), | 88 SkBlurMask::ConvertRadiusToSigma(SkIntToSca
lar(2)), |
94 0, 0)); | 89 0, 0)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 188 |
194 typedef SampleView INHERITED; | 189 typedef SampleView INHERITED; |
195 }; | 190 }; |
196 | 191 |
197 ////////////////////////////////////////////////////////////////////////////// | 192 ////////////////////////////////////////////////////////////////////////////// |
198 | 193 |
199 static SkView* MyFactory() { | 194 static SkView* MyFactory() { |
200 return new UnpremulView(GetResourcePath()); | 195 return new UnpremulView(GetResourcePath()); |
201 } | 196 } |
202 static SkViewRegister reg(MyFactory); | 197 static SkViewRegister reg(MyFactory); |
OLD | NEW |