Changeset 234318 in webkit
- Timestamp:
- Jul 27, 2018, 11:21:16 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r234317 r234318 1 2018-07-27 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WIN] Crash when trying to access store pages 4 https://bugs.webkit.org/show_bug.cgi?id=188032 5 <rdar://problem/42467016> 6 7 Reviewed by Brent Fulgham. 8 9 The Windows implementation of GlyphBuffer has an additional member, m_offsets, which represents 10 an additional offset to the position to paint each glyph. It also has two add() functions, one 11 which appends to this vector, and one which doesn't. The one that doesn't append to the vector 12 should never be called on Windows (because Windows requires this vector to be full). 13 14 There were two situations where it was getting called: 15 1) Inside ComplexTextController 16 2) Inside display list playback 17 18 Windows shouldn't be using ComplexTextController because the Windows implementation of this 19 class isn't ready yet; instead it should be using UniscribeController. The display list playback 20 code should be used on Windows. 21 22 Rather than fix the function to append an offset, we actually don't need the m_offsets vector 23 in the first place. Instead, we can do it the same way that the Cocoa ports do it, which is to 24 bake the offsets into the glyph advances. This is possible because the GlyphBuffer doesn't need 25 to distinguish between layout advances and paint advances, so we can bake them together and 26 just put paint advances in the GlyphBuffer. This should be a small (probably within-the-noise) 27 performance and memory improvement. 28 29 * platform/graphics/ComplexTextController.cpp: 30 (WebCore::ComplexTextController::ComplexTextController): Make sure that ComplexTextController 31 isn't used on Windows. 32 * platform/graphics/FontCascade.cpp: 33 (WebCore::FontCascade::widthOfTextRange const): Switch from ComplexTextController to 34 UniscribeController on Windows. 35 (WebCore::FontCascade::drawGlyphBuffer const): After deleting the m_offsets vector, there's 36 no reason to consult it when drawing. 37 * platform/graphics/GlyphBuffer.h: Remove m_offsets 38 (WebCore::GlyphBuffer::clear): 39 (WebCore::GlyphBuffer::advanceAt const): 40 (WebCore::GlyphBuffer::add): 41 (WebCore::GlyphBuffer::expandLastAdvance): 42 (WebCore::GlyphBuffer::shrink): 43 (WebCore::GlyphBuffer::swap): 44 (WebCore::GlyphBuffer::offsetAt const): Deleted. 45 * platform/graphics/win/FontCGWin.cpp: 46 (WebCore::FontCascade::drawGlyphs): After deleting the m_offsets vector, there's no reason 47 to consult it when drawing. 48 * platform/graphics/win/FontCascadeDirect2D.cpp: 49 (WebCore::FontCascade::drawGlyphs): Ditto. 50 * platform/graphics/win/UniscribeController.cpp: 51 (WebCore::UniscribeController::shapeAndPlaceItem): Bake in the offsets into the glyph advances. 52 1 53 2018-07-27 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 54 -
trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp
r229400 r234318 145 145 , m_forTextEmphasis(forTextEmphasis) 146 146 { 147 #if PLATFORM(WIN) 148 ASSERT_NOT_REACHED(); 149 #endif 150 147 151 computeExpansionOpportunity(); 148 152 -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r233851 r234318 42 42 #include <wtf/text/StringBuilder.h> 43 43 44 #if PLATFORM(WIN) 45 #include "UniscribeController.h" 46 #endif 47 44 48 namespace WebCore { 45 49 using namespace WTF; … … 344 348 auto codePathToUse = codePath(run); 345 349 if (codePathToUse == Complex) { 350 #if PLATFORM(WIN) 351 UniscribeController it(this, run); 352 it.advance(from); 353 offsetBeforeRange = it.runWidthSoFar(); 354 it.advance(to); 355 offsetAfterRange = it.runWidthSoFar(); 356 it.advance(to); 357 totalWidth = it.runWidthSoFar(); 358 #else 346 359 ComplexTextController complexIterator(*this, run, false, fallbackFonts); 347 360 complexIterator.advance(from, nullptr, IncludePartialGlyphs, fallbackFonts); … … 351 364 complexIterator.advance(run.length(), nullptr, IncludePartialGlyphs, fallbackFonts); 352 365 totalWidth = complexIterator.runWidthSoFar(); 366 #endif 353 367 } else { 354 368 WidthIterator simpleIterator(this, run, fallbackFonts); … … 1419 1433 // Draw each contiguous run of glyphs that use the same font data. 1420 1434 const Font* fontData = glyphBuffer.fontAt(0); 1421 FloatSize offset = glyphBuffer.offsetAt(0);1435 // FIXME: Why do we subtract the initial advance's height but not its width??? 1422 1436 FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height()); 1423 1437 float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width(); … … 1427 1441 while (nextGlyph < glyphBuffer.size()) { 1428 1442 const Font* nextFontData = glyphBuffer.fontAt(nextGlyph); 1429 FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph); 1430 1431 if (nextFontData != fontData || nextOffset != offset) { 1443 1444 if (nextFontData != fontData) { 1432 1445 if (shouldDrawIfLoading(*fontData, customFontNotReadyAction)) 1433 1446 context.drawGlyphs(*fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint, m_fontDescription.fontSmoothing()); … … 1435 1448 lastFrom = nextGlyph; 1436 1449 fontData = nextFontData; 1437 offset = nextOffset;1438 1450 startPoint.setX(nextX); 1439 1451 startPoint.setY(nextY); -
trunk/Source/WebCore/platform/graphics/GlyphBuffer.h
r222610 r234318 28 28 */ 29 29 30 #ifndef GlyphBuffer_h 31 #define GlyphBuffer_h 30 #pragma once 32 31 33 32 #include "FloatSize.h" … … 86 85 if (m_offsetsInString) 87 86 m_offsetsInString->clear(); 88 #if PLATFORM(WIN)89 m_offsets.clear();90 #endif91 87 } 92 88 … … 111 107 return m_advances[index]; 112 108 } 113 114 FloatSize offsetAt(unsigned index) const115 {116 #if PLATFORM(WIN)117 return m_offsets[index];118 #else119 UNUSED_PARAM(index);120 return FloatSize();121 #endif122 }123 109 124 110 static const unsigned noOffset = UINT_MAX; 125 void add(Glyph glyph, const Font* font, float width, unsigned offsetInString = noOffset , const FloatSize* offset = 0)111 void add(Glyph glyph, const Font* font, float width, unsigned offsetInString = noOffset) 126 112 { 127 m_font.append(font); 128 m_glyphs.append(glyph); 113 GlyphBufferAdvance advance; 114 advance.setWidth(width); 115 advance.setHeight(0); 129 116 130 #if USE(CG) 131 CGSize advance = { width, 0 }; 132 m_advances.append(advance); 133 #else 134 m_advances.append(FloatSize(width, 0)); 135 #endif 117 add(glyph, font, advance, offsetInString); 118 } 136 119 137 #if PLATFORM(WIN)138 if (offset)139 m_offsets.append(*offset);140 else141 m_offsets.append(FloatSize());142 #else143 UNUSED_PARAM(offset);144 #endif145 146 if (offsetInString != noOffset && m_offsetsInString)147 m_offsetsInString->append(offsetInString);148 }149 150 #if !USE(WINGDI)151 120 void add(Glyph glyph, const Font* font, GlyphBufferAdvance advance, unsigned offsetInString = noOffset) 152 121 { … … 159 128 m_offsetsInString->append(offsetInString); 160 129 } 161 #endif162 130 163 131 void reverse(unsigned from, unsigned length) … … 172 140 GlyphBufferAdvance& lastAdvance = m_advances.last(); 173 141 lastAdvance.setWidth(lastAdvance.width() + width); 142 } 143 144 void expandLastAdvance(GlyphBufferAdvance expansion) 145 { 146 ASSERT(!isEmpty()); 147 GlyphBufferAdvance& lastAdvance = m_advances.last(); 148 lastAdvance.setWidth(lastAdvance.width() + expansion.width()); 149 lastAdvance.setHeight(lastAdvance.height() + expansion.height()); 174 150 } 175 151 … … 192 168 if (m_offsetsInString) 193 169 m_offsetsInString->shrink(truncationPoint); 194 #if PLATFORM(WIN)195 m_offsets.shrink(truncationPoint);196 #endif197 170 } 198 171 … … 211 184 m_advances[index1] = m_advances[index2]; 212 185 m_advances[index2] = s; 213 214 #if PLATFORM(WIN)215 FloatSize offset = m_offsets[index1];216 m_offsets[index1] = m_offsets[index2];217 m_offsets[index2] = offset;218 #endif219 186 } 220 187 … … 224 191 GlyphBufferAdvance m_initialAdvance; 225 192 std::unique_ptr<Vector<unsigned, 2048>> m_offsetsInString; 226 #if PLATFORM(WIN)227 Vector<FloatSize, 2048> m_offsets;228 #endif229 193 }; 230 194 231 195 } 232 #endif -
trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp
r233851 r234318 175 175 CGContextSetTextMatrix(cgContext, matrix); 176 176 177 // Uniscribe gives us offsets to help refine the positioning of combining glyphs.178 FloatSize translation = glyphBuffer.offsetAt(from);179 180 177 CGContextSetFontSize(cgContext, platformData.size()); 181 178 wkSetCGContextFontRenderingStyle(cgContext, font.platformData().isSystemFont(), false, font.platformData().useGDI()); … … 193 190 Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255); 194 191 graphicsContext.setFillColor(shadowFillColor); 195 float shadowTextX = point.x() + translation.width() +shadowOffset.width();192 float shadowTextX = point.x() + shadowOffset.width(); 196 193 // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative. 197 float shadowTextY = point.y() + translation.height() +shadowOffset.height() * (graphicsContext.shadowsIgnoreTransforms() ? -1 : 1);194 float shadowTextY = point.y() + shadowOffset.height() * (graphicsContext.shadowsIgnoreTransforms() ? -1 : 1); 198 195 CGContextSetTextPosition(cgContext, shadowTextX, shadowTextY); 199 196 CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs); 200 197 if (font.syntheticBoldOffset()) { 201 CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width() + font.syntheticBoldOffset(), point.y() + translation.height() + shadowOffset.height());198 CGContextSetTextPosition(cgContext, point.x() + shadowOffset.width() + font.syntheticBoldOffset(), point.y() + shadowOffset.height()); 202 199 CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs); 203 200 } … … 205 202 } 206 203 207 CGContextSetTextPosition(cgContext, point.x() + translation.width(), point.y() + translation.height());204 CGContextSetTextPosition(cgContext, point.x(), point.y()); 208 205 CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs); 209 206 if (font.syntheticBoldOffset()) { 210 CGContextSetTextPosition(cgContext, point.x() + translation.width() + font.syntheticBoldOffset(), point.y() + translation.height());207 CGContextSetTextPosition(cgContext, point.x() + font.syntheticBoldOffset(), point.y()); 211 208 CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs); 212 209 } -
trunk/Source/WebCore/platform/graphics/win/FontCascadeDirect2D.cpp
r233851 r234318 84 84 } 85 85 86 // Uniscribe gives us offsets to help refine the positioning of combining glyphs.87 FloatSize translation = glyphBuffer.offsetAt(from);88 89 86 RELEASE_ASSERT(platformData.dwFont()); 90 87 RELEASE_ASSERT(platformData.dwFontFace()); … … 126 123 Color fillColor = graphicsContext.fillColor(); 127 124 Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255); 128 float shadowTextX = point.x() + translation.width() +shadowOffset.width();125 float shadowTextX = point.x() + shadowOffset.width(); 129 126 // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative. 130 float shadowTextY = point.y() + translation.height() +shadowOffset.height() * (graphicsContext.shadowsIgnoreTransforms() ? -1 : 1);127 float shadowTextY = point.y() + shadowOffset.height() * (graphicsContext.shadowsIgnoreTransforms() ? -1 : 1); 131 128 132 129 auto shadowBrush = graphicsContext.brushWithColor(shadowFillColor); … … 136 133 } 137 134 138 context->DrawGlyphRun(D2D1::Point2F(point.x() + translation.width(), point.y() + translation.height()), &glyphRun, graphicsContext.solidFillBrush());135 context->DrawGlyphRun(D2D1::Point2F(point.x(), point.y()), &glyphRun, graphicsContext.solidFillBrush()); 139 136 if (font.syntheticBoldOffset()) 140 context->DrawGlyphRun(D2D1::Point2F(point.x() + translation.width() + font.syntheticBoldOffset(), point.y() + translation.height()), &glyphRun, graphicsContext.solidFillBrush());137 context->DrawGlyphRun(D2D1::Point2F(point.x() + font.syntheticBoldOffset(), point.y()), &glyphRun, graphicsContext.solidFillBrush()); 141 138 142 139 if (hasSimpleShadow) -
trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp
r232932 r234318 365 365 // translation. 366 366 if (glyphBuffer) { 367 FloatSize size(offsetX, -offsetY); 368 glyphBuffer->add(glyph, fontData, advance, GlyphBuffer::noOffset, &size); 367 GlyphBufferAdvance origin(offsetX, -offsetY); 368 if (!glyphBuffer->advancesCount()) 369 glyphBuffer->setInitialAdvance(origin); 370 else 371 glyphBuffer->expandLastAdvance(origin); 372 GlyphBufferAdvance advance(-origin.width() + advance, -origin.height()); 373 glyphBuffer->add(glyph, fontData, advance); 369 374 } 370 375
Note:
See TracChangeset
for help on using the changeset viewer.