From waddlesplash <waddlesplash@xxxxxxxxx>:
waddlesplash has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/2936 )
Change subject: app_server: Use RecursiveLocker in AlphaMask instead of BLocker.
......................................................................
app_server: Use RecursiveLocker in AlphaMask instead of BLocker.
This avoids creaing a semaphore where it is not needed, especially
as most of these locks are never used from another thread (in the
reports in #16246, there are thousands of semaphores from this
with only a small handful having a "last acquirer" != 0.)
---
M src/servers/app/drawing/AlphaMask.cpp
M src/servers/app/drawing/AlphaMask.h
2 files changed, 13 insertions(+), 7 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/36/2936/1
diff --git a/src/servers/app/drawing/AlphaMask.cpp
b/src/servers/app/drawing/AlphaMask.cpp
index 4393444..eac6ace 100644
--- a/src/servers/app/drawing/AlphaMask.cpp
+++ b/src/servers/app/drawing/AlphaMask.cpp
@@ -45,6 +45,8 @@
fMask(),
fScanline(fMask)
{
+ recursive_lock_init(&fLock, "AlphaMask");
+
if (previousMask != NULL)
atomic_add(&previousMask->fNextMaskCount, 1);
}
@@ -67,6 +69,8 @@
fMask(other->fMask),
fScanline(fMask)
{
+ recursive_lock_init(&fLock, "AlphaMask");
+
fMask.attach(fBuffer);
if (previousMask != NULL)
@@ -92,6 +96,7 @@
fMask(),
fScanline(fMask)
{
+ recursive_lock_init(&fLock, "AlphaMask");
}
@@ -101,13 +106,15 @@
fBits->ReleaseReference();
if (fPreviousMask.Get() != NULL)
atomic_add(&fPreviousMask->fNextMaskCount, -1);
+
+ recursive_lock_destroy(&fLock);
}
IntPoint
AlphaMask::SetCanvasGeometry(IntPoint origin, IntRect bounds)
{
- AutoLocker<BLocker> locker(fLock);
+ RecursiveLocker locker(fLock);
if (origin == fCanvasOrigin && bounds.Width() == fCanvasBounds.Width()
&& bounds.Height() == fCanvasBounds.Height())
@@ -165,8 +172,8 @@
void
AlphaMask::_Generate()
{
- AutoLocker<BLocker> locker(fLock);
- AutoLocker<BLocker> previousLocker;
+ RecursiveLocker locker(fLock);
+ RecursiveLocker previousLocker;
if (fPreviousMask != NULL)
previousLocker.SetTo(fPreviousMask->fLock, false);
@@ -495,7 +502,7 @@
// TODO: don't make a new mask if the cache entry has no
drawstate
// using it anymore, because then we ca just immediately reuse
it
AlphaMask* cachedMask = mask;
- AutoLocker<BLocker> locker(mask->fLock);
+ RecursiveLocker locker(mask->fLock);
mask = new(std::nothrow) ShapeAlphaMask(previousMask, mask);
cachedMask->ReleaseReference();
}
diff --git a/src/servers/app/drawing/AlphaMask.h
b/src/servers/app/drawing/AlphaMask.h
index 9156c23..8ae7a72 100644
--- a/src/servers/app/drawing/AlphaMask.h
+++ b/src/servers/app/drawing/AlphaMask.h
@@ -7,6 +7,7 @@
#define ALPHA_MASK_H
#include <Referenceable.h>
+#include <locks.h>
#include "agg_clipped_alpha_mask.h"
#include "ServerPicture.h"
@@ -15,8 +16,6 @@
#include "drawing/Painter/defines.h"
#include "IntRect.h"
-#include <Locker.h>
-
class BShape;
class ServerBitmap;
@@ -65,7 +64,7 @@
BReference<AlphaMask> fPreviousMask;
IntRect fBounds;
bool fClippedToCanvas;
- BLocker fLock;
+ recursive_lock fLock;
private:
friend class AlphaMaskCache;
--
To view, visit https://review.haiku-os.org/c/haiku/+/2936
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: If9e19d4ced5fee1454a8cbdac2f63c3e58784fe3
Gerrit-Change-Number: 2936
Gerrit-PatchSet: 1
Gerrit-Owner: waddlesplash <waddlesplash@xxxxxxxxx>
Gerrit-MessageType: newchange