diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index 55587b3a0b7..d1751162495 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -127,6 +127,9 @@ extern "C" { #include "gfxPlatformGtk.h" #include "gfxContext.h" #include "gfxImageSurface.h" +#include "Layers.h" +#include "LayerManagerOGL.h" +#include "GLContextProvider.h" #ifdef MOZ_X11 #include "gfxXlibSurface.h" @@ -715,6 +718,9 @@ nsWindow::Destroy(void) if (mIsDestroyed || !mCreated) return NS_OK; + /** Need to clean our LayerManager up while still alive */ + mLayerManager = NULL; + LOG(("nsWindow::Destroy [%p]\n", (void *)this)); mIsDestroyed = PR_TRUE; mCreated = PR_FALSE; @@ -2354,6 +2360,17 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent) return TRUE; } + if (GetLayerManager()->GetBackendType() == LayerManager::LAYERS_OPENGL) + { + mozilla::layers::LayerManagerOGL *manager = static_cast(GetLayerManager()); + manager->SetClippingRegion(event.region); + + nsEventStatus status; + DispatchEvent(&event, status); + g_free(rects); + return TRUE; + } + nsRefPtr ctx = new gfxContext(GetThebesSurface()); if (NS_UNLIKELY(!ctx)) { g_free(rects); @@ -6748,6 +6765,25 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable, } #endif +mozilla::layers::LayerManager* +nsWindow::GetLayerManager() +{ + GtkWidget *topWidget; + GetToplevelWidget(&topWidget); + + nsWindow *topWindow = get_window_for_gtk_widget(topWidget); + if (!topWindow) { + return nsBaseWidget::GetLayerManager(); + } + + if (mUseAcceleratedRendering != topWindow->GetAcceleratedRendering()) { + mLayerManager = NULL; + mUseAcceleratedRendering = topWindow->GetAcceleratedRendering(); + } + + return nsBaseWidget::GetLayerManager(); +} + // return the gfxASurface for rendering to this widget gfxASurface* nsWindow::GetThebesSurface() diff --git a/widget/src/gtk2/nsWindow.h b/widget/src/gtk2/nsWindow.h index 8df030d598c..10424780f62 100644 --- a/widget/src/gtk2/nsWindow.h +++ b/widget/src/gtk2/nsWindow.h @@ -328,6 +328,7 @@ public: nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect, PRUint8* aAlphas, PRInt32 aStride); + virtual LayerManager* GetLayerManager(); gfxASurface *GetThebesSurface(); static already_AddRefed GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,