summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/GraphicsContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/GraphicsContext.cpp')
-rw-r--r--WebCore/platform/graphics/GraphicsContext.cpp183
1 files changed, 118 insertions, 65 deletions
diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp
index d80b365..49a7a9c 100644
--- a/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/WebCore/platform/graphics/GraphicsContext.cpp
@@ -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,139 @@ 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;
+ m_state.shadowColorSpace = colorSpace;
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();
+ m_state.shadowColorSpace = ColorSpaceDeviceRGB;
clearPlatformShadow();
}
-bool GraphicsContext::getShadow(FloatSize& offset, float& blur, Color& color) const
+bool GraphicsContext::getShadow(FloatSize& offset, float& blur, Color& color, ColorSpace& colorSpace) 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;
+ colorSpace = m_state.shadowColorSpace;
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;
+}
+
+void GraphicsContext::setShouldSmoothFonts(bool b)
+{
+ m_state.shouldSmoothFonts = b;
+ setPlatformShouldSmoothFonts(b);
+}
+
+bool GraphicsContext::shouldSmoothFonts() const
+{
+ return m_state.shouldSmoothFonts;
+}
+
+const GraphicsContextState& GraphicsContext::state() const
+{
+ return m_state;
}
void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
@@ -222,9 +241,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 +253,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 +265,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,34 +277,39 @@ 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::shadowsIgnoreTransforms() const
+{
+ return m_state.shadowsIgnoreTransforms;
}
bool GraphicsContext::shadowsIgnoreTransforms() const
@@ -295,23 +319,23 @@ bool GraphicsContext::shadowsIgnoreTransforms() const
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)
@@ -344,6 +368,14 @@ void GraphicsContext::drawText(const Font& font, const TextRun& run, const IntPo
}
#endif
+void GraphicsContext::drawEmphasisMarks(const Font& font, const TextRun& run, const AtomicString& mark, const IntPoint& point, int from, int to)
+{
+ if (paintingDisabled())
+ return;
+
+ font.drawEmphasisMarks(this, run, mark, point, from, to);
+}
+
void GraphicsContext::drawBidiText(const Font& font, const TextRun& run, const FloatPoint& point)
{
if (paintingDisabled())
@@ -531,14 +563,14 @@ void GraphicsContext::clipToImageBuffer(ImageBuffer* buffer, const FloatRect& re
buffer->clip(this, rect);
}
-int GraphicsContext::textDrawingMode()
+TextDrawingModeFlags GraphicsContext::textDrawingMode() const
{
- return m_common->state.textDrawingMode;
+ return m_state.textDrawingMode;
}
-void GraphicsContext::setTextDrawingMode(int mode)
+void GraphicsContext::setTextDrawingMode(TextDrawingModeFlags mode)
{
- m_common->state.textDrawingMode = mode;
+ m_state.textDrawingMode = mode;
if (paintingDisabled())
return;
setPlatformTextDrawingMode(mode);
@@ -551,7 +583,22 @@ void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator)
generator.fill(this, rect);
}
+<<<<<<< HEAD
#if !(PLATFORM(SKIA) && !PLATFORM(ANDROID))
+=======
+void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation)
+{
+ m_state.compositeOperator = compositeOperation;
+ setPlatformCompositeOperation(compositeOperation);
+}
+
+CompositeOperator GraphicsContext::compositeOperation() const
+{
+ return m_state.compositeOperator;
+}
+
+#if !PLATFORM(SKIA)
+>>>>>>> webkit.org at r74534 (trunk)
void GraphicsContext::setPlatformFillGradient(Gradient*)
{
}
@@ -572,7 +619,7 @@ void GraphicsContext::setPlatformStrokePattern(Pattern*)
#if !PLATFORM(CG) && !(PLATFORM(SKIA) && !PLATFORM(ANDROID))
// Implement this if you want to go ahead and push the drawing mode into your native context
// immediately.
-void GraphicsContext::setPlatformTextDrawingMode(int mode)
+void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
{
}
#endif
@@ -583,6 +630,12 @@ void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle&)
}
#endif
+#if !PLATFORM(CG)
+void GraphicsContext::setPlatformShouldSmoothFonts(bool)
+{
+}
+#endif
+
#if !PLATFORM(SKIA)
void GraphicsContext::setSharedGraphicsContext3D(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&)
{