Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: src/core/SkCanvas.cpp

Issue 1156003002: deprecate calling lockPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkMipMap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698