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

Side by Side Diff: tests/GpuDrawPathTest.cpp

Issue 1448873002: Generate list of GPU contexts outside tests (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-01-gpu-test-context-support
Patch Set: make blurtest for all rendering contexts Created 5 years 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 | « tests/GpuColorFilterTest.cpp ('k') | tests/GpuLayerCacheTest.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 * 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"
14 #include "GrPath.h" 13 #include "GrPath.h"
15 #include "GrStrokeInfo.h" 14 #include "GrStrokeInfo.h"
16 #include "SkBitmap.h" 15 #include "SkBitmap.h"
17 #include "SkCanvas.h" 16 #include "SkCanvas.h"
18 #include "SkColor.h" 17 #include "SkColor.h"
19 #include "SkPaint.h" 18 #include "SkPaint.h"
20 #include "SkPath.h" 19 #include "SkPath.h"
21 #include "SkDashPathEffect.h" 20 #include "SkDashPathEffect.h"
22 #include "SkRRect.h" 21 #include "SkRRect.h"
23 #include "SkRect.h" 22 #include "SkRect.h"
24 #include "SkSurface.h" 23 #include "SkSurface.h"
25 #include "Test.h" 24 #include "Test.h"
26 25
26 #include <initializer_list>
27
27 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) { 28 static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
28 // Filling an empty path should not crash. 29 // Filling an empty path should not crash.
29 SkPaint paint; 30 SkPaint paint;
30 SkRect emptyRect = SkRect::MakeEmpty(); 31 SkRect emptyRect = SkRect::MakeEmpty();
31 canvas->drawRect(emptyRect, paint); 32 canvas->drawRect(emptyRect, paint);
32 canvas->drawPath(SkPath(), paint); 33 canvas->drawPath(SkPath(), paint);
33 canvas->drawOval(emptyRect, paint); 34 canvas->drawOval(emptyRect, paint);
34 canvas->drawRect(emptyRect, paint); 35 canvas->drawRect(emptyRect, paint);
35 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint); 36 canvas->drawRRect(SkRRect::MakeRect(emptyRect), paint);
36 37
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 oval1.addOval(rect, SkPath::kCW_Direction); 70 oval1.addOval(rect, SkPath::kCW_Direction);
70 oval2.addOval(rect, SkPath::kCCW_Direction); 71 oval2.addOval(rect, SkPath::kCCW_Direction);
71 72
72 fill_and_stroke(canvas, oval1, oval2, nullptr); 73 fill_and_stroke(canvas, oval1, oval2, nullptr);
73 74
74 const SkScalar intervals[] = { 1, 1 }; 75 const SkScalar intervals[] = { 1, 1 };
75 SkAutoTUnref<SkPathEffect> dashEffect(SkDashPathEffect::Create(intervals, 2, 0)); 76 SkAutoTUnref<SkPathEffect> dashEffect(SkDashPathEffect::Create(intervals, 2, 0));
76 fill_and_stroke(canvas, oval1, oval2, dashEffect); 77 fill_and_stroke(canvas, oval1, oval2, dashEffect);
77 } 78 }
78 79
79 DEF_GPUTEST(GpuDrawPath, reporter, factory) { 80 DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) {
80 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 81 for (auto& test_func : { &test_drawPathEmpty, &test_drawSameRectOvals }) {
81 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 82 for (auto& sampleCount : {0, 4, 16}) {
82
83 GrContext* grContext = factory->get(glType);
84 if (nullptr == grContext) {
85 continue;
86 }
87 static const int sampleCounts[] = { 0, 4, 16 };
88
89 for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
90 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255); 83 SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
91
92 SkAutoTUnref<SkSurface> surface( 84 SkAutoTUnref<SkSurface> surface(
93 SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, i nfo, 85 SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, inf o,
94 sampleCounts[i], nullptr)); 86 sampleCount, nullptr));
95 if (!surface) { 87 if (!surface) {
96 continue; 88 continue;
97 } 89 }
98 test_drawPathEmpty(reporter, surface->getCanvas()); 90 test_func(reporter, surface->getCanvas());
99 } 91 }
100 } 92 }
101 } 93 }
102 94
103 DEF_GPUTEST(GpuDrawPathSameRectOvals, reporter, factory) { 95 DEF_GPUTEST(GrPathKeys, reporter, /*factory*/) {
104 GrContext* grContext = factory->get(GrContextFactory::kNVPR_GLContextType);
105 if (!grContext) {
106 return;
107 }
108
109 SkAutoTUnref<SkSurface> surface(
110 SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted,
111 SkImageInfo::MakeN32Premul(255, 255), 4));
112 test_drawSameRectOvals(reporter, surface->getCanvas());
113 }
114
115 DEF_TEST(GrPathKeys, reporter) {
116 // Keys should not ignore conic weights. 96 // Keys should not ignore conic weights.
117 SkPath path1, path2; 97 SkPath path1, path2;
118 path1.setIsVolatile(true); 98 path1.setIsVolatile(true);
119 path2.setIsVolatile(true); 99 path2.setIsVolatile(true);
120 SkPoint p0 = SkPoint::Make(100, 0); 100 SkPoint p0 = SkPoint::Make(100, 0);
121 SkPoint p1 = SkPoint::Make(100, 100); 101 SkPoint p1 = SkPoint::Make(100, 100);
122 102
123 path1.conicTo(p0, p1, .5f); 103 path1.conicTo(p0, p1, .5f);
124 path2.conicTo(p0, p1, .7f); 104 path2.conicTo(p0, p1, .7f);
125 105
126 bool isVolatile; 106 bool isVolatile;
127 GrUniqueKey key1, key2; 107 GrUniqueKey key1, key2;
128 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle); 108 GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
129 GrPath::ComputeKey(path1, stroke, &key1, &isVolatile); 109 GrPath::ComputeKey(path1, stroke, &key1, &isVolatile);
130 GrPath::ComputeKey(path2, stroke, &key2, &isVolatile); 110 GrPath::ComputeKey(path2, stroke, &key2, &isVolatile);
131 REPORTER_ASSERT(reporter, key1 != key2); 111 REPORTER_ASSERT(reporter, key1 != key2);
132 } 112 }
133 113
134 #endif 114 #endif
OLDNEW
« no previous file with comments | « tests/GpuColorFilterTest.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698