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

Side by Side Diff: tests/SerializationTest.cpp

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 years, 11 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/PDFPrimitivesTest.cpp ('k') | tests/StreamTest.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 2013 Google Inc. 2 * Copyright 2013 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 "Resources.h" 8 #include "Resources.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(canvasRect.width()) , 343 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(canvasRect.width()) ,
344 SkIntToScalar(canvasRect.height() ), 344 SkIntToScalar(canvasRect.height() ),
345 NULL, 0); 345 NULL, 0);
346 canvas->drawColor(SK_ColorWHITE); 346 canvas->drawColor(SK_ColorWHITE);
347 canvas->drawText("A!", 2, 24, 32, paint); 347 canvas->drawText("A!", 2, 24, 32, paint);
348 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 348 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
349 349
350 // Serlialize picture and create its clone from stream. 350 // Serlialize picture and create its clone from stream.
351 SkDynamicMemoryWStream stream; 351 SkDynamicMemoryWStream stream;
352 picture->serialize(&stream); 352 picture->serialize(&stream);
353 SkAutoTUnref<SkStream> inputStream(stream.detachAsStream()); 353 SkAutoTDelete<SkStream> inputStream(stream.detachAsStream());
354 SkAutoTUnref<SkPicture> loadedPicture(SkPicture::CreateFromStream(inputStrea m.get())); 354 SkAutoTUnref<SkPicture> loadedPicture(SkPicture::CreateFromStream(inputStrea m.get()));
355 355
356 // Draw both original and clone picture and compare bitmaps -- they should b e identical. 356 // Draw both original and clone picture and compare bitmaps -- they should b e identical.
357 SkBitmap origBitmap = draw_picture(*picture); 357 SkBitmap origBitmap = draw_picture(*picture);
358 SkBitmap destBitmap = draw_picture(*loadedPicture); 358 SkBitmap destBitmap = draw_picture(*loadedPicture);
359 compare_bitmaps(reporter, origBitmap, destBitmap); 359 compare_bitmaps(reporter, origBitmap, destBitmap);
360 } 360 }
361 361
362 static void setup_bitmap_for_canvas(SkBitmap* bitmap) { 362 static void setup_bitmap_for_canvas(SkBitmap* bitmap) {
363 bitmap->allocN32Pixels(kBitmapSize, kBitmapSize); 363 bitmap->allocN32Pixels(kBitmapSize, kBitmapSize);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 517
518 // Deserialize picture 518 // Deserialize picture
519 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size); 519 SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size);
520 SkAutoTUnref<SkPicture> readPict( 520 SkAutoTUnref<SkPicture> readPict(
521 SkPicture::CreateFromBuffer(reader)); 521 SkPicture::CreateFromBuffer(reader));
522 REPORTER_ASSERT(reporter, readPict.get()); 522 REPORTER_ASSERT(reporter, readPict.get());
523 } 523 }
524 524
525 TestPictureTypefaceSerialization(reporter); 525 TestPictureTypefaceSerialization(reporter);
526 } 526 }
OLDNEW
« no previous file with comments | « tests/PDFPrimitivesTest.cpp ('k') | tests/StreamTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698