Introduce Props to surface (patchset #27 id:520001 of https://codereview.chromium.org/551463004/)"

This reverts commit 29c857d0f3a1cb837f73406eeb6ba9771879b5e7.

TBR=

Author: reed@google.com

Review URL: https://codereview.chromium.org/588143004
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 313c02a..df07204 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -131,8 +131,7 @@
     flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0;
     flags |= fUseLCDText && fTextMatrix.rectStaysRect() ?
     kRectToRect_DistanceFieldEffectFlag : 0;
-    bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout ==
-    fDeviceProperties.fGeometry.getLayout();
+    bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry);
     flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0;
     
     // see if we need to create a new effect
@@ -149,7 +148,7 @@
                                                                         flags));
         } else {
 #ifdef SK_GAMMA_APPLY_TO_A8
-            U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.fGamma,
+            U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.getGamma(),
                                                                 filteredColor);
             fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture,
                                                                      params,
@@ -502,8 +501,8 @@
 #else
         SkScalar contrast = 0.5f;
 #endif
-        SkScalar paintGamma = deviceProperties.fGamma;
-        SkScalar deviceGamma = deviceProperties.fGamma;
+        SkScalar paintGamma = deviceProperties.getGamma();
+        SkScalar deviceGamma = deviceProperties.getGamma();
 
         size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamma,
                                                 &width, &height);
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index ba431d3..165716f 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -142,8 +142,7 @@
     if (atlased.count() > 0) {
         // All the atlased layers are rendered into the same GrTexture
         SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
-                                                atlased[0]->texture()->asRenderTarget(),
-                                                SkSurface::kStandard_TextRenderMode));
+                                        atlased[0]->texture()->asRenderTarget(), NULL));
 
         SkCanvas* atlasCanvas = surface->getCanvas();
 
@@ -196,8 +195,7 @@
 
         // Each non-atlased layer has its own GrTexture
         SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
-                                                layer->texture()->asRenderTarget(),
-                                                SkSurface::kStandard_TextRenderMode));
+                                        layer->texture()->asRenderTarget(), NULL));
 
         SkCanvas* layerCanvas = surface->getCanvas();
 
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 02dca83..7ce3446 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -133,15 +133,15 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, unsigned flags) {
+SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, const SkSurfaceProps& props, unsigned flags) {
     SkASSERT(surface);
     if (NULL == surface->asRenderTarget() || surface->wasDestroyed()) {
         return NULL;
     }
-    return SkNEW_ARGS(SkGpuDevice, (surface, flags));
+    return SkNEW_ARGS(SkGpuDevice, (surface, props, flags));
 }
 
-SkGpuDevice::SkGpuDevice(GrSurface* surface, unsigned flags) {
+SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsigned flags) {
 
     fDrawProcs = NULL;
 
@@ -156,13 +156,15 @@
     fLegacyBitmap.setInfo(surface->info());
     fLegacyBitmap.setPixelRef(pr)->unref();
 
+    this->setPixelGeometry(props.pixelGeometry());
+
     bool useDFFonts = !!(flags & kDFFonts_Flag);
     fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFFonts);
     fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getLeakyProperties()));
 }
 
 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo,
-                                 int sampleCount) {
+                                 const SkSurfaceProps& props, int sampleCount) {
     if (kUnknown_SkColorType == origInfo.colorType() ||
         origInfo.width() < 0 || origInfo.height() < 0) {
         return NULL;
@@ -194,7 +196,7 @@
         return NULL;
     }
 
-    return SkNEW_ARGS(SkGpuDevice, (texture.get()));
+    return SkNEW_ARGS(SkGpuDevice, (texture.get(), props));
 }
 
 SkGpuDevice::~SkGpuDevice() {
@@ -1805,7 +1807,7 @@
     texture.reset(fContext->createUncachedTexture(desc, NULL, 0));
 #endif
     if (texture.get()) {
-        return SkGpuDevice::Create(texture, flags);
+        return SkGpuDevice::Create(texture, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType), flags);
     } else {
         GrPrintf("---- failed to create compatible device texture [%d %d]\n",
                  info.width(), info.height());
@@ -1813,8 +1815,8 @@
     }
 }
 
-SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) {
-    return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples());
+SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
+    return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples(), &props);
 }
 
 void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index dc59009..41b53b1 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -43,7 +43,7 @@
      * the kCached_Flag should be specified to make the device responsible for unlocking
      * the surface when it is released.
      */
-    static SkGpuDevice* Create(GrSurface* surface, unsigned flags = 0);
+    static SkGpuDevice* Create(GrSurface* surface, const SkSurfaceProps&, unsigned flags = 0);
 
     /**
      *  New device that will create an offscreen renderTarget based on the
@@ -51,7 +51,8 @@
      *  count against the GrContext's texture cache budget. The device's pixels
      *  will be uninitialized. On failure, returns NULL.
      */
-    static SkGpuDevice* Create(GrContext*, const SkImageInfo&, int sampleCount);
+    static SkGpuDevice* Create(GrContext*, const SkImageInfo&, const SkSurfaceProps&,
+                               int sampleCount);
 
     virtual ~SkGpuDevice();
 
@@ -145,11 +146,11 @@
     // remove when our clients don't rely on accessBitmap()
     SkBitmap fLegacyBitmap;
 
-    SkGpuDevice(GrSurface*, unsigned flags = 0);
+    SkGpuDevice(GrSurface*, const SkSurfaceProps&, unsigned flags = 0);
 
     virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
 
-    virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
+    virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
 
     virtual SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE;