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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 2341693004: add helpers for using SkData with picture serialization (Closed)
Patch Set: update sampleview 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 | « no previous file | include/core/SkPicture.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 "DMSrcSink.h" 8 #include "DMSrcSink.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 #include "SkAndroidCodec.h" 10 #include "SkAndroidCodec.h"
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 auto size = src.size(); 1421 auto size = src.size();
1422 SkPictureRecorder recorder; 1422 SkPictureRecorder recorder;
1423 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()), 1423 Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
1424 SkIntToScalar(size.height()))); 1424 SkIntToScalar(size.height())));
1425 if (!err.isEmpty()) { 1425 if (!err.isEmpty()) {
1426 return err; 1426 return err;
1427 } 1427 }
1428 sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture()); 1428 sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture());
1429 1429
1430 // Serialize it and then deserialize it. 1430 // Serialize it and then deserialize it.
1431 SkDynamicMemoryWStream wStream; 1431 sk_sp<SkPicture> deserialized(SkPicture::MakeFromData(pic->serialize().get() ));
1432 pic->serialize(&wStream);
1433 SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
1434 sk_sp<SkPicture> deserialized(SkPicture::MakeFromStream(rStream));
1435 1432
1436 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) { 1433 return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas ) {
1437 canvas->drawPicture(deserialized); 1434 canvas->drawPicture(deserialized);
1438 return check_against_reference(bitmap, src, fSink); 1435 return check_against_reference(bitmap, src, fSink);
1439 }); 1436 });
1440 } 1437 }
1441 1438
1442 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1439 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1443 1440
1444 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink) 1441 ViaTiles::ViaTiles(int w, int h, SkBBHFactory* factory, Sink* sink)
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 Error err = src.draw(&rec); 1659 Error err = src.draw(&rec);
1663 if (!err.isEmpty()) { 1660 if (!err.isEmpty()) {
1664 return err; 1661 return err;
1665 } 1662 }
1666 dl->draw(canvas); 1663 dl->draw(canvas);
1667 return check_against_reference(bitmap, src, fSink); 1664 return check_against_reference(bitmap, src, fSink);
1668 }); 1665 });
1669 } 1666 }
1670 1667
1671 } // namespace DM 1668 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698