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

Side by Side Diff: tests/PaintTest.cpp

Issue 1920423002: Prototype code that turns any/every flattenable into JSON (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix copyright dates in new files Created 4 years, 7 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 | « tests/ImageIsOpaqueTest.cpp ('k') | tests/SerializationTest.cpp » ('j') | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurMask.h" 8 #include "SkBlurMask.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkLayerDrawLooper.h" 10 #include "SkLayerDrawLooper.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 paint.setFlags(0x1234); 248 paint.setFlags(0x1234);
249 249
250 FOR_SETUP(i, levels, setFilterQuality) 250 FOR_SETUP(i, levels, setFilterQuality)
251 FOR_SETUP(j, hinting, setHinting) 251 FOR_SETUP(j, hinting, setHinting)
252 FOR_SETUP(k, align, setTextAlign) 252 FOR_SETUP(k, align, setTextAlign)
253 FOR_SETUP(l, caps, setStrokeCap) 253 FOR_SETUP(l, caps, setStrokeCap)
254 FOR_SETUP(m, joins, setStrokeJoin) 254 FOR_SETUP(m, joins, setStrokeJoin)
255 FOR_SETUP(n, encodings, setTextEncoding) 255 FOR_SETUP(n, encodings, setTextEncoding)
256 FOR_SETUP(p, styles, setStyle) 256 FOR_SETUP(p, styles, setStyle)
257 257
258 SkWriteBuffer writer; 258 SkBinaryWriteBuffer writer;
259 paint.flatten(writer); 259 paint.flatten(writer);
260 260
261 SkAutoMalloc buf(writer.bytesWritten()); 261 SkAutoMalloc buf(writer.bytesWritten());
262 writer.writeToMemory(buf.get()); 262 writer.writeToMemory(buf.get());
263 SkReadBuffer reader(buf.get(), writer.bytesWritten()); 263 SkReadBuffer reader(buf.get(), writer.bytesWritten());
264 264
265 SkPaint paint2; 265 SkPaint paint2;
266 paint2.unflatten(reader); 266 paint2.unflatten(reader);
267 REPORTER_ASSERT(reporter, paint2 == paint); 267 REPORTER_ASSERT(reporter, paint2 == paint);
268 268
(...skipping 19 matching lines...) Expand all
288 #define ASSERT(expr) REPORTER_ASSERT(r, expr) 288 #define ASSERT(expr) REPORTER_ASSERT(r, expr)
289 289
290 DEF_TEST(Paint_MoreFlattening, r) { 290 DEF_TEST(Paint_MoreFlattening, r) {
291 SkPaint paint; 291 SkPaint paint;
292 paint.setColor(0x00AABBCC); 292 paint.setColor(0x00AABBCC);
293 paint.setTextScaleX(1.0f); // Default value, ignored. 293 paint.setTextScaleX(1.0f); // Default value, ignored.
294 paint.setTextSize(19); 294 paint.setTextSize(19);
295 paint.setXfermode(SkXfermode::Make(SkXfermode::kModulate_Mode)); 295 paint.setXfermode(SkXfermode::Make(SkXfermode::kModulate_Mode));
296 paint.setLooper(nullptr); // Default value, ignored. 296 paint.setLooper(nullptr); // Default value, ignored.
297 297
298 SkWriteBuffer writer; 298 SkBinaryWriteBuffer writer;
299 paint.flatten(writer); 299 paint.flatten(writer);
300 300
301 SkAutoMalloc buf(writer.bytesWritten()); 301 SkAutoMalloc buf(writer.bytesWritten());
302 writer.writeToMemory(buf.get()); 302 writer.writeToMemory(buf.get());
303 SkReadBuffer reader(buf.get(), writer.bytesWritten()); 303 SkReadBuffer reader(buf.get(), writer.bytesWritten());
304 304
305 SkPaint other; 305 SkPaint other;
306 other.unflatten(reader); 306 other.unflatten(reader);
307 ASSERT(reader.offset() == writer.bytesWritten()); 307 ASSERT(reader.offset() == writer.bytesWritten());
308 308
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
364 SkColorMatrix cm; 364 SkColorMatrix cm;
365 cm.setIdentity(); // does not change alpha 365 cm.setIdentity(); // does not change alpha
366 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 366 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
367 REPORTER_ASSERT(r, paint.nothingToDraw()); 367 REPORTER_ASSERT(r, paint.nothingToDraw());
368 368
369 cm.postTranslate(0, 0, 0, 1); // wacks alpha 369 cm.postTranslate(0, 0, 0, 1); // wacks alpha
370 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 370 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
371 REPORTER_ASSERT(r, !paint.nothingToDraw()); 371 REPORTER_ASSERT(r, !paint.nothingToDraw());
372 } 372 }
OLDNEW
« no previous file with comments | « tests/ImageIsOpaqueTest.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698