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

Side by Side Diff: tests/GrPorterDuffTest.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: rebase, remove a hunk 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkXfermode.h" 8 #include "SkXfermode.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
11 #if SK_SUPPORT_GPU 11 #if SK_SUPPORT_GPU
12 12
13 #include "GrContextFactory.h" 13 #include "GrContextFactory.h"
14 #include "GrContextOptions.h" 14 #include "GrContextOptions.h"
15 #include "GrGpu.h" 15 #include "GrGpu.h"
16 #include "GrResourceProvider.h" 16 #include "GrResourceProvider.h"
17 #include "GrXferProcessor.h" 17 #include "GrXferProcessor.h"
18 #include "batches/GrVertexBatch.h" 18 #include "batches/GrVertexBatch.h"
19 #include "effects/GrPorterDuffXferProcessor.h" 19 #include "effects/GrPorterDuffXferProcessor.h"
20 #include "gl/GrGLCaps.h" 20 #include "gl/GrGLCaps.h"
21 21
22 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
23 23
24 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps); 24 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
25 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G rCaps& caps); 25 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G rCaps& caps);
26 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps); 26 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
27 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr Caps& caps); 27 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr Caps& caps);
28 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps); 28 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
29 static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps); 29 static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps);
30 static void test_no_dual_source_blending(skiatest::Reporter* reporter);
31 30
32 DEF_GPUTEST(GrPorterDuff, reporter, factory) { 31 DEF_GPUTEST_FOR_NULL_CONTEXT(GrPorterDuff, reporter, context) {
33 GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); 32 const GrCaps& caps = *context->getGpu()->caps();
34 if (!ctx) {
35 SkFAIL("Failed to create null context.");
36 return;
37 }
38
39 const GrCaps& caps = *ctx->getGpu()->caps();
40 if (!caps.shaderCaps()->dualSourceBlendingSupport()) { 33 if (!caps.shaderCaps()->dualSourceBlendingSupport()) {
41 SkFAIL("Null context does not support dual source blending."); 34 SkFAIL("Null context does not support dual source blending.");
42 return; 35 return;
43 } 36 }
44 37
45 test_color_unknown_with_coverage(reporter, caps); 38 test_color_unknown_with_coverage(reporter, caps);
46 test_color_unknown_no_coverage(reporter, caps); 39 test_color_unknown_no_coverage(reporter, caps);
47 test_color_opaque_with_coverage(reporter, caps); 40 test_color_opaque_with_coverage(reporter, caps);
48 test_color_opaque_no_coverage(reporter, caps); 41 test_color_opaque_no_coverage(reporter, caps);
49 test_lcd_coverage(reporter, caps); 42 test_lcd_coverage(reporter, caps);
50 test_lcd_coverage_fallback_case(reporter, caps); 43 test_lcd_coverage_fallback_case(reporter, caps);
51 test_no_dual_source_blending(reporter);
52 } 44 }
53 45
54 //////////////////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////////////////
55 47
56 #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) 48 #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__)
57 49
58 enum { 50 enum {
59 kNone_OutputType, 51 kNone_OutputType,
60 kCoverage_OutputType, 52 kCoverage_OutputType,
61 kModulate_OutputType, 53 kModulate_OutputType,
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); 1132 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags);
1141 1133
1142 GrColor overrideColor; 1134 GrColor overrideColor;
1143 xp->getOptimizations(colorPOI, covPOI, false, &overrideColor, caps); 1135 xp->getOptimizations(colorPOI, covPOI, false, &overrideColor, caps);
1144 1136
1145 GrXferProcessor::BlendInfo blendInfo; 1137 GrXferProcessor::BlendInfo blendInfo;
1146 xp->getBlendInfo(&blendInfo); 1138 xp->getBlendInfo(&blendInfo);
1147 TEST_ASSERT(blendInfo.fWriteColor); 1139 TEST_ASSERT(blendInfo.fWriteColor);
1148 } 1140 }
1149 1141
1150 static void test_no_dual_source_blending(skiatest::Reporter* reporter) { 1142 DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
1151 GrContextOptions opts; 1143 GrContextOptions opts;
1152 opts.fSuppressDualSourceBlending = true; 1144 opts.fSuppressDualSourceBlending = true;
1153 GrContextFactory factory(opts); 1145 GrContextFactory mockFactory(opts);
1154 factory.get(GrContextFactory::kNull_GLContextType); 1146 GrContext* ctx = mockFactory.get(GrContextFactory::kNull_GLContextType);
1155 GrContext* ctx = factory.get(GrContextFactory::kNull_GLContextType);
1156 if (!ctx) { 1147 if (!ctx) {
1157 SkFAIL("Failed to create null context without ARB_blend_func_extended.") ; 1148 SkFAIL("Failed to create null context without ARB_blend_func_extended.") ;
1158 return; 1149 return;
1159 } 1150 }
1160 1151
1161 const GrCaps& caps = *ctx->caps(); 1152 const GrCaps& caps = *ctx->caps();
1162 if (caps.shaderCaps()->dualSourceBlendingSupport()) { 1153 if (caps.shaderCaps()->dualSourceBlendingSupport()) {
1163 SkFAIL("Null context failed to honor request for no ARB_blend_func_exten ded."); 1154 SkFAIL("Null context failed to honor request for no ARB_blend_func_exten ded.");
1164 return; 1155 return;
1165 } 1156 }
1166 1157
1167 GrBackendObject backendTex = 1158 GrBackendObject backendTex =
1168 ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_ 8888_GrPixelConfig); 1159 ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100,
1160 kRGBA_8888_GrPixelCon fig);
1169 GrBackendTextureDesc fakeDesc; 1161 GrBackendTextureDesc fakeDesc;
1170 fakeDesc.fConfig = kRGBA_8888_GrPixelConfig; 1162 fakeDesc.fConfig = kRGBA_8888_GrPixelConfig;
1171 fakeDesc.fWidth = fakeDesc.fHeight = 100; 1163 fakeDesc.fWidth = fakeDesc.fHeight = 100;
1172 fakeDesc.fTextureHandle = backendTex; 1164 fakeDesc.fTextureHandle = backendTex;
1173 SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTextu re(fakeDesc, 1165 SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTextu re(fakeDesc,
1174 kBorrow_GrWrapOwnership)); 1166 kBorrow_GrWrapOwnership));
1175 GrXferProcessor::DstTexture fakeDstTexture; 1167 GrXferProcessor::DstTexture fakeDstTexture;
1176 fakeDstTexture.setTexture(fakeTexture); 1168 fakeDstTexture.setTexture(fakeTexture);
1177 1169
1178 static const GrColor testColors[] = { 1170 static const GrColor testColors[] = {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); 1205 xp->getOptimizations(colorPOI, covPOI, false, 0, caps);
1214 TEST_ASSERT(!xp->hasSecondaryOutput()); 1206 TEST_ASSERT(!xp->hasSecondaryOutput());
1215 } 1207 }
1216 } 1208 }
1217 } 1209 }
1218 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); 1210 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
1219 } 1211 }
1220 1212
1221 #endif 1213 #endif
1222 1214
OLDNEW
« tests/BlurTest.cpp ('K') | « tests/GrDrawTargetTest.cpp ('k') | tests/GrSurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698