1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef GFXGDKNATIVERENDER_H_ 7 #define GFXGDKNATIVERENDER_H_ 8 9 #include <gdk/gdk.h> 10 #include "nsSize.h" 11 #ifdef MOZ_X11 12 # include "gfxXlibNativeRenderer.h" 13 #endif 14 15 class gfxContext; 16 17 /** 18 * This class lets us take code that draws into an GDK drawable and lets us 19 * use it to draw into any Thebes context. The user should subclass this class, 20 * override DrawWithGDK, and then call Draw(). The drawing will be subjected 21 * to all Thebes transformations, clipping etc. 22 */ 23 class gfxGdkNativeRenderer 24 #ifdef MOZ_X11 25 : private gfxXlibNativeRenderer 26 #endif 27 { 28 public: 29 /** 30 * Perform the native drawing. 31 * @param offsetX draw at this offset into the given drawable 32 * @param offsetY draw at this offset into the given drawable 33 * @param clipRects an array of rects; clip to the union 34 * @param numClipRects the number of rects in the array, or zero if 35 * no clipping is required 36 */ 37 38 enum { 39 // If set, then Draw() is opaque, i.e., every pixel in the intersection 40 // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height) 41 // will be set and there is no dependence on what the existing pixels 42 // in the drawable are set to. 43 DRAW_IS_OPAQUE = 44 #ifdef MOZ_X11 45 gfxXlibNativeRenderer::DRAW_IS_OPAQUE 46 #else 47 0x1 48 #endif 49 // If set, then numClipRects can be zero or one. 50 // If not set, then numClipRects will be zero. 51 , 52 DRAW_SUPPORTS_CLIP_RECT = 53 #ifdef MOZ_X11 54 gfxXlibNativeRenderer::DRAW_SUPPORTS_CLIP_RECT 55 #else 56 0x2 57 #endif 58 }; 59 60 /** 61 * @param flags see above 62 * @param bounds Draw()'s drawing is guaranteed to be restricted to 63 * the rectangle (offset.x,offset.y,bounds.width,bounds.height) 64 * @param dpy a display to use for the drawing if ctx doesn't have one 65 */ 66 67 private: 68 #ifdef MOZ_X11 69 // for gfxXlibNativeRenderer: 70 virtual nsresult DrawWithXlib(cairo_surface_t* surface, nsIntPoint offset, 71 mozilla::gfx::IntRect* clipRects, 72 uint32_t numClipRects) override; 73 74 #endif 75 }; 76 77 #endif /*GFXGDKNATIVERENDER_H_*/ 78