| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2012 Google Inc. | 2  * Copyright 2012 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 "SkBitmap.h" | 8 #include "SkBitmap.h" | 
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" | 
| 10 #include "SkDashPathEffect.h" | 10 #include "SkDashPathEffect.h" | 
| 11 #include "SkSurface.h" | 11 #include "SkSurface.h" | 
| 12 #include "Test.h" | 12 #include "Test.h" | 
| 13 | 13 | 
| 14 static SkCanvas* create(SkBitmap::Config config, int w, int h, int rb, | 14 static SkCanvas* new_canvas(int w, int h) { | 
| 15                         void* addr = NULL) { |  | 
| 16     SkBitmap bm; | 15     SkBitmap bm; | 
| 17     bm.setConfig(config, w, h, rb); | 16     bm.allocN32Pixels(w, h); | 
| 18     if (addr) { |  | 
| 19         bm.setPixels(addr); |  | 
| 20     } else { |  | 
| 21         bm.allocPixels(); |  | 
| 22     } |  | 
| 23     return new SkCanvas(bm); | 17     return new SkCanvas(bm); | 
| 24 } | 18 } | 
| 25 | 19 | 
| 26 static SkCanvas* new_canvas(int w, int h) { |  | 
| 27     return create(SkBitmap::kARGB_8888_Config, w, h, 0, NULL); |  | 
| 28 } |  | 
| 29 |  | 
| 30 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// | 
| 31 | 21 | 
| 32 // test that we can draw an aa-rect at coordinates > 32K (bigger than fixedpoint
     ) | 22 // test that we can draw an aa-rect at coordinates > 32K (bigger than fixedpoint
     ) | 
| 33 static void test_big_aa_rect(skiatest::Reporter* reporter) { | 23 static void test_big_aa_rect(skiatest::Reporter* reporter) { | 
| 34     SkBitmap output; | 24     SkBitmap output; | 
| 35     SkPMColor pixel[1]; | 25     SkPMColor pixel[1]; | 
| 36     output.setConfig(SkBitmap::kARGB_8888_Config, 1, 1, 4); | 26     output.installPixels(SkImageInfo::MakeN32Premul(1, 1), | 
| 37     output.setPixels(pixel); | 27                          pixel, 4, NULL, NULL); | 
| 38 | 28 | 
| 39     SkSurface* surf = SkSurface::NewRasterPMColor(300, 33300); | 29     SkSurface* surf = SkSurface::NewRasterPMColor(300, 33300); | 
| 40     SkCanvas* canvas = surf->getCanvas(); | 30     SkCanvas* canvas = surf->getCanvas(); | 
| 41 | 31 | 
| 42     SkRect r = { 0, 33000, 300, 33300 }; | 32     SkRect r = { 0, 33000, 300, 33300 }; | 
| 43     int x = SkScalarRoundToInt(r.left()); | 33     int x = SkScalarRoundToInt(r.left()); | 
| 44     int y = SkScalarRoundToInt(r.top()); | 34     int y = SkScalarRoundToInt(r.top()); | 
| 45 | 35 | 
| 46     // check that the pixel in question starts as transparent (by the surface) | 36     // check that the pixel in question starts as transparent (by the surface) | 
| 47     if (canvas->readPixels(&output, x, y)) { | 37     if (canvas->readPixels(&output, x, y)) { | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 118     SkPaint paint; | 108     SkPaint paint; | 
| 119     paint.setAntiAlias(true); | 109     paint.setAntiAlias(true); | 
| 120     canvas->drawPath(path, paint); | 110     canvas->drawPath(path, paint); | 
| 121 } | 111 } | 
| 122 | 112 | 
| 123 // This used to assert in debug builds (and crash writing bad memory in release) | 113 // This used to assert in debug builds (and crash writing bad memory in release) | 
| 124 // because we overflowed an intermediate value (B coefficient) setting up our | 114 // because we overflowed an intermediate value (B coefficient) setting up our | 
| 125 // stepper for the quadratic. Now we bias that value by 1/2 so we don't overflow | 115 // stepper for the quadratic. Now we bias that value by 1/2 so we don't overflow | 
| 126 static void test_crbug_140803() { | 116 static void test_crbug_140803() { | 
| 127     SkBitmap bm; | 117     SkBitmap bm; | 
| 128     bm.setConfig(SkBitmap::kARGB_8888_Config, 2700, 30*1024); | 118     bm.allocN32Pixels(2700, 30*1024); | 
| 129     bm.allocPixels(); |  | 
| 130     SkCanvas canvas(bm); | 119     SkCanvas canvas(bm); | 
| 131 | 120 | 
| 132     SkPath path; | 121     SkPath path; | 
| 133     path.moveTo(2762, 20); | 122     path.moveTo(2762, 20); | 
| 134     path.quadTo(11, 21702, 10, 21706); | 123     path.quadTo(11, 21702, 10, 21706); | 
| 135     SkPaint paint; | 124     SkPaint paint; | 
| 136     paint.setAntiAlias(true); | 125     paint.setAntiAlias(true); | 
| 137     canvas.drawPath(path, paint); | 126     canvas.drawPath(path, paint); | 
| 138 } | 127 } | 
| 139 | 128 | 
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 304     test_crbug_124652(); | 293     test_crbug_124652(); | 
| 305     test_crbug_140642(); | 294     test_crbug_140642(); | 
| 306     test_crbug_140803(); | 295     test_crbug_140803(); | 
| 307     test_inversepathwithclip(); | 296     test_inversepathwithclip(); | 
| 308     // why? | 297     // why? | 
| 309     if (false) test_crbug131181(); | 298     if (false) test_crbug131181(); | 
| 310     test_infinite_dash(reporter); | 299     test_infinite_dash(reporter); | 
| 311     test_crbug_165432(reporter); | 300     test_crbug_165432(reporter); | 
| 312     test_big_aa_rect(reporter); | 301     test_big_aa_rect(reporter); | 
| 313 } | 302 } | 
| OLD | NEW | 
|---|