Make all pixel ops go thru ctx so we can correctly flush. Unify two texture upload code paths. 

Review URL: http://codereview.appspot.com/5373108/



git-svn-id: http://skia.googlecode.com/svn/trunk@2701 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 77868df..c145c71 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -14,14 +14,31 @@
 #include "GrRenderTarget.h"
 
 bool GrTexture::readPixels(int left, int top, int width, int height,
-                           GrPixelConfig config, void* buffer) {
+                           GrPixelConfig config, void* buffer,
+                           size_t rowBytes) {
     // go through context so that all necessary flushing occurs
-    GrContext* context = this->getGpu()->getContext();
-    GrAssert(NULL != context);
+    GrContext* context = this->getContext();
+    if (NULL == context) {
+        return false;
+    }
     return context->readTexturePixels(this,
-                                        left, top, 
-                                        width, height,
-                                        config, buffer);
+                                      left, top,
+                                      width, height,
+                                      config, buffer, rowBytes);
+}
+
+void GrTexture::writePixels(int left, int top, int width, int height,
+                            GrPixelConfig config, const void* buffer,
+                            size_t rowBytes) {
+    // go through context so that all necessary flushing occurs
+    GrContext* context = this->getContext();
+    if (NULL == context) {
+        return;
+    }
+    context->writeTexturePixels(this,
+                                left, top,
+                                width, height,
+                                config, buffer, rowBytes);
 }
 
 void GrTexture::releaseRenderTarget() {