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

Side by Side Diff: Source/platform/fonts/Font.cpp

Issue 778233002: TextBlob: Use deferred bounds if negative letter or word spacing exists. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 | « no previous file | 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) 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) { 252 if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty())) {
253 cacheEntry->glyphBounds = glyphBounds; 253 cacheEntry->glyphBounds = glyphBounds;
254 cacheEntry->width = result; 254 cacheEntry->width = result;
255 } 255 }
256 256
257 if (glyphOverflow) 257 if (glyphOverflow)
258 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ; 258 updateGlyphOverflowFromBounds(glyphBounds, fontMetrics(), glyphOverflow) ;
259 return result; 259 return result;
260 } 260 }
261 261
262 static bool requiresRecomputingBounds(const Font& font)
263 {
264 const FontDescription& fontDescription = font.fontDescription();
265 return fontDescription.letterSpacing() < 0 || fontDescription.wordSpacing() < 0;
266 }
267
262 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR ect& bounds, 268 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const FloatR ect& bounds,
263 bool couldUseLCD) const 269 bool couldUseLCD) const
264 { 270 {
265 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); 271 ASSERT(RuntimeEnabledFeatures::textBlobEnabled());
266 272
267 SkTextBlobBuilder builder; 273 SkTextBlobBuilder builder;
268 SkRect skBounds = bounds; 274 SkRect skBounds = bounds;
275 // FIXME: Identify these cases earlier on and avoid using bounds that are
276 // not visually correct in other places.
277 const SkRect* skBoundsPtr = requiresRecomputingBounds(*this) ? nullptr : &sk Bounds;
269 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets(); 278 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets();
270 279
271 unsigned i = 0; 280 unsigned i = 0;
272 while (i < glyphBuffer.size()) { 281 while (i < glyphBuffer.size()) {
273 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); 282 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i);
274 283
275 // FIXME: Handle vertical text. 284 // FIXME: Handle vertical text.
276 if (fontData->platformData().orientation() == Vertical) 285 if (fontData->platformData().orientation() == Vertical)
277 return nullptr; 286 return nullptr;
278 287
279 // FIXME: FontPlatformData makes some decisions on the device scale 288 // FIXME: FontPlatformData makes some decisions on the device scale
280 // factor, which is found via the GraphicsContext. This should be fixed 289 // factor, which is found via the GraphicsContext. This should be fixed
281 // to avoid correctness problems here. 290 // to avoid correctness problems here.
282 SkPaint paint; 291 SkPaint paint;
283 fontData->platformData().setupPaint(&paint, 0, this); 292 fontData->platformData().setupPaint(&paint, 0, this);
284 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 293 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
285 294
286 // FIXME: this should go away after the big LCD cleanup. 295 // FIXME: this should go away after the big LCD cleanup.
287 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD); 296 paint.setLCDRenderText(paint.isLCDRenderText() && couldUseLCD);
288 297
289 unsigned start = i++; 298 unsigned start = i++;
290 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData) 299 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData)
291 i++; 300 i++;
292 unsigned count = i - start; 301 unsigned count = i - start;
293 302
294 const SkTextBlobBuilder::RunBuffer& buffer = hasVerticalOffsets 303 const SkTextBlobBuilder::RunBuffer& buffer = hasVerticalOffsets
295 ? builder.allocRunPos(paint, count, &skBounds) 304 ? builder.allocRunPos(paint, count, skBoundsPtr)
296 : builder.allocRunPosH(paint, count, 0, &skBounds); 305 : builder.allocRunPosH(paint, count, 0, skBoundsPtr);
297 306
298 const uint16_t* glyphs = glyphBuffer.glyphs(start); 307 const uint16_t* glyphs = glyphBuffer.glyphs(start);
299 const float* offsets = glyphBuffer.offsets(start); 308 const float* offsets = glyphBuffer.offsets(start);
300 std::copy(glyphs, glyphs + count, buffer.glyphs); 309 std::copy(glyphs, glyphs + count, buffer.glyphs);
301 std::copy(offsets, offsets + (hasVerticalOffsets ? 2 * count : count), b uffer.pos); 310 std::copy(offsets, offsets + (hasVerticalOffsets ? 2 * count : count), b uffer.pos);
302 } 311 }
303 312
304 return adoptRef(builder.build()); 313 return adoptRef(builder.build());
305 } 314 }
306 315
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 if (delta <= 0) 983 if (delta <= 0)
975 break; 984 break;
976 } 985 }
977 } 986 }
978 } 987 }
979 988
980 return offset; 989 return offset;
981 } 990 }
982 991
983 } // namespace blink 992 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698