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