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

Side by Side Diff: tests/PaintTest.cpp

Issue 1936563002: remove SkWriteBuffer::getWriter32(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/core/SkWriteBuffer.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 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SkWriteBuffer writer;
259 paint.flatten(writer); 259 paint.flatten(writer);
260 260
261 const uint32_t* written = writer.getWriter32()->contiguousArray(); 261 SkAutoMalloc buf(writer.bytesWritten());
262 SkReadBuffer reader(written, writer.bytesWritten()); 262 writer.writeToMemory(buf.get());
263 SkReadBuffer reader(buf.get(), writer.bytesWritten());
263 264
264 SkPaint paint2; 265 SkPaint paint2;
265 paint2.unflatten(reader); 266 paint2.unflatten(reader);
266 REPORTER_ASSERT(reporter, paint2 == paint); 267 REPORTER_ASSERT(reporter, paint2 == paint);
267 268
268 }}}}}}} 269 }}}}}}}
269 #undef FOR_SETUP 270 #undef FOR_SETUP
270 271
271 } 272 }
272 273
(...skipping 17 matching lines...) Expand all
290 SkPaint paint; 291 SkPaint paint;
291 paint.setColor(0x00AABBCC); 292 paint.setColor(0x00AABBCC);
292 paint.setTextScaleX(1.0f); // Default value, ignored. 293 paint.setTextScaleX(1.0f); // Default value, ignored.
293 paint.setTextSize(19); 294 paint.setTextSize(19);
294 paint.setXfermode(SkXfermode::Make(SkXfermode::kModulate_Mode)); 295 paint.setXfermode(SkXfermode::Make(SkXfermode::kModulate_Mode));
295 paint.setLooper(nullptr); // Default value, ignored. 296 paint.setLooper(nullptr); // Default value, ignored.
296 297
297 SkWriteBuffer writer; 298 SkWriteBuffer writer;
298 paint.flatten(writer); 299 paint.flatten(writer);
299 300
300 SkReadBuffer reader(writer.getWriter32()->contiguousArray(), writer.bytesWri tten()); 301 SkAutoMalloc buf(writer.bytesWritten());
302 writer.writeToMemory(buf.get());
303 SkReadBuffer reader(buf.get(), writer.bytesWritten());
304
301 SkPaint other; 305 SkPaint other;
302 other.unflatten(reader); 306 other.unflatten(reader);
303 ASSERT(reader.offset() == writer.bytesWritten()); 307 ASSERT(reader.offset() == writer.bytesWritten());
304 308
305 // No matter the encoding, these must always hold. 309 // No matter the encoding, these must always hold.
306 ASSERT(other.getColor() == paint.getColor()); 310 ASSERT(other.getColor() == paint.getColor());
307 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); 311 ASSERT(other.getTextScaleX() == paint.getTextScaleX());
308 ASSERT(other.getTextSize() == paint.getTextSize()); 312 ASSERT(other.getTextSize() == paint.getTextSize());
309 ASSERT(other.getLooper() == paint.getLooper()); 313 ASSERT(other.getLooper() == paint.getLooper());
310 314
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 363
360 SkColorMatrix cm; 364 SkColorMatrix cm;
361 cm.setIdentity(); // does not change alpha 365 cm.setIdentity(); // does not change alpha
362 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 366 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
363 REPORTER_ASSERT(r, paint.nothingToDraw()); 367 REPORTER_ASSERT(r, paint.nothingToDraw());
364 368
365 cm.postTranslate(0, 0, 0, 1); // wacks alpha 369 cm.postTranslate(0, 0, 0, 1); // wacks alpha
366 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 370 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
367 REPORTER_ASSERT(r, !paint.nothingToDraw()); 371 REPORTER_ASSERT(r, !paint.nothingToDraw());
368 } 372 }
OLDNEW
« no previous file with comments | « src/core/SkWriteBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698