OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkColor.h" | 8 #include "SkColor.h" |
9 #include "SkColorMatrixFilter.h" | 9 #include "SkColorMatrixFilter.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 { make_color_sh, true, 1.0f/255 }, | 146 { make_color_sh, true, 1.0f/255 }, |
147 // PMColor 4f gradients are interpolated in 255-multiplied values, so we
need a | 147 // PMColor 4f gradients are interpolated in 255-multiplied values, so we
need a |
148 // slightly relaxed tolerance to accommodate the cumulative precision de
viation. | 148 // slightly relaxed tolerance to accommodate the cumulative precision de
viation. |
149 { make_grad_sh, true, 1.001f/255 }, | 149 { make_grad_sh, true, 1.001f/255 }, |
150 { make_image_sh, false, 1.0f/255 }, | 150 { make_image_sh, false, 1.0f/255 }, |
151 { make_cf_sh, true, 1.0f/255 }, | 151 { make_cf_sh, true, 1.0f/255 }, |
152 }; | 152 }; |
153 | 153 |
154 SkPaint paint; | 154 SkPaint paint; |
155 for (const auto& rec : recs) { | 155 for (const auto& rec : recs) { |
156 uint32_t storage[300]; | 156 uint32_t storage[400]; |
157 paint.setShader(rec.fFact()); | 157 paint.setShader(rec.fFact()); |
158 // Encourage 4f context selection. At some point we may need | 158 // Encourage 4f context selection. At some point we may need |
159 // to instantiate two separate contexts for optimal 4b/4f selection. | 159 // to instantiate two separate contexts for optimal 4b/4f selection. |
160 const SkShader::ContextRec contextRec(paint, SkMatrix::I(), nullptr, | 160 const SkShader::ContextRec contextRec(paint, SkMatrix::I(), nullptr, |
161 SkShader::ContextRec::kPM4f_DstTyp
e); | 161 SkShader::ContextRec::kPM4f_DstTyp
e); |
162 SkASSERT(paint.getShader()->contextSize(contextRec) <= sizeof(storage)); | 162 SkASSERT(paint.getShader()->contextSize(contextRec) <= sizeof(storage)); |
163 SkShader::Context* ctx = paint.getShader()->createContext(contextRec, st
orage); | 163 SkShader::Context* ctx = paint.getShader()->createContext(contextRec, st
orage); |
164 if (rec.fSupports4f) { | 164 if (rec.fSupports4f) { |
165 const int N = 100; | 165 const int N = 100; |
166 SkPM4f buffer4f[N]; | 166 SkPM4f buffer4f[N]; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // | 240 // |
241 DEF_TEST(Color4f_xfermode_proc4f, reporter) { | 241 DEF_TEST(Color4f_xfermode_proc4f, reporter) { |
242 // TODO: extend xfermodes so that all cases can be tested. | 242 // TODO: extend xfermodes so that all cases can be tested. |
243 // | 243 // |
244 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; +
+mode) { | 244 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; +
+mode) { |
245 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); | 245 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); |
246 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); | 246 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); |
247 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); | 247 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); |
248 } | 248 } |
249 } | 249 } |
OLD | NEW |