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

Unified Diff: src/core/SkBlitter_Sprite.cpp

Issue 1144923005: use SkPixmap inside sprite blitters (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/SkSpriteBlitter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBlitter_Sprite.cpp
diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp
index 91a3cd1fee1c385acf1ad3ac8d497eb9486f7bab..ab70222c6b0e8976a557e91418f2e5dcf74af6c8 100644
--- a/src/core/SkBlitter_Sprite.cpp
+++ b/src/core/SkBlitter_Sprite.cpp
@@ -8,21 +8,21 @@
#include "SkSmallAllocator.h"
#include "SkSpriteBlitter.h"
-SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source)
- : fSource(&source) {
- fSource->lockPixels();
-}
-
-SkSpriteBlitter::~SkSpriteBlitter() {
- fSource->unlockPixels();
+SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source) : fSource(NULL) {
+ if (source.requestLock(&fUnlocker)) {
+ fSource = &fUnlocker.pixmap();
+ }
}
-void SkSpriteBlitter::setup(const SkBitmap& device, int left, int top,
- const SkPaint& paint) {
+bool SkSpriteBlitter::setup(const SkBitmap& device, int left, int top, const SkPaint& paint) {
+ if (NULL == fSource) {
+ return false;
+ }
fDevice = &device;
fLeft = left;
fTop = top;
fPaint = &paint;
+ return true;
}
#ifdef SK_DEBUG
@@ -76,7 +76,11 @@ SkBlitter* SkBlitter::ChooseSprite(const SkBitmap& device, const SkPaint& paint,
}
if (blitter) {
- blitter->setup(device, left, top, paint);
+ if (!blitter->setup(device, left, top, paint)) {
+ // blitter was allocated by allocator, so we have to manually call its destructor
+ blitter->~SkSpriteBlitter();
+ blitter = NULL;
+ }
}
return blitter;
}
« no previous file with comments | « no previous file | src/core/SkSpriteBlitter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698