Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: Source/core/rendering/svg/SVGTextRunRenderingContext.cpp

Issue 657553002: Fold SVGRenderSupport::fillOrStrokePath into only user (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/svg/SVGRenderSupport.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 22
23 #if ENABLE(SVG_FONTS) 23 #if ENABLE(SVG_FONTS)
24 #include "core/rendering/svg/SVGTextRunRenderingContext.h" 24 #include "core/rendering/svg/SVGTextRunRenderingContext.h"
25 25
26 #include "core/rendering/RenderObject.h" 26 #include "core/rendering/RenderObject.h"
27 #include "core/rendering/svg/RenderSVGInlineText.h"
28 #include "core/rendering/svg/RenderSVGResourceSolidColor.h"
29 #include "core/rendering/svg/SVGRenderSupport.h"
30 #include "core/svg/SVGFontData.h" 27 #include "core/svg/SVGFontData.h"
31 #include "core/svg/SVGFontElement.h" 28 #include "core/svg/SVGFontElement.h"
32 #include "core/svg/SVGFontFaceElement.h" 29 #include "core/svg/SVGFontFaceElement.h"
33 #include "core/svg/SVGGlyphElement.h" 30 #include "core/svg/SVGGlyphElement.h"
34 #include "platform/fonts/GlyphBuffer.h" 31 #include "platform/fonts/GlyphBuffer.h"
35 #include "platform/fonts/shaping/SimpleShaper.h" 32 #include "platform/fonts/shaping/SimpleShaper.h"
36 #include "platform/graphics/GraphicsContext.h" 33 #include "platform/graphics/GraphicsContext.h"
37 34
38 namespace blink { 35 namespace blink {
39 36
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 ASSERT(parentRenderObjectStyle); 95 ASSERT(parentRenderObjectStyle);
99 isVerticalText = parentRenderObjectStyle->svgStyle().isVerticalWritingMo de(); 96 isVerticalText = parentRenderObjectStyle->svgStyle().isVerticalWritingMo de();
100 } 97 }
101 98
102 float scale = scaleEmToUnits(fontData->platformData().size(), fontFaceElemen t->unitsPerEm()); 99 float scale = scaleEmToUnits(fontData->platformData().size(), fontFaceElemen t->unitsPerEm());
103 100
104 FloatPoint glyphOrigin; 101 FloatPoint glyphOrigin;
105 glyphOrigin.setX(svgFontData->horizontalOriginX() * scale); 102 glyphOrigin.setX(svgFontData->horizontalOriginX() * scale);
106 glyphOrigin.setY(svgFontData->horizontalOriginY() * scale); 103 glyphOrigin.setY(svgFontData->horizontalOriginY() * scale);
107 104
108 unsigned short resourceMode = context->textDrawingMode() == TextModeStroke ? ApplyToStrokeMode : ApplyToFillMode;
109
110 FloatPoint currentPoint = point; 105 FloatPoint currentPoint = point;
111 for (int i = 0; i < numGlyphs; ++i) { 106 for (int i = 0; i < numGlyphs; ++i) {
112 Glyph glyph = glyphBuffer.glyphAt(from + i); 107 Glyph glyph = glyphBuffer.glyphAt(from + i);
113 if (!glyph) 108 if (!glyph)
114 continue; 109 continue;
115 110
116 float advance = glyphBuffer.advanceAt(from + i); 111 float advance = glyphBuffer.advanceAt(from + i);
117 SVGGlyph svgGlyph = fontElement->svgGlyphForGlyph(glyph); 112 SVGGlyph svgGlyph = fontElement->svgGlyphForGlyph(glyph);
118 ASSERT(!svgGlyph.isPartOfLigature); 113 ASSERT(!svgGlyph.isPartOfLigature);
119 ASSERT(svgGlyph.tableEntry == glyph); 114 ASSERT(svgGlyph.tableEntry == glyph);
(...skipping 14 matching lines...) Expand all
134 glyphOrigin.setY(svgGlyph.verticalOriginY * scale); 129 glyphOrigin.setY(svgGlyph.verticalOriginY * scale);
135 } 130 }
136 131
137 AffineTransform glyphPathTransform; 132 AffineTransform glyphPathTransform;
138 glyphPathTransform.translate(currentPoint.x() + glyphOrigin.x(), current Point.y() + glyphOrigin.y()); 133 glyphPathTransform.translate(currentPoint.x() + glyphOrigin.x(), current Point.y() + glyphOrigin.y());
139 glyphPathTransform.scale(scale, -scale); 134 glyphPathTransform.scale(scale, -scale);
140 135
141 Path glyphPath = svgGlyph.pathData; 136 Path glyphPath = svgGlyph.pathData;
142 glyphPath.transform(glyphPathTransform); 137 glyphPath.transform(glyphPathTransform);
143 138
144 SVGRenderSupport::fillOrStrokePath(context, resourceMode, glyphPath); 139 if (context->textDrawingMode() == TextModeStroke)
140 context->strokePath(glyphPath);
141 else
142 context->fillPath(glyphPath);
145 143
146 if (isVerticalText) 144 if (isVerticalText)
147 currentPoint.move(0, advance); 145 currentPoint.move(0, advance);
148 else 146 else
149 currentPoint.move(advance, 0); 147 currentPoint.move(advance, 0);
150 } 148 }
151 } 149 }
152 150
153 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, co nst TextRun& run, SimpleShaper& iterator, UChar32 character, bool mirror, int cu rrentCharacter, unsigned& advanceLength) 151 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, co nst TextRun& run, SimpleShaper& iterator, UChar32 character, bool mirror, int cu rrentCharacter, unsigned& advanceLength)
154 { 152 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Restore original state of the SVG Font glyph table and the current font f allback list, 218 // Restore original state of the SVG Font glyph table and the current font f allback list,
221 // to assure the next lookup of the same glyph won't immediately return the fallback glyph. 219 // to assure the next lookup of the same glyph won't immediately return the fallback glyph.
222 page->setGlyphDataForCharacter(character, glyphData.glyph, originalFontData) ; 220 page->setGlyphDataForCharacter(character, glyphData.glyph, originalFontData) ;
223 ASSERT(fallbackGlyphData.fontData); 221 ASSERT(fallbackGlyphData.fontData);
224 return fallbackGlyphData; 222 return fallbackGlyphData;
225 } 223 }
226 224
227 } 225 }
228 226
229 #endif 227 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGRenderSupport.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698