OLD | NEW |
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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 { kNone_SkFilterQuality, "None", "F0 " }, | 458 { kNone_SkFilterQuality, "None", "F0 " }, |
459 { kLow_SkFilterQuality, "Low", "F1 " }, | 459 { kLow_SkFilterQuality, "Low", "F1 " }, |
460 { kMedium_SkFilterQuality, "Medium", "F2 " }, | 460 { kMedium_SkFilterQuality, "Medium", "F2 " }, |
461 { kHigh_SkFilterQuality, "High", "F3 " }, | 461 { kHigh_SkFilterQuality, "High", "F3 " }, |
462 }; | 462 }; |
463 | 463 |
464 class FlagsFilterCanvas : public SkPaintFilterCanvas { | 464 class FlagsFilterCanvas : public SkPaintFilterCanvas { |
465 public: | 465 public: |
466 FlagsFilterCanvas(SkCanvas* canvas, SkOSMenu::TriState lcd, SkOSMenu::TriSta
te aa, | 466 FlagsFilterCanvas(SkCanvas* canvas, SkOSMenu::TriState lcd, SkOSMenu::TriSta
te aa, |
467 SkOSMenu::TriState subpixel, int hinting, int filterQualit
y) | 467 SkOSMenu::TriState subpixel, int hinting, int filterQualit
y) |
468 : INHERITED(canvas->imageInfo().width(), canvas->imageInfo().height()) | 468 : INHERITED(canvas) |
469 , fLCDState(lcd) | 469 , fLCDState(lcd) |
470 , fAAState(aa) | 470 , fAAState(aa) |
471 , fSubpixelState(subpixel) | 471 , fSubpixelState(subpixel) |
472 , fHintingState(hinting) | 472 , fHintingState(hinting) |
473 , fFilterQualityIndex(filterQuality) { | 473 , fFilterQualityIndex(filterQuality) { |
474 SkASSERT((unsigned)filterQuality < SK_ARRAY_COUNT(gFilterQualityStates))
; | 474 SkASSERT((unsigned)filterQuality < SK_ARRAY_COUNT(gFilterQualityStates))
; |
475 | |
476 this->addCanvas(canvas); | |
477 } | 475 } |
478 | 476 |
479 protected: | 477 protected: |
480 void onFilterPaint(SkPaint* paint, Type t) const override { | 478 bool onFilter(SkPaint* paint, Type t) const override { |
481 if (kText_Type == t && SkOSMenu::kMixedState != fLCDState) { | 479 if (paint) { |
482 paint->setLCDRenderText(SkOSMenu::kOnState == fLCDState); | 480 if (kText_Type == t && SkOSMenu::kMixedState != fLCDState) { |
| 481 paint->setLCDRenderText(SkOSMenu::kOnState == fLCDState); |
| 482 } |
| 483 if (SkOSMenu::kMixedState != fAAState) { |
| 484 paint->setAntiAlias(SkOSMenu::kOnState == fAAState); |
| 485 } |
| 486 if (0 != fFilterQualityIndex) { |
| 487 paint->setFilterQuality(gFilterQualityStates[fFilterQualityIndex
].fQuality); |
| 488 } |
| 489 if (SkOSMenu::kMixedState != fSubpixelState) { |
| 490 paint->setSubpixelText(SkOSMenu::kOnState == fSubpixelState); |
| 491 } |
| 492 if (0 != fHintingState && fHintingState < (int)SK_ARRAY_COUNT(gHinti
ngStates)) { |
| 493 paint->setHinting(gHintingStates[fHintingState].hinting); |
| 494 } |
483 } | 495 } |
484 if (SkOSMenu::kMixedState != fAAState) { | 496 return true; |
485 paint->setAntiAlias(SkOSMenu::kOnState == fAAState); | |
486 } | |
487 if (0 != fFilterQualityIndex) { | |
488 paint->setFilterQuality(gFilterQualityStates[fFilterQualityIndex].fQ
uality); | |
489 } | |
490 if (SkOSMenu::kMixedState != fSubpixelState) { | |
491 paint->setSubpixelText(SkOSMenu::kOnState == fSubpixelState); | |
492 } | |
493 if (0 != fHintingState && fHintingState < (int)SK_ARRAY_COUNT(gHintingSt
ates)) { | |
494 paint->setHinting(gHintingStates[fHintingState].hinting); | |
495 } | |
496 } | 497 } |
497 | 498 |
498 private: | 499 private: |
499 SkOSMenu::TriState fLCDState; | 500 SkOSMenu::TriState fLCDState; |
500 SkOSMenu::TriState fAAState; | 501 SkOSMenu::TriState fAAState; |
501 SkOSMenu::TriState fSubpixelState; | 502 SkOSMenu::TriState fSubpixelState; |
502 int fHintingState; | 503 int fHintingState; |
503 int fFilterQualityIndex; | 504 int fFilterQualityIndex; |
504 | 505 |
505 typedef SkPaintFilterCanvas INHERITED; | 506 typedef SkPaintFilterCanvas INHERITED; |
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 #ifdef SK_BUILD_FOR_MAC | 2263 #ifdef SK_BUILD_FOR_MAC |
2263 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2264 setenv("ANDROID_ROOT", "/android/device/data", 0); |
2264 #endif | 2265 #endif |
2265 SkGraphics::Init(); | 2266 SkGraphics::Init(); |
2266 SkEvent::Init(); | 2267 SkEvent::Init(); |
2267 } | 2268 } |
2268 | 2269 |
2269 void application_term() { | 2270 void application_term() { |
2270 SkEvent::Term(); | 2271 SkEvent::Term(); |
2271 } | 2272 } |
OLD | NEW |