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/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 7a53c0b..7901648 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -14,14 +14,31 @@
#include "GrStencilBuffer.h"
bool GrRenderTarget::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->readRenderTargetPixels(this,
- left, top,
+ left, top,
width, height,
- config, buffer);
+ config, buffer, rowBytes);
+}
+
+void GrRenderTarget::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->writeRenderTargetPixels(this,
+ left, top,
+ width, height,
+ config, buffer, rowBytes);
}
size_t GrRenderTarget::sizeInBytes() const {