Adds read pixels to GrTexture and GrRenderTarget
Adds SkGrRenderTargetPixelRef for SkBitmaps that are backed by RTs that aren't textures.
Adds onReadPixels implementations for SkGr pixel ref types



git-svn-id: http://skia.googlecode.com/svn/trunk@1056 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrGpu.cpp b/gpu/src/GrGpu.cpp
index 31e4d99..06de3ac 100644
--- a/gpu/src/GrGpu.cpp
+++ b/gpu/src/GrGpu.cpp
@@ -28,42 +28,6 @@
 static const size_t VERTEX_POOL_VB_SIZE = 1 << 12;
 static const int VERTEX_POOL_VB_COUNT = 1;
 
-////////////////////////////////////////////////////////////////////////////////
-
-size_t GrTexture::BytesPerPixel(PixelConfig config) {
-    switch (config) {
-        case kAlpha_8_PixelConfig:
-        case kIndex_8_PixelConfig:
-            return 1;
-        case kRGB_565_PixelConfig:
-        case kRGBA_4444_PixelConfig:
-            return 2;
-        case kRGBA_8888_PixelConfig:
-        case kRGBX_8888_PixelConfig:
-            return 4;
-        default:
-            return 0;
-    }
-}
-
-bool GrTexture::PixelConfigIsOpaque(PixelConfig config) {
-    switch (config) {
-        case GrTexture::kRGB_565_PixelConfig:
-        case GrTexture::kRGBX_8888_PixelConfig:
-            return true;
-        default:
-            return false;
-    }
-}
-
-bool GrTexture::PixelConfigIsAlphaOnly(PixelConfig config) {
-    switch (config) {
-        case GrTexture::kAlpha_8_PixelConfig:
-            return true;
-        default:
-            return false;
-    }
-}
 
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -75,6 +39,7 @@
     , fCurrPoolStartVertex(0)
     , fCurrPoolIndexBuffer(NULL)
     , fCurrPoolStartIndex(0)
+    , fContext(NULL)
     , fVertexPool(NULL)
     , fIndexPool(NULL)
     , fQuadIndexBuffer(NULL)
@@ -85,6 +50,7 @@
     , fVertexPoolInUse(false)
     , fIndexPoolInUse(false)
     , fResourceHead(NULL) {
+
 #if GR_DEBUG
     //gr_run_unittests();
 #endif
@@ -210,10 +176,17 @@
     this->forceRenderTargetFlushHelper();
 }
 
-bool GrGpu::readPixels(int left, int top, int width, int height,
-                       GrTexture::PixelConfig config, void* buffer) {
+bool GrGpu::readPixels(GrRenderTarget* target,
+                       int left, int top, int width, int height,
+                       GrPixelConfig config, void* buffer) {
+
     this->handleDirtyContext();
+    GrRenderTarget* prevTarget = fCurrDrawState.fRenderTarget;
+    if (NULL != target) {
+        fCurrDrawState.fRenderTarget = target;
+    }
     return this->readPixelsHelper(left, top, width, height, config, buffer);
+    fCurrDrawState.fRenderTarget = prevTarget;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -775,12 +748,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-
-GrTexture::~GrTexture() {
-    // use this to set a break-point if needed
-//    Gr_clz(3);
-}
-
 const GrSamplerState GrSamplerState::gClampNoFilter(
     GrSamplerState::kClamp_WrapMode,
     GrSamplerState::kClamp_WrapMode,