| 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(const SkPaint* paint, Type t, SkTLazy<SkPaint>* filteredPaint)
const override { |
| 479 if (!paint) { |
| 480 return true; |
| 481 } |
| 482 |
| 483 filteredPaint->set(*paint); |
| 481 if (kText_Type == t && SkOSMenu::kMixedState != fLCDState) { | 484 if (kText_Type == t && SkOSMenu::kMixedState != fLCDState) { |
| 482 paint->setLCDRenderText(SkOSMenu::kOnState == fLCDState); | 485 filteredPaint->get()->setLCDRenderText(SkOSMenu::kOnState == fLCDSta
te); |
| 483 } | 486 } |
| 484 if (SkOSMenu::kMixedState != fAAState) { | 487 if (SkOSMenu::kMixedState != fAAState) { |
| 485 paint->setAntiAlias(SkOSMenu::kOnState == fAAState); | 488 filteredPaint->get()->setAntiAlias(SkOSMenu::kOnState == fAAState); |
| 486 } | 489 } |
| 487 if (0 != fFilterQualityIndex) { | 490 if (0 != fFilterQualityIndex) { |
| 488 paint->setFilterQuality(gFilterQualityStates[fFilterQualityIndex].fQ
uality); | 491 filteredPaint->get()->setFilterQuality( |
| 492 gFilterQualityStates[fFilterQualityIndex].fQuality); |
| 489 } | 493 } |
| 490 if (SkOSMenu::kMixedState != fSubpixelState) { | 494 if (SkOSMenu::kMixedState != fSubpixelState) { |
| 491 paint->setSubpixelText(SkOSMenu::kOnState == fSubpixelState); | 495 filteredPaint->get()->setSubpixelText(SkOSMenu::kOnState == fSubpixe
lState); |
| 492 } | 496 } |
| 493 if (0 != fHintingState && fHintingState < (int)SK_ARRAY_COUNT(gHintingSt
ates)) { | 497 if (0 != fHintingState && fHintingState < (int)SK_ARRAY_COUNT(gHintingSt
ates)) { |
| 494 paint->setHinting(gHintingStates[fHintingState].hinting); | 498 filteredPaint->get()->setHinting(gHintingStates[fHintingState].hinti
ng); |
| 495 } | 499 } |
| 500 return true; |
| 496 } | 501 } |
| 497 | 502 |
| 498 private: | 503 private: |
| 499 SkOSMenu::TriState fLCDState; | 504 SkOSMenu::TriState fLCDState; |
| 500 SkOSMenu::TriState fAAState; | 505 SkOSMenu::TriState fAAState; |
| 501 SkOSMenu::TriState fSubpixelState; | 506 SkOSMenu::TriState fSubpixelState; |
| 502 int fHintingState; | 507 int fHintingState; |
| 503 int fFilterQualityIndex; | 508 int fFilterQualityIndex; |
| 504 | 509 |
| 505 typedef SkPaintFilterCanvas INHERITED; | 510 typedef SkPaintFilterCanvas INHERITED; |
| (...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 #ifdef SK_BUILD_FOR_MAC | 2267 #ifdef SK_BUILD_FOR_MAC |
| 2263 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2268 setenv("ANDROID_ROOT", "/android/device/data", 0); |
| 2264 #endif | 2269 #endif |
| 2265 SkGraphics::Init(); | 2270 SkGraphics::Init(); |
| 2266 SkEvent::Init(); | 2271 SkEvent::Init(); |
| 2267 } | 2272 } |
| 2268 | 2273 |
| 2269 void application_term() { | 2274 void application_term() { |
| 2270 SkEvent::Term(); | 2275 SkEvent::Term(); |
| 2271 } | 2276 } |
| OLD | NEW |