1 /* 2 * Copyright 2018 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "gm.h" 9 #include "SkCanvas.h" 10 #include "SkPath.h" 11 #include "SkSurface.h" 12 13 DEF_SIMPLE_GM(path_huge_crbug_800804, canvas, 50, 600) { 14 SkPaint paint; 15 paint.setAntiAlias(true); 16 paint.setStyle(SkPaint::kStroke_Style); 17 18 // exercise various special-cases (e.g. hairlines or not) 19 const float widths[] = { 0.9f, 1.0f, 1.1f }; 20 21 SkPath path; 22 for (float w : widths) { 23 paint.setStrokeWidth(w); 24 25 path.reset(); 26 path.moveTo(-1000,12345678901234567890.f); 27 path.lineTo(10.5f,200); 28 canvas->drawPath(path, paint); 29 30 path.reset(); 31 path.moveTo(30.5f,400); 32 path.lineTo(1000,-9.8765432109876543210e+19f); 33 canvas->drawPath(path, paint); 34 35 canvas->translate(3, 0); 36 } 37 } 38 39 // Test that we can draw into a huge surface ( > 64K ) and still retain paths and antialiasing. 40 DEF_SIMPLE_GM(path_huge_aa, canvas, 200, 200) { 41 auto proc = [](SkCanvas* canvas, int w, int h) { 42 SkAutoCanvasRestore acr(canvas, true); 43 44 auto surf = SkSurface::MakeRasterN32Premul(w, h); 45 auto can = surf->getCanvas(); 46 47 SkPaint paint; 48 SkPath path; 49 path.addRoundRect(SkRect::MakeXYWH(4, 4, w - 8, h - 8), 12, 12); 50 51 canvas->save(); 52 canvas->clipRect(SkRect::MakeXYWH(4, 4, 64, 64)); 53 can->drawPath(path, paint); 54 surf->draw(canvas, 64 - w, 0, nullptr); 55 canvas->restore(); 56 57 canvas->translate(80, 0); 58 canvas->save(); 59 canvas->clipRect(SkRect::MakeXYWH(4, 4, 64, 64)); 60 can->clear(0); 61 paint.setAntiAlias(true); 62 can->drawPath(path, paint); 63 surf->draw(canvas, 64 - w, 0, nullptr); 64 canvas->restore(); 65 }; 66 67 proc(canvas, 100, 60); 68 canvas->translate(0, 80); 69 proc(canvas, 100 * 1024, 60); 70 } 71