OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "Test.h" | 8 #include "Test.h" |
| 9 #include "SkBlurMask.h" |
| 10 #include "SkBlurMaskFilter.h" |
| 11 #include "SkLayerDrawLooper.h" |
9 #include "SkPath.h" | 12 #include "SkPath.h" |
10 #include "SkPaint.h" | 13 #include "SkPaint.h" |
11 #include "SkLayerDrawLooper.h" | |
12 #include "SkBlurMaskFilter.h" | |
13 #include "SkRandom.h" | 14 #include "SkRandom.h" |
14 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
15 #include "SkUtils.h" | 16 #include "SkUtils.h" |
16 | 17 |
17 static size_t uni_to_utf8(const SkUnichar src[], void* dst, int count) { | 18 static size_t uni_to_utf8(const SkUnichar src[], void* dst, int count) { |
18 char* u8 = (char*)dst; | 19 char* u8 = (char*)dst; |
19 for (int i = 0; i < count; ++i) { | 20 for (int i = 0; i < count; ++i) { |
20 int n = SkUTF8_FromUnichar(src[i], u8); | 21 int n = SkUTF8_FromUnichar(src[i], u8); |
21 u8 += n; | 22 u8 += n; |
22 } | 23 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 136 |
136 static void test_copy(skiatest::Reporter* reporter) { | 137 static void test_copy(skiatest::Reporter* reporter) { |
137 SkPaint paint; | 138 SkPaint paint; |
138 // set a few member variables | 139 // set a few member variables |
139 paint.setStyle(SkPaint::kStrokeAndFill_Style); | 140 paint.setStyle(SkPaint::kStrokeAndFill_Style); |
140 paint.setTextAlign(SkPaint::kLeft_Align); | 141 paint.setTextAlign(SkPaint::kLeft_Align); |
141 paint.setStrokeWidth(SkIntToScalar(2)); | 142 paint.setStrokeWidth(SkIntToScalar(2)); |
142 // set a few pointers | 143 // set a few pointers |
143 SkLayerDrawLooper* looper = new SkLayerDrawLooper(); | 144 SkLayerDrawLooper* looper = new SkLayerDrawLooper(); |
144 paint.setLooper(looper)->unref(); | 145 paint.setLooper(looper)->unref(); |
145 SkMaskFilter* mask = SkBlurMaskFilter::Create(1, SkBlurMaskFilter::kNormal_B
lurStyle); | 146 SkMaskFilter* mask = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_Blur
Style, |
| 147 SkBlurMask::ConvertRadiusToSigma(SkIntToSc
alar(1))); |
146 paint.setMaskFilter(mask)->unref(); | 148 paint.setMaskFilter(mask)->unref(); |
147 | 149 |
148 // copy the paint using the copy constructor and check they are the same | 150 // copy the paint using the copy constructor and check they are the same |
149 SkPaint copiedPaint = paint; | 151 SkPaint copiedPaint = paint; |
150 REPORTER_ASSERT(reporter, paint == copiedPaint); | 152 REPORTER_ASSERT(reporter, paint == copiedPaint); |
151 | 153 |
152 #ifdef SK_BUILD_FOR_ANDROID | 154 #ifdef SK_BUILD_FOR_ANDROID |
153 // the copy constructor should preserve the Generation ID | 155 // the copy constructor should preserve the Generation ID |
154 uint32_t paintGenID = paint.getGenerationID(); | 156 uint32_t paintGenID = paint.getGenerationID(); |
155 uint32_t copiedPaintGenID = copiedPaint.getGenerationID(); | 157 uint32_t copiedPaintGenID = copiedPaint.getGenerationID(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 247 |
246 // need to implement charsToGlyphs on other backends (e.g. linux, win) | 248 // need to implement charsToGlyphs on other backends (e.g. linux, win) |
247 // before we can run this tests everywhere | 249 // before we can run this tests everywhere |
248 if (false) { | 250 if (false) { |
249 test_cmap(reporter); | 251 test_cmap(reporter); |
250 } | 252 } |
251 } | 253 } |
252 | 254 |
253 #include "TestClassDef.h" | 255 #include "TestClassDef.h" |
254 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) | 256 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) |
OLD | NEW |