gfx/thebes/gfxGdkNativeRenderer.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "gfxGdkNativeRenderer.h"
     7 #include "gfxContext.h"
     8 #include "gfxPlatformGtk.h"
    10 #ifdef MOZ_X11
    11 #include <gdk/gdkx.h>
    12 #include "cairo-xlib.h"
    13 #include "gfxXlibSurface.h"
    15 #if (MOZ_WIDGET_GTK == 2)
    16 nsresult
    17 gfxGdkNativeRenderer::DrawWithXlib(cairo_surface_t* surface,
    18                                    nsIntPoint offset,
    19                                    nsIntRect* clipRects, uint32_t numClipRects)
    20 {
    21     GdkDrawable *drawable = gfxPlatformGtk::GetGdkDrawable(surface);
    22     if (!drawable) {
    23         int depth = cairo_xlib_surface_get_depth(surface);
    24         GdkScreen* screen = gdk_colormap_get_screen(mColormap);
    25         drawable =
    26             gdk_pixmap_foreign_new_for_screen(screen, cairo_xlib_surface_get_drawable(surface),
    27                                               cairo_xlib_surface_get_width(surface),
    28                                               cairo_xlib_surface_get_height(surface),
    29                                               depth);
    30         if (!drawable)
    31             return NS_ERROR_FAILURE;
    33         gdk_drawable_set_colormap(drawable, mColormap);
    34         gfxPlatformGtk::SetGdkDrawable(surface, drawable);
    35         g_object_unref(drawable); // The drawable now belongs to |surface|.
    36     }
    38     GdkRectangle clipRect;
    39     if (numClipRects) {
    40         NS_ASSERTION(numClipRects == 1, "Too many clip rects");
    41         clipRect.x = clipRects[0].x;
    42         clipRect.y = clipRects[0].y;
    43         clipRect.width = clipRects[0].width;
    44         clipRect.height = clipRects[0].height;
    45     }
    47     return DrawWithGDK(drawable, offset.x, offset.y,
    48                        numClipRects ? &clipRect : nullptr, numClipRects);
    49 }
    51 void
    52 gfxGdkNativeRenderer::Draw(gfxContext* ctx, nsIntSize size,
    53                            uint32_t flags, GdkColormap* colormap)
    54 {
    55     mColormap = colormap;
    57     Visual* visual =
    58         gdk_x11_visual_get_xvisual(gdk_colormap_get_visual(colormap));
    59     Screen* screen =
    60         gdk_x11_screen_get_xscreen(gdk_colormap_get_screen(colormap));
    62     gfxXlibNativeRenderer::Draw(ctx, size, flags, screen, visual);
    63 }
    65 #else
    66 // TODO GTK3
    67 #endif
    69 #endif

mercurial