Commit a1db5cff authored by reni@webkit.org's avatar reni@webkit.org

GraphicsContext: Merge m_common and m_data

https://bugs.webkit.org/show_bug.cgi?id=49914

Patch by Renata Hodovan <reni@webkit.org> on 2010-12-10
Reviewed by Andreas Kling.

Move data members from GraphicsContextPrivate into GraphicsContext. So GraphicsContextPlatform.h
and m_common became unnecessary. They are removed.
Add two methods to GraphicsContext: platformInit() and platformDestroy(), which
make the constructor of GraphicsContext clearer.
Besides add a getter to the private GraphicsContext::m_state member, because some inline
functions in cairo need it.

No new test is needed, because this is a refactoring.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::~GraphicsContext):
(WebCore::GraphicsContext::save):
(WebCore::GraphicsContext::restore):
(WebCore::GraphicsContext::setStrokeThickness):
(WebCore::GraphicsContext::setStrokeStyle):
(WebCore::GraphicsContext::setStrokeColor):
(WebCore::GraphicsContext::setShadow):
(WebCore::GraphicsContext::clearShadow):
(WebCore::GraphicsContext::getShadow):
(WebCore::GraphicsContext::strokeThickness):
(WebCore::GraphicsContext::strokeStyle):
(WebCore::GraphicsContext::strokeColor):
(WebCore::GraphicsContext::strokeColorSpace):
(WebCore::GraphicsContext::fillRule):
(WebCore::GraphicsContext::setFillRule):
(WebCore::GraphicsContext::setFillColor):
(WebCore::GraphicsContext::fillColor):
(WebCore::GraphicsContext::fillColorSpace):
(WebCore::GraphicsContext::setShouldAntialias):
(WebCore::GraphicsContext::shouldAntialias):
(WebCore::GraphicsContext::state):
(WebCore::GraphicsContext::setStrokePattern):
(WebCore::GraphicsContext::setFillPattern):
(WebCore::GraphicsContext::setStrokeGradient):
(WebCore::GraphicsContext::setFillGradient):
(WebCore::GraphicsContext::fillGradient):
(WebCore::GraphicsContext::strokeGradient):
(WebCore::GraphicsContext::fillPattern):
(WebCore::GraphicsContext::strokePattern):
(WebCore::GraphicsContext::setShadowsIgnoreTransforms):
(WebCore::GraphicsContext::updatingControlTints):
(WebCore::GraphicsContext::setUpdatingControlTints):
(WebCore::GraphicsContext::setPaintingDisabled):
(WebCore::GraphicsContext::paintingDisabled):
(WebCore::GraphicsContext::textDrawingMode):
(WebCore::GraphicsContext::setTextDrawingMode):
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContextState::GraphicsContextState):
* platform/graphics/GraphicsContextPrivate.h: Removed.
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::setPlatformFill):
(WebCore::setPlatformStroke):
(WebCore::drawPathShadow):
(WebCore::fillCurrentCairoPath):
(WebCore::strokeCurrentCairoPath):
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::setPlatformShadow):
(WebCore::GraphicsContext::strokeRect):
(WebCore::GraphicsContext::setAlpha):
(WebCore::GraphicsContext::getAlpha):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::applyStrokePattern):
(WebCore::GraphicsContext::applyFillPattern):
(WebCore::GraphicsContext::drawPath):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::setPlatformShadow):
(WebCore::GraphicsContext::strokeRect):
* platform/graphics/haiku/GraphicsContextHaiku.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
* platform/graphics/openvg/GraphicsContextOpenVG.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::clip):
(WebCore::GraphicsContext::clipOut):
(WebCore::GraphicsContext::addInnerRoundedRectClip):
* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::setPlatformShadow):
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::setPlatformShadow):
* platform/graphics/win/GraphicsContextCGWin.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::platformInit):
* platform/graphics/win/GraphicsContextCairoWin.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::platformInit):
* platform/graphics/wince/GraphicsContextWinCE.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::fillRect):
* platform/graphics/wx/GraphicsContextWx.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6f4b5c9f
2010-12-10 Renata Hodovan <reni@webkit.org>
Reviewed by Andreas Kling.
GraphicsContext: Merge m_common and m_data
https://bugs.webkit.org/show_bug.cgi?id=49914
Move data members from GraphicsContextPrivate into GraphicsContext. So GraphicsContextPlatform.h
and m_common became unnecessary. They are removed.
Add two methods to GraphicsContext: platformInit() and platformDestroy(), which
make the constructor of GraphicsContext clearer.
Besides add a getter to the private GraphicsContext::m_state member, because some inline
functions in cairo need it.
No new test is needed, because this is a refactoring.
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::~GraphicsContext):
(WebCore::GraphicsContext::save):
(WebCore::GraphicsContext::restore):
(WebCore::GraphicsContext::setStrokeThickness):
(WebCore::GraphicsContext::setStrokeStyle):
(WebCore::GraphicsContext::setStrokeColor):
(WebCore::GraphicsContext::setShadow):
(WebCore::GraphicsContext::clearShadow):
(WebCore::GraphicsContext::getShadow):
(WebCore::GraphicsContext::strokeThickness):
(WebCore::GraphicsContext::strokeStyle):
(WebCore::GraphicsContext::strokeColor):
(WebCore::GraphicsContext::strokeColorSpace):
(WebCore::GraphicsContext::fillRule):
(WebCore::GraphicsContext::setFillRule):
(WebCore::GraphicsContext::setFillColor):
(WebCore::GraphicsContext::fillColor):
(WebCore::GraphicsContext::fillColorSpace):
(WebCore::GraphicsContext::setShouldAntialias):
(WebCore::GraphicsContext::shouldAntialias):
(WebCore::GraphicsContext::state):
(WebCore::GraphicsContext::setStrokePattern):
(WebCore::GraphicsContext::setFillPattern):
(WebCore::GraphicsContext::setStrokeGradient):
(WebCore::GraphicsContext::setFillGradient):
(WebCore::GraphicsContext::fillGradient):
(WebCore::GraphicsContext::strokeGradient):
(WebCore::GraphicsContext::fillPattern):
(WebCore::GraphicsContext::strokePattern):
(WebCore::GraphicsContext::setShadowsIgnoreTransforms):
(WebCore::GraphicsContext::updatingControlTints):
(WebCore::GraphicsContext::setUpdatingControlTints):
(WebCore::GraphicsContext::setPaintingDisabled):
(WebCore::GraphicsContext::paintingDisabled):
(WebCore::GraphicsContext::textDrawingMode):
(WebCore::GraphicsContext::setTextDrawingMode):
* platform/graphics/GraphicsContext.h:
(WebCore::GraphicsContextState::GraphicsContextState):
* platform/graphics/GraphicsContextPrivate.h: Removed.
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::setPlatformFill):
(WebCore::setPlatformStroke):
(WebCore::drawPathShadow):
(WebCore::fillCurrentCairoPath):
(WebCore::strokeCurrentCairoPath):
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::setPlatformShadow):
(WebCore::GraphicsContext::strokeRect):
(WebCore::GraphicsContext::setAlpha):
(WebCore::GraphicsContext::getAlpha):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::applyStrokePattern):
(WebCore::GraphicsContext::applyFillPattern):
(WebCore::GraphicsContext::drawPath):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::setPlatformShadow):
(WebCore::GraphicsContext::strokeRect):
* platform/graphics/haiku/GraphicsContextHaiku.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
* platform/graphics/openvg/GraphicsContextOpenVG.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::clip):
(WebCore::GraphicsContext::clipOut):
(WebCore::GraphicsContext::addInnerRoundedRectClip):
* platform/graphics/qt/GraphicsContextQt.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::strokePath):
(WebCore::GraphicsContext::fillRect):
(WebCore::GraphicsContext::setPlatformShadow):
* platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::setPlatformShadow):
* platform/graphics/win/GraphicsContextCGWin.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::platformInit):
* platform/graphics/win/GraphicsContextCairoWin.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::platformInit):
* platform/graphics/wince/GraphicsContextWinCE.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
(WebCore::GraphicsContext::fillPath):
(WebCore::GraphicsContext::fillRect):
* platform/graphics/wx/GraphicsContextWx.cpp:
(WebCore::GraphicsContext::platformInit):
(WebCore::GraphicsContext::platformDestroy):
2010-12-10 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
......
......@@ -3928,7 +3928,7 @@
A8F4FB960C169E85002AFED5 /* SVGRenderSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8F4FB950C169E85002AFED5 /* SVGRenderSupport.cpp */; };
A8F5C0B80F9285AC0098E06B /* RenderSVGModelObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8F5C0B60F9285AC0098E06B /* RenderSVGModelObject.h */; };
A8F5C0B90F9285AC0098E06B /* RenderSVGModelObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8F5C0B70F9285AC0098E06B /* RenderSVGModelObject.cpp */; };
A8FA6E5D0E4CFDED00D5CF49 /* Pattern.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */; };
A8FA6E5D0E4CFDED00D5CF49 /* Pattern.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
A8FA6E5E0E4CFDED00D5CF49 /* Pattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */; };
A9C6E4E30D745E05006442E9 /* DOMMimeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A9C6E4E10D745E05006442E9 /* DOMMimeType.cpp */; };
A9C6E4E40D745E05006442E9 /* DOMMimeType.h in Headers */ = {isa = PBXBuildFile; fileRef = A9C6E4E20D745E05006442E9 /* DOMMimeType.h */; };
......@@ -29,7 +29,6 @@
#include "BidiResolver.h"
#include "Font.h"
#include "Generator.h"
#include "GraphicsContextPrivate.h"
#include "ImageBuffer.h"
using namespace std;
......@@ -74,14 +73,15 @@ private:
int m_offset;
};
GraphicsContextPrivate* GraphicsContext::createGraphicsContextPrivate()
GraphicsContext::GraphicsContext(PlatformGraphicsContext* platformGraphicsContext)
: m_updatingControlTints(false)
{
return new GraphicsContextPrivate;
platformInit(platformGraphicsContext);
}
void GraphicsContext::destroyGraphicsContextPrivate(GraphicsContextPrivate* deleteMe)
GraphicsContext::~GraphicsContext()
{
delete deleteMe;
platformDestroy();
}
void GraphicsContext::save()
......@@ -89,7 +89,7 @@ void GraphicsContext::save()
if (paintingDisabled())
return;
m_common->stack.append(m_common->state);
m_stack.append(m_state);
savePlatformState();
}
......@@ -99,120 +99,125 @@ void GraphicsContext::restore()
if (paintingDisabled())
return;
if (m_common->stack.isEmpty()) {
if (m_stack.isEmpty()) {
LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
return;
}
m_common->state = m_common->stack.last();
m_common->stack.removeLast();
m_state = m_stack.last();
m_stack.removeLast();
restorePlatformState();
}
void GraphicsContext::setStrokeThickness(float thickness)
{
m_common->state.strokeThickness = thickness;
m_state.strokeThickness = thickness;
setPlatformStrokeThickness(thickness);
}
void GraphicsContext::setStrokeStyle(const StrokeStyle& style)
{
m_common->state.strokeStyle = style;
m_state.strokeStyle = style;
setPlatformStrokeStyle(style);
}
void GraphicsContext::setStrokeColor(const Color& color, ColorSpace colorSpace)
{
m_common->state.strokeColor = color;
m_common->state.strokeColorSpace = colorSpace;
m_common->state.strokeGradient.clear();
m_common->state.strokePattern.clear();
m_state.strokeColor = color;
m_state.strokeColorSpace = colorSpace;
m_state.strokeGradient.clear();
m_state.strokePattern.clear();
setPlatformStrokeColor(color, colorSpace);
}
void GraphicsContext::setShadow(const FloatSize& offset, float blur, const Color& color, ColorSpace colorSpace)
{
m_common->state.shadowOffset = offset;
m_common->state.shadowBlur = blur;
m_common->state.shadowColor = color;
m_state.shadowOffset = offset;
m_state.shadowBlur = blur;
m_state.shadowColor = color;
setPlatformShadow(offset, blur, color, colorSpace);
}
void GraphicsContext::clearShadow()
{
m_common->state.shadowOffset = FloatSize();
m_common->state.shadowBlur = 0;
m_common->state.shadowColor = Color();
m_state.shadowOffset = FloatSize();
m_state.shadowBlur = 0;
m_state.shadowColor = Color();
clearPlatformShadow();
}
bool GraphicsContext::getShadow(FloatSize& offset, float& blur, Color& color) const
{
offset = m_common->state.shadowOffset;
blur = m_common->state.shadowBlur;
color = m_common->state.shadowColor;
offset = m_state.shadowOffset;
blur = m_state.shadowBlur;
color = m_state.shadowColor;
return color.isValid() && color.alpha() && (blur || offset.width() || offset.height());
}
float GraphicsContext::strokeThickness() const
{
return m_common->state.strokeThickness;
return m_state.strokeThickness;
}
StrokeStyle GraphicsContext::strokeStyle() const
{
return m_common->state.strokeStyle;
return m_state.strokeStyle;
}
Color GraphicsContext::strokeColor() const
{
return m_common->state.strokeColor;
return m_state.strokeColor;
}
ColorSpace GraphicsContext::strokeColorSpace() const
{
return m_common->state.strokeColorSpace;
return m_state.strokeColorSpace;
}
WindRule GraphicsContext::fillRule() const
{
return m_common->state.fillRule;
return m_state.fillRule;
}
void GraphicsContext::setFillRule(WindRule fillRule)
{
m_common->state.fillRule = fillRule;
m_state.fillRule = fillRule;
}
void GraphicsContext::setFillColor(const Color& color, ColorSpace colorSpace)
{
m_common->state.fillColor = color;
m_common->state.fillColorSpace = colorSpace;
m_common->state.fillGradient.clear();
m_common->state.fillPattern.clear();
m_state.fillColor = color;
m_state.fillColorSpace = colorSpace;
m_state.fillGradient.clear();
m_state.fillPattern.clear();
setPlatformFillColor(color, colorSpace);
}
Color GraphicsContext::fillColor() const
{
return m_common->state.fillColor;
return m_state.fillColor;
}
ColorSpace GraphicsContext::fillColorSpace() const
{
return m_common->state.fillColorSpace;
return m_state.fillColorSpace;
}
void GraphicsContext::setShouldAntialias(bool b)
{
m_common->state.shouldAntialias = b;
m_state.shouldAntialias = b;
setPlatformShouldAntialias(b);
}
bool GraphicsContext::shouldAntialias() const
{
return m_common->state.shouldAntialias;
return m_state.shouldAntialias;
}
const GraphicsContextState& GraphicsContext::state() const
{
return m_state;
}
void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
......@@ -222,9 +227,9 @@ void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
setStrokeColor(Color::black, ColorSpaceDeviceRGB);
return;
}
m_common->state.strokeGradient.clear();
m_common->state.strokePattern = pattern;
setPlatformStrokePattern(m_common->state.strokePattern.get());
m_state.strokeGradient.clear();
m_state.strokePattern = pattern;
setPlatformStrokePattern(m_state.strokePattern.get());
}
void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
......@@ -234,9 +239,9 @@ void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
setFillColor(Color::black, ColorSpaceDeviceRGB);
return;
}
m_common->state.fillGradient.clear();
m_common->state.fillPattern = pattern;
setPlatformFillPattern(m_common->state.fillPattern.get());
m_state.fillGradient.clear();
m_state.fillPattern = pattern;
setPlatformFillPattern(m_state.fillPattern.get());
}
void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
......@@ -246,9 +251,9 @@ void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
setStrokeColor(Color::black, ColorSpaceDeviceRGB);
return;
}
m_common->state.strokeGradient = gradient;
m_common->state.strokePattern.clear();
setPlatformStrokeGradient(m_common->state.strokeGradient.get());
m_state.strokeGradient = gradient;
m_state.strokePattern.clear();
setPlatformStrokeGradient(m_state.strokeGradient.get());
}
void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient)
......@@ -258,55 +263,55 @@ void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient)
setFillColor(Color::black, ColorSpaceDeviceRGB);
return;
}
m_common->state.fillGradient = gradient;
m_common->state.fillPattern.clear();
setPlatformFillGradient(m_common->state.fillGradient.get());
m_state.fillGradient = gradient;
m_state.fillPattern.clear();
setPlatformFillGradient(m_state.fillGradient.get());
}
Gradient* GraphicsContext::fillGradient() const
{
return m_common->state.fillGradient.get();
return m_state.fillGradient.get();
}
Gradient* GraphicsContext::strokeGradient() const
{
return m_common->state.strokeGradient.get();
return m_state.strokeGradient.get();
}
Pattern* GraphicsContext::fillPattern() const
{
return m_common->state.fillPattern.get();
return m_state.fillPattern.get();
}
Pattern* GraphicsContext::strokePattern() const
{
return m_common->state.strokePattern.get();
return m_state.strokePattern.get();
}
void GraphicsContext::setShadowsIgnoreTransforms(bool ignoreTransforms)
{
m_common->state.shadowsIgnoreTransforms = ignoreTransforms;
m_state.shadowsIgnoreTransforms = ignoreTransforms;
}
bool GraphicsContext::updatingControlTints() const
{
return m_common->m_updatingControlTints;
return m_updatingControlTints;
}
void GraphicsContext::setUpdatingControlTints(bool b)
{
setPaintingDisabled(b);
m_common->m_updatingControlTints = b;
m_updatingControlTints = b;
}
void GraphicsContext::setPaintingDisabled(bool f)
{
m_common->state.paintingDisabled = f;
m_state.paintingDisabled = f;
}
bool GraphicsContext::paintingDisabled() const
{
return m_common->state.paintingDisabled;
return m_state.paintingDisabled;
}
void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntPoint& p, CompositeOperator op)
......@@ -528,12 +533,12 @@ void GraphicsContext::clipToImageBuffer(ImageBuffer* buffer, const FloatRect& re
TextDrawingModeFlags GraphicsContext::textDrawingMode() const
{
return m_common->state.textDrawingMode;
return m_state.textDrawingMode;
}
void GraphicsContext::setTextDrawingMode(TextDrawingModeFlags mode)
{
m_common->state.textDrawingMode = mode;
m_state.textDrawingMode = mode;
if (paintingDisabled())
return;
setPlatformTextDrawingMode(mode);
......
......@@ -30,9 +30,11 @@
#include "ColorSpace.h"
#include "DashArray.h"
#include "FloatRect.h"
#include "Gradient.h"
#include "Image.h"
#include "IntRect.h"
#include "Path.h"
#include "Pattern.h"
#include "TextDirection.h"
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
......@@ -117,12 +119,9 @@ namespace WebCore {
class DrawingBuffer;
class Font;
class Generator;
class Gradient;
class GraphicsContextPlatformPrivate;
class GraphicsContextPrivate;
class ImageBuffer;
class KURL;
class Pattern;
class SharedGraphicsContext3D;
class TextRun;
......@@ -149,6 +148,57 @@ namespace WebCore {
InterpolationHigh
};
struct GraphicsContextState {
GraphicsContextState()
: strokeThickness(0)
, shadowBlur(0)
#if PLATFORM(CAIRO)
, globalAlpha(1)
#endif
, textDrawingMode(TextModeFill)
, strokeColor(Color::black)
, fillColor(Color::black)
, strokeStyle(SolidStroke)
, fillRule(RULE_NONZERO)
, strokeColorSpace(ColorSpaceDeviceRGB)
, fillColorSpace(ColorSpaceDeviceRGB)
, shouldAntialias(true)
, paintingDisabled(false)
, shadowsIgnoreTransforms(false)
{
}
RefPtr<Gradient> strokeGradient;
RefPtr<Pattern> strokePattern;
RefPtr<Gradient> fillGradient;
RefPtr<Pattern> fillPattern;
FloatSize shadowOffset;
float strokeThickness;
float shadowBlur;
#if PLATFORM(CAIRO)
float globalAlpha;
#endif
TextDrawingModeFlags textDrawingMode;
Color strokeColor;
Color fillColor;
Color shadowColor;
StrokeStyle strokeStyle;
WindRule fillRule;
ColorSpace strokeColorSpace;
ColorSpace fillColorSpace;
bool shouldAntialias;
bool paintingDisabled;
bool shadowsIgnoreTransforms;
};
class GraphicsContext : public Noncopyable {
public:
GraphicsContext(PlatformGraphicsContext*);
......@@ -189,6 +239,8 @@ namespace WebCore {
void setShouldAntialias(bool);
bool shouldAntialias() const;
const GraphicsContextState& state() const;
#if PLATFORM(CG)
void applyStrokePattern();
void applyFillPattern();
......@@ -418,6 +470,13 @@ namespace WebCore {
void markDirtyRect(const IntRect&); // Hints that a portion of the backing store is dirty.
private:
void platformInit(PlatformGraphicsContext*);
void platformDestroy();
#if PLATFORM(WIN)
void platformInit(HDC, bool hasAlpha = false);
#endif
void savePlatformState();
void restorePlatformState();
......@@ -441,11 +500,11 @@ namespace WebCore {
static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, const StrokeStyle&);
static GraphicsContextPrivate* createGraphicsContextPrivate();
static void destroyGraphicsContextPrivate(GraphicsContextPrivate*);
GraphicsContextPlatformPrivate* m_data;
GraphicsContextPrivate* m_common;
GraphicsContextPlatformPrivate* m_data; // Deprecated; m_commmon can just be downcasted. To be removed.
GraphicsContextState m_state;
Vector<GraphicsContextState> m_stack;
bool m_updatingControlTints;
};
} // namespace WebCore
......
/*
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GraphicsContextPrivate_h
#define GraphicsContextPrivate_h
#include "Gradient.h"
#include "GraphicsContext.h"
#include "Pattern.h"
namespace WebCore {
struct GraphicsContextState {
GraphicsContextState()
: strokeThickness(0)
, shadowBlur(0)
#if PLATFORM(CAIRO)
, globalAlpha(1)
#endif
, textDrawingMode(TextModeFill)
, strokeColor(Color::black)
, fillColor(Color::black)
, strokeStyle(SolidStroke)
, fillRule(RULE_NONZERO)
, strokeColorSpace(ColorSpaceDeviceRGB)
, fillColorSpace(ColorSpaceDeviceRGB)
, shouldAntialias(true)
, paintingDisabled(false)
, shadowsIgnoreTransforms(false)
{
}
RefPtr<Gradient> strokeGradient;
RefPtr<Pattern> strokePattern;
RefPtr<Gradient> fillGradient;
RefPtr<Pattern> fillPattern;
FloatSize shadowOffset;
float strokeThickness;