gfx/thebes/gfxXlibNativeRenderer.h

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

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef GFXXLIBNATIVERENDER_H_
michael@0 7 #define GFXXLIBNATIVERENDER_H_
michael@0 8
michael@0 9 #include "nsPoint.h"
michael@0 10 #include "nsRect.h"
michael@0 11 #include <X11/Xlib.h>
michael@0 12
michael@0 13 namespace mozilla {
michael@0 14 namespace gfx {
michael@0 15 class DrawTarget;
michael@0 16 }
michael@0 17 }
michael@0 18
michael@0 19 class gfxASurface;
michael@0 20 class gfxContext;
michael@0 21 struct nsIntRect;
michael@0 22 struct nsIntPoint;
michael@0 23 struct nsIntSize;
michael@0 24 typedef struct _cairo cairo_t;
michael@0 25 typedef struct _cairo_surface cairo_surface_t;
michael@0 26
michael@0 27 /**
michael@0 28 * This class lets us take code that draws into an X drawable and lets us
michael@0 29 * use it to draw into any Thebes context. The user should subclass this class,
michael@0 30 * override DrawWithXib, and then call Draw(). The drawing will be subjected
michael@0 31 * to all Thebes transformations, clipping etc.
michael@0 32 */
michael@0 33 class gfxXlibNativeRenderer {
michael@0 34 public:
michael@0 35 /**
michael@0 36 * Perform the native drawing.
michael@0 37 * @param surface the cairo_surface_t for drawing. Must be a cairo_xlib_surface_t.
michael@0 38 * The extents of this surface do not necessarily cover the
michael@0 39 * entire rectangle with size provided to Draw().
michael@0 40 * @param offset draw at this offset into the given drawable
michael@0 41 * @param clipRects an array of rectangles; clip to the union.
michael@0 42 * Any rectangles provided will be contained by the
michael@0 43 * rectangle with size provided to Draw and by the
michael@0 44 * surface extents.
michael@0 45 * @param numClipRects the number of rects in the array, or zero if
michael@0 46 * no clipping is required.
michael@0 47 */
michael@0 48 virtual nsresult DrawWithXlib(cairo_surface_t* surface,
michael@0 49 nsIntPoint offset,
michael@0 50 nsIntRect* clipRects, uint32_t numClipRects) = 0;
michael@0 51
michael@0 52 enum {
michael@0 53 // If set, then Draw() is opaque, i.e., every pixel in the intersection
michael@0 54 // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
michael@0 55 // will be set and there is no dependence on what the existing pixels
michael@0 56 // in the drawable are set to.
michael@0 57 DRAW_IS_OPAQUE = 0x01,
michael@0 58 // If set, then numClipRects can be zero or one
michael@0 59 DRAW_SUPPORTS_CLIP_RECT = 0x04,
michael@0 60 // If set, then numClipRects can be any value. If neither this
michael@0 61 // nor CLIP_RECT are set, then numClipRects will be zero
michael@0 62 DRAW_SUPPORTS_CLIP_LIST = 0x08,
michael@0 63 // If set, then the surface in the callback may have any visual;
michael@0 64 // otherwise the pixels will have the same format as the visual
michael@0 65 // passed to 'Draw'.
michael@0 66 DRAW_SUPPORTS_ALTERNATE_VISUAL = 0x10,
michael@0 67 // If set, then the Screen 'screen' in the callback can be different
michael@0 68 // from the default Screen of the display passed to 'Draw' and can be
michael@0 69 // on a different display.
michael@0 70 DRAW_SUPPORTS_ALTERNATE_SCREEN = 0x20
michael@0 71 };
michael@0 72
michael@0 73 /**
michael@0 74 * @param flags see above
michael@0 75 * @param size the size of the rectangle being drawn;
michael@0 76 * the caller guarantees that drawing will not extend beyond the rectangle
michael@0 77 * (0,0,size.width,size.height).
michael@0 78 * @param screen a Screen to use for the drawing if ctx doesn't have one.
michael@0 79 * @param visual a Visual to use for the drawing if ctx doesn't have one.
michael@0 80 * @param result if non-null, we will try to capture a copy of the
michael@0 81 * rendered image into a surface similar to the surface of ctx; if
michael@0 82 * successful, a pointer to the new gfxASurface is stored in *resultSurface,
michael@0 83 * otherwise *resultSurface is set to nullptr.
michael@0 84 */
michael@0 85 void Draw(gfxContext* ctx, nsIntSize size,
michael@0 86 uint32_t flags, Screen *screen, Visual *visual);
michael@0 87
michael@0 88 private:
michael@0 89 bool DrawDirect(gfxContext *ctx, nsIntSize bounds,
michael@0 90 uint32_t flags, Screen *screen, Visual *visual);
michael@0 91
michael@0 92 bool DrawCairo(cairo_t* cr, nsIntSize size,
michael@0 93 uint32_t flags, Screen *screen, Visual *visual);
michael@0 94
michael@0 95 void DrawFallback(mozilla::gfx::DrawTarget* dt, gfxContext* ctx,
michael@0 96 gfxASurface* aSurface, nsIntSize& size,
michael@0 97 nsIntRect& drawingRect, bool canDrawOverBackground,
michael@0 98 uint32_t flags, Screen* screen, Visual* visual);
michael@0 99
michael@0 100 bool DrawOntoTempSurface(cairo_surface_t *tempXlibSurface,
michael@0 101 nsIntPoint offset);
michael@0 102
michael@0 103 };
michael@0 104
michael@0 105 #endif /*GFXXLIBNATIVERENDER_H_*/

mercurial