OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. |
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. | 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) { | 249 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) { |
250 cacheEntry->glyphBounds = glyphBounds; | 250 cacheEntry->glyphBounds = glyphBounds; |
251 cacheEntry->width = result; | 251 cacheEntry->width = result; |
252 } | 252 } |
253 | 253 |
254 if (glyphOverflow) | 254 if (glyphOverflow) |
255 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow)
; | 255 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow)
; |
256 return result; | 256 return result; |
257 } | 257 } |
258 | 258 |
259 static bool requiresRecomputingBounds(const Font& font, const FloatRect& bounds) | |
260 { | |
261 // Blobs should never have empty bounds, but see http://crbug.com/445527 | |
262 if (bounds.isEmpty()) | |
263 return true; | |
264 | |
265 const FontDescription& fontDescription = font.fontDescription(); | |
266 return fontDescription.letterSpacing() < 0 || fontDescription.wordSpacing()
< 0; | |
267 } | |
268 | |
269 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR
ect& bounds, | 259 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR
ect& bounds, |
270 bool couldUseLCD) const | 260 bool couldUseLCD) const |
271 { | 261 { |
272 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); | 262 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); |
273 | 263 |
274 SkTextBlobBuilder builder; | 264 SkTextBlobBuilder builder; |
275 SkRect skBounds = bounds; | |
276 // FIXME: Identify these cases earlier on and avoid using bounds that are | |
277 // not visually correct in other places. | |
278 const SkRect* skBoundsPtr = requiresRecomputingBounds(*this, bounds) ? nullp
tr : &skBounds; | |
279 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets(); | 265 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets(); |
280 | 266 |
281 unsigned i = 0; | 267 unsigned i = 0; |
282 while (i < glyphBuffer.size()) { | 268 while (i < glyphBuffer.size()) { |
283 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); | 269 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); |
284 | 270 |
285 // FIXME: Handle vertical text. | 271 // FIXME: Handle vertical text. |
286 if (fontData->platformData().orientation() == Vertical) | 272 if (fontData->platformData().orientation() == Vertical) |
287 return nullptr; | 273 return nullptr; |
288 | 274 |
289 // FIXME: FontPlatformData makes some decisions on the device scale | 275 // FIXME: FontPlatformData makes some decisions on the device scale |
290 // factor, which is found via the GraphicsContext. This should be fixed | 276 // factor, which is found via the GraphicsContext. This should be fixed |
291 // to avoid correctness problems here. | 277 // to avoid correctness problems here. |
292 SkPaint paint; | 278 SkPaint paint; |
293 fontData->platformData().setupPaint(&paint, 0, this); | 279 fontData->platformData().setupPaint(&paint, 0, this); |
294 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 280 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
295 | 281 |
296 // FIXME: this should go away after the big LCD cleanup. | 282 // FIXME: this should go away after the big LCD cleanup. |
297 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD); | 283 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD); |
298 | 284 |
299 unsigned start = i++; | 285 unsigned start = i++; |
300 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData) | 286 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData) |
301 i++; | 287 i++; |
302 unsigned count = i - start; | 288 unsigned count = i - start; |
303 | 289 |
304 const SkTextBlobBuilder::RunBuffer& buffer = hasVerticalOffsets | 290 const SkTextBlobBuilder::RunBuffer& buffer = hasVerticalOffsets |
305 ? builder.allocRunPos(paint, count, skBoundsPtr) | 291 ? builder.allocRunPos(paint, count) |
306 : builder.allocRunPosH(paint, count, 0, skBoundsPtr); | 292 : builder.allocRunPosH(paint, count, 0); |
307 | 293 |
308 const uint16_t* glyphs = glyphBuffer.glyphs(start); | 294 const uint16_t* glyphs = glyphBuffer.glyphs(start); |
309 const float* offsets = glyphBuffer.offsets(start); | 295 const float* offsets = glyphBuffer.offsets(start); |
310 std::copy(glyphs, glyphs + count, buffer.glyphs); | 296 std::copy(glyphs, glyphs + count, buffer.glyphs); |
311 std::copy(offsets, offsets + (hasVerticalOffsets ? 2 * count : count), b
uffer.pos); | 297 std::copy(offsets, offsets + (hasVerticalOffsets ? 2 * count : count), b
uffer.pos); |
312 } | 298 } |
313 | 299 |
314 return adoptRef(builder.build()); | 300 return adoptRef(builder.build()); |
315 } | 301 } |
316 | 302 |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 if (delta <= 0) | 952 if (delta <= 0) |
967 break; | 953 break; |
968 } | 954 } |
969 } | 955 } |
970 } | 956 } |
971 | 957 |
972 return offset; | 958 return offset; |
973 } | 959 } |
974 | 960 |
975 } // namespace blink | 961 } // namespace blink |
OLD | NEW |