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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drawVertices and drawTextOnPath Created 4 years, 4 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
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 16 matching lines...) Expand all
27 #include "SkPM4fPriv.h" 27 #include "SkPM4fPriv.h"
28 #include "SkStream.h" 28 #include "SkStream.h"
29 #include "SkSurface.h" 29 #include "SkSurface.h"
30 #include "SkTemplates.h" 30 #include "SkTemplates.h"
31 #include "SkTSort.h" 31 #include "SkTSort.h"
32 #include "SkTime.h" 32 #include "SkTime.h"
33 #include "SkTypeface.h" 33 #include "SkTypeface.h"
34 #include "SkWindow.h" 34 #include "SkWindow.h"
35 #include "sk_tool_utils.h" 35 #include "sk_tool_utils.h"
36 36
37 #include "SkReadBuffer.h"
38 #include "SkStream.h"
39
37 #if SK_SUPPORT_GPU 40 #if SK_SUPPORT_GPU
38 # include "gl/GrGLInterface.h" 41 # include "gl/GrGLInterface.h"
39 # include "gl/GrGLUtil.h" 42 # include "gl/GrGLUtil.h"
40 # include "GrContext.h" 43 # include "GrContext.h"
41 # include "SkGr.h" 44 # include "SkGr.h"
42 # if SK_ANGLE 45 # if SK_ANGLE
43 # include "gl/angle/GLTestContext_angle.h" 46 # include "gl/angle/GLTestContext_angle.h"
44 # endif 47 # endif
45 #else 48 #else
46 class GrContext; 49 class GrContext;
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 DEFINE_bool(sort, false, "Sort samples by title."); 692 DEFINE_bool(sort, false, "Sort samples by title.");
690 DEFINE_bool(list, false, "List samples?"); 693 DEFINE_bool(list, false, "List samples?");
691 DEFINE_bool(gpu, false, "Start up with gpu?"); 694 DEFINE_bool(gpu, false, "Start up with gpu?");
692 DEFINE_bool(redraw, false, "Force continuous redrawing, for profiling or debuggi ng tools."); 695 DEFINE_bool(redraw, false, "Force continuous redrawing, for profiling or debuggi ng tools.");
693 DEFINE_string(key, "", ""); // dummy to enable gm tests that have platform-spec ific names 696 DEFINE_string(key, "", ""); // dummy to enable gm tests that have platform-spec ific names
694 #ifdef SAMPLE_PDF_FILE_VIEWER 697 #ifdef SAMPLE_PDF_FILE_VIEWER
695 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files."); 698 DEFINE_string(pdfPath, "", "Path to direcotry of pdf files.");
696 #endif 699 #endif
697 700
698 #include "SkTaskGroup.h" 701 #include "SkTaskGroup.h"
702 #include "SkForceLinking.h"
699 703
700 SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev Manager) 704 SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev Manager)
701 : INHERITED(hwnd) 705 : INHERITED(hwnd)
702 , fDevManager(nullptr) { 706 , fDevManager(nullptr) {
703 707
708 SkForceLinking(false);
709
704 SkCommandLineFlags::Parse(argc, argv); 710 SkCommandLineFlags::Parse(argc, argv);
705 711
706 fCurrIndex = -1; 712 fCurrIndex = -1;
707 713
708 if (!FLAGS_pictureDir.isEmpty()) { 714 if (!FLAGS_pictureDir.isEmpty()) {
709 SkOSFile::Iter iter(FLAGS_pictureDir[0], "skp"); 715 SkOSFile::Iter iter(FLAGS_pictureDir[0], "skp");
710 SkString filename; 716 SkString filename;
711 while (iter.next(&filename)) { 717 while (iter.next(&filename)) {
712 *fSamples.append() = new PictFileFactory( 718 *fSamples.append() = new PictFileFactory(
713 SkOSPath::Join(FLAGS_pictureDir[0], filename.c_str())); 719 SkOSPath::Join(FLAGS_pictureDir[0], filename.c_str()));
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 } 1304 }
1299 name.append(".pdf"); 1305 name.append(".pdf");
1300 #ifdef SK_BUILD_FOR_ANDROID 1306 #ifdef SK_BUILD_FOR_ANDROID
1301 name.prepend("/sdcard/"); 1307 name.prepend("/sdcard/");
1302 #endif 1308 #endif
1303 fPDFDocument = SkDocument::MakePDF(name.c_str()); 1309 fPDFDocument = SkDocument::MakePDF(name.c_str());
1304 canvas = fPDFDocument->beginPage(this->width(), this->height()); 1310 canvas = fPDFDocument->beginPage(this->width(), this->height());
1305 } else if (fSaveToSKP) { 1311 } else if (fSaveToSKP) {
1306 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0); 1312 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
1307 } else if (fUsePicture) { 1313 } else if (fUsePicture) {
1308 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0); 1314 fPipeStream = new SkDynamicMemoryWStream;
1315 canvas = fPipeSerializer.beginWrite(SkRect::MakeWH(this->width(), this-> height()),
1316 fPipeStream);
1317 // canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
1309 } else { 1318 } else {
1310 canvas = this->INHERITED::beforeChildren(canvas); 1319 canvas = this->INHERITED::beforeChildren(canvas);
1311 } 1320 }
1312 1321
1313 if (fUseClip) { 1322 if (fUseClip) {
1314 canvas->drawColor(0xFFFF88FF); 1323 canvas->drawColor(0xFFFF88FF);
1315 canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true); 1324 canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true);
1316 } 1325 }
1317 1326
1318 // Install a flags filter proxy canvas if needed 1327 // Install a flags filter proxy canvas if needed
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 if (fSaveToSKP) { 1369 if (fSaveToSKP) {
1361 sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture()); 1370 sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
1362 SkFILEWStream stream("sample_app.skp"); 1371 SkFILEWStream stream("sample_app.skp");
1363 picture->serialize(&stream); 1372 picture->serialize(&stream);
1364 fSaveToSKP = false; 1373 fSaveToSKP = false;
1365 this->inval(nullptr); 1374 this->inval(nullptr);
1366 return; 1375 return;
1367 } 1376 }
1368 1377
1369 if (fUsePicture) { 1378 if (fUsePicture) {
1370 sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture()); 1379 if (true) {
1371 1380 fPipeSerializer.endWrite();
1372 // serialize/deserialize? 1381 sk_sp<SkData> data(fPipeStream->copyToData());
1373 if (false) { 1382 fPipeDeserializer.playback(data->data(), data->size(), orig);
1374 SkDynamicMemoryWStream wstream; 1383 delete fPipeStream;
1375 picture->serialize(&wstream); 1384 } else {
1376 1385 sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
1377 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1386 orig->drawPicture(picture.get());
1378 picture = SkPicture::MakeFromStream(rstream);
1379 } 1387 }
1380 orig->drawPicture(picture.get());
1381 } 1388 }
1382 1389
1383 // Do this after presentGL and other finishing, rather than in afterChild 1390 // Do this after presentGL and other finishing, rather than in afterChild
1384 if (fMeasureFPS) { 1391 if (fMeasureFPS) {
1385 orig->flush(); 1392 orig->flush();
1386 fTimer.end(); 1393 fTimer.end();
1387 fMeasureFPS_Time += fTimer.fWall; 1394 fMeasureFPS_Time += fTimer.fWall;
1388 } 1395 }
1389 } 1396 }
1390 1397
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 #ifdef SK_BUILD_FOR_MAC 2277 #ifdef SK_BUILD_FOR_MAC
2271 setenv("ANDROID_ROOT", "/android/device/data", 0); 2278 setenv("ANDROID_ROOT", "/android/device/data", 0);
2272 #endif 2279 #endif
2273 SkGraphics::Init(); 2280 SkGraphics::Init();
2274 SkEvent::Init(); 2281 SkEvent::Init();
2275 } 2282 }
2276 2283
2277 void application_term() { 2284 void application_term() {
2278 SkEvent::Term(); 2285 SkEvent::Term();
2279 } 2286 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/core/SkDeduper.h » ('j') | src/core/SkReadBuffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698