[haiku-commits] haiku: hrev49850 - src/servers/app/drawing

  • From: julian.harnath@xxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 15 Nov 2015 22:06:20 +0100 (CET)

hrev49850 adds 1 changeset to branch 'master'
old head: 97921e3f437bcfdea15b1c00a3e5ce9b48f9d3bf
new head: 3c9d8d6460e77526ece3da7a46578f7471554877
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=3c9d8d6460e7+%5E97921e3f437b

----------------------------------------------------------------------------

3c9d8d6460e7: app_server: fix race condition in alpha mask cloning

* Add a lock which is acquired when reattaching/regenerating masks,
and also acquired for a cached mask before making a clone of it,
to prevent the clone from having an inconsistent state in
concurrent edge cases.

* Maybe fixes #12469

[ Julian Harnath <julian.harnath@xxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49850
Commit: 3c9d8d6460e77526ece3da7a46578f7471554877
URL: http://cgit.haiku-os.org/haiku/commit/?id=3c9d8d6460e7
Author: Julian Harnath <julian.harnath@xxxxxxxxxxxxxx>
Date: Sun Nov 15 21:03:14 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/12469

----------------------------------------------------------------------------

2 files changed, 10 insertions(+)
src/servers/app/drawing/AlphaMask.cpp | 7 +++++++
src/servers/app/drawing/AlphaMask.h | 3 +++

----------------------------------------------------------------------------

diff --git a/src/servers/app/drawing/AlphaMask.cpp
b/src/servers/app/drawing/AlphaMask.cpp
index 3716c7b..9ed68dc 100644
--- a/src/servers/app/drawing/AlphaMask.cpp
+++ b/src/servers/app/drawing/AlphaMask.cpp
@@ -22,6 +22,8 @@
#include "Shape.h"
#include "ShapePrivate.h"

+#include <AutoLocker.h>
+

// #pragma mark - AlphaMask

@@ -103,6 +105,8 @@ AlphaMask::~AlphaMask()
IntPoint
AlphaMask::SetCanvasGeometry(IntPoint origin, IntRect bounds)
{
+ AutoLocker<BLocker> locker(fLock);
+
if (origin == fCanvasOrigin && bounds.Width() == fCanvasBounds.Width()
&& bounds.Height() == fCanvasBounds.Height())
return fCanvasOrigin;
@@ -159,6 +163,8 @@ AlphaMask::_CreateTemporaryBitmap(BRect bounds) const
void
AlphaMask::_Generate()
{
+ AutoLocker<BLocker> locker(fLock);
+
ServerBitmap* const bitmap = _RenderSource(fCanvasBounds);
BReference<ServerBitmap> bitmapRef(bitmap, true);
if (bitmap == NULL) {
@@ -484,6 +490,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);
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 7d53d67..9156c23 100644
--- a/src/servers/app/drawing/AlphaMask.h
+++ b/src/servers/app/drawing/AlphaMask.h
@@ -15,6 +15,8 @@
#include "drawing/Painter/defines.h"
#include "IntRect.h"

+#include <Locker.h>
+

class BShape;
class ServerBitmap;
@@ -63,6 +65,7 @@ protected:
BReference<AlphaMask> fPreviousMask;
IntRect fBounds;
bool fClippedToCanvas;
+ BLocker fLock;

private:
friend class AlphaMaskCache;


Other related posts:

  • » [haiku-commits] haiku: hrev49850 - src/servers/app/drawing - julian . harnath