Chromium Code Reviews| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 const char* label; | 461 const char* label; |
| 462 }; | 462 }; |
| 463 static HintingState gHintingStates[] = { | 463 static HintingState gHintingStates[] = { |
| 464 {SkPaint::kNo_Hinting, "Mixed", nullptr }, | 464 {SkPaint::kNo_Hinting, "Mixed", nullptr }, |
| 465 {SkPaint::kNo_Hinting, "None", "H0 " }, | 465 {SkPaint::kNo_Hinting, "None", "H0 " }, |
| 466 {SkPaint::kSlight_Hinting, "Slight", "Hs " }, | 466 {SkPaint::kSlight_Hinting, "Slight", "Hs " }, |
| 467 {SkPaint::kNormal_Hinting, "Normal", "Hn " }, | 467 {SkPaint::kNormal_Hinting, "Normal", "Hn " }, |
| 468 {SkPaint::kFull_Hinting, "Full", "Hf " }, | 468 {SkPaint::kFull_Hinting, "Full", "Hf " }, |
| 469 }; | 469 }; |
| 470 | 470 |
| 471 struct PixelGeometryState { | |
| 472 SkPixelGeometry pixelGeometry; | |
| 473 const char* name; | |
| 474 const char* label; | |
| 475 }; | |
| 476 static PixelGeometryState gPixelGeometryStates[] = { | |
| 477 {SkPixelGeometry::kUnknown_SkPixelGeometry, "Mixed", nullptr }, | |
| 478 {SkPixelGeometry::kUnknown_SkPixelGeometry, "Flat", "{Flat} " }, | |
|
reed1
2016/03/31 11:04:13
I presume Flat means ... unknown?
bungeman-skia
2016/03/31 14:15:27
Right here I'm not stating that the created surfac
| |
| 479 {SkPixelGeometry::kRGB_H_SkPixelGeometry, "RGB H", "{RGB H} " }, | |
| 480 {SkPixelGeometry::kBGR_H_SkPixelGeometry, "BGR H", "{BGR H} " }, | |
| 481 {SkPixelGeometry::kRGB_V_SkPixelGeometry, "RGB_V", "{RGB V} " }, | |
| 482 {SkPixelGeometry::kBGR_V_SkPixelGeometry, "BGR_V", "{BGR V} " }, | |
| 483 }; | |
| 484 | |
| 471 struct FilterQualityState { | 485 struct FilterQualityState { |
| 472 SkFilterQuality fQuality; | 486 SkFilterQuality fQuality; |
| 473 const char* fName; | 487 const char* fName; |
| 474 const char* fLabel; | 488 const char* fLabel; |
| 475 }; | 489 }; |
| 476 static FilterQualityState gFilterQualityStates[] = { | 490 static FilterQualityState gFilterQualityStates[] = { |
| 477 { kNone_SkFilterQuality, "Mixed", nullptr }, | 491 { kNone_SkFilterQuality, "Mixed", nullptr }, |
| 478 { kNone_SkFilterQuality, "None", "F0 " }, | 492 { kNone_SkFilterQuality, "None", "F0 " }, |
| 479 { kLow_SkFilterQuality, "Low", "F1 " }, | 493 { kLow_SkFilterQuality, "Low", "F1 " }, |
| 480 { kMedium_SkFilterQuality, "Medium", "F2 " }, | 494 { kMedium_SkFilterQuality, "Medium", "F2 " }, |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 | 859 |
| 846 static SkTaskGroup::Enabler enabled(-1); | 860 static SkTaskGroup::Enabler enabled(-1); |
| 847 gSampleWindow = this; | 861 gSampleWindow = this; |
| 848 | 862 |
| 849 fDeviceType = kRaster_DeviceType; | 863 fDeviceType = kRaster_DeviceType; |
| 850 #if SK_SUPPORT_GPU | 864 #if SK_SUPPORT_GPU |
| 851 if (FLAGS_gpu) { | 865 if (FLAGS_gpu) { |
| 852 fDeviceType = kGPU_DeviceType; | 866 fDeviceType = kGPU_DeviceType; |
| 853 } | 867 } |
| 854 #endif | 868 #endif |
| 855 | 869 |
| 856 #if DEFAULT_TO_GPU | 870 #if DEFAULT_TO_GPU |
| 857 fDeviceType = kGPU_DeviceType; | 871 fDeviceType = kGPU_DeviceType; |
| 858 #endif | 872 #endif |
| 859 #if SK_ANGLE && DEFAULT_TO_ANGLE | 873 #if SK_ANGLE && DEFAULT_TO_ANGLE |
| 860 fDeviceType = kANGLE_DeviceType; | 874 fDeviceType = kANGLE_DeviceType; |
| 861 #endif | 875 #endif |
| 862 #if SK_COMMAND_BUFFER && DEFAULT_TO_COMMAND_BUFFER | 876 #if SK_COMMAND_BUFFER && DEFAULT_TO_COMMAND_BUFFER |
| 863 fDeviceType = kCommandBuffer_DeviceType; | 877 fDeviceType = kCommandBuffer_DeviceType; |
| 864 #endif | 878 #endif |
| 865 | 879 |
| 866 fUseClip = false; | 880 fUseClip = false; |
| 867 fUsePicture = false; | 881 fUsePicture = false; |
| 868 fAnimating = false; | 882 fAnimating = false; |
| 869 fRotate = false; | 883 fRotate = false; |
| 870 fPerspAnim = false; | 884 fPerspAnim = false; |
| 871 fRequestGrabImage = false; | 885 fRequestGrabImage = false; |
| 872 fTilingMode = kNo_Tiling; | 886 fTilingMode = kNo_Tiling; |
| 873 fMeasureFPS = false; | 887 fMeasureFPS = false; |
| 874 fLCDState = SkOSMenu::kMixedState; | 888 fLCDState = SkOSMenu::kMixedState; |
| 875 fAAState = SkOSMenu::kMixedState; | 889 fAAState = SkOSMenu::kMixedState; |
| 876 fSubpixelState = SkOSMenu::kMixedState; | 890 fSubpixelState = SkOSMenu::kMixedState; |
| 877 fHintingState = 0; | 891 fHintingState = 0; |
| 892 fPixelGeometryIndex = 0; | |
| 878 fFilterQualityIndex = 0; | 893 fFilterQualityIndex = 0; |
| 879 fFlipAxis = 0; | 894 fFlipAxis = 0; |
| 880 | 895 |
| 881 fMouseX = fMouseY = 0; | 896 fMouseX = fMouseY = 0; |
| 882 fFatBitsScale = 8; | 897 fFatBitsScale = 8; |
| 883 fTypeface = SkTypeface::CreateFromTypeface(nullptr, SkTypeface::kBold); | 898 fTypeface = SkTypeface::CreateFromTypeface(nullptr, SkTypeface::kBold); |
| 884 fShowZoomer = false; | 899 fShowZoomer = false; |
| 885 | 900 |
| 886 fZoomLevel = 0; | 901 fZoomLevel = 0; |
| 887 fZoomScale = SK_Scalar1; | 902 fZoomScale = SK_Scalar1; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 928 fAppMenu->assignKeyEquivalentToItem(itemID, 's'); | 943 fAppMenu->assignKeyEquivalentToItem(itemID, 's'); |
| 929 itemID = fAppMenu->appendList("Hinting", "Hinting", sinkID, fHintingState, | 944 itemID = fAppMenu->appendList("Hinting", "Hinting", sinkID, fHintingState, |
| 930 gHintingStates[0].name, | 945 gHintingStates[0].name, |
| 931 gHintingStates[1].name, | 946 gHintingStates[1].name, |
| 932 gHintingStates[2].name, | 947 gHintingStates[2].name, |
| 933 gHintingStates[3].name, | 948 gHintingStates[3].name, |
| 934 gHintingStates[4].name, | 949 gHintingStates[4].name, |
| 935 nullptr); | 950 nullptr); |
| 936 fAppMenu->assignKeyEquivalentToItem(itemID, 'h'); | 951 fAppMenu->assignKeyEquivalentToItem(itemID, 'h'); |
| 937 | 952 |
| 953 itemID = fAppMenu->appendList("Pixel Geometry", "Pixel Geometry", sinkID, fP ixelGeometryIndex, | |
| 954 gPixelGeometryStates[0].name, | |
| 955 gPixelGeometryStates[1].name, | |
| 956 gPixelGeometryStates[2].name, | |
| 957 gPixelGeometryStates[3].name, | |
| 958 gPixelGeometryStates[4].name, | |
| 959 gPixelGeometryStates[5].name, | |
| 960 nullptr); | |
| 961 fAppMenu->assignKeyEquivalentToItem(itemID, 'P'); | |
| 962 | |
| 938 itemID =fAppMenu->appendList("Tiling", "Tiling", sinkID, fTilingMode, | 963 itemID =fAppMenu->appendList("Tiling", "Tiling", sinkID, fTilingMode, |
| 939 gTilingInfo[kNo_Tiling].label, | 964 gTilingInfo[kNo_Tiling].label, |
| 940 gTilingInfo[kAbs_128x128_Tiling].label, | 965 gTilingInfo[kAbs_128x128_Tiling].label, |
| 941 gTilingInfo[kAbs_256x256_Tiling].label, | 966 gTilingInfo[kAbs_256x256_Tiling].label, |
| 942 gTilingInfo[kRel_4x4_Tiling].label, | 967 gTilingInfo[kRel_4x4_Tiling].label, |
| 943 gTilingInfo[kRel_1x16_Tiling].label, | 968 gTilingInfo[kRel_1x16_Tiling].label, |
| 944 gTilingInfo[kRel_16x1_Tiling].label, | 969 gTilingInfo[kRel_16x1_Tiling].label, |
| 945 nullptr); | 970 nullptr); |
| 946 fAppMenu->assignKeyEquivalentToItem(itemID, 't'); | 971 fAppMenu->assignKeyEquivalentToItem(itemID, 't'); |
| 947 | 972 |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1604 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) || | 1629 SkOSMenu::FindTriState(evt, "Subpixel", &fSubpixelState) || |
| 1605 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) || | 1630 SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) || |
| 1606 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) || | 1631 SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) || |
| 1607 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) || | 1632 SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) || |
| 1608 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify)) | 1633 SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify)) |
| 1609 { | 1634 { |
| 1610 this->inval(nullptr); | 1635 this->inval(nullptr); |
| 1611 this->updateTitle(); | 1636 this->updateTitle(); |
| 1612 return true; | 1637 return true; |
| 1613 } | 1638 } |
| 1639 if (SkOSMenu::FindListIndex(evt, "Pixel Geometry", &fPixelGeometryIndex)) { | |
| 1640 this->setPixelGeometry(fPixelGeometryIndex); | |
| 1641 return true; | |
| 1642 } | |
| 1614 if (SkOSMenu::FindListIndex(evt, "Tiling", &fTilingMode)) { | 1643 if (SkOSMenu::FindListIndex(evt, "Tiling", &fTilingMode)) { |
| 1615 if (SampleView::IsSampleView(curr_view(this))) { | 1644 if (SampleView::IsSampleView(curr_view(this))) { |
| 1616 ((SampleView*)curr_view(this))->onTileSizeChanged(this->tileSize()); | 1645 ((SampleView*)curr_view(this))->onTileSizeChanged(this->tileSize()); |
| 1617 } | 1646 } |
| 1618 this->inval(nullptr); | 1647 this->inval(nullptr); |
| 1619 this->updateTitle(); | 1648 this->updateTitle(); |
| 1620 return true; | 1649 return true; |
| 1621 } | 1650 } |
| 1622 if (SkOSMenu::FindSwitchState(evt, "Flip X", nullptr)) { | 1651 if (SkOSMenu::FindSwitchState(evt, "Flip X", nullptr)) { |
| 1623 fFlipAxis ^= kFlipAxis_X; | 1652 fFlipAxis ^= kFlipAxis_X; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1785 this->onUpdateMenu(fAppMenu); | 1814 this->onUpdateMenu(fAppMenu); |
| 1786 this->onUpdateMenu(fSlideMenu); | 1815 this->onUpdateMenu(fSlideMenu); |
| 1787 return true; | 1816 return true; |
| 1788 } | 1817 } |
| 1789 return this->INHERITED::onHandleChar(uni); | 1818 return this->INHERITED::onHandleChar(uni); |
| 1790 } | 1819 } |
| 1791 | 1820 |
| 1792 void SampleWindow::setDeviceType(DeviceType type) { | 1821 void SampleWindow::setDeviceType(DeviceType type) { |
| 1793 if (type == fDeviceType) | 1822 if (type == fDeviceType) |
| 1794 return; | 1823 return; |
| 1795 | 1824 |
| 1796 fDevManager->tearDownBackend(this); | 1825 fDevManager->tearDownBackend(this); |
| 1797 | |
| 1798 fDeviceType = type; | 1826 fDeviceType = type; |
| 1799 | |
| 1800 fDevManager->setUpBackend(this, fMSAASampleCount); | 1827 fDevManager->setUpBackend(this, fMSAASampleCount); |
| 1801 | 1828 |
| 1802 this->updateTitle(); | 1829 this->updateTitle(); |
| 1803 this->inval(nullptr); | 1830 this->inval(nullptr); |
| 1804 } | 1831 } |
| 1805 | 1832 |
| 1806 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { | 1833 void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { |
| 1807 this->setColorType(ct, pt); | 1834 this->setColorType(ct, pt); |
| 1808 | 1835 |
| 1809 fDevManager->tearDownBackend(this); | 1836 fDevManager->tearDownBackend(this); |
| 1810 | |
| 1811 fDevManager->setUpBackend(this, fMSAASampleCount); | 1837 fDevManager->setUpBackend(this, fMSAASampleCount); |
| 1812 | 1838 |
| 1813 this->updateTitle(); | 1839 this->updateTitle(); |
| 1814 this->inval(nullptr); | 1840 this->inval(nullptr); |
| 1815 } | 1841 } |
| 1816 | 1842 |
| 1817 void SampleWindow::toggleSlideshow() { | 1843 void SampleWindow::toggleSlideshow() { |
| 1818 fAnimating = !fAnimating; | 1844 fAnimating = !fAnimating; |
| 1819 this->postAnimatingEvent(); | 1845 this->postAnimatingEvent(); |
| 1820 this->updateTitle(); | 1846 this->updateTitle(); |
| 1821 } | 1847 } |
| 1822 | 1848 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1838 fDevManager->setUpBackend(this, fMSAASampleCount); | 1864 fDevManager->setUpBackend(this, fMSAASampleCount); |
| 1839 | 1865 |
| 1840 SkSurfaceProps props = this->getSurfaceProps(); | 1866 SkSurfaceProps props = this->getSurfaceProps(); |
| 1841 uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDeviceIndependentFonts_ Flag; | 1867 uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDeviceIndependentFonts_ Flag; |
| 1842 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); | 1868 this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry())); |
| 1843 | 1869 |
| 1844 this->updateTitle(); | 1870 this->updateTitle(); |
| 1845 this->inval(nullptr); | 1871 this->inval(nullptr); |
| 1846 } | 1872 } |
| 1847 | 1873 |
| 1874 void SampleWindow::setPixelGeometry(int pixelGeometryIndex) { | |
| 1875 // reset backend | |
| 1876 fDevManager->tearDownBackend(this); | |
| 1877 fDevManager->setUpBackend(this, fMSAASampleCount); | |
| 1878 | |
| 1879 const SkSurfaceProps& oldProps = this->getSurfaceProps(); | |
| 1880 SkSurfaceProps newProps(oldProps.flags(), SkSurfaceProps::kLegacyFontHost_In itType); | |
| 1881 if (pixelGeometryIndex > 0) { | |
| 1882 newProps = SkSurfaceProps(oldProps.flags(), | |
| 1883 gPixelGeometryStates[pixelGeometryIndex].pixel Geometry); | |
| 1884 } | |
| 1885 this->setSurfaceProps(newProps); | |
| 1886 | |
| 1887 this->updateTitle(); | |
| 1888 this->inval(nullptr); | |
| 1889 } | |
| 1890 | |
| 1848 #include "SkDumpCanvas.h" | 1891 #include "SkDumpCanvas.h" |
| 1849 | 1892 |
| 1850 bool SampleWindow::onHandleKey(SkKey key) { | 1893 bool SampleWindow::onHandleKey(SkKey key) { |
| 1851 { | 1894 { |
| 1852 SkView* view = curr_view(this); | 1895 SkView* view = curr_view(this); |
| 1853 if (view) { | 1896 if (view) { |
| 1854 SkEvent evt(gKeyEvtName); | 1897 SkEvent evt(gKeyEvtName); |
| 1855 evt.setFast32(key); | 1898 evt.setFast32(key); |
| 1856 if (view->doQuery(&evt)) { | 1899 if (view->doQuery(&evt)) { |
| 1857 return true; | 1900 return true; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2064 title.prepend("<P> "); | 2107 title.prepend("<P> "); |
| 2065 } | 2108 } |
| 2066 | 2109 |
| 2067 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); | 2110 title.prepend(trystate_str(fLCDState, "LCD ", "lcd ")); |
| 2068 title.prepend(trystate_str(fAAState, "AA ", "aa ")); | 2111 title.prepend(trystate_str(fAAState, "AA ", "aa ")); |
| 2069 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel); | 2112 title.prepend(gFilterQualityStates[fFilterQualityIndex].fLabel); |
| 2070 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); | 2113 title.prepend(trystate_str(fSubpixelState, "S ", "s ")); |
| 2071 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr); | 2114 title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr); |
| 2072 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr); | 2115 title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr); |
| 2073 title.prepend(gHintingStates[fHintingState].label); | 2116 title.prepend(gHintingStates[fHintingState].label); |
| 2117 title.prepend(gPixelGeometryStates[fPixelGeometryIndex].label); | |
| 2074 | 2118 |
| 2075 if (fOffset.fX || fOffset.fY) { | 2119 if (fOffset.fX || fOffset.fY) { |
| 2076 title.prependf("(%.2f, %.2f) ", SkScalarToFloat(fOffset.fX), SkScalarToF loat(fOffset.fY)); | 2120 title.prependf("(%.2f, %.2f) ", SkScalarToFloat(fOffset.fX), SkScalarToF loat(fOffset.fY)); |
| 2077 } | 2121 } |
| 2078 if (fZoomLevel) { | 2122 if (fZoomLevel) { |
| 2079 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel)); | 2123 title.prependf("{%.2f} ", SkScalarToFloat(fZoomLevel)); |
| 2080 } | 2124 } |
| 2081 | 2125 |
| 2082 if (fMeasureFPS) { | 2126 if (fMeasureFPS) { |
| 2083 title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT); | 2127 title.appendf(" %8.4f ms", fMeasureFPS_Time / (float)FPS_REPEAT_COUNT); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2330 #ifdef SK_BUILD_FOR_MAC | 2374 #ifdef SK_BUILD_FOR_MAC |
| 2331 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2375 setenv("ANDROID_ROOT", "/android/device/data", 0); |
| 2332 #endif | 2376 #endif |
| 2333 SkGraphics::Init(); | 2377 SkGraphics::Init(); |
| 2334 SkEvent::Init(); | 2378 SkEvent::Init(); |
| 2335 } | 2379 } |
| 2336 | 2380 |
| 2337 void application_term() { | 2381 void application_term() { |
| 2338 SkEvent::Term(); | 2382 SkEvent::Term(); |
| 2339 } | 2383 } |
| OLD | NEW |