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

Side by Side Diff: tests/GpuColorFilterTest.cpp

Issue 1213613016: More threading of GrShaderDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@GrShaderDataManager
Patch Set: build issue Created 5 years, 5 months 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 | « src/gpu/SkGr.cpp ('k') | no next file » | 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 /* 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 #include "SkColorFilter.h"
10 #include "Test.h"
11
9 #if SK_SUPPORT_GPU 12 #if SK_SUPPORT_GPU
10 13
11 #include "GrContext.h" 14 #include "GrContext.h"
12 #include "GrContextFactory.h" 15 #include "GrContextFactory.h"
13 #include "GrFragmentProcessor.h" 16 #include "GrFragmentProcessor.h"
14 #include "GrInvariantOutput.h" 17 #include "GrInvariantOutput.h"
15 #include "SkColorFilter.h"
16 #include "SkGr.h" 18 #include "SkGr.h"
17 #include "Test.h"
18 19
19 static GrColor filterColor(const GrColor& color, uint32_t flags) { 20 static GrColor filterColor(const GrColor& color, uint32_t flags) {
20 uint32_t mask = 0; 21 uint32_t mask = 0;
21 if (flags & kR_GrColorComponentFlag) { 22 if (flags & kR_GrColorComponentFlag) {
22 mask = 0xFF << GrColor_SHIFT_R; 23 mask = 0xFF << GrColor_SHIFT_R;
23 } 24 }
24 if (flags & kG_GrColorComponentFlag) { 25 if (flags & kG_GrColorComponentFlag) {
25 mask |= 0xFF << GrColor_SHIFT_G; 26 mask |= 0xFF << GrColor_SHIFT_G;
26 } 27 }
27 if (flags & kB_GrColorComponentFlag) { 28 if (flags & kB_GrColorComponentFlag) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 { kRGBA, gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, kRGBA, GrColorPackRGBA(178, 178, 178, 192)}, 90 { kRGBA, gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, kRGBA, GrColorPackRGBA(178, 178, 178, 192)},
90 // An unknown color with known alpha filtered with DstOver produces an u nknown color with known alpha. 91 // An unknown color with known alpha filtered with DstOver produces an u nknown color with known alpha.
91 { kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, kA , GrColorPackRGBA(0, 0, 0, 192)}, 92 { kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, kA , GrColorPackRGBA(0, 0, 0, 192)},
92 // A color with unknown alpha filtered with DstOver produces an unknown color. 93 // A color with unknown alpha filtered with DstOver produces an unknown color.
93 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, 0 , gr_black}, 94 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, 0 , gr_black},
94 95
95 // An unknown color with known alpha and red component filtered with Mul tiply produces an unknown color with known red and alpha. 96 // An unknown color with known alpha and red component filtered with Mul tiply produces an unknown color with known red and alpha.
96 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode: :kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) } 97 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode: :kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) }
97 }; 98 };
98 99
100 GrPaint paint;
99 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) { 101 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
100 const GetConstantComponentTestCase& test = filterTests[i]; 102 const GetConstantComponentTestCase& test = filterTests[i];
101 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filt erColor, test.filterMode)); 103 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filt erColor, test.filterMode));
102 SkTDArray<GrFragmentProcessor*> array; 104 SkTDArray<GrFragmentProcessor*> array;
103 bool hasFrag = cf->asFragmentProcessors(grContext, &array); 105 bool hasFrag = cf->asFragmentProcessors(grContext, paint.getShaderDataMa nager(), &array);
104 REPORTER_ASSERT(reporter, hasFrag); 106 REPORTER_ASSERT(reporter, hasFrag);
105 REPORTER_ASSERT(reporter, 1 == array.count()); 107 REPORTER_ASSERT(reporter, 1 == array.count());
106 GrInvariantOutput inout(test.inputColor, 108 GrInvariantOutput inout(test.inputColor,
107 static_cast<GrColorComponentFlags>(test.inputCom ponents), 109 static_cast<GrColorComponentFlags>(test.inputCom ponents),
108 false); 110 false);
109 array[0]->computeInvariantOutput(&inout); 111 array[0]->computeInvariantOutput(&inout);
110 112
111 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) == test.outputColor); 113 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) == test.outputColor);
112 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags()); 114 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags());
113 array[0]->unref(); 115 array[0]->unref();
114 } 116 }
115 } 117 }
116 118
117 DEF_GPUTEST(GpuColorFilter, reporter, factory) { 119 DEF_GPUTEST(GpuColorFilter, reporter, factory) {
118 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 120 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
119 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 121 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
120 122
121 GrContext* grContext = factory->get(glType); 123 GrContext* grContext = factory->get(glType);
122 if (NULL == grContext) { 124 if (NULL == grContext) {
123 continue; 125 continue;
124 } 126 }
125 127
126 test_getConstantColorComponents(reporter, grContext); 128 test_getConstantColorComponents(reporter, grContext);
127 } 129 }
128 } 130 }
129 131
130 #endif 132 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698