Changeset 55923 in webkit
- Timestamp:
- Mar 12, 2010 11:45:13 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55922 r55923 1 2010-03-12 Jakob Petsovits <jpetsovits@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 [OpenVG] Add support for drawing text to PainterOpenVG 6 https://bugs.webkit.org/show_bug.cgi?id=35581 7 8 Doesn't come with any actual font classes, as OpenVG 9 by itself doesn't provide any access to platform fonts 10 but just the means to draw glyphs that have been loaded 11 manually before. 12 13 * platform/graphics/openvg/PainterOpenVG.cpp: 14 (WebCore::PlatformPainterState::PlatformPainterState): 15 (WebCore::PlatformPainterState::copyPaintState): 16 (WebCore::PainterOpenVG::textDrawingMode): 17 (WebCore::PainterOpenVG::setTextDrawingMode): 18 (WebCore::PainterOpenVG::drawText): 19 * platform/graphics/openvg/PainterOpenVG.h: 20 1 21 2010-03-12 Jakob Petsovits <jpetsovits@rim.com> 2 22 -
trunk/WebCore/platform/graphics/openvg/PainterOpenVG.cpp
r55922 r55923 123 123 float strokeDashOffset; 124 124 125 int textDrawingMode; 125 126 bool antialiasingEnabled; 126 127 … … 140 141 , strokeMiterLimit(4.0) 141 142 , strokeDashOffset(0.0) 143 , textDrawingMode(cTextFill) 142 144 , antialiasingEnabled(true) 143 145 { … … 188 190 strokeDashOffset = other->strokeDashOffset; 189 191 192 textDrawingMode = other->textDrawingMode; 190 193 antialiasingEnabled = other->antialiasingEnabled; 191 194 } … … 651 654 m_state->fillColor = color; 652 655 setVGSolidColor(VG_FILL_PATH, color); 656 } 657 658 int PainterOpenVG::textDrawingMode() const 659 { 660 ASSERT(m_state); 661 return m_state->textDrawingMode; 662 } 663 664 void PainterOpenVG::setTextDrawingMode(int mode) 665 { 666 ASSERT(m_state); 667 m_state->textDrawingMode = mode; 653 668 } 654 669 … … 1071 1086 } 1072 1087 1088 #ifdef OPENVG_VERSION_1_1 1089 void PainterOpenVG::drawText(VGFont vgFont, Vector<VGuint>& characters, VGfloat* adjustmentsX, VGfloat* adjustmentsY, const FloatPoint& point) 1090 { 1091 ASSERT(m_state); 1092 1093 VGbitfield paintModes = 0; 1094 1095 if (m_state->textDrawingMode & cTextClip) 1096 return; // unsupported for every port except CG at the time of writing 1097 if (m_state->textDrawingMode & cTextFill && !m_state->fillDisabled()) 1098 paintModes |= VG_FILL_PATH; 1099 if (m_state->textDrawingMode & cTextStroke && !m_state->strokeDisabled()) 1100 paintModes |= VG_STROKE_PATH; 1101 1102 m_surface->makeCurrent(); 1103 1104 FloatPoint effectivePoint = m_state->surfaceTransformation.mapPoint(point); 1105 FloatPoint p = point; 1106 AffineTransform* originalTransformation = 0; 1107 1108 // In case the font isn't drawn at a pixel-exact baseline and we can easily 1109 // fix that (which is the case for non-rotated affine transforms), let's 1110 // align the starting point to the pixel boundary in order to prevent 1111 // font rendering issues such as glyphs that appear off by a pixel. 1112 // This causes us to have inconsistent spacing between baselines in a 1113 // larger paragraph, but that seems to be the least of all evils. 1114 if ((fmod(effectivePoint.x() + 0.01, 1.0) > 0.02 || fmod(effectivePoint.y() + 0.01, 1.0) > 0.02) 1115 && isNonRotatedAffineTransformation(m_state->surfaceTransformation)) 1116 { 1117 originalTransformation = new AffineTransform(m_state->surfaceTransformation); 1118 setTransformation(AffineTransform( 1119 m_state->surfaceTransformation.a(), 0, 1120 0, m_state->surfaceTransformation.d(), 1121 roundf(effectivePoint.x()), roundf(effectivePoint.y()))); 1122 p = FloatPoint(); 1123 } 1124 1125 const VGfloat vgPoint[2] = { p.x(), p.y() }; 1126 vgSetfv(VG_GLYPH_ORIGIN, 2, vgPoint); 1127 ASSERT_VG_NO_ERROR(); 1128 1129 vgDrawGlyphs(vgFont, characters.size(), characters.data(), 1130 adjustmentsX, adjustmentsY, paintModes, VG_TRUE /* allow autohinting */); 1131 ASSERT_VG_NO_ERROR(); 1132 1133 if (originalTransformation) { 1134 setTransformation(*originalTransformation); 1135 delete originalTransformation; 1136 } 1137 } 1138 #endif 1139 1073 1140 void PainterOpenVG::save(PainterOpenVG::SaveMode saveMode) 1074 1141 { -
trunk/WebCore/platform/graphics/openvg/PainterOpenVG.h
r55922 r55923 90 90 void setFillColor(const Color&); 91 91 92 int textDrawingMode() const; 93 void setTextDrawingMode(int mode); 94 92 95 bool antialiasingEnabled() const; 93 96 void setAntialiasingEnabled(bool); … … 99 102 void drawEllipse(const IntRect& bounds, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH)); 100 103 void drawPolygon(size_t numPoints, const FloatPoint* points, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH)); 104 #ifdef OPENVG_VERSION_1_1 105 void drawText(VGFont, Vector<VGuint>& characters, VGfloat* adjustmentsX, VGfloat* adjustmentsY, const FloatPoint&); 106 #endif 101 107 102 108 void scale(const FloatSize& scaleFactors);
Note: See TracChangeset
for help on using the changeset viewer.