OLD | NEW |
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 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); | 1139 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); |
1148 | 1140 |
1149 GrColor overrideColor; | 1141 GrColor overrideColor; |
1150 xp->getOptimizations(opts, false, &overrideColor, caps); | 1142 xp->getOptimizations(opts, false, &overrideColor, caps); |
1151 | 1143 |
1152 GrXferProcessor::BlendInfo blendInfo; | 1144 GrXferProcessor::BlendInfo blendInfo; |
1153 xp->getBlendInfo(&blendInfo); | 1145 xp->getBlendInfo(&blendInfo); |
1154 TEST_ASSERT(blendInfo.fWriteColor); | 1146 TEST_ASSERT(blendInfo.fWriteColor); |
1155 } | 1147 } |
1156 | 1148 |
1157 static void test_no_dual_source_blending(skiatest::Reporter* reporter) { | 1149 DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) { |
1158 GrContextOptions opts; | 1150 GrContextOptions opts; |
1159 opts.fSuppressDualSourceBlending = true; | 1151 opts.fSuppressDualSourceBlending = true; |
1160 GrContextFactory factory(opts); | 1152 GrContextFactory mockFactory(opts); |
1161 factory.get(GrContextFactory::kNull_GLContextType); | 1153 GrContext* ctx = mockFactory.get(GrContextFactory::kNull_GLContextType); |
1162 GrContext* ctx = factory.get(GrContextFactory::kNull_GLContextType); | |
1163 if (!ctx) { | 1154 if (!ctx) { |
1164 SkFAIL("Failed to create null context without ARB_blend_func_extended.")
; | 1155 SkFAIL("Failed to create null context without ARB_blend_func_extended.")
; |
1165 return; | 1156 return; |
1166 } | 1157 } |
1167 | 1158 |
1168 const GrCaps& caps = *ctx->caps(); | 1159 const GrCaps& caps = *ctx->caps(); |
1169 if (caps.shaderCaps()->dualSourceBlendingSupport()) { | 1160 if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
1170 SkFAIL("Null context failed to honor request for no ARB_blend_func_exten
ded."); | 1161 SkFAIL("Null context failed to honor request for no ARB_blend_func_exten
ded."); |
1171 return; | 1162 return; |
1172 } | 1163 } |
1173 | 1164 |
1174 GrBackendObject backendTex = | 1165 GrBackendObject backendTex = |
1175 ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_
8888_GrPixelConfig); | 1166 ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, |
| 1167 kRGBA_8888_GrPixelCon
fig); |
1176 GrBackendTextureDesc fakeDesc; | 1168 GrBackendTextureDesc fakeDesc; |
1177 fakeDesc.fConfig = kRGBA_8888_GrPixelConfig; | 1169 fakeDesc.fConfig = kRGBA_8888_GrPixelConfig; |
1178 fakeDesc.fWidth = fakeDesc.fHeight = 100; | 1170 fakeDesc.fWidth = fakeDesc.fHeight = 100; |
1179 fakeDesc.fTextureHandle = backendTex; | 1171 fakeDesc.fTextureHandle = backendTex; |
1180 SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTextu
re(fakeDesc, | 1172 SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTextu
re(fakeDesc, |
1181 kBorrow_GrWrapOwnership)); | 1173 kBorrow_GrWrapOwnership)); |
1182 GrXferProcessor::DstTexture fakeDstTexture; | 1174 GrXferProcessor::DstTexture fakeDstTexture; |
1183 fakeDstTexture.setTexture(fakeTexture); | 1175 fakeDstTexture.setTexture(fakeTexture); |
1184 | 1176 |
1185 static const GrColor testColors[] = { | 1177 static const GrColor testColors[] = { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 xp->getOptimizations(optimizations, false, 0, caps); | 1213 xp->getOptimizations(optimizations, false, 0, caps); |
1222 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1214 TEST_ASSERT(!xp->hasSecondaryOutput()); |
1223 } | 1215 } |
1224 } | 1216 } |
1225 } | 1217 } |
1226 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); | 1218 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
1227 } | 1219 } |
1228 | 1220 |
1229 #endif | 1221 #endif |
1230 | 1222 |
OLD | NEW |