OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 | 10 |
11 #include "GrContext.h" | 11 #include "GrContext.h" |
12 #include "GrContextFactory.h" | 12 #include "GrContextFactory.h" |
13 #include "GrFragmentProcessor.h" | 13 #include "GrFragmentProcessor.h" |
| 14 #include "GrInvariantOutput.h" |
14 #include "SkColorFilter.h" | 15 #include "SkColorFilter.h" |
15 #include "SkGr.h" | 16 #include "SkGr.h" |
16 #include "Test.h" | 17 #include "Test.h" |
17 | 18 |
18 static GrColor filterColor(const GrColor& color, uint32_t flags) { | 19 static GrColor filterColor(const GrColor& color, uint32_t flags) { |
19 uint32_t mask = 0; | 20 uint32_t mask = 0; |
20 if (flags & kR_GrColorComponentFlag) { | 21 if (flags & kR_GrColorComponentFlag) { |
21 mask = 0xFF << GrColor_SHIFT_R; | 22 mask = 0xFF << GrColor_SHIFT_R; |
22 } | 23 } |
23 if (flags & kG_GrColorComponentFlag) { | 24 if (flags & kG_GrColorComponentFlag) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode::
kDstOver_Mode, 0 , gr_black}, | 93 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode::
kDstOver_Mode, 0 , gr_black}, |
93 | 94 |
94 // An unknown color with known alpha and red component filtered with Mul
tiply produces an unknown color with known red and alpha. | 95 // An unknown color with known alpha and red component filtered with Mul
tiply produces an unknown color with known red and alpha. |
95 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:
:kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) } | 96 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:
:kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) } |
96 }; | 97 }; |
97 | 98 |
98 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) { | 99 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) { |
99 const GetConstantComponentTestCase& test = filterTests[i]; | 100 const GetConstantComponentTestCase& test = filterTests[i]; |
100 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filt
erColor, test.filterMode)); | 101 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filt
erColor, test.filterMode)); |
101 SkAutoTUnref<GrFragmentProcessor> effect(cf->asFragmentProcessor(grConte
xt)); | 102 SkAutoTUnref<GrFragmentProcessor> effect(cf->asFragmentProcessor(grConte
xt)); |
102 GrProcessor::InvariantOutput inout; | 103 GrInvariantOutput inout(test.inputColor, |
103 inout.setToOther(test.inputComponents, test.inputColor, | 104 static_cast<GrColorComponentFlags>(test.inputCom
ponents), |
104 GrProcessor::InvariantOutput::kWill_ReadInput); | 105 false); |
105 effect->computeInvariantOutput(&inout); | 106 effect->computeInvariantOutput(&inout); |
106 | 107 |
107 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags())
== test.outputColor); | 108 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags())
== test.outputColor); |
108 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags()); | 109 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags()); |
109 } | 110 } |
110 } | 111 } |
111 | 112 |
112 DEF_GPUTEST(GpuColorFilter, reporter, factory) { | 113 DEF_GPUTEST(GpuColorFilter, reporter, factory) { |
113 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { | 114 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
114 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); | 115 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); |
115 | 116 |
116 GrContext* grContext = factory->get(glType); | 117 GrContext* grContext = factory->get(glType); |
117 if (NULL == grContext) { | 118 if (NULL == grContext) { |
118 continue; | 119 continue; |
119 } | 120 } |
120 | 121 |
121 test_getConstantColorComponents(reporter, grContext); | 122 test_getConstantColorComponents(reporter, grContext); |
122 } | 123 } |
123 } | 124 } |
124 | 125 |
125 #endif | 126 #endif |
OLD | NEW |