1 /* 2 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef GraphicsContextPrivate_h 27 #define GraphicsContextPrivate_h 28 29 #include "TransformationMatrix.h" 30 #include "Gradient.h" 31 #include "GraphicsContext.h" 32 #include "Pattern.h" 33 34 namespace WebCore { 35 36 // FIXME: This is a place-holder until we decide to add 37 // real color space support to WebCore. At that time, ColorSpace will be a 38 // class and instances will be held off of Colors. There will be 39 // special singleton Gradient and Pattern color spaces to mark when 40 // a fill or stroke is using a gradient or pattern instead of a solid color. 41 // https://bugs.webkit.org/show_bug.cgi?id=20558 42 enum ColorSpace { 43 SolidColorSpace, 44 PatternColorSpace, 45 GradientColorSpace 46 }; 47 48 struct GraphicsContextState { GraphicsContextStateGraphicsContextState49 GraphicsContextState() 50 : textDrawingMode(cTextFill) 51 , strokeStyle(SolidStroke) 52 , strokeThickness(0) 53 #if PLATFORM(CAIRO) 54 , globalAlpha(1.0f) 55 #endif 56 , strokeColorSpace(SolidColorSpace) 57 , strokeColor(Color::black) 58 , fillRule(RULE_NONZERO) 59 , fillColorSpace(SolidColorSpace) 60 , fillColor(Color::black) 61 , shouldAntialias(true) 62 , paintingDisabled(false) 63 , shadowBlur(0) 64 , shadowsIgnoreTransforms(false) 65 { 66 } 67 68 int textDrawingMode; 69 70 StrokeStyle strokeStyle; 71 float strokeThickness; 72 #if PLATFORM(CAIRO) 73 float globalAlpha; 74 #elif PLATFORM(QT) 75 TransformationMatrix pathTransform; 76 #endif 77 ColorSpace strokeColorSpace; 78 Color strokeColor; 79 RefPtr<Gradient> strokeGradient; 80 RefPtr<Pattern> strokePattern; 81 82 WindRule fillRule; 83 GradientSpreadMethod spreadMethod; 84 ColorSpace fillColorSpace; 85 Color fillColor; 86 RefPtr<Gradient> fillGradient; 87 RefPtr<Pattern> fillPattern; 88 89 bool shouldAntialias; 90 91 bool paintingDisabled; 92 93 IntSize shadowSize; 94 unsigned shadowBlur; 95 Color shadowColor; 96 97 bool shadowsIgnoreTransforms; 98 }; 99 100 class GraphicsContextPrivate { 101 public: GraphicsContextPrivate()102 GraphicsContextPrivate() 103 : m_focusRingWidth(0) 104 , m_focusRingOffset(0) 105 , m_updatingControlTints(false) 106 { 107 } 108 109 GraphicsContextState state; 110 Vector<GraphicsContextState> stack; 111 Vector<IntRect> m_focusRingRects; 112 int m_focusRingWidth; 113 int m_focusRingOffset; 114 bool m_updatingControlTints; 115 }; 116 117 } // namespace WebCore 118 119 #endif // GraphicsContextPrivate_h 120