Chromium Code Reviews| Index: samplecode/SampleApp.cpp |
| diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp |
| index 3149711d86b30e88784715a4862c7c526b714896..36e89498f58e98af419a8ce0b942a5c26ff0fa27 100644 |
| --- a/samplecode/SampleApp.cpp |
| +++ b/samplecode/SampleApp.cpp |
| @@ -468,6 +468,20 @@ static HintingState gHintingStates[] = { |
| {SkPaint::kFull_Hinting, "Full", "Hf " }, |
| }; |
| +struct PixelGeometryState { |
| + SkPixelGeometry pixelGeometry; |
| + const char* name; |
| + const char* label; |
| +}; |
| +static PixelGeometryState gPixelGeometryStates[] = { |
| + {SkPixelGeometry::kUnknown_SkPixelGeometry, "Mixed", nullptr }, |
| + {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
|
| + {SkPixelGeometry::kRGB_H_SkPixelGeometry, "RGB H", "{RGB H} " }, |
| + {SkPixelGeometry::kBGR_H_SkPixelGeometry, "BGR H", "{BGR H} " }, |
| + {SkPixelGeometry::kRGB_V_SkPixelGeometry, "RGB_V", "{RGB V} " }, |
| + {SkPixelGeometry::kBGR_V_SkPixelGeometry, "BGR_V", "{BGR V} " }, |
| +}; |
| + |
| struct FilterQualityState { |
| SkFilterQuality fQuality; |
| const char* fName; |
| @@ -852,7 +866,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev |
| fDeviceType = kGPU_DeviceType; |
| } |
| #endif |
| - |
| + |
| #if DEFAULT_TO_GPU |
| fDeviceType = kGPU_DeviceType; |
| #endif |
| @@ -875,6 +889,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev |
| fAAState = SkOSMenu::kMixedState; |
| fSubpixelState = SkOSMenu::kMixedState; |
| fHintingState = 0; |
| + fPixelGeometryIndex = 0; |
| fFilterQualityIndex = 0; |
| fFlipAxis = 0; |
| @@ -935,6 +950,16 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev |
| nullptr); |
| fAppMenu->assignKeyEquivalentToItem(itemID, 'h'); |
| + itemID = fAppMenu->appendList("Pixel Geometry", "Pixel Geometry", sinkID, fPixelGeometryIndex, |
| + gPixelGeometryStates[0].name, |
| + gPixelGeometryStates[1].name, |
| + gPixelGeometryStates[2].name, |
| + gPixelGeometryStates[3].name, |
| + gPixelGeometryStates[4].name, |
| + gPixelGeometryStates[5].name, |
| + nullptr); |
| + fAppMenu->assignKeyEquivalentToItem(itemID, 'P'); |
| + |
| itemID =fAppMenu->appendList("Tiling", "Tiling", sinkID, fTilingMode, |
| gTilingInfo[kNo_Tiling].label, |
| gTilingInfo[kAbs_128x128_Tiling].label, |
| @@ -1611,6 +1636,10 @@ bool SampleWindow::onEvent(const SkEvent& evt) { |
| this->updateTitle(); |
| return true; |
| } |
| + if (SkOSMenu::FindListIndex(evt, "Pixel Geometry", &fPixelGeometryIndex)) { |
| + this->setPixelGeometry(fPixelGeometryIndex); |
| + return true; |
| + } |
| if (SkOSMenu::FindListIndex(evt, "Tiling", &fTilingMode)) { |
| if (SampleView::IsSampleView(curr_view(this))) { |
| ((SampleView*)curr_view(this))->onTileSizeChanged(this->tileSize()); |
| @@ -1792,13 +1821,11 @@ bool SampleWindow::onHandleChar(SkUnichar uni) { |
| void SampleWindow::setDeviceType(DeviceType type) { |
| if (type == fDeviceType) |
| return; |
| - |
| + |
| fDevManager->tearDownBackend(this); |
| - |
| fDeviceType = type; |
| - |
| fDevManager->setUpBackend(this, fMSAASampleCount); |
| - |
| + |
| this->updateTitle(); |
| this->inval(nullptr); |
| } |
| @@ -1807,9 +1834,8 @@ void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) { |
| this->setColorType(ct, pt); |
| fDevManager->tearDownBackend(this); |
| - |
| fDevManager->setUpBackend(this, fMSAASampleCount); |
| - |
| + |
| this->updateTitle(); |
| this->inval(nullptr); |
| } |
| @@ -1845,6 +1871,23 @@ void SampleWindow::toggleDistanceFieldFonts() { |
| this->inval(nullptr); |
| } |
| +void SampleWindow::setPixelGeometry(int pixelGeometryIndex) { |
| + // reset backend |
| + fDevManager->tearDownBackend(this); |
| + fDevManager->setUpBackend(this, fMSAASampleCount); |
| + |
| + const SkSurfaceProps& oldProps = this->getSurfaceProps(); |
| + SkSurfaceProps newProps(oldProps.flags(), SkSurfaceProps::kLegacyFontHost_InitType); |
| + if (pixelGeometryIndex > 0) { |
| + newProps = SkSurfaceProps(oldProps.flags(), |
| + gPixelGeometryStates[pixelGeometryIndex].pixelGeometry); |
| + } |
| + this->setSurfaceProps(newProps); |
| + |
| + this->updateTitle(); |
| + this->inval(nullptr); |
| +} |
| + |
| #include "SkDumpCanvas.h" |
| bool SampleWindow::onHandleKey(SkKey key) { |
| @@ -2071,6 +2114,7 @@ void SampleWindow::updateTitle() { |
| title.prepend(fFlipAxis & kFlipAxis_X ? "X " : nullptr); |
| title.prepend(fFlipAxis & kFlipAxis_Y ? "Y " : nullptr); |
| title.prepend(gHintingStates[fHintingState].label); |
| + title.prepend(gPixelGeometryStates[fPixelGeometryIndex].label); |
| if (fOffset.fX || fOffset.fY) { |
| title.prependf("(%.2f, %.2f) ", SkScalarToFloat(fOffset.fX), SkScalarToFloat(fOffset.fY)); |