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" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 REPORTER_ASSERT(reporter, memcmp(&cleanPaint, &copiedPaint, sizeof(cleanPain
t))); | 186 REPORTER_ASSERT(reporter, memcmp(&cleanPaint, &copiedPaint, sizeof(cleanPain
t))); |
187 #endif | 187 #endif |
188 } | 188 } |
189 | 189 |
190 // found and fixed for webkit: mishandling when we hit recursion limit on | 190 // found and fixed for webkit: mishandling when we hit recursion limit on |
191 // mostly degenerate cubic flatness test | 191 // mostly degenerate cubic flatness test |
192 static void regression_cubic(skiatest::Reporter* reporter) { | 192 static void regression_cubic(skiatest::Reporter* reporter) { |
193 SkPath path, stroke; | 193 SkPath path, stroke; |
194 SkPaint paint; | 194 SkPaint paint; |
195 | 195 |
196 path.moveTo(SkFloatToScalar(460.2881309415525f), | 196 path.moveTo(460.2881309415525f, |
197 SkFloatToScalar(303.250847066498f)); | 197 303.250847066498f); |
198 path.cubicTo(SkFloatToScalar(463.36378422175284f), | 198 path.cubicTo(463.36378422175284f, |
199 SkFloatToScalar(302.1169735073363f), | 199 302.1169735073363f, |
200 SkFloatToScalar(456.32239330810046f), | 200 456.32239330810046f, |
201 SkFloatToScalar(304.720354932878f), | 201 304.720354932878f, |
202 SkFloatToScalar(453.15255460013304f), | 202 453.15255460013304f, |
203 SkFloatToScalar(305.788586869862f)); | 203 305.788586869862f); |
204 | 204 |
205 SkRect fillR, strokeR; | 205 SkRect fillR, strokeR; |
206 fillR = path.getBounds(); | 206 fillR = path.getBounds(); |
207 | 207 |
208 paint.setStyle(SkPaint::kStroke_Style); | 208 paint.setStyle(SkPaint::kStroke_Style); |
209 paint.setStrokeWidth(SkIntToScalar(2)); | 209 paint.setStrokeWidth(SkIntToScalar(2)); |
210 paint.getFillPath(path, &stroke); | 210 paint.getFillPath(path, &stroke); |
211 strokeR = stroke.getBounds(); | 211 strokeR = stroke.getBounds(); |
212 | 212 |
213 SkRect maxR = fillR; | 213 SkRect maxR = fillR; |
214 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); | 214 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); |
215 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? | 215 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? |
216 SkScalarMul(paint.getStrokeWidth(), miter) : | 216 SkScalarMul(paint.getStrokeWidth(), miter) : |
217 paint.getStrokeWidth(); | 217 paint.getStrokeWidth(); |
218 maxR.inset(-inset, -inset); | 218 maxR.inset(-inset, -inset); |
219 | 219 |
220 // test that our stroke didn't explode | 220 // test that our stroke didn't explode |
221 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); | 221 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); |
222 } | 222 } |
223 | 223 |
224 // found and fixed for android: not initializing rect for string's of length 0 | 224 // found and fixed for android: not initializing rect for string's of length 0 |
225 static void regression_measureText(skiatest::Reporter* reporter) { | 225 static void regression_measureText(skiatest::Reporter* reporter) { |
226 | 226 |
227 SkPaint paint; | 227 SkPaint paint; |
228 paint.setTextSize(SkFloatToScalar(12.0f)); | 228 paint.setTextSize(12.0f); |
229 | 229 |
230 SkRect r; | 230 SkRect r; |
231 r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN); | 231 r.setLTRB(SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN, SK_ScalarNaN); |
232 | 232 |
233 // test that the rect was reset | 233 // test that the rect was reset |
234 paint.measureText("", 0, &r, SkFloatToScalar(1.0f)); | 234 paint.measureText("", 0, &r, 1.0f); |
235 REPORTER_ASSERT(reporter, r.isEmpty()); | 235 REPORTER_ASSERT(reporter, r.isEmpty()); |
236 } | 236 } |
237 | 237 |
238 static void TestPaint(skiatest::Reporter* reporter) { | 238 static void TestPaint(skiatest::Reporter* reporter) { |
239 // TODO add general paint tests | 239 // TODO add general paint tests |
240 test_copy(reporter); | 240 test_copy(reporter); |
241 | 241 |
242 // regression tests | 242 // regression tests |
243 regression_cubic(reporter); | 243 regression_cubic(reporter); |
244 regression_measureText(reporter); | 244 regression_measureText(reporter); |
245 | 245 |
246 test_filterlevel(reporter); | 246 test_filterlevel(reporter); |
247 | 247 |
248 // need to implement charsToGlyphs on other backends (e.g. linux, win) | 248 // need to implement charsToGlyphs on other backends (e.g. linux, win) |
249 // before we can run this tests everywhere | 249 // before we can run this tests everywhere |
250 if (false) { | 250 if (false) { |
251 test_cmap(reporter); | 251 test_cmap(reporter); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 #include "TestClassDef.h" | 255 #include "TestClassDef.h" |
256 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) | 256 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) |
OLD | NEW |