1/* 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2008 Brent Fulgham <bfulgham@gmail.com> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#ifndef GraphicsContextPlatformPrivateCairo_h 29#define GraphicsContextPlatformPrivateCairo_h 30 31#include "GraphicsContext.h" 32 33#include "PlatformContextCairo.h" 34#include "RefPtrCairo.h" 35#include <cairo.h> 36#include <math.h> 37#include <stdio.h> 38#include <wtf/MathExtras.h> 39 40#if PLATFORM(GTK) 41#include <pango/pango.h> 42typedef struct _GdkExposeEvent GdkExposeEvent; 43#elif PLATFORM(WIN) 44#include <cairo-win32.h> 45#endif 46 47namespace WebCore { 48 49class GraphicsContextPlatformPrivate { 50public: 51 GraphicsContextPlatformPrivate(PlatformContextCairo* newPlatformContext) 52 : platformContext(newPlatformContext) 53#if PLATFORM(GTK) 54 , expose(0) 55#endif 56#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) 57 // NOTE: These may note be needed: review and remove once Cairo implementation is complete 58 , m_hdc(0) 59 , m_shouldIncludeChildWindows(false) 60#endif 61 { 62 } 63 64 virtual ~GraphicsContextPlatformPrivate() 65 { 66 } 67 68#if PLATFORM(WIN) 69 // On Windows, we need to update the HDC for form controls to draw in the right place. 70 void save(); 71 void restore(); 72 void flush(); 73 void clip(const FloatRect&); 74 void clip(const Path&); 75 void scale(const FloatSize&); 76 void rotate(float); 77 void translate(float, float); 78 void concatCTM(const AffineTransform&); 79 void setCTM(const AffineTransform&); 80 void syncContext(cairo_t* cr); 81#else 82 // On everything else, we do nothing. 83 void save() {} 84 void restore() {} 85 void flush() {} 86 void clip(const FloatRect&) {} 87 void clip(const Path&) {} 88 void scale(const FloatSize&) {} 89 void rotate(float) {} 90 void translate(float, float) {} 91 void concatCTM(const AffineTransform&) {} 92 void setCTM(const AffineTransform&) {} 93 void syncContext(cairo_t*) { } 94#endif 95 96 PlatformContextCairo* platformContext; 97 Vector<float> layers; 98 99#if PLATFORM(GTK) 100 GdkEventExpose* expose; 101#endif 102#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) 103 HDC m_hdc; 104 bool m_shouldIncludeChildWindows; 105#endif 106}; 107 108// This is a specialized private section for the Cairo GraphicsContext, which knows how 109// to clean up the heap allocated PlatformContextCairo that we must use for the top-level 110// GraphicsContext. 111class GraphicsContextPlatformPrivateToplevel : public GraphicsContextPlatformPrivate { 112public: 113 GraphicsContextPlatformPrivateToplevel(PlatformContextCairo* platformContext) 114 : GraphicsContextPlatformPrivate(platformContext) 115 { 116 } 117 118 virtual ~GraphicsContextPlatformPrivateToplevel() 119 { 120 delete platformContext; 121 } 122}; 123 124 125} // namespace WebCore 126 127#endif // GraphicsContextPlatformPrivateCairo_h 128