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.)
This commit is contained in:
Augustin Cavalier
2020-06-20 19:46:22 -04:00
parent b344d252e9
commit 67ace0bfab
2 changed files with 13 additions and 7 deletions
+11 -4
View File
@@ -45,6 +45,8 @@ AlphaMask::AlphaMask(AlphaMask* previousMask, bool inverse)
fMask(),
fScanline(fMask)
{
recursive_lock_init(&fLock, "AlphaMask");
if (previousMask != NULL)
atomic_add(&previousMask->fNextMaskCount, 1);
}
@@ -67,6 +69,8 @@ AlphaMask::AlphaMask(AlphaMask* previousMask, AlphaMask* other)
fMask(other->fMask),
fScanline(fMask)
{
recursive_lock_init(&fLock, "AlphaMask");
fMask.attach(fBuffer);
if (previousMask != NULL)
@@ -92,6 +96,7 @@ AlphaMask::AlphaMask(uint8 backgroundOpacity)
fMask(),
fScanline(fMask)
{
recursive_lock_init(&fLock, "AlphaMask");
}
@@ -101,13 +106,15 @@ AlphaMask::~AlphaMask()
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 @@ AlphaMask::_CreateTemporaryBitmap(BRect bounds) const
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 @@ ShapeAlphaMask::Create(AlphaMask* previousMask, const shape_data& shape,
// 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();
}
+2 -3
View File
@@ -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 @@ protected:
BReference<AlphaMask> fPreviousMask;
IntRect fBounds;
bool fClippedToCanvas;
BLocker fLock;
recursive_lock fLock;
private:
friend class AlphaMaskCache;