| Index: src/core/SkCanvas.cpp
|
| diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
|
| index 34d6aaa0ab4ddbb9ae5f158a846d77636c326642..aa25ca0b41c96dcafe053d05d7066a50e8bcb8b8 100644
|
| --- a/src/core/SkCanvas.cpp
|
| +++ b/src/core/SkCanvas.cpp
|
| @@ -712,10 +712,12 @@ bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) {
|
| weAllocated = true;
|
| }
|
|
|
| - SkBitmap bm(*bitmap);
|
| - bm.lockPixels();
|
| - if (bm.getPixels() && this->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), x, y)) {
|
| - return true;
|
| + SkAutoPixmapUnlock unlocker;
|
| + if (bitmap->requestLock(&unlocker)) {
|
| + const SkPixmap& pm = unlocker.pixmap();
|
| + if (this->readPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), x, y)) {
|
| + return true;
|
| + }
|
| }
|
|
|
| if (weAllocated) {
|
| @@ -763,10 +765,11 @@ bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) {
|
| if (bitmap.getTexture()) {
|
| return false;
|
| }
|
| - SkBitmap bm(bitmap);
|
| - bm.lockPixels();
|
| - if (bm.getPixels()) {
|
| - return this->writePixels(bm.info(), bm.getPixels(), bm.rowBytes(), x, y);
|
| +
|
| + SkAutoPixmapUnlock unlocker;
|
| + if (bitmap.requestLock(&unlocker)) {
|
| + const SkPixmap& pm = unlocker.pixmap();
|
| + return this->writePixels(pm.info(), pm.addr(), pm.rowBytes(), x, y);
|
| }
|
| return false;
|
| }
|
|
|