diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-02 20:06:25 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-11-02 20:06:25 +0000 |
commit | 910267dde2d036b6298f62943f019bda3d662eb2 (patch) | |
tree | 21ed302747dfc92c792493002653ba19a9f61493 | |
parent | c69809745e6496564639e42ef998ad39adf7dfb8 (diff) |
Make SkDevice::onReadPixels take a const& rather than const*
git-svn-id: http://skia.googlecode.com/svn/trunk@2587 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkDevice.h | 3 | ||||
-rw-r--r-- | include/device/xps/SkXPSDevice.h | 2 | ||||
-rw-r--r-- | include/gpu/SkGpuDevice.h | 2 | ||||
-rw-r--r-- | include/pdf/SkPDFDevice.h | 2 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 22 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 18 |
6 files changed, 24 insertions, 25 deletions
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 5d184e478f..4dadfc43cb 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -275,9 +275,8 @@ protected: * 2. bitmap has pixels. * 3. The rectangle (x, y, x + bitmap->width(), y + bitmap->height()) is * contained in the device bounds. - * 4. the bitmap struct is safe to partially overwrite in case of failure */ - virtual bool onReadPixels(const SkBitmap* bitmap, int x, int y); + virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y); /** Called when this device is installed into a Canvas. Balanaced by a call diff --git a/include/device/xps/SkXPSDevice.h b/include/device/xps/SkXPSDevice.h index ed61ced8d0..bac7f38a4a 100644 --- a/include/device/xps/SkXPSDevice.h +++ b/include/device/xps/SkXPSDevice.h @@ -141,7 +141,7 @@ protected: int x, int y, const SkPaint& paint) SK_OVERRIDE; - virtual bool onReadPixels(const SkBitmap* bitmap, + virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y) SK_OVERRIDE { return false; diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h index 047fd0740c..d394d1202d 100644 --- a/include/gpu/SkGpuDevice.h +++ b/include/gpu/SkGpuDevice.h @@ -141,7 +141,7 @@ protected: friend class SkAutoTexCache; // overrides from SkDevice - virtual bool onReadPixels(const SkBitmap* bitmap, + virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y) SK_OVERRIDE; diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h index b25e39a7d0..1e4db86d2d 100644 --- a/include/pdf/SkPDFDevice.h +++ b/include/pdf/SkPDFDevice.h @@ -158,7 +158,7 @@ public: } protected: - virtual bool onReadPixels(const SkBitmap* bitmap, + virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y) SK_OVERRIDE { return false; } diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index f5523bd9db..4e2cd0a6cc 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -135,20 +135,20 @@ bool SkDevice::readPixels(SkBitmap* bitmap, int x, int y) { SkBitmap bmpSubset; bmp->extractSubset(&bmpSubset, subrect); - bool result = this->onReadPixels(&bmpSubset, srcRect.fLeft, srcRect.fTop); + bool result = this->onReadPixels(bmpSubset, srcRect.fLeft, srcRect.fTop); if (result && bmp == &tmp) { tmp.swap(*bitmap); } return result; } -bool SkDevice::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()))); +bool SkDevice::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()))); - SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap->width(), - bitmap->height()); + SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap.width(), + bitmap.height()); const SkBitmap& src = this->accessBitmap(false); SkBitmap subset; @@ -161,10 +161,10 @@ bool SkDevice::onReadPixels(const SkBitmap* bitmap, int x, int y) { // or make copyTo lazily allocate. subset.copyTo(&subset, SkBitmap::kARGB_8888_Config); } - SkAutoLockPixels alp(*bitmap); - return subset.copyPixelsTo(bitmap->getPixels(), - bitmap->getSize(), - bitmap->rowBytes(), + SkAutoLockPixels alp(bitmap); + return subset.copyPixelsTo(bitmap.getPixels(), + bitmap.getSize(), + bitmap.rowBytes(), true); } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 790cf6d09e..f145939086 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -256,19 +256,19 @@ void SkGpuDevice::makeRenderTargetCurrent() { /////////////////////////////////////////////////////////////////////////////// -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()))); +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); + SkAutoLockPixels alp(bitmap); return fContext->readRenderTargetPixels(fRenderTarget, x, y, - bitmap->width(), - bitmap->height(), + bitmap.width(), + bitmap.height(), kRGBA_8888_GrPixelConfig, - bitmap->getPixels(), - bitmap->rowBytes()); + bitmap.getPixels(), + bitmap.rowBytes()); } void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y) { |