зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1467363: Protect access to mTransparentSurface with a lock. r=rhunt
MozReview-Commit-ID: 6E9YpDIcuQk
This commit is contained in:
Родитель
e6892b931a
Коммит
572e54cead
|
@ -19,6 +19,7 @@ namespace mozilla {
|
|||
namespace widget {
|
||||
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla;
|
||||
|
||||
WinCompositorWidget::WinCompositorWidget(const WinCompositorWidgetInitData& aInitData,
|
||||
const layers::CompositorOptions& aOptions)
|
||||
|
@ -26,6 +27,7 @@ WinCompositorWidget::WinCompositorWidget(const WinCompositorWidgetInitData& aIni
|
|||
, mWidgetKey(aInitData.widgetKey()),
|
||||
mWnd(reinterpret_cast<HWND>(aInitData.hWnd())),
|
||||
mCompositorWnd(nullptr),
|
||||
mTransparentSurfaceLock("mTransparentSurfaceLock"),
|
||||
mTransparencyMode(aInitData.transparencyMode()),
|
||||
mMemoryDC(nullptr),
|
||||
mCompositeDC(nullptr),
|
||||
|
@ -48,6 +50,7 @@ WinCompositorWidget::~WinCompositorWidget()
|
|||
void
|
||||
WinCompositorWidget::OnDestroyWindow()
|
||||
{
|
||||
MutexAutoLock lock(mTransparentSurfaceLock);
|
||||
mTransparentSurface = nullptr;
|
||||
mMemoryDC = nullptr;
|
||||
}
|
||||
|
@ -84,6 +87,8 @@ WinCompositorWidget::GetClientSize()
|
|||
already_AddRefed<gfx::DrawTarget>
|
||||
WinCompositorWidget::StartRemoteDrawing()
|
||||
{
|
||||
MutexAutoLock lock(mTransparentSurfaceLock);
|
||||
|
||||
MOZ_ASSERT(!mCompositeDC);
|
||||
|
||||
RefPtr<gfxASurface> surf;
|
||||
|
@ -244,6 +249,7 @@ WinCompositorWidget::LeavePresentLock()
|
|||
RefPtr<gfxASurface>
|
||||
WinCompositorWidget::EnsureTransparentSurface()
|
||||
{
|
||||
mTransparentSurfaceLock.AssertCurrentThreadOwns();
|
||||
MOZ_ASSERT(mTransparencyMode == eTransparencyTransparent);
|
||||
|
||||
IntSize size = GetClientSize().ToUnknownSize();
|
||||
|
@ -260,6 +266,7 @@ WinCompositorWidget::EnsureTransparentSurface()
|
|||
void
|
||||
WinCompositorWidget::CreateTransparentSurface(const gfx::IntSize& aSize)
|
||||
{
|
||||
mTransparentSurfaceLock.AssertCurrentThreadOwns();
|
||||
MOZ_ASSERT(!mTransparentSurface && !mMemoryDC);
|
||||
RefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(aSize, SurfaceFormat::A8R8G8B8_UINT32);
|
||||
mTransparentSurface = surface;
|
||||
|
@ -269,6 +276,7 @@ WinCompositorWidget::CreateTransparentSurface(const gfx::IntSize& aSize)
|
|||
void
|
||||
WinCompositorWidget::UpdateTransparency(nsTransparencyMode aMode)
|
||||
{
|
||||
MutexAutoLock lock(mTransparentSurfaceLock);
|
||||
if (mTransparencyMode == aMode) {
|
||||
return;
|
||||
}
|
||||
|
@ -285,6 +293,7 @@ WinCompositorWidget::UpdateTransparency(nsTransparencyMode aMode)
|
|||
void
|
||||
WinCompositorWidget::ClearTransparentWindow()
|
||||
{
|
||||
MutexAutoLock lock(mTransparentSurfaceLock);
|
||||
if (!mTransparentSurface) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "gfxASurface.h"
|
||||
#include "mozilla/gfx/CriticalSection.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
class nsWindow;
|
||||
|
@ -106,6 +107,8 @@ public:
|
|||
void DestroyCompositorWindow();
|
||||
void UpdateCompositorWndSizeIfNecessary();
|
||||
|
||||
mozilla::Mutex& GetTransparentSurfaceLock() { return mTransparentSurfaceLock; }
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
@ -124,6 +127,7 @@ private:
|
|||
gfx::CriticalSection mPresentLock;
|
||||
|
||||
// Transparency handling.
|
||||
mozilla::Mutex mTransparentSurfaceLock;
|
||||
nsTransparencyMode mTransparencyMode;
|
||||
RefPtr<gfxASurface> mTransparentSurface;
|
||||
HDC mMemoryDC;
|
||||
|
|
|
@ -325,6 +325,8 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel)
|
|||
#if defined(MOZ_XUL)
|
||||
// don't support transparency for non-GDI rendering, for now
|
||||
if (eTransparencyTransparent == mTransparencyMode) {
|
||||
// This mutex needs to be held when EnsureTransparentSurface is called.
|
||||
MutexAutoLock lock(mBasicLayersSurface->GetTransparentSurfaceLock());
|
||||
targetSurface = mBasicLayersSurface->EnsureTransparentSurface();
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче