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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1014533004: SkPaint::FilterLevel -> SkFilterQuality (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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/SampleApp.h ('k') | samplecode/SampleBitmapRect.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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 const char* label; 444 const char* label;
445 }; 445 };
446 static HintingState gHintingStates[] = { 446 static HintingState gHintingStates[] = {
447 {SkPaint::kNo_Hinting, "Mixed", NULL }, 447 {SkPaint::kNo_Hinting, "Mixed", NULL },
448 {SkPaint::kNo_Hinting, "None", "H0 " }, 448 {SkPaint::kNo_Hinting, "None", "H0 " },
449 {SkPaint::kSlight_Hinting, "Slight", "Hs " }, 449 {SkPaint::kSlight_Hinting, "Slight", "Hs " },
450 {SkPaint::kNormal_Hinting, "Normal", "Hn " }, 450 {SkPaint::kNormal_Hinting, "Normal", "Hn " },
451 {SkPaint::kFull_Hinting, "Full", "Hf " }, 451 {SkPaint::kFull_Hinting, "Full", "Hf " },
452 }; 452 };
453 453
454 struct FilterLevelState { 454 struct FilterQualityState {
455 SkPaint::FilterLevel fLevel; 455 SkFilterQuality fQuality;
456 const char* fName; 456 const char* fName;
457 const char* fLabel; 457 const char* fLabel;
458 }; 458 };
459 static FilterLevelState gFilterLevelStates[] = { 459 static FilterQualityState gFilterQualityStates[] = {
460 { SkPaint::kNone_FilterLevel, "Mixed", NULL }, 460 { kNone_SkFilterQuality, "Mixed", NULL },
461 { SkPaint::kNone_FilterLevel, "None", "F0 " }, 461 { kNone_SkFilterQuality, "None", "F0 " },
462 { SkPaint::kLow_FilterLevel, "Low", "F1 " }, 462 { kLow_SkFilterQuality, "Low", "F1 " },
463 { SkPaint::kMedium_FilterLevel, "Medium", "F2 " }, 463 { kMedium_SkFilterQuality, "Medium", "F2 " },
464 { SkPaint::kHigh_FilterLevel, "High", "F3 " }, 464 { kHigh_SkFilterQuality, "High", "F3 " },
465 }; 465 };
466 466
467 class FlagsDrawFilter : public SkDrawFilter { 467 class FlagsDrawFilter : public SkDrawFilter {
468 public: 468 public:
469 FlagsDrawFilter(SkOSMenu::TriState lcd, SkOSMenu::TriState aa, 469 FlagsDrawFilter(SkOSMenu::TriState lcd, SkOSMenu::TriState aa,
470 SkOSMenu::TriState subpixel, int hinting, int filterlevel) 470 SkOSMenu::TriState subpixel, int hinting, int filterQuality)
471 : fLCDState(lcd) 471 : fLCDState(lcd)
472 , fAAState(aa) 472 , fAAState(aa)
473 , fSubpixelState(subpixel) 473 , fSubpixelState(subpixel)
474 , fHintingState(hinting) 474 , fHintingState(hinting)
475 , fFilterLevelIndex(filterlevel) 475 , fFilterQualityIndex(filterQuality)
476 { 476 {
477 SkASSERT((unsigned)filterlevel < SK_ARRAY_COUNT(gFilterLevelStates)); 477 SkASSERT((unsigned)filterQuality < SK_ARRAY_COUNT(gFilterQualityStates)) ;
478 } 478 }
479 479
480 virtual bool filter(SkPaint* paint, Type t) { 480 virtual bool filter(SkPaint* paint, Type t) {
481 if (kText_Type == t && SkOSMenu::kMixedState != fLCDState) { 481 if (kText_Type == t && SkOSMenu::kMixedState != fLCDState) {
482 paint->setLCDRenderText(SkOSMenu::kOnState == fLCDState); 482 paint->setLCDRenderText(SkOSMenu::kOnState == fLCDState);
483 } 483 }
484 if (SkOSMenu::kMixedState != fAAState) { 484 if (SkOSMenu::kMixedState != fAAState) {
485 paint->setAntiAlias(SkOSMenu::kOnState == fAAState); 485 paint->setAntiAlias(SkOSMenu::kOnState == fAAState);
486 } 486 }
487 if (0 != fFilterLevelIndex) { 487 if (0 != fFilterQualityIndex) {
488 paint->setFilterLevel(gFilterLevelStates[fFilterLevelIndex].fLevel); 488 paint->setFilterQuality(gFilterQualityStates[fFilterQualityIndex].fQ uality);
489 } 489 }
490 if (SkOSMenu::kMixedState != fSubpixelState) { 490 if (SkOSMenu::kMixedState != fSubpixelState) {
491 paint->setSubpixelText(SkOSMenu::kOnState == fSubpixelState); 491 paint->setSubpixelText(SkOSMenu::kOnState == fSubpixelState);
492 } 492 }
493 if (0 != fHintingState && fHintingState < (int)SK_ARRAY_COUNT(gHintingSt ates)) { 493 if (0 != fHintingState && fHintingState < (int)SK_ARRAY_COUNT(gHintingSt ates)) {
494 paint->setHinting(gHintingStates[fHintingState].hinting); 494 paint->setHinting(gHintingStates[fHintingState].hinting);
495 } 495 }
496 return true; 496 return true;
497 } 497 }
498 498
499 private: 499 private:
500 SkOSMenu::TriState fLCDState; 500 SkOSMenu::TriState fLCDState;
501 SkOSMenu::TriState fAAState; 501 SkOSMenu::TriState fAAState;
502 SkOSMenu::TriState fSubpixelState; 502 SkOSMenu::TriState fSubpixelState;
503 int fHintingState; 503 int fHintingState;
504 int fFilterLevelIndex; 504 int fFilterQualityIndex;
505 }; 505 };
506 506
507 ////////////////////////////////////////////////////////////////////////////// 507 //////////////////////////////////////////////////////////////////////////////
508 508
509 #define MAX_ZOOM_LEVEL 8 509 #define MAX_ZOOM_LEVEL 8
510 #define MIN_ZOOM_LEVEL -8 510 #define MIN_ZOOM_LEVEL -8
511 511
512 static const char gCharEvtName[] = "SampleCode_Char_Event"; 512 static const char gCharEvtName[] = "SampleCode_Char_Event";
513 static const char gKeyEvtName[] = "SampleCode_Key_Event"; 513 static const char gKeyEvtName[] = "SampleCode_Key_Event";
514 static const char gTitleEvtName[] = "SampleCode_Title_Event"; 514 static const char gTitleEvtName[] = "SampleCode_Title_Event";
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 fRotate = false; 797 fRotate = false;
798 fPerspAnim = false; 798 fPerspAnim = false;
799 fRequestGrabImage = false; 799 fRequestGrabImage = false;
800 fPipeState = SkOSMenu::kOffState; 800 fPipeState = SkOSMenu::kOffState;
801 fTilingMode = kNo_Tiling; 801 fTilingMode = kNo_Tiling;
802 fMeasureFPS = false; 802 fMeasureFPS = false;
803 fLCDState = SkOSMenu::kMixedState; 803 fLCDState = SkOSMenu::kMixedState;
804 fAAState = SkOSMenu::kMixedState; 804 fAAState = SkOSMenu::kMixedState;
805 fSubpixelState = SkOSMenu::kMixedState; 805 fSubpixelState = SkOSMenu::kMixedState;
806 fHintingState = 0; 806 fHintingState = 0;
807 fFilterLevelIndex = 0; 807 fFilterQualityIndex = 0;
808 fFlipAxis = 0; 808 fFlipAxis = 0;
809 fScrollTestX = fScrollTestY = 0; 809 fScrollTestX = fScrollTestY = 0;
810 810
811 fMouseX = fMouseY = 0; 811 fMouseX = fMouseY = 0;
812 fFatBitsScale = 8; 812 fFatBitsScale = 8;
813 fTypeface = SkTypeface::CreateFromTypeface(NULL, SkTypeface::kBold); 813 fTypeface = SkTypeface::CreateFromTypeface(NULL, SkTypeface::kBold);
814 fShowZoomer = false; 814 fShowZoomer = false;
815 815
816 fZoomLevel = 0; 816 fZoomLevel = 0;
817 fZoomScale = SK_Scalar1; 817 fZoomScale = SK_Scalar1;
(...skipping 14 matching lines...) Expand all
832 "Raster", "Picture", "OpenGL", 832 "Raster", "Picture", "OpenGL",
833 #if SK_ANGLE 833 #if SK_ANGLE
834 "ANGLE", 834 "ANGLE",
835 #endif 835 #endif
836 NULL); 836 NULL);
837 fAppMenu->assignKeyEquivalentToItem(itemID, 'd'); 837 fAppMenu->assignKeyEquivalentToItem(itemID, 'd');
838 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState); 838 itemID = fAppMenu->appendTriState("AA", "AA", sinkID, fAAState);
839 fAppMenu->assignKeyEquivalentToItem(itemID, 'b'); 839 fAppMenu->assignKeyEquivalentToItem(itemID, 'b');
840 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState); 840 itemID = fAppMenu->appendTriState("LCD", "LCD", sinkID, fLCDState);
841 fAppMenu->assignKeyEquivalentToItem(itemID, 'l'); 841 fAppMenu->assignKeyEquivalentToItem(itemID, 'l');
842 itemID = fAppMenu->appendList("FilterLevel", "FilterLevel", sinkID, fFilterL evelIndex, 842 itemID = fAppMenu->appendList("FilterQuality", "FilterQuality", sinkID, fFil terQualityIndex,
843 gFilterLevelStates[0].fName, 843 gFilterQualityStates[0].fName,
844 gFilterLevelStates[1].fName, 844 gFilterQualityStates[1].fName,
845 gFilterLevelStates[2].fName, 845 gFilterQualityStates[2].fName,
846 gFilterLevelStates[3].fName, 846 gFilterQualityStates[3].fName,
847 gFilterLevelStates[4].fName, 847 gFilterQualityStates[4].fName,
848 NULL); 848 NULL);
849 fAppMenu->assignKeyEquivalentToItem(itemID, 'n'); 849 fAppMenu->assignKeyEquivalentToItem(itemID, 'n');
850 itemID = fAppMenu->appendTriState("Subpixel", "Subpixel", sinkID, fSubpixelS tate); 850 itemID = fAppMenu->appendTriState("Subpixel", "Subpixel", sinkID, fSubpixelS tate);
851 fAppMenu->assignKeyEquivalentToItem(itemID, 's'); 851 fAppMenu->assignKeyEquivalentToItem(itemID, 's');
852 itemID = fAppMenu->appendList("Hinting", "Hinting", sinkID, fHintingState, 852 itemID = fAppMenu->appendList("Hinting", "Hinting", sinkID, fHintingState,
853 gHintingStates[0].name, 853 gHintingStates[0].name,
854 gHintingStates[1].name, 854 gHintingStates[1].name,
855 gHintingStates[2].name, 855 gHintingStates[2].name,
856 gHintingStates[3].name, 856 gHintingStates[3].name,
857 gHintingStates[4].name, 857 gHintingStates[4].name,
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 int SampleWindow::sampleCount() { 1416 int SampleWindow::sampleCount() {
1417 return fSamples.count(); 1417 return fSamples.count();
1418 } 1418 }
1419 1419
1420 void SampleWindow::showOverview() { 1420 void SampleWindow::showOverview() {
1421 this->loadView(create_overview(fSamples.count(), fSamples.begin())); 1421 this->loadView(create_overview(fSamples.count(), fSamples.begin()));
1422 } 1422 }
1423 1423
1424 void SampleWindow::installDrawFilter(SkCanvas* canvas) { 1424 void SampleWindow::installDrawFilter(SkCanvas* canvas) {
1425 canvas->setDrawFilter(new FlagsDrawFilter(fLCDState, fAAState, fSubpixelStat e, 1425 canvas->setDrawFilter(new FlagsDrawFilter(fLCDState, fAAState, fSubpixelStat e,
1426 fHintingState, fFilterLevelIndex)) ->unref(); 1426 fHintingState, fFilterQualityIndex ))->unref();
1427 } 1427 }
1428 1428
1429 void SampleWindow::postAnimatingEvent() { 1429 void SampleWindow::postAnimatingEvent() {
1430 if (fAnimating) { 1430 if (fAnimating) {
1431 (new SkEvent(ANIMATING_EVENTTYPE, this->getSinkID()))->postDelay(ANIMATI NG_DELAY); 1431 (new SkEvent(ANIMATING_EVENTTYPE, this->getSinkID()))->postDelay(ANIMATI NG_DELAY);
1432 } 1432 }
1433 } 1433 }
1434 1434
1435 bool SampleWindow::onEvent(const SkEvent& evt) { 1435 bool SampleWindow::onEvent(const SkEvent& evt) {
1436 if (evt.isType(gUpdateWindowTitleEvtName)) { 1436 if (evt.isType(gUpdateWindowTitleEvtName)) {
(...skipping 29 matching lines...) Expand all
1466 this->updateTitle(); 1466 this->updateTitle();
1467 this->inval(NULL); 1467 this->inval(NULL);
1468 return true; 1468 return true;
1469 } 1469 }
1470 if (SkOSMenu::FindSwitchState(evt, "Slide Show", NULL)) { 1470 if (SkOSMenu::FindSwitchState(evt, "Slide Show", NULL)) {
1471 this->toggleSlideshow(); 1471 this->toggleSlideshow();
1472 return true; 1472 return true;
1473 } 1473 }
1474 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) || 1474 if (SkOSMenu::FindTriState(evt, "AA", &fAAState) ||
1475 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) || 1475 SkOSMenu::FindTriState(evt, "LCD", &fLCDState) ||
1476 SkOSMenu::FindListIndex(evt, "FilterLevel", &fFilterLevelIndex) || 1476 SkOSMenu::FindListIndex(evt, "FilterQuality", &fFilterQualityIndex) ||
1477 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) || 1477 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) ||
1478 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) || 1478 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) ||
1479 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) || 1479 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) ||
1480 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) || 1480 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) ||
1481 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify) || 1481 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify) ||
1482 SkOSMenu::FindListIndex(evt, "Transition-Next", &fTransitionNext) || 1482 SkOSMenu::FindListIndex(evt, "Transition-Next", &fTransitionNext) ||
1483 SkOSMenu::FindListIndex(evt, "Transition-Prev", &fTransitionPrev)) { 1483 SkOSMenu::FindListIndex(evt, "Transition-Prev", &fTransitionPrev)) {
1484 this->inval(NULL); 1484 this->inval(NULL);
1485 this->updateTitle(); 1485 this->updateTitle();
1486 return true; 1486 return true;
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 } 1898 }
1899 if (fPerspAnim) { 1899 if (fPerspAnim) {
1900 title.prepend("<K> "); 1900 title.prepend("<K> ");
1901 } 1901 }
1902 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDistanceFieldFonts _Flag) { 1902 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDistanceFieldFonts _Flag) {
1903 title.prepend("<DFF> "); 1903 title.prepend("<DFF> ");
1904 } 1904 }
1905 1905
1906 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); 1906 title.prepend(trystate_str(fLCDState, "LCD ", "lcd "));
1907 title.prepend(trystate_str(fAAState, "AA ", "aa ")); 1907 title.prepend(trystate_str(fAAState, "AA ", "aa "));
1908 title.prepend(gFilterLevelStates[fFilterLevelIndex].fLabel); 1908 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel);
1909 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); 1909 title.prepend(trystate_str(fSubpixelState, "S ", "s "));
1910 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : NULL); 1910 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : NULL);
1911 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : NULL); 1911 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : NULL);
1912 title.prepend(gHintingStates[fHintingState].label); 1912 title.prepend(gHintingStates[fHintingState].label);
1913 1913
1914 if (fZoomLevel) { 1914 if (fZoomLevel) {
1915 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel)); 1915 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel));
1916 } 1916 }
1917 1917
1918 if (fMeasureFPS) { 1918 if (fMeasureFPS) {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 setenv("ANDROID_ROOT", "/android/device/data", 0); 2285 setenv("ANDROID_ROOT", "/android/device/data", 0);
2286 #endif 2286 #endif
2287 SkGraphics::Init(); 2287 SkGraphics::Init();
2288 SkEvent::Init(); 2288 SkEvent::Init();
2289 } 2289 }
2290 2290
2291 void application_term() { 2291 void application_term() {
2292 SkEvent::Term(); 2292 SkEvent::Term();
2293 SkGraphics::Term(); 2293 SkGraphics::Term();
2294 } 2294 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.h ('k') | samplecode/SampleBitmapRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698