| Index: src/core/SkBitmapDevice.cpp
|
| diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
|
| index 96f4e40298914e52b2e7009a1ea138109b656011..c01b7205e5e5429aac5514012bccce83b4f678a4 100644
|
| --- a/src/core/SkBitmapDevice.cpp
|
| +++ b/src/core/SkBitmapDevice.cpp
|
| @@ -173,6 +173,7 @@ bool SkBitmapDevice::allowImageFilter(const SkImageFilter*) {
|
| return true;
|
| }
|
|
|
| +#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
|
| bool SkBitmapDevice::onReadPixels(const SkBitmap& bitmap,
|
| int x, int y,
|
| SkCanvas::Config8888 config8888) {
|
| @@ -198,6 +199,7 @@ bool SkBitmapDevice::onReadPixels(const SkBitmap& bitmap,
|
| SkCopyBitmapToConfig8888(bmpPixels, bitmap.rowBytes(), config8888, subset);
|
| return true;
|
| }
|
| +#endif
|
|
|
| #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
|
| void SkBitmapDevice::writePixels(const SkBitmap& bitmap,
|
| @@ -315,8 +317,8 @@ static bool info2config8888(const SkImageInfo& info, SkCanvas::Config8888* confi
|
|
|
| // TODO: make this guy real, and not rely on legacy config8888 utility
|
| #include "SkConfig8888.h"
|
| -static bool write_pixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
| - const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes) {
|
| +static bool copy_pixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
| + const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes) {
|
| if (srcInfo.dimensions() != dstInfo.dimensions()) {
|
| return false;
|
| }
|
| @@ -364,13 +366,39 @@ bool SkBitmapDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPi
|
| void* dstPixels = fBitmap.getAddr(x, y);
|
| size_t dstRowBytes = fBitmap.rowBytes();
|
|
|
| - if (write_pixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPixels, srcRowBytes)) {
|
| + if (copy_pixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPixels, srcRowBytes)) {
|
| fBitmap.notifyPixelsChanged();
|
| return true;
|
| }
|
| return false;
|
| }
|
|
|
| +bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
| + int x, int y) {
|
| + // since we don't stop creating un-pixeled devices yet, check for no pixels here
|
| + if (NULL == fBitmap.getPixels()) {
|
| + return false;
|
| + }
|
| +
|
| + SkImageInfo srcInfo = fBitmap.info();
|
| +
|
| + // perhaps can relax these in the future
|
| + if (4 != dstInfo.bytesPerPixel()) {
|
| + return false;
|
| + }
|
| + if (4 != srcInfo.bytesPerPixel()) {
|
| + return false;
|
| + }
|
| +
|
| + srcInfo.fWidth = dstInfo.width();
|
| + srcInfo.fHeight = dstInfo.height();
|
| +
|
| + const void* srcPixels = fBitmap.getAddr(x, y);
|
| + const size_t srcRowBytes = fBitmap.rowBytes();
|
| +
|
| + return copy_pixels(dstInfo, dstPixels, dstRowBytes, srcInfo, srcPixels, srcRowBytes);
|
| +}
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
|
|
|