Skip to content

Commit

Permalink
Bug 868259 - Fix BasicCompositor rendering. r=roc
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwoodrow committed May 9, 2013
1 parent 8fb135c commit f6a99c3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
4 changes: 3 additions & 1 deletion gfx/layers/client/ClientLayerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class ClientLayerManager : public LayerManager,

void SetTransactionIncomplete() { mTransactionIncomplete = true; }

bool HasShadowTarget() { return !!mShadowTarget; }
bool HasShadowTarget() { return !!mShadowTarget; }

void SetShadowTarget(gfxContext *aTarget) { mShadowTarget = aTarget; }

bool CompositorMightResample() { return mCompositorMightResample; }

Expand Down
8 changes: 8 additions & 0 deletions widget/cocoa/nsChildView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "nsRegion.h"
#include "Layers.h"
#include "LayerManagerOGL.h"
#include "ClientLayerManager.h"
#include "mozilla/layers/LayerManagerComposite.h"
#include "GLTextureImage.h"
#include "mozilla/layers/GLManager.h"
Expand Down Expand Up @@ -1873,6 +1874,9 @@ inline uint16_t COLOR8TOCOLOR16(uint8_t color8)
nsChildView::PreRender(LayerManager* aManager)
{
nsAutoPtr<GLManager> manager(GLManager::CreateGLManager(aManager));
if (!manager) {
return;
}
NSOpenGLContext *glContext = (NSOpenGLContext *)manager->gl()->GetNativeData(GLContext::NativeGLContext);
[(ChildView*)mView preRender:glContext];
}
Expand Down Expand Up @@ -2864,6 +2868,10 @@ - (void)drawRect:(NSRect)aRect inContext:(CGContextRef)aContext alternate:(BOOL)
painted = mGeckoChild->PaintWindow(region, aIsAlternate);
} 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());
manager->SetShadowTarget(targetContext);
}
painted = mGeckoChild->PaintWindow(region, aIsAlternate);
}

Expand Down
13 changes: 10 additions & 3 deletions widget/gtk2/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,8 @@ nsWindow::OnExposeEvent(cairo_t *cr)
return TRUE;
}
// If this widget uses OMTC...
if (GetLayerManager()->AsShadowForwarder() && GetLayerManager()->AsShadowForwarder()->HasShadowManager()) {
if (GetLayerManager()->AsShadowForwarder() && GetLayerManager()->AsShadowForwarder()->HasShadowManager() &&
Compositor::GetBackend() != LAYERS_BASIC) {
listener->DidPaintWindow();

g_free(rects);
Expand Down Expand Up @@ -2194,8 +2195,14 @@ nsWindow::OnExposeEvent(cairo_t *cr)

bool painted = false;
{
AutoLayerManagerSetup setupLayerManager(this, ctx, layerBuffering);
painted = listener->PaintWindow(this, region, 0);
if (GetLayerManager()->GetBackendType() == LAYERS_BASIC) {
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
Expand Down
14 changes: 14 additions & 0 deletions widget/xpwidgets/nsBaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,20 @@ void nsBaseWidget::CreateCompositor()
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)
{
// Recreating this is tricky, as we may still have an old and we need
Expand Down
3 changes: 1 addition & 2 deletions widget/xpwidgets/nsBaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ class nsBaseWidget : public nsIWidget

virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;

virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend()
{ return mUseLayersAcceleration ? mozilla::layers::LAYERS_OPENGL : mozilla::layers::LAYERS_BASIC; }
virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend();

protected:
/**
Expand Down

0 comments on commit f6a99c3

Please sign in to comment.