Move some parts of onReadPixels up to GrGpu readPixels.

BUG=skia:

Review URL: https://codereview.chromium.org/1270583003
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index c7137ef..bb020f5 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -17,6 +17,7 @@
 #include "GrResourceCache.h"
 #include "GrRenderTargetPriv.h"
 #include "GrStencilAttachment.h"
+#include "GrSurfacePriv.h"
 #include "GrVertexBuffer.h"
 #include "GrVertices.h"
 
@@ -239,6 +240,11 @@
     SkASSERT(tempDrawInfo);
     SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
 
+    // We currently do not support reading into a compressed buffer
+    if (GrPixelConfigIsCompressed(readConfig)) {
+        return false;
+    }
+
     if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConfig, drawPreference,
                                    tempDrawInfo)) {
         return false;
@@ -292,7 +298,24 @@
                        GrPixelConfig config, void* buffer,
                        size_t rowBytes) {
     this->handleDirtyContext();
-    return this->onReadPixels(surface, left, top, width, height, config, buffer, rowBytes);
+
+    // We cannot read pixels into a compressed buffer
+    if (GrPixelConfigIsCompressed(config)) {
+        return false;
+    }
+
+    size_t bpp = GrBytesPerPixel(config);
+    if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp,
+                                              &left, &top, &width, &height,
+                                              &buffer,
+                                              &rowBytes)) {
+        return false;
+    }
+
+    return this->onReadPixels(surface,
+                              left, top, width, height,
+                              config, buffer,
+                              rowBytes);
 }
 
 bool GrGpu::writePixels(GrSurface* surface,
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index e6f37cc..b814abf 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -470,7 +470,8 @@
 
     // overridden by backend-specific derived class to perform the surface read
     virtual bool onReadPixels(GrSurface*,
-                              int left, int top, int width, int height,
+                              int left, int top,
+                              int width, int height,
                               GrPixelConfig,
                               void* buffer,
                               size_t rowBytes) = 0;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 781e772..74f7e0b 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1731,10 +1731,6 @@
 bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes,
                                   GrPixelConfig readConfig, DrawPreference* drawPreference,
                                   ReadPixelTempDrawInfo* tempDrawInfo) {
-    if (GrPixelConfigIsCompressed(readConfig)) {
-        return false;
-    }
-
     // This subclass can only read pixels from a render target. We could use glTexSubImage2D on
     // GL versions that support it but we don't today.
     if (!srcSurface->asRenderTarget()) {
@@ -1796,11 +1792,6 @@
                            size_t rowBytes) {
     SkASSERT(surface);
 
-    // We cannot read pixels into a compressed buffer
-    if (GrPixelConfigIsCompressed(config)) {
-        return false;
-    }
-
     GrGLRenderTarget* tgt = static_cast<GrGLRenderTarget*>(surface->asRenderTarget());
     if (!tgt) {
         return false;
@@ -1812,13 +1803,6 @@
     if (!this->configToGLFormats(config, false, NULL, &format, &type)) {
         return false;
     }
-    size_t bpp = GrBytesPerPixel(config);
-    if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp,
-                                              &left, &top, &width, &height,
-                                              &buffer,
-                                              &rowBytes)) {
-        return false;
-    }
 
     // resolve the render target if necessary
     switch (tgt->getResolveType()) {
@@ -1844,10 +1828,8 @@
     GrGLIRect readRect;
     readRect.setRelativeTo(glvp, left, top, width, height, tgt->origin());
 
-    size_t tightRowBytes = bpp * width;
-    if (0 == rowBytes) {
-        rowBytes = tightRowBytes;
-    }
+    size_t tightRowBytes = GrBytesPerPixel(config) * width;
+
     size_t readDstRowBytes = tightRowBytes;
     void* readDst = buffer;