aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GpuDrawPathTest.cpp
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-12-01 04:35:26 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-01 04:35:26 -0800
commit1530283c483cb88aa725bce50a6d193dd00ee570 (patch)
treec34d73ac28d83690a4cbf1196854176677e07366 /tests/GpuDrawPathTest.cpp
parent362c900625dc2ece854678455776b711c1e44c04 (diff)
Generate list of GPU contexts outside tests
Use DEF_GPUTEST_FOR_*_CONTEXT macros to obtain the test GPU context. Makes changing the context -related classes easier, since not all tests need to be changed. BUG=skia:2992 Review URL: https://codereview.chromium.org/1448873002
Diffstat (limited to 'tests/GpuDrawPathTest.cpp')
-rw-r--r--tests/GpuDrawPathTest.cpp38
1 files changed, 9 insertions, 29 deletions
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index 7a6be6d983..b0d483b8c4 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -10,7 +10,6 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrContextFactory.h"
#include "GrPath.h"
#include "GrStrokeInfo.h"
#include "SkBitmap.h"
@@ -24,6 +23,8 @@
#include "SkSurface.h"
#include "Test.h"
+#include <initializer_list>
+
static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
// Filling an empty path should not crash.
SkPaint paint;
@@ -76,43 +77,22 @@ static void test_drawSameRectOvals(skiatest::Reporter*, SkCanvas* canvas) {
fill_and_stroke(canvas, oval1, oval2, dashEffect);
}
-DEF_GPUTEST(GpuDrawPath, reporter, factory) {
- for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
- GrContextFactory::GLContextType glType = static_cast<GrContextFactory::GLContextType>(type);
-
- GrContext* grContext = factory->get(glType);
- if (nullptr == grContext) {
- continue;
- }
- static const int sampleCounts[] = { 0, 4, 16 };
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(sampleCounts); ++i) {
+DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) {
+ for (auto& test_func : { &test_drawPathEmpty, &test_drawSameRectOvals }) {
+ for (auto& sampleCount : {0, 4, 16}) {
SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
-
SkAutoTUnref<SkSurface> surface(
- SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted, info,
- sampleCounts[i], nullptr));
+ SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, info,
+ sampleCount, nullptr));
if (!surface) {
continue;
}
- test_drawPathEmpty(reporter, surface->getCanvas());
+ test_func(reporter, surface->getCanvas());
}
}
}
-DEF_GPUTEST(GpuDrawPathSameRectOvals, reporter, factory) {
- GrContext* grContext = factory->get(GrContextFactory::kNVPR_GLContextType);
- if (!grContext) {
- return;
- }
-
- SkAutoTUnref<SkSurface> surface(
- SkSurface::NewRenderTarget(grContext, SkSurface::kNo_Budgeted,
- SkImageInfo::MakeN32Premul(255, 255), 4));
- test_drawSameRectOvals(reporter, surface->getCanvas());
-}
-
-DEF_TEST(GrPathKeys, reporter) {
+DEF_GPUTEST(GrPathKeys, reporter, /*factory*/) {
// Keys should not ignore conic weights.
SkPath path1, path2;
path1.setIsVolatile(true);