1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxGdkNativeRenderer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 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 GFXGDKNATIVERENDER_H_ 1.10 +#define GFXGDKNATIVERENDER_H_ 1.11 + 1.12 +#include <gdk/gdk.h> 1.13 +#include "nsSize.h" 1.14 +#ifdef MOZ_X11 1.15 +#include "gfxXlibNativeRenderer.h" 1.16 +#endif 1.17 + 1.18 +class gfxContext; 1.19 + 1.20 +/** 1.21 + * This class lets us take code that draws into an GDK drawable and lets us 1.22 + * use it to draw into any Thebes context. The user should subclass this class, 1.23 + * override DrawWithGDK, and then call Draw(). The drawing will be subjected 1.24 + * to all Thebes transformations, clipping etc. 1.25 + */ 1.26 +class gfxGdkNativeRenderer 1.27 +#ifdef MOZ_X11 1.28 + : private gfxXlibNativeRenderer 1.29 +#endif 1.30 +{ 1.31 +public: 1.32 + /** 1.33 + * Perform the native drawing. 1.34 + * @param offsetX draw at this offset into the given drawable 1.35 + * @param offsetY draw at this offset into the given drawable 1.36 + * @param clipRects an array of rects; clip to the union 1.37 + * @param numClipRects the number of rects in the array, or zero if 1.38 + * no clipping is required 1.39 + */ 1.40 + 1.41 +#if (MOZ_WIDGET_GTK == 2) 1.42 + virtual nsresult DrawWithGDK(GdkDrawable * drawable, gint offsetX, 1.43 + gint offsetY, GdkRectangle * clipRects, uint32_t numClipRects) = 0; 1.44 +#endif 1.45 + 1.46 + enum { 1.47 + // If set, then Draw() is opaque, i.e., every pixel in the intersection 1.48 + // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height) 1.49 + // will be set and there is no dependence on what the existing pixels 1.50 + // in the drawable are set to. 1.51 + DRAW_IS_OPAQUE = 1.52 +#ifdef MOZ_X11 1.53 + gfxXlibNativeRenderer::DRAW_IS_OPAQUE 1.54 +#else 1.55 + 0x1 1.56 +#endif 1.57 + // If set, then numClipRects can be zero or one. 1.58 + // If not set, then numClipRects will be zero. 1.59 + , DRAW_SUPPORTS_CLIP_RECT = 1.60 +#ifdef MOZ_X11 1.61 + gfxXlibNativeRenderer::DRAW_SUPPORTS_CLIP_RECT 1.62 +#else 1.63 + 0x2 1.64 +#endif 1.65 + }; 1.66 + 1.67 + /** 1.68 + * @param flags see above 1.69 + * @param bounds Draw()'s drawing is guaranteed to be restricted to 1.70 + * the rectangle (offset.x,offset.y,bounds.width,bounds.height) 1.71 + * @param dpy a display to use for the drawing if ctx doesn't have one 1.72 + */ 1.73 +#if (MOZ_WIDGET_GTK == 2) 1.74 + void Draw(gfxContext* ctx, nsIntSize size, 1.75 + uint32_t flags, GdkColormap* colormap); 1.76 +#endif 1.77 + 1.78 +private: 1.79 +#ifdef MOZ_X11 1.80 + // for gfxXlibNativeRenderer: 1.81 + virtual nsresult DrawWithXlib(cairo_surface_t* surface, 1.82 + nsIntPoint offset, 1.83 + nsIntRect* clipRects, uint32_t numClipRects) MOZ_OVERRIDE; 1.84 + 1.85 +#if (MOZ_WIDGET_GTK == 2) 1.86 + GdkColormap *mColormap; 1.87 +#endif 1.88 +#endif 1.89 +}; 1.90 + 1.91 +#endif /*GFXGDKNATIVERENDER_H_*/