aboutsummaryrefslogtreecommitdiffstats
path: root/src/ports/SkImageRef_ashmem.cpp
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2012-05-14 16:30:59 -0400
committerDerek Sollenberger <djsollen@google.com>2012-05-14 16:32:12 -0400
commitf1a1e8d5528d123890c9e86f672084b86c69dcfe (patch)
tree71dadcdedea55ce38dbe1cde0660fe262f84c7ad /src/ports/SkImageRef_ashmem.cpp
parent7c6d54cdf8d0da62a7478bda7927d779b0481218 (diff)
downloadexternal_skia-f1a1e8d5528d123890c9e86f672084b86c69dcfe.zip
external_skia-f1a1e8d5528d123890c9e86f672084b86c69dcfe.tar.gz
external_skia-f1a1e8d5528d123890c9e86f672084b86c69dcfe.tar.bz2
Cleanup pixel ref mutexes in Skia
Mutexes in pixelrefs were done very sloppily initially. The code (a) assumes all pixelref subclasses want a mutex to guard their lock/unlock virtuals, and (b) most subclasses use the same mutex for *all* of their instances, even when there is no explicit need to guard modifying one instances with another. When we try drawing bitmaps from multiple threads, we are seeing a lot of slow- down from these mutexes. This CL has two changes to try to speed things up. 1. Add setPreLocked(), for pixelrefs who never need the onLockPixels virtual to be called. This speeds up those subclasses in multithreaded environs as it avoids the mutex lock all together (e.g. SkMallocPixelRef). 2. Add setMutex() to allow a subclass to change the mutex choice. ashmem wants this, since its unflattening constructor cannot pass down the null, it needs to cleanup afterwards. see https://codereview.appspot.com/6199075/ bug: 6469917 Change-Id: I81a7cfa0b2ead5a42059697eafa58de1e7a87da2
Diffstat (limited to 'src/ports/SkImageRef_ashmem.cpp')
-rw-r--r--src/ports/SkImageRef_ashmem.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ports/SkImageRef_ashmem.cpp b/src/ports/SkImageRef_ashmem.cpp
index f9c6aff..46ebb0d 100644
--- a/src/ports/SkImageRef_ashmem.cpp
+++ b/src/ports/SkImageRef_ashmem.cpp
@@ -41,6 +41,8 @@ SkImageRef_ashmem::SkImageRef_ashmem(SkStream* stream,
fRec.fPinned = false;
fCT = NULL;
+
+ this->useDefaultMutex(); // we don't need/want the shared imageref mutex
}
SkImageRef_ashmem::~SkImageRef_ashmem() {
@@ -235,6 +237,7 @@ SkImageRef_ashmem::SkImageRef_ashmem(SkFlattenableReadBuffer& buffer)
buffer.read(buf, length);
setURI(buf, length);
}
+ this->useDefaultMutex(); // we don't need/want the shared imageref mutex
}
SkPixelRef* SkImageRef_ashmem::Create(SkFlattenableReadBuffer& buffer) {