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 "SkBlurMask.h" | 8 #include "SkBlurMask.h" |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkLayerDrawLooper.h" | 10 #include "SkLayerDrawLooper.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 if (contains) { | 109 if (contains) { |
110 REPORTER_ASSERT(reporter, NGLYPHS == first); | 110 REPORTER_ASSERT(reporter, NGLYPHS == first); |
111 } else { | 111 } else { |
112 REPORTER_ASSERT(reporter, NGLYPHS > first); | 112 REPORTER_ASSERT(reporter, NGLYPHS > first); |
113 } | 113 } |
114 } | 114 } |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 // temparary api for bicubic, just be sure we can set/clear it | 118 // temparary api for bicubic, just be sure we can set/clear it |
119 DEF_TEST(Paint_filterlevel, reporter) { | 119 DEF_TEST(Paint_filterQuality, reporter) { |
120 SkPaint p0, p1; | 120 SkPaint p0, p1; |
121 | 121 |
122 REPORTER_ASSERT(reporter, | 122 REPORTER_ASSERT(reporter, kNone_SkFilterQuality == p0.getFilterQuality()); |
123 SkPaint::kNone_FilterLevel == p0.getFilterLevel()); | |
124 | 123 |
125 static const SkPaint::FilterLevel gLevels[] = { | 124 static const SkFilterQuality gQualitys[] = { |
126 SkPaint::kNone_FilterLevel, | 125 kNone_SkFilterQuality, |
127 SkPaint::kLow_FilterLevel, | 126 kLow_SkFilterQuality, |
128 SkPaint::kMedium_FilterLevel, | 127 kMedium_SkFilterQuality, |
129 SkPaint::kHigh_FilterLevel | 128 kHigh_SkFilterQuality |
130 }; | 129 }; |
131 for (size_t i = 0; i < SK_ARRAY_COUNT(gLevels); ++i) { | 130 for (size_t i = 0; i < SK_ARRAY_COUNT(gQualitys); ++i) { |
132 p0.setFilterLevel(gLevels[i]); | 131 p0.setFilterQuality(gQualitys[i]); |
133 REPORTER_ASSERT(reporter, gLevels[i] == p0.getFilterLevel()); | 132 REPORTER_ASSERT(reporter, gQualitys[i] == p0.getFilterQuality()); |
134 p1 = p0; | 133 p1 = p0; |
135 REPORTER_ASSERT(reporter, gLevels[i] == p1.getFilterLevel()); | 134 REPORTER_ASSERT(reporter, gQualitys[i] == p1.getFilterQuality()); |
136 | 135 |
137 p0.reset(); | 136 p0.reset(); |
138 REPORTER_ASSERT(reporter, | 137 REPORTER_ASSERT(reporter, kNone_SkFilterQuality == p0.getFilterQuality()
); |
139 SkPaint::kNone_FilterLevel == p0.getFilterLevel()); | |
140 } | 138 } |
141 } | 139 } |
142 | 140 |
143 DEF_TEST(Paint_copy, reporter) { | 141 DEF_TEST(Paint_copy, reporter) { |
144 SkPaint paint; | 142 SkPaint paint; |
145 // set a few member variables | 143 // set a few member variables |
146 paint.setStyle(SkPaint::kStrokeAndFill_Style); | 144 paint.setStyle(SkPaint::kStrokeAndFill_Style); |
147 paint.setTextAlign(SkPaint::kLeft_Align); | 145 paint.setTextAlign(SkPaint::kLeft_Align); |
148 paint.setStrokeWidth(SkIntToScalar(2)); | 146 paint.setStrokeWidth(SkIntToScalar(2)); |
149 // set a few pointers | 147 // set a few pointers |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? | 196 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? |
199 SkScalarMul(paint.getStrokeWidth(), miter) : | 197 SkScalarMul(paint.getStrokeWidth(), miter) : |
200 paint.getStrokeWidth(); | 198 paint.getStrokeWidth(); |
201 maxR.inset(-inset, -inset); | 199 maxR.inset(-inset, -inset); |
202 | 200 |
203 // test that our stroke didn't explode | 201 // test that our stroke didn't explode |
204 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); | 202 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); |
205 } | 203 } |
206 | 204 |
207 DEF_TEST(Paint_flattening, reporter) { | 205 DEF_TEST(Paint_flattening, reporter) { |
208 const SkPaint::FilterLevel levels[] = { | 206 const SkFilterQuality levels[] = { |
209 SkPaint::kNone_FilterLevel, | 207 kNone_SkFilterQuality, |
210 SkPaint::kLow_FilterLevel, | 208 kLow_SkFilterQuality, |
211 SkPaint::kMedium_FilterLevel, | 209 kMedium_SkFilterQuality, |
212 SkPaint::kHigh_FilterLevel, | 210 kHigh_SkFilterQuality, |
213 }; | 211 }; |
214 const SkPaint::Hinting hinting[] = { | 212 const SkPaint::Hinting hinting[] = { |
215 SkPaint::kNo_Hinting, | 213 SkPaint::kNo_Hinting, |
216 SkPaint::kSlight_Hinting, | 214 SkPaint::kSlight_Hinting, |
217 SkPaint::kNormal_Hinting, | 215 SkPaint::kNormal_Hinting, |
218 SkPaint::kFull_Hinting, | 216 SkPaint::kFull_Hinting, |
219 }; | 217 }; |
220 const SkPaint::Align align[] = { | 218 const SkPaint::Align align[] = { |
221 SkPaint::kLeft_Align, | 219 SkPaint::kLeft_Align, |
222 SkPaint::kCenter_Align, | 220 SkPaint::kCenter_Align, |
(...skipping 21 matching lines...) Expand all Loading... |
244 SkPaint::kStrokeAndFill_Style, | 242 SkPaint::kStrokeAndFill_Style, |
245 }; | 243 }; |
246 | 244 |
247 #define FOR_SETUP(index, array, setter) \ | 245 #define FOR_SETUP(index, array, setter) \ |
248 for (size_t index = 0; index < SK_ARRAY_COUNT(array); ++index) { \ | 246 for (size_t index = 0; index < SK_ARRAY_COUNT(array); ++index) { \ |
249 paint.setter(array[index]); \ | 247 paint.setter(array[index]); \ |
250 | 248 |
251 SkPaint paint; | 249 SkPaint paint; |
252 paint.setFlags(0x1234); | 250 paint.setFlags(0x1234); |
253 | 251 |
254 FOR_SETUP(i, levels, setFilterLevel) | 252 FOR_SETUP(i, levels, setFilterQuality) |
255 FOR_SETUP(j, hinting, setHinting) | 253 FOR_SETUP(j, hinting, setHinting) |
256 FOR_SETUP(k, align, setTextAlign) | 254 FOR_SETUP(k, align, setTextAlign) |
257 FOR_SETUP(l, caps, setStrokeCap) | 255 FOR_SETUP(l, caps, setStrokeCap) |
258 FOR_SETUP(m, joins, setStrokeJoin) | 256 FOR_SETUP(m, joins, setStrokeJoin) |
259 FOR_SETUP(n, encodings, setTextEncoding) | 257 FOR_SETUP(n, encodings, setTextEncoding) |
260 FOR_SETUP(p, styles, setStyle) | 258 FOR_SETUP(p, styles, setStyle) |
261 | 259 |
262 SkWriteBuffer writer; | 260 SkWriteBuffer writer; |
263 paint.flatten(writer); | 261 paint.flatten(writer); |
264 | 262 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 SkColorMatrix cm; | 362 SkColorMatrix cm; |
365 cm.setIdentity(); // does not change alpha | 363 cm.setIdentity(); // does not change alpha |
366 paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref(); | 364 paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref(); |
367 REPORTER_ASSERT(r, paint.nothingToDraw()); | 365 REPORTER_ASSERT(r, paint.nothingToDraw()); |
368 | 366 |
369 cm.postTranslate(0, 0, 0, 1); // wacks alpha | 367 cm.postTranslate(0, 0, 0, 1); // wacks alpha |
370 paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref(); | 368 paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref(); |
371 REPORTER_ASSERT(r, !paint.nothingToDraw()); | 369 REPORTER_ASSERT(r, !paint.nothingToDraw()); |
372 } | 370 } |
373 | 371 |
OLD | NEW |