| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 fCurRenderTarget = NULL; | 268 fCurRenderTarget = NULL; |
| 269 #endif | 269 #endif |
| 270 win->detach(); | 270 win->detach(); |
| 271 fBackend = kNone_BackEndType; | 271 fBackend = kNone_BackEndType; |
| 272 } | 272 } |
| 273 | 273 |
| 274 virtual SkSurface* createSurface(SampleWindow::DeviceType dType, | 274 virtual SkSurface* createSurface(SampleWindow::DeviceType dType, |
| 275 SampleWindow* win) SK_OVERRIDE { | 275 SampleWindow* win) SK_OVERRIDE { |
| 276 #if SK_SUPPORT_GPU | 276 #if SK_SUPPORT_GPU |
| 277 if (IsGpuDeviceType(dType) && fCurContext) { | 277 if (IsGpuDeviceType(dType) && fCurContext) { |
| 278 return SkSurface::NewRenderTargetDirect(fCurRenderTarget); | 278 SkSurfaceProps props(win->getSurfaceProps()); |
| 279 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); |
| 279 } | 280 } |
| 280 #endif | 281 #endif |
| 281 return NULL; | 282 return NULL; |
| 282 } | 283 } |
| 283 | 284 |
| 284 virtual void publishCanvas(SampleWindow::DeviceType dType, | 285 virtual void publishCanvas(SampleWindow::DeviceType dType, |
| 285 SkCanvas* canvas, | 286 SkCanvas* canvas, |
| 286 SampleWindow* win) { | 287 SampleWindow* win) { |
| 287 #if SK_SUPPORT_GPU | 288 #if SK_SUPPORT_GPU |
| 288 if (fCurContext) { | 289 if (fCurContext) { |
| (...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 } | 1709 } |
| 1709 | 1710 |
| 1710 switch (uni) { | 1711 switch (uni) { |
| 1711 case 'B': | 1712 case 'B': |
| 1712 post_event_to_sink(SkNEW_ARGS(SkEvent, ("PictFileView::toggleBBox"))
, curr_view(this)); | 1713 post_event_to_sink(SkNEW_ARGS(SkEvent, ("PictFileView::toggleBBox"))
, curr_view(this)); |
| 1713 // Cannot call updateTitle() synchronously, because the toggleBBox e
vent is still in | 1714 // Cannot call updateTitle() synchronously, because the toggleBBox e
vent is still in |
| 1714 // the queue. | 1715 // the queue. |
| 1715 post_event_to_sink(SkNEW_ARGS(SkEvent, (gUpdateWindowTitleEvtName)),
this); | 1716 post_event_to_sink(SkNEW_ARGS(SkEvent, (gUpdateWindowTitleEvtName)),
this); |
| 1716 this->inval(NULL); | 1717 this->inval(NULL); |
| 1717 break; | 1718 break; |
| 1719 case 'D': |
| 1720 toggleDistanceFieldFonts(); |
| 1721 break; |
| 1718 case 'f': | 1722 case 'f': |
| 1719 // only | 1723 // only |
| 1720 toggleFPS(); | 1724 toggleFPS(); |
| 1721 break; | 1725 break; |
| 1722 case 'F': | 1726 case 'F': |
| 1723 FLAGS_portableFonts ^= true; | 1727 FLAGS_portableFonts ^= true; |
| 1724 this->inval(NULL); | 1728 this->inval(NULL); |
| 1725 break; | 1729 break; |
| 1726 case 'g': | 1730 case 'g': |
| 1727 fRequestGrabImage = true; | 1731 fRequestGrabImage = true; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 this->updateTitle(); | 1809 this->updateTitle(); |
| 1806 this->inval(NULL); | 1810 this->inval(NULL); |
| 1807 } | 1811 } |
| 1808 | 1812 |
| 1809 void SampleWindow::toggleFPS() { | 1813 void SampleWindow::toggleFPS() { |
| 1810 fMeasureFPS = !fMeasureFPS; | 1814 fMeasureFPS = !fMeasureFPS; |
| 1811 this->updateTitle(); | 1815 this->updateTitle(); |
| 1812 this->inval(NULL); | 1816 this->inval(NULL); |
| 1813 } | 1817 } |
| 1814 | 1818 |
| 1819 void SampleWindow::toggleDistanceFieldFonts() { |
| 1820 SkSurfaceProps props = this->getSurfaceProps(); |
| 1821 uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDistanceFieldFonts_Flag
; |
| 1822 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); |
| 1823 |
| 1824 this->updateTitle(); |
| 1825 this->inval(NULL); |
| 1826 } |
| 1827 |
| 1815 #include "SkDumpCanvas.h" | 1828 #include "SkDumpCanvas.h" |
| 1816 | 1829 |
| 1817 bool SampleWindow::onHandleKey(SkKey key) { | 1830 bool SampleWindow::onHandleKey(SkKey key) { |
| 1818 { | 1831 { |
| 1819 SkView* view = curr_view(this); | 1832 SkView* view = curr_view(this); |
| 1820 if (view) { | 1833 if (view) { |
| 1821 SkEvent evt(gKeyEvtName); | 1834 SkEvent evt(gKeyEvtName); |
| 1822 evt.setFast32(key); | 1835 evt.setFast32(key); |
| 1823 if (view->doQuery(&evt)) { | 1836 if (view->doQuery(&evt)) { |
| 1824 return true; | 1837 return true; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 } | 2029 } |
| 2017 if (fRotate) { | 2030 if (fRotate) { |
| 2018 title.prepend("<R> "); | 2031 title.prepend("<R> "); |
| 2019 } | 2032 } |
| 2020 if (fNClip) { | 2033 if (fNClip) { |
| 2021 title.prepend("<C> "); | 2034 title.prepend("<C> "); |
| 2022 } | 2035 } |
| 2023 if (fPerspAnim) { | 2036 if (fPerspAnim) { |
| 2024 title.prepend("<K> "); | 2037 title.prepend("<K> "); |
| 2025 } | 2038 } |
| 2039 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDistanceFieldFonts
_Flag) { |
| 2040 title.prepend("<DFF> "); |
| 2041 } |
| 2026 | 2042 |
| 2027 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); | 2043 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); |
| 2028 title.prepend(trystate_str(fAAState, "AA ", "aa ")); | 2044 title.prepend(trystate_str(fAAState, "AA ", "aa ")); |
| 2029 title.prepend(gFilterLevelStates[fFilterLevelIndex].fLabel); | 2045 title.prepend(gFilterLevelStates[fFilterLevelIndex].fLabel); |
| 2030 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); | 2046 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); |
| 2031 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : NULL); | 2047 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : NULL); |
| 2032 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : NULL); | 2048 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : NULL); |
| 2033 title.prepend(gHintingStates[fHintingState].label); | 2049 title.prepend(gHintingStates[fHintingState].label); |
| 2034 | 2050 |
| 2035 if (fZoomLevel) { | 2051 if (fZoomLevel) { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2399 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2415 setenv("ANDROID_ROOT", "/android/device/data", 0); |
| 2400 #endif | 2416 #endif |
| 2401 SkGraphics::Init(); | 2417 SkGraphics::Init(); |
| 2402 SkEvent::Init(); | 2418 SkEvent::Init(); |
| 2403 } | 2419 } |
| 2404 | 2420 |
| 2405 void application_term() { | 2421 void application_term() { |
| 2406 SkEvent::Term(); | 2422 SkEvent::Term(); |
| 2407 SkGraphics::Term(); | 2423 SkGraphics::Term(); |
| 2408 } | 2424 } |
| OLD | NEW |