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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 { make_color_sh, true }, | 141 { make_color_sh, true }, |
142 { make_grad_sh, false }, | 142 { make_grad_sh, false }, |
143 { make_image_sh, false }, | 143 { make_image_sh, false }, |
144 { make_cf_sh, true }, | 144 { make_cf_sh, true }, |
145 }; | 145 }; |
146 | 146 |
147 SkPaint paint; | 147 SkPaint paint; |
148 for (const auto& rec : recs) { | 148 for (const auto& rec : recs) { |
149 uint32_t storage[200]; | 149 uint32_t storage[200]; |
150 paint.setShader(rec.fFact())->unref(); | 150 paint.setShader(rec.fFact())->unref(); |
151 const SkShader::ContextRec contextRec(paint, SkMatrix::I(), nullptr); | 151 // Encourage 4f context selection. At some point we may need |
| 152 // to instantiate two separate contexts for optimal 4b/4f selection. |
| 153 const SkShader::ContextRec contextRec(paint, SkMatrix::I(), nullptr, |
| 154 SkShader::ContextRec::kPM4f_DstTyp
e); |
152 SkASSERT(paint.getShader()->contextSize(contextRec) <= sizeof(storage)); | 155 SkASSERT(paint.getShader()->contextSize(contextRec) <= sizeof(storage)); |
153 SkShader::Context* ctx = paint.getShader()->createContext(contextRec, st
orage); | 156 SkShader::Context* ctx = paint.getShader()->createContext(contextRec, st
orage); |
154 REPORTER_ASSERT(reporter, ctx->supports4f() == rec.fSupports4f); | 157 REPORTER_ASSERT(reporter, ctx->supports4f() == rec.fSupports4f); |
155 if (ctx->supports4f()) { | 158 if (ctx->supports4f()) { |
156 const int N = 100; | 159 const int N = 100; |
157 SkPM4f buffer4f[N]; | 160 SkPM4f buffer4f[N]; |
158 ctx->shadeSpan4f(0, 0, buffer4f, N); | 161 ctx->shadeSpan4f(0, 0, buffer4f, N); |
159 SkPMColor buffer4b[N]; | 162 SkPMColor buffer4b[N]; |
160 ctx->shadeSpan(0, 0, buffer4b, N); | 163 ctx->shadeSpan(0, 0, buffer4b, N); |
161 compare_spans(buffer4f, buffer4b, N, reporter); | 164 compare_spans(buffer4f, buffer4b, N, reporter); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // | 233 // |
231 DEF_TEST(Color4f_xfermode_proc4f, reporter) { | 234 DEF_TEST(Color4f_xfermode_proc4f, reporter) { |
232 // TODO: extend xfermodes so that all cases can be tested. | 235 // TODO: extend xfermodes so that all cases can be tested. |
233 // | 236 // |
234 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; +
+mode) { | 237 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; +
+mode) { |
235 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); | 238 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); |
236 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); | 239 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); |
237 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); | 240 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); |
238 } | 241 } |
239 } | 242 } |
OLD | NEW |