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

Side by Side Diff: tests/PictureTest.cpp

Issue 2333713002: change SkStreams to work with sk_sp<SkData> instead of SkData* (Closed)
Patch Set: fix xpsdevice Created 4 years, 3 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/PathTest.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBigPicture.h" 8 #include "SkBigPicture.h"
9 #include "SkBBoxHierarchy.h" 9 #include "SkBBoxHierarchy.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 SkPictureRecorder recorder; 625 SkPictureRecorder recorder;
626 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()), 626 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()),
627 SkIntToScalar(bitmap.height())); 627 SkIntToScalar(bitmap.height()));
628 canvas->drawBitmap(bitmap, 0, 0); 628 canvas->drawBitmap(bitmap, 0, 0);
629 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); 629 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
630 630
631 SkDynamicMemoryWStream wStream; 631 SkDynamicMemoryWStream wStream;
632 SkAutoTUnref<SkPixelSerializer> serializer( 632 SkAutoTUnref<SkPixelSerializer> serializer(
633 SkImageEncoder::CreatePixelSerializer()); 633 SkImageEncoder::CreatePixelSerializer());
634 picture->serialize(&wStream, serializer); 634 picture->serialize(&wStream, serializer);
635 return sk_sp<SkData>(wStream.copyToData()); 635 return wStream.detachAsData();
636 } 636 }
637 637
638 struct ErrorContext { 638 struct ErrorContext {
639 int fErrors; 639 int fErrors;
640 skiatest::Reporter* fReporter; 640 skiatest::Reporter* fReporter;
641 }; 641 };
642 642
643 static void assert_one_parse_error_cb(SkError error, void* context) { 643 static void assert_one_parse_error_cb(SkError error, void* context) {
644 ErrorContext* errorContext = static_cast<ErrorContext*>(context); 644 ErrorContext* errorContext = static_cast<ErrorContext*>(context);
645 errorContext->fErrors++; 645 errorContext->fErrors++;
(...skipping 17 matching lines...) Expand all
663 } 663 }
664 664
665 DEF_TEST(Picture_EncodedData, reporter) { 665 DEF_TEST(Picture_EncodedData, reporter) {
666 // Create a bitmap that will be encoded. 666 // Create a bitmap that will be encoded.
667 SkBitmap original; 667 SkBitmap original;
668 make_bm(&original, 100, 100, SK_ColorBLUE, true); 668 make_bm(&original, 100, 100, SK_ColorBLUE, true);
669 SkDynamicMemoryWStream wStream; 669 SkDynamicMemoryWStream wStream;
670 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T ype, 100)) { 670 if (!SkImageEncoder::EncodeStream(&wStream, original, SkImageEncoder::kPNG_T ype, 100)) {
671 return; 671 return;
672 } 672 }
673 sk_sp<SkData> data(wStream.copyToData()); 673 sk_sp<SkData> data = wStream.detachAsData();
674 674
675 SkBitmap bm; 675 SkBitmap bm;
676 bool installSuccess = SkDEPRECATED_InstallDiscardablePixelRef(data.get(), &b m); 676 bool installSuccess = SkDEPRECATED_InstallDiscardablePixelRef(data.get(), &b m);
677 REPORTER_ASSERT(reporter, installSuccess); 677 REPORTER_ASSERT(reporter, installSuccess);
678 678
679 // Write both bitmaps to pictures, and ensure that the resulting data stream s are the same. 679 // Write both bitmaps to pictures, and ensure that the resulting data stream s are the same.
680 // Flattening original will follow the old path of performing an encode, whi le flattening bm 680 // Flattening original will follow the old path of performing an encode, whi le flattening bm
681 // will use the already encoded data. 681 // will use the already encoded data.
682 sk_sp<SkData> picture1(serialized_picture_from_bitmap(original)); 682 sk_sp<SkData> picture1(serialized_picture_from_bitmap(original));
683 sk_sp<SkData> picture2(serialized_picture_from_bitmap(bm)); 683 sk_sp<SkData> picture2(serialized_picture_from_bitmap(bm));
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 SkPictureRecorder rec; 1305 SkPictureRecorder rec;
1306 proc(rec.beginRecording(cull)); 1306 proc(rec.beginRecording(cull));
1307 sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable( 1307 sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable(
1308 SkPictureRecorder::kReturnNullF orEmpty_FinishFlag); 1308 SkPictureRecorder::kReturnNullF orEmpty_FinishFlag);
1309 REPORTER_ASSERT(r, !dr.get()); 1309 REPORTER_ASSERT(r, !dr.get());
1310 } 1310 }
1311 } 1311 }
1312 } 1312 }
1313 #endif 1313 #endif
1314 1314
OLDNEW
« no previous file with comments | « tests/PathTest.cpp ('k') | tests/StreamTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698