Bug 1013552 - [GTK3] GetThebesSurface() provides xlib surface when cairo target is not available. r=karlt

This commit is contained in:
Martin Stransky 2014-06-02 03:36:00 -04:00
Родитель cf5f0d516e
Коммит 364c9717d2
2 изменённых файлов: 26 добавлений и 30 удалений

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

@ -6022,12 +6022,7 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
TemporaryRef<DrawTarget>
nsWindow::StartRemoteDrawing()
{
#if (MOZ_WIDGET_GTK == 2)
gfxASurface *surf = GetThebesSurface();
#else
// TODO GTK3
gfxASurface *surf = nullptr;
#endif
if (!surf) {
return nullptr;
}
@ -6042,23 +6037,18 @@ nsWindow::StartRemoteDrawing()
// return the gfxASurface for rendering to this widget
gfxASurface*
#if (MOZ_WIDGET_GTK == 2)
nsWindow::GetThebesSurface()
#else
#if (MOZ_WIDGET_GTK == 3)
{
return GetThebesSurface(nullptr);
}
gfxASurface*
nsWindow::GetThebesSurface(cairo_t *cr)
#endif
{
if (!mGdkWindow)
return nullptr;
#if (MOZ_WIDGET_GTK != 2)
cairo_surface_t *surf = cairo_get_target(cr);
if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) {
NS_NOTREACHED("Missing cairo target?");
return nullptr;
}
#endif // MOZ_WIDGET_GTK2
#ifdef MOZ_X11
gint width, height;
@ -6092,21 +6082,27 @@ nsWindow::GetThebesSurface(cairo_t *cr)
if (!usingShm)
# endif // MOZ_HAVE_SHMIMAGE
#if (MOZ_WIDGET_GTK == 2)
mThebesSurface = new gfxXlibSurface
(GDK_WINDOW_XDISPLAY(mGdkWindow),
gdk_x11_window_get_xid(mGdkWindow),
visual,
size);
#else
#if (MOZ_WIDGET_GTK == 3)
#if MOZ_TREE_CAIRO
#error "cairo-gtk3 target must be built with --enable-system-cairo"
#else
mThebesSurface = gfxASurface::Wrap(surf);
#endif
#else
if (cr) {
cairo_surface_t *surf = cairo_get_target(cr);
if (cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS) {
NS_NOTREACHED("Missing cairo target?");
return nullptr;
}
mThebesSurface = gfxASurface::Wrap(surf);
} else
#endif
#endif // (MOZ_WIDGET_GTK == 3)
mThebesSurface = new gfxXlibSurface
(GDK_WINDOW_XDISPLAY(mGdkWindow),
gdk_x11_window_get_xid(mGdkWindow),
visual,
size);
#endif
#endif // MOZ_X11
// if the surface creation is reporting an error, then
// we don't have a surface to give back

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

@ -282,14 +282,11 @@ public:
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations);
nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
uint8_t* aAlphas, int32_t aStride);
virtual gfxASurface *GetThebesSurface() MOZ_OVERRIDE;
#if (MOZ_WIDGET_GTK == 2)
gfxASurface *GetThebesSurface();
static already_AddRefed<gfxASurface> GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
const nsIntSize& aSize);
#else
gfxASurface *GetThebesSurface(cairo_t *cr);
#endif
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
@ -446,6 +443,9 @@ private:
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nullptr) MOZ_OVERRIDE;
#if (MOZ_WIDGET_GTK == 3)
gfxASurface* GetThebesSurface(cairo_t *cr);
#endif
void CleanLayerManagerRecursive();