Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: tests/PathTest.cpp

Issue 24130009: promote SkImage::AlphaType to SkAlphaType (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/DrawPathTest.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "Test.h" 8 #include "Test.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
11 #include "SkPath.h" 11 #include "SkPath.h"
12 #include "SkParse.h" 12 #include "SkParse.h"
13 #include "SkParsePath.h" 13 #include "SkParsePath.h"
14 #include "SkPathEffect.h" 14 #include "SkPathEffect.h"
15 #include "SkRandom.h" 15 #include "SkRandom.h"
16 #include "SkReader32.h" 16 #include "SkReader32.h"
17 #include "SkSize.h" 17 #include "SkSize.h"
18 #include "SkSurface.h" 18 #include "SkSurface.h"
19 #include "SkTypes.h" 19 #include "SkTypes.h"
20 #include "SkWriter32.h" 20 #include "SkWriter32.h"
21 21
22 #if defined(WIN32) 22 #if defined(WIN32)
23 #define SUPPRESS_VISIBILITY_WARNING 23 #define SUPPRESS_VISIBILITY_WARNING
24 #else 24 #else
25 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) 25 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden")))
26 #endif 26 #endif
27 27
28 static SkSurface* new_surface(int w, int h) {
29 SkImage::Info info = {
30 w, h, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType
31 };
32 return SkSurface::NewRaster(info);
33 }
34
35 static void test_path_close_issue1474(skiatest::Reporter* reporter) { 28 static void test_path_close_issue1474(skiatest::Reporter* reporter) {
36 // This test checks that r{Line,Quad,Conic,Cubic}To following a close() 29 // This test checks that r{Line,Quad,Conic,Cubic}To following a close()
37 // are relative to the point we close to, not relative to the point we close from. 30 // are relative to the point we close to, not relative to the point we close from.
38 SkPath path; 31 SkPath path;
39 SkPoint last; 32 SkPoint last;
40 33
41 // Test rLineTo(). 34 // Test rLineTo().
42 path.rLineTo(0, 100); 35 path.rLineTo(0, 100);
43 path.rLineTo(100, 0); 36 path.rLineTo(100, 0);
44 path.close(); // Returns us back to 0,0. 37 path.close(); // Returns us back to 0,0.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // This used to assert in the debug build, as the edges did not all line-up. 127 // This used to assert in the debug build, as the edges did not all line-up.
135 static void test_bad_cubic_crbug234190() { 128 static void test_bad_cubic_crbug234190() {
136 SkPath path; 129 SkPath path;
137 path.moveTo(13.8509f, 3.16858f); 130 path.moveTo(13.8509f, 3.16858f);
138 path.cubicTo(-2.35893e+08f, -4.21044e+08f, 131 path.cubicTo(-2.35893e+08f, -4.21044e+08f,
139 -2.38991e+08f, -4.26573e+08f, 132 -2.38991e+08f, -4.26573e+08f,
140 -2.41016e+08f, -4.30188e+08f); 133 -2.41016e+08f, -4.30188e+08f);
141 134
142 SkPaint paint; 135 SkPaint paint;
143 paint.setAntiAlias(true); 136 paint.setAntiAlias(true);
144 SkAutoTUnref<SkSurface> surface(new_surface(84, 88)); 137 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(84, 88));
145 surface->getCanvas()->drawPath(path, paint); 138 surface->getCanvas()->drawPath(path, paint);
146 } 139 }
147 140
148 static void test_bad_cubic_crbug229478() { 141 static void test_bad_cubic_crbug229478() {
149 const SkPoint pts[] = { 142 const SkPoint pts[] = {
150 { 4595.91064f, -11596.9873f }, 143 { 4595.91064f, -11596.9873f },
151 { 4597.2168f, -11595.9414f }, 144 { 4597.2168f, -11595.9414f },
152 { 4598.52344f, -11594.8955f }, 145 { 4598.52344f, -11594.8955f },
153 { 4599.83008f, -11593.8496f }, 146 { 4599.83008f, -11593.8496f },
154 }; 147 };
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 246 }
254 247
255 // This used to assert in the SK_DEBUG build, as the clip step would fail with 248 // This used to assert in the SK_DEBUG build, as the clip step would fail with
256 // too-few interations in our cubic-line intersection code. That code now runs 249 // too-few interations in our cubic-line intersection code. That code now runs
257 // 24 interations (instead of 16). 250 // 24 interations (instead of 16).
258 static void test_crbug_170666() { 251 static void test_crbug_170666() {
259 SkPath path; 252 SkPath path;
260 SkPaint paint; 253 SkPaint paint;
261 paint.setAntiAlias(true); 254 paint.setAntiAlias(true);
262 255
263 SkAutoTUnref<SkSurface> surface(new_surface(1000, 1000)); 256 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(1000, 1000));
264 257
265 build_path_simple_170666(path); 258 build_path_simple_170666(path);
266 surface->getCanvas()->drawPath(path, paint); 259 surface->getCanvas()->drawPath(path, paint);
267 260
268 build_path_170666(path); 261 build_path_170666(path);
269 surface->getCanvas()->drawPath(path, paint); 262 surface->getCanvas()->drawPath(path, paint);
270 } 263 }
271 264
272 // Make sure we stay non-finite once we get there (unless we reset or rewind). 265 // Make sure we stay non-finite once we get there (unless we reset or rewind).
273 static void test_addrect_isfinite(skiatest::Reporter* reporter) { 266 static void test_addrect_isfinite(skiatest::Reporter* reporter) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 path->quadTo(577198, 1972, 577238, 1971.31f); 298 path->quadTo(577198, 1972, 577238, 1971.31f);
306 path->quadTo(577277, 1970.62f, 577317, 1971.45f); 299 path->quadTo(577277, 1970.62f, 577317, 1971.45f);
307 path->quadTo(577330, 1971.72f, 577341, 1972.11f); 300 path->quadTo(577330, 1971.72f, 577341, 1972.11f);
308 path->cubicTo(10.7082f, -116.596f, 262.057f, 45.6468f, 294.694f, 1.96237 f); 301 path->cubicTo(10.7082f, -116.596f, 262.057f, 45.6468f, 294.694f, 1.96237 f);
309 path->moveTo(306.718f, -32.912f); 302 path->moveTo(306.718f, -32.912f);
310 path->cubicTo(30.531f, 10.0005f, 1502.47f, 13.2804f, 84.3088f, 9.99601f) ; 303 path->cubicTo(30.531f, 10.0005f, 1502.47f, 13.2804f, 84.3088f, 9.99601f) ;
311 } 304 }
312 } 305 }
313 306
314 static void test_clipped_cubic() { 307 static void test_clipped_cubic() {
315 SkAutoTUnref<SkSurface> surface(new_surface(640, 480)); 308 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(640, 480));
316 309
317 // This path used to assert, because our cubic-chopping code incorrectly 310 // This path used to assert, because our cubic-chopping code incorrectly
318 // moved control points after the chop. This test should be run in SK_DEBUG 311 // moved control points after the chop. This test should be run in SK_DEBUG
319 // mode to ensure that we no long assert. 312 // mode to ensure that we no long assert.
320 SkPath path; 313 SkPath path;
321 for (int doReducedCase = 0; doReducedCase <= 1; ++doReducedCase) { 314 for (int doReducedCase = 0; doReducedCase <= 1; ++doReducedCase) {
322 build_big_path(&path, SkToBool(doReducedCase)); 315 build_big_path(&path, SkToBool(doReducedCase));
323 316
324 SkPaint paint; 317 SkPaint paint;
325 for (int doAA = 0; doAA <= 1; ++doAA) { 318 for (int doAA = 0; doAA <= 1; ++doAA) {
(...skipping 15 matching lines...) Expand all
341 { SkDoubleToScalar(18.5030727), SkDoubleToScalar(129.13121) }, 334 { SkDoubleToScalar(18.5030727), SkDoubleToScalar(129.13121) },
342 }; 335 };
343 336
344 SkPath path; 337 SkPath path;
345 path.moveTo(pts[0]); 338 path.moveTo(pts[0]);
346 path.cubicTo(pts[1], pts[2], pts[3]); 339 path.cubicTo(pts[1], pts[2], pts[3]);
347 340
348 SkPaint paint; 341 SkPaint paint;
349 paint.setAntiAlias(true); 342 paint.setAntiAlias(true);
350 343
351 SkSurface* surface = new_surface(19, 130); 344 SkSurface* surface = SkSurface::NewRasterPMColor(19, 130);
352 surface->getCanvas()->drawPath(path, paint); 345 surface->getCanvas()->drawPath(path, paint);
353 surface->unref(); 346 surface->unref();
354 } 347 }
355 348
356 // Inspired by http://code.google.com/p/chromium/issues/detail?id=141651 349 // Inspired by http://code.google.com/p/chromium/issues/detail?id=141651
357 // 350 //
358 static void test_isfinite_after_transform(skiatest::Reporter* reporter) { 351 static void test_isfinite_after_transform(skiatest::Reporter* reporter) {
359 SkPath path; 352 SkPath path;
360 path.quadTo(157, 366, 286, 208); 353 path.quadTo(157, 366, 286, 208);
361 path.arcTo(37, 442, 315, 163, 957494590897113.0f); 354 path.arcTo(37, 442, 315, 163, 957494590897113.0f);
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 test_clipped_cubic(); 2542 test_clipped_cubic();
2550 test_crbug_170666(); 2543 test_crbug_170666();
2551 test_bad_cubic_crbug229478(); 2544 test_bad_cubic_crbug229478();
2552 test_bad_cubic_crbug234190(); 2545 test_bad_cubic_crbug234190();
2553 test_android_specific_behavior(reporter); 2546 test_android_specific_behavior(reporter);
2554 test_path_close_issue1474(reporter); 2547 test_path_close_issue1474(reporter);
2555 } 2548 }
2556 2549
2557 #include "TestClassDef.h" 2550 #include "TestClassDef.h"
2558 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) 2551 DEFINE_TESTCLASS("Path", PathTestClass, TestPath)
OLDNEW
« no previous file with comments | « tests/DrawPathTest.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698