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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 #endif | 797 #endif |
798 | 798 |
799 fUseClip = false; | 799 fUseClip = false; |
800 fUsePicture = false; | 800 fUsePicture = false; |
801 fAnimating = false; | 801 fAnimating = false; |
802 fRotate = false; | 802 fRotate = false; |
803 fPerspAnim = false; | 803 fPerspAnim = false; |
804 fRequestGrabImage = false; | 804 fRequestGrabImage = false; |
805 fTilingMode = kNo_Tiling; | 805 fTilingMode = kNo_Tiling; |
806 fMeasureFPS = false; | 806 fMeasureFPS = false; |
| 807 fUseDeferredCanvas = false; |
807 fLCDState = SkOSMenu::kMixedState; | 808 fLCDState = SkOSMenu::kMixedState; |
808 fAAState = SkOSMenu::kMixedState; | 809 fAAState = SkOSMenu::kMixedState; |
809 fSubpixelState = SkOSMenu::kMixedState; | 810 fSubpixelState = SkOSMenu::kMixedState; |
810 fHintingState = 0; | 811 fHintingState = 0; |
811 fPixelGeometryIndex = 0; | 812 fPixelGeometryIndex = 0; |
812 fFilterQualityIndex = 0; | 813 fFilterQualityIndex = 0; |
813 fFlipAxis = 0; | 814 fFlipAxis = 0; |
814 | 815 |
815 fMouseX = fMouseY = 0; | 816 fMouseX = fMouseY = 0; |
816 fFatBitsScale = 8; | 817 fFatBitsScale = 8; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 paint.setColor(SK_ColorBLACK); | 981 paint.setColor(SK_ColorBLACK); |
981 canvas->drawText(c_str, size, left + SK_Scalar1, top + SK_Scalar1, paint
); | 982 canvas->drawText(c_str, size, left + SK_Scalar1, top + SK_Scalar1, paint
); |
982 } | 983 } |
983 paint.setColor(desiredColor); | 984 paint.setColor(desiredColor); |
984 canvas->drawText(c_str, size, left, top, paint); | 985 canvas->drawText(c_str, size, left, top, paint); |
985 } | 986 } |
986 | 987 |
987 #define XCLIP_N 8 | 988 #define XCLIP_N 8 |
988 #define YCLIP_N 8 | 989 #define YCLIP_N 8 |
989 | 990 |
| 991 #include "SkDeferredCanvas.h" |
| 992 #include "SkDumpCanvas.h" |
| 993 |
990 void SampleWindow::draw(SkCanvas* canvas) { | 994 void SampleWindow::draw(SkCanvas* canvas) { |
991 gAnimTimer.updateTime(); | 995 gAnimTimer.updateTime(); |
992 | 996 |
993 if (fGesture.isActive()) { | 997 if (fGesture.isActive()) { |
994 this->updateMatrix(); | 998 this->updateMatrix(); |
995 } | 999 } |
996 | 1000 |
997 if (fMeasureFPS) { | 1001 if (fMeasureFPS) { |
998 fMeasureFPS_Time = 0; | 1002 fMeasureFPS_Time = 0; |
999 } | 1003 } |
1000 | 1004 |
1001 SkSize tile = this->tileSize(); | 1005 SkSize tile = this->tileSize(); |
1002 | 1006 |
1003 if (kNo_Tiling == fTilingMode) { | 1007 if (kNo_Tiling == fTilingMode) { |
1004 this->INHERITED::draw(canvas); // no looping or surfaces needed | 1008 SkDebugfDumper dumper; |
| 1009 SkDumpCanvas dump(&dumper); |
| 1010 SkDeferredCanvas deferred(canvas); |
| 1011 SkCanvas* c = fUseDeferredCanvas ? &deferred : canvas; |
| 1012 this->INHERITED::draw(c); // no looping or surfaces needed |
1005 } else { | 1013 } else { |
1006 const SkScalar w = SkScalarCeilToScalar(tile.width()); | 1014 const SkScalar w = SkScalarCeilToScalar(tile.width()); |
1007 const SkScalar h = SkScalarCeilToScalar(tile.height()); | 1015 const SkScalar h = SkScalarCeilToScalar(tile.height()); |
1008 SkImageInfo info = SkImageInfo::MakeN32Premul(SkScalarTruncToInt(w), SkS
calarTruncToInt(h)); | 1016 SkImageInfo info = SkImageInfo::MakeN32Premul(SkScalarTruncToInt(w), SkS
calarTruncToInt(h)); |
1009 auto surface(canvas->makeSurface(info)); | 1017 auto surface(canvas->makeSurface(info)); |
1010 SkCanvas* tileCanvas = surface->getCanvas(); | 1018 SkCanvas* tileCanvas = surface->getCanvas(); |
1011 | 1019 |
1012 for (SkScalar y = 0; y < height(); y += h) { | 1020 for (SkScalar y = 0; y < height(); y += h) { |
1013 for (SkScalar x = 0; x < width(); x += w) { | 1021 for (SkScalar x = 0; x < width(); x += w) { |
1014 SkAutoCanvasRestore acr(tileCanvas, true); | 1022 SkAutoCanvasRestore acr(tileCanvas, true); |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 case 'B': | 1668 case 'B': |
1661 post_event_to_sink(new SkEvent("PictFileView::toggleBBox"), curr_vie
w(this)); | 1669 post_event_to_sink(new SkEvent("PictFileView::toggleBBox"), curr_vie
w(this)); |
1662 // Cannot call updateTitle() synchronously, because the toggleBBox e
vent is still in | 1670 // Cannot call updateTitle() synchronously, because the toggleBBox e
vent is still in |
1663 // the queue. | 1671 // the queue. |
1664 post_event_to_sink(new SkEvent(gUpdateWindowTitleEvtName), this); | 1672 post_event_to_sink(new SkEvent(gUpdateWindowTitleEvtName), this); |
1665 this->inval(nullptr); | 1673 this->inval(nullptr); |
1666 break; | 1674 break; |
1667 case 'D': | 1675 case 'D': |
1668 toggleDistanceFieldFonts(); | 1676 toggleDistanceFieldFonts(); |
1669 break; | 1677 break; |
| 1678 case 'E': |
| 1679 fUseDeferredCanvas = !fUseDeferredCanvas; |
| 1680 this->inval(nullptr); |
| 1681 break; |
1670 case 'f': | 1682 case 'f': |
1671 // only | 1683 // only |
1672 toggleFPS(); | 1684 toggleFPS(); |
1673 break; | 1685 break; |
1674 case 'F': | 1686 case 'F': |
1675 FLAGS_portableFonts ^= true; | 1687 FLAGS_portableFonts ^= true; |
1676 this->inval(nullptr); | 1688 this->inval(nullptr); |
1677 break; | 1689 break; |
1678 case 'g': | 1690 case 'g': |
1679 fRequestGrabImage = true; | 1691 fRequestGrabImage = true; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 } | 2025 } |
2014 if (fPerspAnim) { | 2026 if (fPerspAnim) { |
2015 title.prepend("<K> "); | 2027 title.prepend("<K> "); |
2016 } | 2028 } |
2017 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDeviceIndependentF
onts_Flag) { | 2029 if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDeviceIndependentF
onts_Flag) { |
2018 title.prepend("<DIF> "); | 2030 title.prepend("<DIF> "); |
2019 } | 2031 } |
2020 if (fUsePicture) { | 2032 if (fUsePicture) { |
2021 title.prepend("<P> "); | 2033 title.prepend("<P> "); |
2022 } | 2034 } |
| 2035 if (fUseDeferredCanvas) { |
| 2036 title.prepend("<E> "); |
| 2037 } |
2023 | 2038 |
2024 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); | 2039 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); |
2025 title.prepend(trystate_str(fAAState, "AA ", "aa ")); | 2040 title.prepend(trystate_str(fAAState, "AA ", "aa ")); |
2026 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel); | 2041 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel); |
2027 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); | 2042 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); |
2028 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr); | 2043 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr); |
2029 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr); | 2044 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr); |
2030 title.prepend(gHintingStates[fHintingState].label); | 2045 title.prepend(gHintingStates[fHintingState].label); |
2031 title.prepend(gPixelGeometryStates[fPixelGeometryIndex].label); | 2046 title.prepend(gPixelGeometryStates[fPixelGeometryIndex].label); |
2032 | 2047 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2238 #ifdef SK_BUILD_FOR_MAC | 2253 #ifdef SK_BUILD_FOR_MAC |
2239 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2254 setenv("ANDROID_ROOT", "/android/device/data", 0); |
2240 #endif | 2255 #endif |
2241 SkGraphics::Init(); | 2256 SkGraphics::Init(); |
2242 SkEvent::Init(); | 2257 SkEvent::Init(); |
2243 } | 2258 } |
2244 | 2259 |
2245 void application_term() { | 2260 void application_term() { |
2246 SkEvent::Term(); | 2261 SkEvent::Term(); |
2247 } | 2262 } |
OLD | NEW |