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

Side by Side Diff: tests/SkColor4fTest.cpp

Issue 1720933002: Add ContextRec param to SkShader::contextSize() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: ContextRec plumbing only 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/image/SkImageShader.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 SkASSERT(paint.getShader()->contextSize() <= sizeof(storage)); 151 const SkShader::ContextRec contextRec(paint, SkMatrix::I(), nullptr);
152 SkShader::Context* ctx = paint.getShader()->createContext({paint, SkMatr ix::I(), nullptr}, 152 SkASSERT(paint.getShader()->contextSize(contextRec) <= sizeof(storage));
153 storage); 153 SkShader::Context* ctx = paint.getShader()->createContext(contextRec, st orage);
154 REPORTER_ASSERT(reporter, ctx->supports4f() == rec.fSupports4f); 154 REPORTER_ASSERT(reporter, ctx->supports4f() == rec.fSupports4f);
155 if (ctx->supports4f()) { 155 if (ctx->supports4f()) {
156 const int N = 100; 156 const int N = 100;
157 SkPM4f buffer4f[N]; 157 SkPM4f buffer4f[N];
158 ctx->shadeSpan4f(0, 0, buffer4f, N); 158 ctx->shadeSpan4f(0, 0, buffer4f, N);
159 SkPMColor buffer4b[N]; 159 SkPMColor buffer4b[N];
160 ctx->shadeSpan(0, 0, buffer4b, N); 160 ctx->shadeSpan(0, 0, buffer4b, N);
161 compare_spans(buffer4f, buffer4b, N, reporter); 161 compare_spans(buffer4f, buffer4b, N, reporter);
162 } 162 }
163 ctx->~Context(); 163 ctx->~Context();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // 230 //
231 DEF_TEST(Color4f_xfermode_proc4f, reporter) { 231 DEF_TEST(Color4f_xfermode_proc4f, reporter) {
232 // TODO: extend xfermodes so that all cases can be tested. 232 // TODO: extend xfermodes so that all cases can be tested.
233 // 233 //
234 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; + +mode) { 234 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; + +mode) {
235 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); 235 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode);
236 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); 236 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode);
237 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); 237 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f));
238 } 238 }
239 } 239 }
OLDNEW
« no previous file with comments | « src/image/SkImageShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698