michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFXQTNATIVERENDER_H_ michael@0: #define GFXQTNATIVERENDER_H_ michael@0: michael@0: #include "gfxColor.h" michael@0: #include "gfxContext.h" michael@0: #include "gfxXlibSurface.h" michael@0: michael@0: class QRect; michael@0: struct nsIntRect; michael@0: michael@0: /** michael@0: * This class lets us take code that draws into an Xlib surface drawable and lets us michael@0: * use it to draw into any Thebes context. The user should subclass this class, michael@0: * override NativeDraw, and then call Draw(). The drawing will be subjected michael@0: * to all Thebes transformations, clipping etc. michael@0: */ michael@0: class gfxQtNativeRenderer { michael@0: public: michael@0: /** michael@0: * Perform the native drawing. michael@0: * @param offsetX draw at this offset into the given drawable michael@0: * @param offsetY draw at this offset into the given drawable michael@0: * @param clipRects an array of rects; clip to the union michael@0: * @param numClipRects the number of rects in the array, or zero if michael@0: * no clipping is required michael@0: */ michael@0: virtual nsresult DrawWithXlib(cairo_surface_t* surface, michael@0: nsIntPoint offset, michael@0: nsIntRect* clipRects, uint32_t numClipRects) = 0; michael@0: michael@0: enum { michael@0: // If set, then Draw() is opaque, i.e., every pixel in the intersection michael@0: // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height) michael@0: // will be set and there is no dependence on what the existing pixels michael@0: // in the drawable are set to. michael@0: DRAW_IS_OPAQUE = 0x01, michael@0: // If set, then numClipRects can be zero or one michael@0: DRAW_SUPPORTS_CLIP_RECT = 0x04, michael@0: // If set, then numClipRects can be any value. If neither this michael@0: // nor CLIP_RECT are set, then numClipRects will be zero michael@0: DRAW_SUPPORTS_CLIP_LIST = 0x08, michael@0: // If set, then the visual passed in can be any visual, otherwise the michael@0: // visual passed in must be the default visual for dpy's default screen michael@0: DRAW_SUPPORTS_ALTERNATE_VISUAL = 0x10, michael@0: // If set, then the Screen 'screen' in the callback can be different michael@0: // from the default Screen of the display passed to 'Draw' and can be michael@0: // on a different display. michael@0: DRAW_SUPPORTS_ALTERNATE_SCREEN = 0x20 michael@0: }; michael@0: michael@0: /** michael@0: * @param flags see above michael@0: * @param size Draw()'s drawing is guaranteed to be restricted to michael@0: * the rectangle (offset.x,offset.y,size.width,size.height) michael@0: * @param dpy a display to use for the drawing if ctx doesn't have one michael@0: * @param resultSurface if non-null, we will try to capture a copy of the michael@0: * rendered image into a surface similar to the surface of ctx; if michael@0: * successful, a pointer to the new gfxASurface is stored in *resultSurface, michael@0: * otherwise *resultSurface is set to nullptr. michael@0: */ michael@0: nsresult Draw(gfxContext* ctx, nsIntSize size, michael@0: uint32_t flags, Screen* screen, Visual* visual); michael@0: }; michael@0: michael@0: #endif /*GFXQTNATIVERENDER_H_*/