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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder Created 4 years, 9 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 | « samplecode/SampleAll.cpp ('k') | samplecode/SampleArc.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 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 "SampleApp.h" 8 #include "SampleApp.h"
9 9
10 #include "OverView.h" 10 #include "OverView.h"
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 SkString name; 1382 SkString name;
1383 name.printf("sample_grab_%d.png", gSampleGrabCounter++); 1383 name.printf("sample_grab_%d.png", gSampleGrabCounter++);
1384 SkImageEncoder::EncodeFile(name.c_str(), bmp, 1384 SkImageEncoder::EncodeFile(name.c_str(), bmp,
1385 SkImageEncoder::kPNG_Type, 100); 1385 SkImageEncoder::kPNG_Type, 100);
1386 } 1386 }
1387 this->inval(nullptr); 1387 this->inval(nullptr);
1388 return; 1388 return;
1389 } 1389 }
1390 1390
1391 if (fSaveToSKP) { 1391 if (fSaveToSKP) {
1392 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording()); 1392 sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
1393 SkFILEWStream stream("sample_app.skp"); 1393 SkFILEWStream stream("sample_app.skp");
1394 picture->serialize(&stream); 1394 picture->serialize(&stream);
1395 fSaveToSKP = false; 1395 fSaveToSKP = false;
1396 this->inval(nullptr); 1396 this->inval(nullptr);
1397 return; 1397 return;
1398 } 1398 }
1399 1399
1400 if (fUsePicture) { 1400 if (fUsePicture) {
1401 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording()); 1401 sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
1402 1402
1403 // serialize/deserialize? 1403 // serialize/deserialize?
1404 if (false) { 1404 if (false) {
1405 SkDynamicMemoryWStream wstream; 1405 SkDynamicMemoryWStream wstream;
1406 picture->serialize(&wstream); 1406 picture->serialize(&wstream);
1407 1407
1408 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1408 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1409 picture.reset(SkPicture::CreateFromStream(rstream)); 1409 picture = SkPicture::MakeFromStream(rstream);
1410 } 1410 }
1411 orig->drawPicture(picture); 1411 orig->drawPicture(picture.get());
1412 } 1412 }
1413 1413
1414 // Do this after presentGL and other finishing, rather than in afterChild 1414 // Do this after presentGL and other finishing, rather than in afterChild
1415 if (fMeasureFPS) { 1415 if (fMeasureFPS) {
1416 orig->flush(); 1416 orig->flush();
1417 fTimer.end(); 1417 fTimer.end();
1418 fMeasureFPS_Time += fTimer.fWall; 1418 fMeasureFPS_Time += fTimer.fWall;
1419 } 1419 }
1420 } 1420 }
1421 1421
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 #ifdef SK_BUILD_FOR_MAC 2329 #ifdef SK_BUILD_FOR_MAC
2330 setenv("ANDROID_ROOT", "/android/device/data", 0); 2330 setenv("ANDROID_ROOT", "/android/device/data", 0);
2331 #endif 2331 #endif
2332 SkGraphics::Init(); 2332 SkGraphics::Init();
2333 SkEvent::Init(); 2333 SkEvent::Init();
2334 } 2334 }
2335 2335
2336 void application_term() { 2336 void application_term() {
2337 SkEvent::Term(); 2337 SkEvent::Term();
2338 } 2338 }
OLDNEW
« no previous file with comments | « samplecode/SampleAll.cpp ('k') | samplecode/SampleArc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698