Add 'P' to SampleApp to cycle through pixel geometries.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1834243002

Review URL: https://codereview.chromium.org/1834243002
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 780eabd..5bf28aa 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -471,6 +471,20 @@
     {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} "  },
+    {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;
@@ -878,6 +892,7 @@
     fAAState = SkOSMenu::kMixedState;
     fSubpixelState = SkOSMenu::kMixedState;
     fHintingState = 0;
+    fPixelGeometryIndex = 0;
     fFilterQualityIndex = 0;
     fFlipAxis = 0;
 
@@ -938,6 +953,16 @@
                                   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,
@@ -1614,6 +1639,10 @@
         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());
@@ -1797,9 +1826,7 @@
         return;
 
     fDevManager->tearDownBackend(this);
-
     fDeviceType = type;
-
     fDevManager->setUpBackend(this, fMSAASampleCount);
 
     this->updateTitle();
@@ -1810,7 +1837,6 @@
     this->setColorType(ct, pt);
 
     fDevManager->tearDownBackend(this);
-
     fDevManager->setUpBackend(this, fMSAASampleCount);
 
     this->updateTitle();
@@ -1848,6 +1874,23 @@
     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) {
@@ -2074,6 +2117,7 @@
     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));