fix slowness of getImageData() for CanvasRenderingContext2D in linux due to un-optimized format for glReadPixels

This is a continuation of https://codereview.chromium.org/15331003/

BUG=242093
R=robertphillips@google.com, jun.a.jiang@intel.com, bsalomon@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/15746007

git-svn-id: http://skia.googlecode.com/svn/trunk@9280 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d25709f..751d869 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1280,7 +1280,8 @@
     // dstConfig.
     GrPixelConfig readConfig = dstConfig;
     bool swapRAndB = false;
-    if (GrPixelConfigSwapRAndB(dstConfig) == fGpu->preferredReadPixelsConfig(dstConfig)) {
+    if (GrPixelConfigSwapRAndB(dstConfig) ==
+        fGpu->preferredReadPixelsConfig(dstConfig, target->config())) {
         readConfig = GrPixelConfigSwapRAndB(readConfig);
         swapRAndB = true;
     }
@@ -1478,7 +1479,8 @@
     // when drawing the scratch to the dst using a conversion effect.
     bool swapRAndB = false;
     GrPixelConfig writeConfig = srcConfig;
-    if (fGpu->preferredWritePixelsConfig(srcConfig) == GrPixelConfigSwapRAndB(srcConfig)) {
+    if (GrPixelConfigSwapRAndB(srcConfig) ==
+        fGpu->preferredWritePixelsConfig(srcConfig, target->config())) {
         writeConfig = GrPixelConfigSwapRAndB(srcConfig);
         swapRAndB = true;
     }