Bug 565833: Required changes to the GTK widget to support GL accelerated rendering. r=vlad

This commit is contained in:
Matt Woodrow 2010-06-17 16:23:00 -05:00
parent 9ae1b68f3b
commit a527dd8f71
2 changed files with 37 additions and 0 deletions

View File

@ -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<mozilla::layers::LayerManagerOGL*>(GetLayerManager());
manager->SetClippingRegion(event.region);
nsEventStatus status;
DispatchEvent(&event, status);
g_free(rects);
return TRUE;
}
nsRefPtr<gfxContext> 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()

View File

@ -328,6 +328,7 @@ public:
nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
PRUint8* aAlphas, PRInt32 aStride);
virtual LayerManager* GetLayerManager();
gfxASurface *GetThebesSurface();
static already_AddRefed<gfxASurface> GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,