Bug 868259 - Fix BasicCompositor rendering. r=roc

This commit is contained in:
Matt Woodrow 2013-05-10 09:02:50 +12:00
parent de82bbc24f
commit 5ae991f717
5 changed files with 36 additions and 6 deletions

View File

@ -73,7 +73,9 @@ public:
void SetTransactionIncomplete() { mTransactionIncomplete = true; } void SetTransactionIncomplete() { mTransactionIncomplete = true; }
bool HasShadowTarget() { return !!mShadowTarget; } bool HasShadowTarget() { return !!mShadowTarget; }
void SetShadowTarget(gfxContext *aTarget) { mShadowTarget = aTarget; }
bool CompositorMightResample() { return mCompositorMightResample; } bool CompositorMightResample() { return mCompositorMightResample; }

View File

@ -51,6 +51,7 @@
#include "nsRegion.h" #include "nsRegion.h"
#include "Layers.h" #include "Layers.h"
#include "LayerManagerOGL.h" #include "LayerManagerOGL.h"
#include "ClientLayerManager.h"
#include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/LayerManagerComposite.h"
#include "GLTextureImage.h" #include "GLTextureImage.h"
#include "mozilla/layers/GLManager.h" #include "mozilla/layers/GLManager.h"
@ -1873,6 +1874,9 @@ void
nsChildView::PreRender(LayerManager* aManager) nsChildView::PreRender(LayerManager* aManager)
{ {
nsAutoPtr<GLManager> manager(GLManager::CreateGLManager(aManager)); nsAutoPtr<GLManager> manager(GLManager::CreateGLManager(aManager));
if (!manager) {
return;
}
NSOpenGLContext *glContext = (NSOpenGLContext *)manager->gl()->GetNativeData(GLContext::NativeGLContext); NSOpenGLContext *glContext = (NSOpenGLContext *)manager->gl()->GetNativeData(GLContext::NativeGLContext);
[(ChildView*)mView preRender:glContext]; [(ChildView*)mView preRender:glContext];
} }
@ -2864,6 +2868,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
painted = mGeckoChild->PaintWindow(region, aIsAlternate); painted = mGeckoChild->PaintWindow(region, aIsAlternate);
} else if (mGeckoChild->GetLayerManager()->GetBackendType() == LAYERS_CLIENT) { } else if (mGeckoChild->GetLayerManager()->GetBackendType() == LAYERS_CLIENT) {
// We only need this so that we actually get DidPaintWindow fired // We only need this so that we actually get DidPaintWindow fired
if (Compositor::GetBackend() == LAYERS_BASIC) {
ClientLayerManager *manager = static_cast<ClientLayerManager*>(mGeckoChild->GetLayerManager());
manager->SetShadowTarget(targetContext);
}
painted = mGeckoChild->PaintWindow(region, aIsAlternate); painted = mGeckoChild->PaintWindow(region, aIsAlternate);
} }

View File

@ -2122,7 +2122,8 @@ nsWindow::OnExposeEvent(cairo_t *cr)
return TRUE; return TRUE;
} }
// If this widget uses OMTC... // If this widget uses OMTC...
if (GetLayerManager()->AsShadowForwarder() && GetLayerManager()->AsShadowForwarder()->HasShadowManager()) { if (GetLayerManager()->AsShadowForwarder() && GetLayerManager()->AsShadowForwarder()->HasShadowManager() &&
Compositor::GetBackend() != LAYERS_BASIC) {
listener->DidPaintWindow(); listener->DidPaintWindow();
g_free(rects); g_free(rects);
@ -2194,8 +2195,14 @@ nsWindow::OnExposeEvent(cairo_t *cr)
bool painted = false; bool painted = false;
{ {
AutoLayerManagerSetup setupLayerManager(this, ctx, layerBuffering); if (GetLayerManager()->GetBackendType() == LAYERS_BASIC) {
painted = listener->PaintWindow(this, region, 0); AutoLayerManagerSetup setupLayerManager(this, ctx, layerBuffering);
painted = listener->PaintWindow(this, region, 0);
} else if (GetLayerManager()->GetBackendType() == LAYERS_CLIENT) {
ClientLayerManager *manager = static_cast<ClientLayerManager*>(GetLayerManager());
manager->SetShadowTarget(ctx);
painted = listener->PaintWindow(this, region, 0);
}
} }
#ifdef MOZ_X11 #ifdef MOZ_X11

View File

@ -875,6 +875,20 @@ void nsBaseWidget::CreateCompositor()
CreateCompositor(rect.width, rect.height); CreateCompositor(rect.width, rect.height);
} }
mozilla::layers::LayersBackend
nsBaseWidget::GetPreferredCompositorBackend()
{
// We need a separate preference here (instead of using mUseLayersAcceleration)
// because we force enable accelerated layers with e10s. Once the BasicCompositor
// is stable enough to be used for Ripc/Cipc, then we can remove that and this
// pref.
if (Preferences::GetBool("layers.offmainthreadcomposition.prefer-basic", false)) {
return mozilla::layers::LAYERS_BASIC;
}
return mozilla::layers::LAYERS_OPENGL;
}
void nsBaseWidget::CreateCompositor(int aWidth, int aHeight) void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
{ {
// Recreating this is tricky, as we may still have an old and we need // Recreating this is tricky, as we may still have an old and we need

View File

@ -337,8 +337,7 @@ protected:
virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE; virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;
virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend() virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend();
{ return mUseLayersAcceleration ? mozilla::layers::LAYERS_OPENGL : mozilla::layers::LAYERS_BASIC; }
protected: protected:
/** /**