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

Side by Side Diff: tests/SkColor4fTest.cpp

Issue 1724503002: Add dest type hint to SkShader::ContextRec (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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/core/SkDraw.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 * 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
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
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 }
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698