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