[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00
jpetsovits at rim.com
jpetsovits at rim.com
Wed Mar 17 18:37:04 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit bfd5c3edf36a38b62ab1efd3da26837678c196e7
Author: jpetsovits at rim.com <jpetsovits at rim.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Mar 12 19:45:13 2010 +0000
2010-03-12 Jakob Petsovits <jpetsovits at rim.com>
Reviewed by Dirk Schulze.
[OpenVG] Add support for drawing text to PainterOpenVG
https://bugs.webkit.org/show_bug.cgi?id=35581
Doesn't come with any actual font classes, as OpenVG
by itself doesn't provide any access to platform fonts
but just the means to draw glyphs that have been loaded
manually before.
* platform/graphics/openvg/PainterOpenVG.cpp:
(WebCore::PlatformPainterState::PlatformPainterState):
(WebCore::PlatformPainterState::copyPaintState):
(WebCore::PainterOpenVG::textDrawingMode):
(WebCore::PainterOpenVG::setTextDrawingMode):
(WebCore::PainterOpenVG::drawText):
* platform/graphics/openvg/PainterOpenVG.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55923 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 875ca1d..0245152 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,26 @@
Reviewed by Dirk Schulze.
+ [OpenVG] Add support for drawing text to PainterOpenVG
+ https://bugs.webkit.org/show_bug.cgi?id=35581
+
+ Doesn't come with any actual font classes, as OpenVG
+ by itself doesn't provide any access to platform fonts
+ but just the means to draw glyphs that have been loaded
+ manually before.
+
+ * platform/graphics/openvg/PainterOpenVG.cpp:
+ (WebCore::PlatformPainterState::PlatformPainterState):
+ (WebCore::PlatformPainterState::copyPaintState):
+ (WebCore::PainterOpenVG::textDrawingMode):
+ (WebCore::PainterOpenVG::setTextDrawingMode):
+ (WebCore::PainterOpenVG::drawText):
+ * platform/graphics/openvg/PainterOpenVG.h:
+
+2010-03-12 Jakob Petsovits <jpetsovits at rim.com>
+
+ Reviewed by Dirk Schulze.
+
[OpenVG] Use masks to implement non-rectilinear clipping
https://bugs.webkit.org/show_bug.cgi?id=35544
diff --git a/WebCore/platform/graphics/openvg/PainterOpenVG.cpp b/WebCore/platform/graphics/openvg/PainterOpenVG.cpp
index dcf85e5..5842afd 100644
--- a/WebCore/platform/graphics/openvg/PainterOpenVG.cpp
+++ b/WebCore/platform/graphics/openvg/PainterOpenVG.cpp
@@ -122,6 +122,7 @@ struct PlatformPainterState {
DashArray strokeDashArray;
float strokeDashOffset;
+ int textDrawingMode;
bool antialiasingEnabled;
PlatformPainterState()
@@ -139,6 +140,7 @@ struct PlatformPainterState {
, strokeLineJoin(MiterJoin)
, strokeMiterLimit(4.0)
, strokeDashOffset(0.0)
+ , textDrawingMode(cTextFill)
, antialiasingEnabled(true)
{
}
@@ -187,6 +189,7 @@ struct PlatformPainterState {
strokeDashArray = other->strokeDashArray;
strokeDashOffset = other->strokeDashOffset;
+ textDrawingMode = other->textDrawingMode;
antialiasingEnabled = other->antialiasingEnabled;
}
@@ -652,6 +655,18 @@ void PainterOpenVG::setFillColor(const Color& color)
setVGSolidColor(VG_FILL_PATH, color);
}
+int PainterOpenVG::textDrawingMode() const
+{
+ ASSERT(m_state);
+ return m_state->textDrawingMode;
+}
+
+void PainterOpenVG::setTextDrawingMode(int mode)
+{
+ ASSERT(m_state);
+ m_state->textDrawingMode = mode;
+}
+
bool PainterOpenVG::antialiasingEnabled() const
{
ASSERT(m_state);
@@ -1070,6 +1085,58 @@ void PainterOpenVG::drawPolygon(size_t numPoints, const FloatPoint* points, VGbi
ASSERT_VG_NO_ERROR();
}
+#ifdef OPENVG_VERSION_1_1
+void PainterOpenVG::drawText(VGFont vgFont, Vector<VGuint>& characters, VGfloat* adjustmentsX, VGfloat* adjustmentsY, const FloatPoint& point)
+{
+ ASSERT(m_state);
+
+ VGbitfield paintModes = 0;
+
+ if (m_state->textDrawingMode & cTextClip)
+ return; // unsupported for every port except CG at the time of writing
+ if (m_state->textDrawingMode & cTextFill && !m_state->fillDisabled())
+ paintModes |= VG_FILL_PATH;
+ if (m_state->textDrawingMode & cTextStroke && !m_state->strokeDisabled())
+ paintModes |= VG_STROKE_PATH;
+
+ m_surface->makeCurrent();
+
+ FloatPoint effectivePoint = m_state->surfaceTransformation.mapPoint(point);
+ FloatPoint p = point;
+ AffineTransform* originalTransformation = 0;
+
+ // In case the font isn't drawn at a pixel-exact baseline and we can easily
+ // fix that (which is the case for non-rotated affine transforms), let's
+ // align the starting point to the pixel boundary in order to prevent
+ // font rendering issues such as glyphs that appear off by a pixel.
+ // This causes us to have inconsistent spacing between baselines in a
+ // larger paragraph, but that seems to be the least of all evils.
+ if ((fmod(effectivePoint.x() + 0.01, 1.0) > 0.02 || fmod(effectivePoint.y() + 0.01, 1.0) > 0.02)
+ && isNonRotatedAffineTransformation(m_state->surfaceTransformation))
+ {
+ originalTransformation = new AffineTransform(m_state->surfaceTransformation);
+ setTransformation(AffineTransform(
+ m_state->surfaceTransformation.a(), 0,
+ 0, m_state->surfaceTransformation.d(),
+ roundf(effectivePoint.x()), roundf(effectivePoint.y())));
+ p = FloatPoint();
+ }
+
+ const VGfloat vgPoint[2] = { p.x(), p.y() };
+ vgSetfv(VG_GLYPH_ORIGIN, 2, vgPoint);
+ ASSERT_VG_NO_ERROR();
+
+ vgDrawGlyphs(vgFont, characters.size(), characters.data(),
+ adjustmentsX, adjustmentsY, paintModes, VG_TRUE /* allow autohinting */);
+ ASSERT_VG_NO_ERROR();
+
+ if (originalTransformation) {
+ setTransformation(*originalTransformation);
+ delete originalTransformation;
+ }
+}
+#endif
+
void PainterOpenVG::save(PainterOpenVG::SaveMode saveMode)
{
ASSERT(m_state);
diff --git a/WebCore/platform/graphics/openvg/PainterOpenVG.h b/WebCore/platform/graphics/openvg/PainterOpenVG.h
index aa92c82..30cdf31 100644
--- a/WebCore/platform/graphics/openvg/PainterOpenVG.h
+++ b/WebCore/platform/graphics/openvg/PainterOpenVG.h
@@ -89,6 +89,9 @@ public:
Color fillColor() const;
void setFillColor(const Color&);
+ int textDrawingMode() const;
+ void setTextDrawingMode(int mode);
+
bool antialiasingEnabled() const;
void setAntialiasingEnabled(bool);
@@ -98,6 +101,9 @@ public:
void drawArc(const IntRect& ellipseBounds, int startAngle, int angleSpan, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
void drawEllipse(const IntRect& bounds, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
void drawPolygon(size_t numPoints, const FloatPoint* points, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
+#ifdef OPENVG_VERSION_1_1
+ void drawText(VGFont, Vector<VGuint>& characters, VGfloat* adjustmentsX, VGfloat* adjustmentsY, const FloatPoint&);
+#endif
void scale(const FloatSize& scaleFactors);
void rotate(float radians);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list