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 GFXGDKNATIVERENDER_H_ michael@0: #define GFXGDKNATIVERENDER_H_ michael@0: michael@0: #include michael@0: #include "nsSize.h" michael@0: #ifdef MOZ_X11 michael@0: #include "gfxXlibNativeRenderer.h" michael@0: #endif michael@0: michael@0: class gfxContext; michael@0: michael@0: /** michael@0: * This class lets us take code that draws into an GDK drawable and lets us michael@0: * use it to draw into any Thebes context. The user should subclass this class, michael@0: * override DrawWithGDK, and then call Draw(). The drawing will be subjected michael@0: * to all Thebes transformations, clipping etc. michael@0: */ michael@0: class gfxGdkNativeRenderer michael@0: #ifdef MOZ_X11 michael@0: : private gfxXlibNativeRenderer michael@0: #endif michael@0: { 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: michael@0: #if (MOZ_WIDGET_GTK == 2) michael@0: virtual nsresult DrawWithGDK(GdkDrawable * drawable, gint offsetX, michael@0: gint offsetY, GdkRectangle * clipRects, uint32_t numClipRects) = 0; michael@0: #endif 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 = michael@0: #ifdef MOZ_X11 michael@0: gfxXlibNativeRenderer::DRAW_IS_OPAQUE michael@0: #else michael@0: 0x1 michael@0: #endif michael@0: // If set, then numClipRects can be zero or one. michael@0: // If not set, then numClipRects will be zero. michael@0: , DRAW_SUPPORTS_CLIP_RECT = michael@0: #ifdef MOZ_X11 michael@0: gfxXlibNativeRenderer::DRAW_SUPPORTS_CLIP_RECT michael@0: #else michael@0: 0x2 michael@0: #endif michael@0: }; michael@0: michael@0: /** michael@0: * @param flags see above michael@0: * @param bounds Draw()'s drawing is guaranteed to be restricted to michael@0: * the rectangle (offset.x,offset.y,bounds.width,bounds.height) michael@0: * @param dpy a display to use for the drawing if ctx doesn't have one michael@0: */ michael@0: #if (MOZ_WIDGET_GTK == 2) michael@0: void Draw(gfxContext* ctx, nsIntSize size, michael@0: uint32_t flags, GdkColormap* colormap); michael@0: #endif michael@0: michael@0: private: michael@0: #ifdef MOZ_X11 michael@0: // for gfxXlibNativeRenderer: michael@0: virtual nsresult DrawWithXlib(cairo_surface_t* surface, michael@0: nsIntPoint offset, michael@0: nsIntRect* clipRects, uint32_t numClipRects) MOZ_OVERRIDE; michael@0: michael@0: #if (MOZ_WIDGET_GTK == 2) michael@0: GdkColormap *mColormap; michael@0: #endif michael@0: #endif michael@0: }; michael@0: michael@0: #endif /*GFXGDKNATIVERENDER_H_*/