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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1564343003: remove MPD for now, to simplify things (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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/SampleApp.h ('k') | no next file » | 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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 fDeviceType = kGPU_DeviceType; 833 fDeviceType = kGPU_DeviceType;
834 #endif 834 #endif
835 #if SK_ANGLE && DEFAULT_TO_ANGLE 835 #if SK_ANGLE && DEFAULT_TO_ANGLE
836 fDeviceType = kANGLE_DeviceType; 836 fDeviceType = kANGLE_DeviceType;
837 #endif 837 #endif
838 #if SK_COMMAND_BUFFER && DEFAULT_TO_COMMAND_BUFFER 838 #if SK_COMMAND_BUFFER && DEFAULT_TO_COMMAND_BUFFER
839 fDeviceType = kCommandBuffer_DeviceType; 839 fDeviceType = kCommandBuffer_DeviceType;
840 #endif 840 #endif
841 841
842 fUseClip = false; 842 fUseClip = false;
843 fUseMPD = false; 843 fUsePicture = false;
844 fAnimating = false; 844 fAnimating = false;
845 fRotate = false; 845 fRotate = false;
846 fPerspAnim = false; 846 fPerspAnim = false;
847 fRequestGrabImage = false; 847 fRequestGrabImage = false;
848 fTilingMode = kNo_Tiling; 848 fTilingMode = kNo_Tiling;
849 fMeasureFPS = false; 849 fMeasureFPS = false;
850 fLCDState = SkOSMenu::kMixedState; 850 fLCDState = SkOSMenu::kMixedState;
851 fAAState = SkOSMenu::kMixedState; 851 fAAState = SkOSMenu::kMixedState;
852 fSubpixelState = SkOSMenu::kMixedState; 852 fSubpixelState = SkOSMenu::kMixedState;
853 fHintingState = 0; 853 fHintingState = 0;
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 name.set("unknown_sample"); 1301 name.set("unknown_sample");
1302 } 1302 }
1303 name.append(".pdf"); 1303 name.append(".pdf");
1304 #ifdef SK_BUILD_FOR_ANDROID 1304 #ifdef SK_BUILD_FOR_ANDROID
1305 name.prepend("/sdcard/"); 1305 name.prepend("/sdcard/");
1306 #endif 1306 #endif
1307 fPDFDocument.reset(SkDocument::CreatePDF(name.c_str())); 1307 fPDFDocument.reset(SkDocument::CreatePDF(name.c_str()));
1308 canvas = fPDFDocument->beginPage(this->width(), this->height()); 1308 canvas = fPDFDocument->beginPage(this->width(), this->height());
1309 } else if (fSaveToSKP) { 1309 } else if (fSaveToSKP) {
1310 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0); 1310 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
1311 } else if (fUseMPD) { 1311 } else if (fUsePicture) {
1312 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0); 1312 canvas = fRecorder.beginRecording(9999, 9999, nullptr, 0);
1313 } else { 1313 } else {
1314 canvas = this->INHERITED::beforeChildren(canvas); 1314 canvas = this->INHERITED::beforeChildren(canvas);
1315 } 1315 }
1316 1316
1317 if (fUseClip) { 1317 if (fUseClip) {
1318 canvas->drawColor(0xFFFF88FF); 1318 canvas->drawColor(0xFFFF88FF);
1319 canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true); 1319 canvas->clipPath(fClipPath, SkRegion::kIntersect_Op, true);
1320 } 1320 }
1321 1321
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1363
1364 if (fSaveToSKP) { 1364 if (fSaveToSKP) {
1365 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording()); 1365 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
1366 SkFILEWStream stream("sample_app.skp"); 1366 SkFILEWStream stream("sample_app.skp");
1367 picture->serialize(&stream); 1367 picture->serialize(&stream);
1368 fSaveToSKP = false; 1368 fSaveToSKP = false;
1369 this->inval(nullptr); 1369 this->inval(nullptr);
1370 return; 1370 return;
1371 } 1371 }
1372 1372
1373 if (fUseMPD) { 1373 if (fUsePicture) {
1374 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording()); 1374 SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
1375 1375
1376 // serialize/deserialize?
1376 if (false) { 1377 if (false) {
1377 SkDynamicMemoryWStream wstream; 1378 SkDynamicMemoryWStream wstream;
1378 picture->serialize(&wstream); 1379 picture->serialize(&wstream);
1379 1380
1380 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1381 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1381 picture.reset(SkPicture::CreateFromStream(rstream)); 1382 picture.reset(SkPicture::CreateFromStream(rstream));
1382 } 1383 }
1383 1384 orig->drawPicture(picture);
1384 if (true) {
1385 if (true) {
1386 SkImageInfo info;
1387 size_t rowBytes;
1388 void* addr = orig->accessTopLayerPixels(&info, &rowBytes);
1389 if (addr) {
1390 SkSurface* surfs[4];
1391 SkMultiPictureDraw md;
1392
1393 SkImageInfo n = SkImageInfo::Make(info.width()/2, info.heigh t()/2,
1394 info.colorType(), info.alp haType());
1395 int index = 0;
1396 for (int y = 0; y < 2; ++y) {
1397 for (int x = 0; x < 2; ++x) {
1398 char* p = (char*)addr;
1399 p += y * n.height() * rowBytes;
1400 p += x * n.width() * sizeof(SkPMColor);
1401 surfs[index] = SkSurface::NewRasterDirect(n, p, rowB ytes);
1402 SkCanvas* c = surfs[index]->getCanvas();
1403 c->translate(SkIntToScalar(-x * n.width()),
1404 SkIntToScalar(-y * n.height()));
1405 c->concat(orig->getTotalMatrix());
1406 md.add(c, picture, nullptr, nullptr);
1407 index++;
1408 }
1409 }
1410 md.draw();
1411 for (int i = 0; i < 4; ++i) {
1412 surfs[i]->unref();
1413 }
1414 }
1415 } else {
1416 orig->drawPicture(picture);
1417 }
1418 } else if (true) {
1419 SkDynamicMemoryWStream ostream;
1420 picture->serialize(&ostream);
1421
1422 SkAutoDataUnref data(ostream.copyToData());
1423 SkMemoryStream istream(data->data(), data->size());
1424 SkAutoTUnref<SkPicture> pict(SkPicture::CreateFromStream(&istream));
1425 if (pict.get() != nullptr) {
1426 orig->drawPicture(pict.get());
1427 }
1428 } else {
1429 picture->playback(orig);
1430 }
1431 } 1385 }
1432 1386
1433 // Do this after presentGL and other finishing, rather than in afterChild 1387 // Do this after presentGL and other finishing, rather than in afterChild
1434 if (fMeasureFPS) { 1388 if (fMeasureFPS) {
1435 orig->flush(); 1389 orig->flush();
1436 fTimer.end(); 1390 fTimer.end();
1437 fMeasureFPS_Time += fTimer.fWall; 1391 fMeasureFPS_Time += fTimer.fWall;
1438 } 1392 }
1439 } 1393 }
1440 1394
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 case 'k': 1719 case 'k':
1766 fPerspAnim = !fPerspAnim; 1720 fPerspAnim = !fPerspAnim;
1767 this->inval(nullptr); 1721 this->inval(nullptr);
1768 this->updateTitle(); 1722 this->updateTitle();
1769 return true; 1723 return true;
1770 case 'K': 1724 case 'K':
1771 fSaveToSKP = true; 1725 fSaveToSKP = true;
1772 this->inval(nullptr); 1726 this->inval(nullptr);
1773 return true; 1727 return true;
1774 case 'M': 1728 case 'M':
1775 fUseMPD = !fUseMPD; 1729 fUsePicture = !fUsePicture;
1776 this->inval(nullptr); 1730 this->inval(nullptr);
1777 this->updateTitle(); 1731 this->updateTitle();
1778 return true; 1732 return true;
1779 #if SK_SUPPORT_GPU 1733 #if SK_SUPPORT_GPU
1780 case 'p': 1734 case 'p':
1781 { 1735 {
1782 GrContext* grContext = this->getGrContext(); 1736 GrContext* grContext = this->getGrContext();
1783 if (grContext) { 1737 if (grContext) {
1784 size_t cacheBytes; 1738 size_t cacheBytes;
1785 grContext->getResourceCacheUsage(nullptr, &cacheBytes); 1739 grContext->getResourceCacheUsage(nullptr, &cacheBytes);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 } 1990 }
2037 if (fRotate) { 1991 if (fRotate) {
2038 title.prepend("<R> "); 1992 title.prepend("<R> ");
2039 } 1993 }
2040 if (fPerspAnim) { 1994 if (fPerspAnim) {
2041 title.prepend("<K> "); 1995 title.prepend("<K> ");
2042 } 1996 }
2043 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDeviceIndependentF onts_Flag) { 1997 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDeviceIndependentF onts_Flag) {
2044 title.prepend("<DIF> "); 1998 title.prepend("<DIF> ");
2045 } 1999 }
2046 if (fUseMPD) { 2000 if (fUsePicture) {
2047 title.prepend("<MPD> "); 2001 title.prepend("<P> ");
2048 } 2002 }
2049 2003
2050 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); 2004 title.prepend(trystate_str(fLCDState, "LCD ", "lcd "));
2051 title.prepend(trystate_str(fAAState, "AA ", "aa ")); 2005 title.prepend(trystate_str(fAAState, "AA ", "aa "));
2052 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel); 2006 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel);
2053 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); 2007 title.prepend(trystate_str(fSubpixelState, "S ", "s "));
2054 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr); 2008 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr);
2055 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr); 2009 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr);
2056 title.prepend(gHintingStates[fHintingState].label); 2010 title.prepend(gHintingStates[fHintingState].label);
2057 2011
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 #ifdef SK_BUILD_FOR_MAC 2262 #ifdef SK_BUILD_FOR_MAC
2309 setenv("ANDROID_ROOT", "/android/device/data", 0); 2263 setenv("ANDROID_ROOT", "/android/device/data", 0);
2310 #endif 2264 #endif
2311 SkGraphics::Init(); 2265 SkGraphics::Init();
2312 SkEvent::Init(); 2266 SkEvent::Init();
2313 } 2267 }
2314 2268
2315 void application_term() { 2269 void application_term() {
2316 SkEvent::Term(); 2270 SkEvent::Term();
2317 } 2271 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698