aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGpuDevice.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-02 19:57:21 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-11-02 19:57:21 +0000
commitc69809745e6496564639e42ef998ad39adf7dfb8 (patch)
tree970a42d960ca25434d580932a3926d975a76b9be /src/gpu/SkGpuDevice.cpp
parentace7bd5623354ffabbd224d5b76550bab159c296 (diff)
Recommit r2584 with gpu pass of the new ReadPixels test disabled in fixed pt (gpu code doesn't work in general in fixed pt).
git-svn-id: http://skia.googlecode.com/svn/trunk@2586 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r--src/gpu/SkGpuDevice.cpp43
1 files changed, 13 insertions, 30 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index d75838350e..790cf6d09e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -256,36 +256,19 @@ void SkGpuDevice::makeRenderTargetCurrent() {
///////////////////////////////////////////////////////////////////////////////
-bool SkGpuDevice::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
- SkIRect bounds;
- bounds.set(0, 0, this->width(), this->height());
- if (!bounds.intersect(srcRect)) {
- return false;
- }
-
- const int w = bounds.width();
- const int h = bounds.height();
- SkBitmap tmp;
- // note we explicitly specify our rowBytes to be snug (no gap between rows)
- tmp.setConfig(SkBitmap::kARGB_8888_Config, w, h, w * 4);
- if (!tmp.allocPixels()) {
- return false;
- }
-
- tmp.lockPixels();
-
- bool read = fContext->readRenderTargetPixels(fRenderTarget,
- bounds.fLeft, bounds.fTop,
- bounds.width(), bounds.height(),
- kRGBA_8888_GrPixelConfig,
- tmp.getPixels());
- tmp.unlockPixels();
- if (!read) {
- return false;
- }
-
- tmp.swap(*bitmap);
- return true;
+bool SkGpuDevice::onReadPixels(const SkBitmap* bitmap, int x, int y) {
+ SkASSERT(SkBitmap::kARGB_8888_Config == bitmap->config());
+ SkASSERT(!bitmap->isNull());
+ SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y, bitmap->width(), bitmap->height())));
+
+ SkAutoLockPixels alp(*bitmap);
+ return fContext->readRenderTargetPixels(fRenderTarget,
+ x, y,
+ bitmap->width(),
+ bitmap->height(),
+ kRGBA_8888_GrPixelConfig,
+ bitmap->getPixels(),
+ bitmap->rowBytes());
}
void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y) {