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

Side by Side Diff: tests/GpuDrawPathTest.cpp

Issue 1457073002: [Reland] Fix NVPR assert for equivalent ovals (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: don't enable GpuDrawPath Created 5 years, 1 month 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
« no previous file with comments | « src/gpu/GrPath.cpp ('k') | no next file » | 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 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 11
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrContextFactory.h" 13 #include "GrContextFactory.h"
14 #include "SkBitmap.h" 14 #include "SkBitmap.h"
15 #include "SkCanvas.h" 15 #include "SkCanvas.h"
16 #include "SkColor.h" 16 #include "SkColor.h"
17 #include "SkPaint.h" 17 #include "SkPaint.h"
18 #include "SkPath.h"
19 #include "SkDashPathEffect.h"
18 #include "SkRRect.h" 20 #include "SkRRect.h"
19 #include "SkRect.h" 21 #include "SkRect.h"
20 #include "SkSurface.h" 22 #include "SkSurface.h"
21 #include "Test.h" 23 #include "Test.h"
22 24
23 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) { 25 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
24 // Filling an empty path should not crash. 26 // Filling an empty path should not crash.
25 SkPaint paint; 27 SkPaint paint;
26 canvas->drawRect(SkRect(), paint); 28 SkRect emptyRect = SkRect::MakeEmpty();
29 canvas->drawRect(emptyRect, paint);
27 canvas->drawPath(SkPath(), paint); 30 canvas->drawPath(SkPath(), paint);
28 canvas->drawOval(SkRect(), paint); 31 canvas->drawOval(emptyRect, paint);
29 canvas->drawRect(SkRect(), paint); 32 canvas->drawRect(emptyRect, paint);
30 canvas->drawRRect(SkRRect(), paint); 33 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint);
31 34
32 // Stroking an empty path should not crash. 35 // Stroking an empty path should not crash.
33 paint.setAntiAlias(true); 36 paint.setAntiAlias(true);
34 paint.setStyle(SkPaint::kStroke_Style); 37 paint.setStyle(SkPaint::kStroke_Style);
35 paint.setColor(SK_ColorGRAY); 38 paint.setColor(SK_ColorGRAY);
36 paint.setStrokeWidth(SkIntToScalar(20)); 39 paint.setStrokeWidth(SkIntToScalar(20));
37 paint.setStrokeJoin(SkPaint::kRound_Join); 40 paint.setStrokeJoin(SkPaint::kRound_Join);
38 canvas->drawRect(SkRect(), paint); 41 canvas->drawRect(emptyRect, paint);
39 canvas->drawPath(SkPath(), paint); 42 canvas->drawPath(SkPath(), paint);
40 canvas->drawOval(SkRect(), paint); 43 canvas->drawOval(emptyRect, paint);
41 canvas->drawRect(SkRect(), paint); 44 canvas->drawRect(emptyRect, paint);
42 canvas->drawRRect(SkRRect(), paint); 45 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint);
43 } 46 }
44 47
48 static void fill_and_stroke(SkCanvas* canvas, const SkPath& p1, const SkPath& p2 ,
49 SkPathEffect* effect) {
50 SkPaint paint;
51 paint.setAntiAlias(true);
52 paint.setPathEffect(effect);
53
54 canvas->drawPath(p1, paint);
55 canvas->drawPath(p2, paint);
56
57 paint.setStyle(SkPaint::kStroke_Style);
58 canvas->drawPath(p1, paint);
59 canvas->drawPath(p2, paint);
60 }
61
62 static void test_drawSameRectOvals(skiatest::Reporter*, SkCanvas* canvas) {
63 // Drawing ovals with similar bounds but different points order should not c rash.
64
65 SkPath oval1, oval2;
66 const SkRect rect = SkRect::MakeWH(100, 50);
67 oval1.addOval(rect, SkPath::kCW_Direction);
68 oval2.addOval(rect, SkPath::kCCW_Direction);
69
70 fill_and_stroke(canvas, oval1, oval2, nullptr);
71
72 const SkScalar intervals[] = { 1, 1 };
73 SkAutoTUnref<SkPathEffect> dashEffect(SkDashPathEffect::Create(intervals, 2, 0));
74 fill_and_stroke(canvas, oval1, oval2, dashEffect);
75 }
45 76
46 DEF_GPUTEST(GpuDrawPath, reporter, factory) { 77 DEF_GPUTEST(GpuDrawPath, reporter, factory) {
78 // https://bugs.chromium.org/p/skia/issues/detail?id=4581
47 return; 79 return;
48 80
49 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 81 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
50 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 82 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
51 83
52 GrContext* grContext = factory->get(glType); 84 GrContext* grContext = factory->get(glType);
53 if (nullptr == grContext) { 85 if (nullptr == grContext) {
54 continue; 86 continue;
55 } 87 }
56 static const int sampleCounts[] = { 0, 4, 16 }; 88 static const int sampleCounts[] = { 0, 4, 16 };
57 89
58 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) { 90 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
59 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255); 91 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
60 92
61 SkAutoTUnref<SkSurface> surface( 93 SkAutoTUnref<SkSurface> surface(
62 SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, i nfo, 94 SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, i nfo,
63 sampleCounts[i], nullptr)); 95 sampleCounts[i], nullptr));
64 test_drawPathEmpty(reporter, surface->getCanvas()); 96 test_drawPathEmpty(reporter, surface->getCanvas());
65 } 97 }
66 } 98 }
67 } 99 }
68 100
101 DEF_GPUTEST(GpuDrawPathSameRectOvals, reporter, factory) {
102 GrContext* grContext = factory->get(GrContextFactory::kNVPR_GLContextType);
103 if (!grContext) {
104 return;
105 }
106
107 SkAutoTUnref<SkSurface> surface(
108 SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted,
109 SkImageInfo::MakeN32Premul(255, 255), 4));
110 test_drawSameRectOvals(reporter, surface->getCanvas());
111 }
112
69 #endif 113 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698