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

Side by Side Diff: samplecode/GMSampleView.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 | « include/core/SkPicture.h ('k') | src/core/SkPicture.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 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 "GMSampleView.h" 8 #include "GMSampleView.h"
9 9
10 GMSampleView::GMSampleView(GM* gm) : fShowSize(false), fGM(gm) {} 10 GMSampleView::GMSampleView(GM* gm) : fShowSize(false), fGM(gm) {}
(...skipping 29 matching lines...) Expand all
40 40
41 bool GMSampleView::onEvent(const SkEvent& evt) { 41 bool GMSampleView::onEvent(const SkEvent& evt) {
42 if (evt.isType("GMSampleView::showSize")) { 42 if (evt.isType("GMSampleView::showSize")) {
43 fShowSize = SkToBool(evt.getFast32()); 43 fShowSize = SkToBool(evt.getFast32());
44 return true; 44 return true;
45 } 45 }
46 return this->INHERITED::onEvent(evt); 46 return this->INHERITED::onEvent(evt);
47 } 47 }
48 48
49 #include "SkPicture.h" 49 #include "SkPicture.h"
50 #include "SkStream.h"
51 static sk_sp<SkPicture> round_trip_serialize(SkPicture* src) { 50 static sk_sp<SkPicture> round_trip_serialize(SkPicture* src) {
52 SkDynamicMemoryWStream stream; 51 return SkPicture::MakeFromData(src->serialize().get());
53 src->serialize(&stream);
54 SkAutoTDelete<SkStream> reader(stream.detachAsStream());
55 return SkPicture::MakeFromStream(reader);
56 } 52 }
57 53
58 #include "SkPictureRecorder.h" 54 #include "SkPictureRecorder.h"
59 void GMSampleView::onDrawContent(SkCanvas* canvas) { 55 void GMSampleView::onDrawContent(SkCanvas* canvas) {
60 SkPictureRecorder recorder; 56 SkPictureRecorder recorder;
61 SkCanvas* origCanvas = canvas; 57 SkCanvas* origCanvas = canvas;
62 58
63 if (false) { 59 if (false) {
64 SkISize size = fGM->getISize(); 60 SkISize size = fGM->getISize();
65 canvas = recorder.beginRecording(SkRect::MakeIWH(size.width(), size.heig ht())); 61 canvas = recorder.beginRecording(SkRect::MakeIWH(size.width(), size.heig ht()));
(...skipping 23 matching lines...) Expand all
89 } 85 }
90 } 86 }
91 87
92 void GMSampleView::onDrawBackground(SkCanvas* canvas) { 88 void GMSampleView::onDrawBackground(SkCanvas* canvas) {
93 fGM->drawBackground(canvas); 89 fGM->drawBackground(canvas);
94 } 90 }
95 91
96 bool GMSampleView::onAnimate(const SkAnimTimer& timer) { 92 bool GMSampleView::onAnimate(const SkAnimTimer& timer) {
97 return fGM->animate(timer); 93 return fGM->animate(timer);
98 } 94 }
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698