Bug 885580 - Make sure that Compositor::GetBackend is only used [Cfrom the compositor thread. r=nical

This commit is contained in:
Matt Woodrow 2013-06-27 11:30:52 +12:00
Родитель 6ede90be99
Коммит 8baed26d9b
6 изменённых файлов: 20 добавлений и 13 удалений

Просмотреть файл

@ -5,6 +5,7 @@
#include "mozilla/layers/Compositor.h"
#include "mozilla/layers/Effects.h"
#include "mozilla/layers/CompositorParent.h"
namespace mozilla {
namespace layers {
@ -13,6 +14,9 @@ namespace layers {
/* static */ LayersBackend
Compositor::GetBackend()
{
MOZ_ASSERT(CompositorParent::CompositorLoop() ==
MessageLoop::current(),
"Can only call this from the compositor thread!");
return sBackend;
}

Просмотреть файл

@ -391,6 +391,8 @@ public:
* thread at the same time. The backend type in use can be checked with this
* static method. We need this for creating texture clients/hosts etc. when we
* don't have a reference to a Compositor.
*
* This can only be used from the compositor thread!
*/
static LayersBackend GetBackend();

Просмотреть файл

@ -383,7 +383,7 @@ ClientLayerManager::ClearLayer(Layer* aLayer)
void
ClientLayerManager::GetBackendName(nsAString& aName)
{
switch (Compositor::GetBackend()) {
switch (GetCompositorBackendType()) {
case LAYERS_BASIC: aName.AssignLiteral("Basic"); return;
case LAYERS_OPENGL: aName.AssignLiteral("OpenGL"); return;
case LAYERS_D3D9: aName.AssignLiteral("Direct3D 9"); return;

Просмотреть файл

@ -55,7 +55,7 @@ public:
virtual void FlushRendering() MOZ_OVERRIDE;
virtual bool NeedsWidgetInvalidation() MOZ_OVERRIDE { return Compositor::GetBackend() == LAYERS_BASIC; }
virtual bool NeedsWidgetInvalidation() MOZ_OVERRIDE { return GetCompositorBackendType() == LAYERS_BASIC; }
ShadowableLayer* Hold(Layer* aLayer);

Просмотреть файл

@ -1387,7 +1387,7 @@ NS_IMETHODIMP nsChildView::Invalidate(const nsIntRect &aRect)
return NS_OK;
NS_ASSERTION(GetLayerManager()->GetBackendType() != LAYERS_CLIENT ||
Compositor::GetBackend() == LAYERS_BASIC,
static_cast<ClientLayerManager*>(GetLayerManager())->GetCompositorBackendType() == LAYERS_BASIC,
"Shouldn't need to invalidate with accelerated OMTC layers!");
if ([NSView focusView]) {
@ -1821,8 +1821,8 @@ nsChildView::CreateCompositor()
compositor::GetLayerManager(mCompositorParent);
Compositor *compositor = manager->GetCompositor();
LayersBackend backend = compositor->GetBackend();
if (backend == LAYERS_OPENGL) {
ClientLayerManager *clientManager = static_cast<ClientLayerManager*>(GetLayerManager());
if (clientManager->GetCompositorBackendType() == LAYERS_OPENGL) {
CompositorOGL *compositorOGL = static_cast<CompositorOGL*>(compositor);
NSOpenGLContext *glContext = (NSOpenGLContext *)compositorOGL->gl()->GetNativeData(GLContext::NativeGLContext);
@ -3073,8 +3073,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
painted = mGeckoChild->PaintWindow(region);
} else if (mGeckoChild->GetLayerManager()->GetBackendType() == LAYERS_CLIENT) {
// We only need this so that we actually get DidPaintWindow fired
if (Compositor::GetBackend() == LAYERS_BASIC) {
ClientLayerManager *manager = static_cast<ClientLayerManager*>(mGeckoChild->GetLayerManager());
ClientLayerManager *manager = static_cast<ClientLayerManager*>(mGeckoChild->GetLayerManager());
if (manager->GetCompositorBackendType() == LAYERS_BASIC) {
manager->SetShadowTarget(targetContext);
}
painted = mGeckoChild->PaintWindow(region);

Просмотреть файл

@ -2124,13 +2124,14 @@ nsWindow::OnExposeEvent(cairo_t *cr)
return TRUE;
}
// If this widget uses OMTC...
if (GetLayerManager()->AsShadowForwarder() && GetLayerManager()->AsShadowForwarder()->HasShadowManager() &&
Compositor::GetBackend() != LAYERS_BASIC) {
listener->DidPaintWindow();
g_free(rects);
return TRUE;
if (GetLayerManager()->GetBackendType() == LAYERS_CLIENT) {
ClientLayerManager *manager = static_cast<ClientLayerManager*>(GetLayerManager());
if (manager->GetCompositorBackendType() != LAYERS_BASIC) {
listener->DidPaintWindow();
g_free(rects);
return TRUE;
}
} else if (GetLayerManager()->GetBackendType() == mozilla::layers::LAYERS_OPENGL) {
LayerManagerOGL *manager = static_cast<LayerManagerOGL*>(GetLayerManager());
manager->SetClippingRegion(region);