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:
@@ -45,6 +45,8 @@ AlphaMask::AlphaMask(AlphaMask* previousMask, bool inverse)
|
|||||||
fMask(),
|
fMask(),
|
||||||
fScanline(fMask)
|
fScanline(fMask)
|
||||||
{
|
{
|
||||||
|
recursive_lock_init(&fLock, "AlphaMask");
|
||||||
|
|
||||||
if (previousMask != NULL)
|
if (previousMask != NULL)
|
||||||
atomic_add(&previousMask->fNextMaskCount, 1);
|
atomic_add(&previousMask->fNextMaskCount, 1);
|
||||||
}
|
}
|
||||||
@@ -67,6 +69,8 @@ AlphaMask::AlphaMask(AlphaMask* previousMask, AlphaMask* other)
|
|||||||
fMask(other->fMask),
|
fMask(other->fMask),
|
||||||
fScanline(fMask)
|
fScanline(fMask)
|
||||||
{
|
{
|
||||||
|
recursive_lock_init(&fLock, "AlphaMask");
|
||||||
|
|
||||||
fMask.attach(fBuffer);
|
fMask.attach(fBuffer);
|
||||||
|
|
||||||
if (previousMask != NULL)
|
if (previousMask != NULL)
|
||||||
@@ -92,6 +96,7 @@ AlphaMask::AlphaMask(uint8 backgroundOpacity)
|
|||||||
fMask(),
|
fMask(),
|
||||||
fScanline(fMask)
|
fScanline(fMask)
|
||||||
{
|
{
|
||||||
|
recursive_lock_init(&fLock, "AlphaMask");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -101,13 +106,15 @@ AlphaMask::~AlphaMask()
|
|||||||
fBits->ReleaseReference();
|
fBits->ReleaseReference();
|
||||||
if (fPreviousMask.Get() != NULL)
|
if (fPreviousMask.Get() != NULL)
|
||||||
atomic_add(&fPreviousMask->fNextMaskCount, -1);
|
atomic_add(&fPreviousMask->fNextMaskCount, -1);
|
||||||
|
|
||||||
|
recursive_lock_destroy(&fLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IntPoint
|
IntPoint
|
||||||
AlphaMask::SetCanvasGeometry(IntPoint origin, IntRect bounds)
|
AlphaMask::SetCanvasGeometry(IntPoint origin, IntRect bounds)
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> locker(fLock);
|
RecursiveLocker locker(fLock);
|
||||||
|
|
||||||
if (origin == fCanvasOrigin && bounds.Width() == fCanvasBounds.Width()
|
if (origin == fCanvasOrigin && bounds.Width() == fCanvasBounds.Width()
|
||||||
&& bounds.Height() == fCanvasBounds.Height())
|
&& bounds.Height() == fCanvasBounds.Height())
|
||||||
@@ -165,8 +172,8 @@ AlphaMask::_CreateTemporaryBitmap(BRect bounds) const
|
|||||||
void
|
void
|
||||||
AlphaMask::_Generate()
|
AlphaMask::_Generate()
|
||||||
{
|
{
|
||||||
AutoLocker<BLocker> locker(fLock);
|
RecursiveLocker locker(fLock);
|
||||||
AutoLocker<BLocker> previousLocker;
|
RecursiveLocker previousLocker;
|
||||||
if (fPreviousMask != NULL)
|
if (fPreviousMask != NULL)
|
||||||
previousLocker.SetTo(fPreviousMask->fLock, false);
|
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
|
// 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
|
// using it anymore, because then we ca just immediately reuse it
|
||||||
AlphaMask* cachedMask = mask;
|
AlphaMask* cachedMask = mask;
|
||||||
AutoLocker<BLocker> locker(mask->fLock);
|
RecursiveLocker locker(mask->fLock);
|
||||||
mask = new(std::nothrow) ShapeAlphaMask(previousMask, mask);
|
mask = new(std::nothrow) ShapeAlphaMask(previousMask, mask);
|
||||||
cachedMask->ReleaseReference();
|
cachedMask->ReleaseReference();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#define ALPHA_MASK_H
|
#define ALPHA_MASK_H
|
||||||
|
|
||||||
#include <Referenceable.h>
|
#include <Referenceable.h>
|
||||||
|
#include <locks.h>
|
||||||
|
|
||||||
#include "agg_clipped_alpha_mask.h"
|
#include "agg_clipped_alpha_mask.h"
|
||||||
#include "ServerPicture.h"
|
#include "ServerPicture.h"
|
||||||
@@ -15,8 +16,6 @@
|
|||||||
#include "drawing/Painter/defines.h"
|
#include "drawing/Painter/defines.h"
|
||||||
#include "IntRect.h"
|
#include "IntRect.h"
|
||||||
|
|
||||||
#include <Locker.h>
|
|
||||||
|
|
||||||
|
|
||||||
class BShape;
|
class BShape;
|
||||||
class ServerBitmap;
|
class ServerBitmap;
|
||||||
@@ -65,7 +64,7 @@ protected:
|
|||||||
BReference<AlphaMask> fPreviousMask;
|
BReference<AlphaMask> fPreviousMask;
|
||||||
IntRect fBounds;
|
IntRect fBounds;
|
||||||
bool fClippedToCanvas;
|
bool fClippedToCanvas;
|
||||||
BLocker fLock;
|
recursive_lock fLock;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AlphaMaskCache;
|
friend class AlphaMaskCache;
|
||||||
|
|||||||
Reference in New Issue
Block a user