1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxQtNativeRenderer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFXQTNATIVERENDER_H_ 1.10 +#define GFXQTNATIVERENDER_H_ 1.11 + 1.12 +#include "gfxColor.h" 1.13 +#include "gfxContext.h" 1.14 +#include "gfxXlibSurface.h" 1.15 + 1.16 +class QRect; 1.17 +struct nsIntRect; 1.18 + 1.19 +/** 1.20 + * This class lets us take code that draws into an Xlib surface drawable and lets us 1.21 + * use it to draw into any Thebes context. The user should subclass this class, 1.22 + * override NativeDraw, and then call Draw(). The drawing will be subjected 1.23 + * to all Thebes transformations, clipping etc. 1.24 + */ 1.25 +class gfxQtNativeRenderer { 1.26 +public: 1.27 + /** 1.28 + * Perform the native drawing. 1.29 + * @param offsetX draw at this offset into the given drawable 1.30 + * @param offsetY draw at this offset into the given drawable 1.31 + * @param clipRects an array of rects; clip to the union 1.32 + * @param numClipRects the number of rects in the array, or zero if 1.33 + * no clipping is required 1.34 + */ 1.35 + virtual nsresult DrawWithXlib(cairo_surface_t* surface, 1.36 + nsIntPoint offset, 1.37 + nsIntRect* clipRects, uint32_t numClipRects) = 0; 1.38 + 1.39 + enum { 1.40 + // If set, then Draw() is opaque, i.e., every pixel in the intersection 1.41 + // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height) 1.42 + // will be set and there is no dependence on what the existing pixels 1.43 + // in the drawable are set to. 1.44 + DRAW_IS_OPAQUE = 0x01, 1.45 + // If set, then numClipRects can be zero or one 1.46 + DRAW_SUPPORTS_CLIP_RECT = 0x04, 1.47 + // If set, then numClipRects can be any value. If neither this 1.48 + // nor CLIP_RECT are set, then numClipRects will be zero 1.49 + DRAW_SUPPORTS_CLIP_LIST = 0x08, 1.50 + // If set, then the visual passed in can be any visual, otherwise the 1.51 + // visual passed in must be the default visual for dpy's default screen 1.52 + DRAW_SUPPORTS_ALTERNATE_VISUAL = 0x10, 1.53 + // If set, then the Screen 'screen' in the callback can be different 1.54 + // from the default Screen of the display passed to 'Draw' and can be 1.55 + // on a different display. 1.56 + DRAW_SUPPORTS_ALTERNATE_SCREEN = 0x20 1.57 + }; 1.58 + 1.59 + /** 1.60 + * @param flags see above 1.61 + * @param size Draw()'s drawing is guaranteed to be restricted to 1.62 + * the rectangle (offset.x,offset.y,size.width,size.height) 1.63 + * @param dpy a display to use for the drawing if ctx doesn't have one 1.64 + * @param resultSurface if non-null, we will try to capture a copy of the 1.65 + * rendered image into a surface similar to the surface of ctx; if 1.66 + * successful, a pointer to the new gfxASurface is stored in *resultSurface, 1.67 + * otherwise *resultSurface is set to nullptr. 1.68 + */ 1.69 + nsresult Draw(gfxContext* ctx, nsIntSize size, 1.70 + uint32_t flags, Screen* screen, Visual* visual); 1.71 +}; 1.72 + 1.73 +#endif /*GFXQTNATIVERENDER_H_*/