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

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

Issue 2598393002: Do not skip ink for ideographic scripts (Closed)
Patch Set: drott nits Created 3 years, 11 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
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 STACK_ALLOCATED() 250 STACK_ALLOCATED()
251 public: 251 public:
252 GlyphBufferBloberizer(const GlyphBuffer& buffer, 252 GlyphBufferBloberizer(const GlyphBuffer& buffer,
253 const Font* font, 253 const Font* font,
254 float deviceScaleFactor) 254 float deviceScaleFactor)
255 : m_buffer(buffer), 255 : m_buffer(buffer),
256 m_font(font), 256 m_font(font),
257 m_deviceScaleFactor(deviceScaleFactor), 257 m_deviceScaleFactor(deviceScaleFactor),
258 m_hasVerticalOffsets(buffer.hasVerticalOffsets()), 258 m_hasVerticalOffsets(buffer.hasVerticalOffsets()),
259 m_index(0), 259 m_index(0),
260 m_endIndex(m_buffer.size()),
260 m_blobCount(0), 261 m_blobCount(0),
261 m_rotation(buffer.isEmpty() ? NoRotation : computeBlobRotation( 262 m_rotation(buffer.isEmpty() ? NoRotation : computeBlobRotation(
262 buffer.fontDataAt(0))) {} 263 buffer.fontDataAt(0))) {
264 if (m_buffer.hasSkipInkExceptions()) {
265 while (m_endIndex > 0 && m_buffer.isSkipInkException(m_endIndex - 1))
266 m_endIndex--;
267 }
268 }
263 269
264 bool done() const { return m_index >= m_buffer.size(); } 270 bool done() const { return m_index >= m_endIndex; }
265 unsigned blobCount() const { return m_blobCount; } 271 unsigned blobCount() const { return m_blobCount; }
266 272
267 std::pair<sk_sp<SkTextBlob>, BlobRotation> next() { 273 std::pair<sk_sp<SkTextBlob>, BlobRotation> next() {
268 ASSERT(!done()); 274 ASSERT(!done());
269 const BlobRotation currentRotation = m_rotation; 275 const BlobRotation currentRotation = m_rotation;
270 276
271 while (m_index < m_buffer.size()) { 277 while (m_index < m_endIndex) {
278 if (m_buffer.hasSkipInkExceptions()) {
279 while (m_index < m_endIndex && m_buffer.isSkipInkException(m_index))
280 m_index++;
281 }
282
272 const SimpleFontData* fontData = m_buffer.fontDataAt(m_index); 283 const SimpleFontData* fontData = m_buffer.fontDataAt(m_index);
273 ASSERT(fontData); 284 ASSERT(fontData);
274 285
275 const BlobRotation newRotation = computeBlobRotation(fontData); 286 const BlobRotation newRotation = computeBlobRotation(fontData);
276 if (newRotation != m_rotation) { 287 if (newRotation != m_rotation) {
277 // We're switching to an orientation which requires a different rotation 288 // We're switching to an orientation which requires a different rotation
278 // => emit the pending blob (and start a new one with the new 289 // => emit the pending blob (and start a new one with the new
279 // rotation). 290 // rotation).
280 m_rotation = newRotation; 291 m_rotation = newRotation;
281 break; 292 break;
282 } 293 }
283 294
284 const unsigned start = m_index++; 295 const unsigned start = m_index++;
285 while (m_index < m_buffer.size() && 296 while (m_index < m_endIndex && m_buffer.fontDataAt(m_index) == fontData &&
286 m_buffer.fontDataAt(m_index) == fontData) 297 !m_buffer.isSkipInkException(m_index))
287 m_index++; 298 m_index++;
288 299
289 appendRun(start, m_index - start, fontData); 300 appendRun(start, m_index - start, fontData);
290 } 301 }
291 302
292 m_blobCount++; 303 m_blobCount++;
293 return std::make_pair(m_builder.make(), currentRotation); 304 return std::make_pair(m_builder.make(), currentRotation);
294 } 305 }
295 306
296 private: 307 private:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 347 }
337 } 348 }
338 349
339 const GlyphBuffer& m_buffer; 350 const GlyphBuffer& m_buffer;
340 const Font* m_font; 351 const Font* m_font;
341 const float m_deviceScaleFactor; 352 const float m_deviceScaleFactor;
342 const bool m_hasVerticalOffsets; 353 const bool m_hasVerticalOffsets;
343 354
344 SkTextBlobBuilder m_builder; 355 SkTextBlobBuilder m_builder;
345 unsigned m_index; 356 unsigned m_index;
357 unsigned m_endIndex;
346 unsigned m_blobCount; 358 unsigned m_blobCount;
347 BlobRotation m_rotation; 359 BlobRotation m_rotation;
348 }; 360 };
349 361
350 } // anonymous namespace 362 } // anonymous namespace
351 363
352 void Font::drawGlyphBuffer(SkCanvas* canvas, 364 void Font::drawGlyphBuffer(SkCanvas* canvas,
353 const SkPaint& paint, 365 const SkPaint& paint,
354 const TextRunPaintInfo& runInfo, 366 const TextRunPaintInfo& runInfo,
355 const GlyphBuffer& glyphBuffer, 367 const GlyphBuffer& glyphBuffer,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (!numIntervals) 444 if (!numIntervals)
433 return; 445 return;
434 DCHECK_EQ(numIntervals % 2, 0); 446 DCHECK_EQ(numIntervals % 2, 0);
435 intercepts.resize(numIntervals / 2); 447 intercepts.resize(numIntervals / 2);
436 paint.getTextBlobIntercepts(runInfo.cachedTextBlob->get(), boundsArray, 448 paint.getTextBlobIntercepts(runInfo.cachedTextBlob->get(), boundsArray,
437 reinterpret_cast<SkScalar*>(intercepts.data())); 449 reinterpret_cast<SkScalar*>(intercepts.data()));
438 return; 450 return;
439 } 451 }
440 452
441 GlyphBuffer glyphBuffer; 453 GlyphBuffer glyphBuffer;
454 // Compute skip-ink exceptions in the GlyphBuffer.
455 // Skip the computation if 8Bit(), no such characters in Latin-1.
456 if (!runInfo.run.is8Bit())
457 glyphBuffer.saveSkipInkExceptions();
442 buildGlyphBuffer(runInfo, glyphBuffer); 458 buildGlyphBuffer(runInfo, glyphBuffer);
443 459
444 // Get the number of intervals, without copying the actual values by 460 // Get the number of intervals, without copying the actual values by
445 // specifying nullptr for the buffer, following the Skia allocation model for 461 // specifying nullptr for the buffer, following the Skia allocation model for
446 // retrieving text intercepts. 462 // retrieving text intercepts.
447 int numIntervals = getInterceptsFromBloberizer( 463 int numIntervals = getInterceptsFromBloberizer(
448 glyphBuffer, this, paint, deviceScaleFactor, bounds, nullptr); 464 glyphBuffer, this, paint, deviceScaleFactor, bounds, nullptr);
449 if (!numIntervals) 465 if (!numIntervals)
450 return; 466 return;
451 DCHECK_EQ(numIntervals % 2, 0); 467 DCHECK_EQ(numIntervals % 2, 0);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 636
621 bool Font::loadingCustomFonts() const { 637 bool Font::loadingCustomFonts() const {
622 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 638 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
623 } 639 }
624 640
625 bool Font::isFallbackValid() const { 641 bool Font::isFallbackValid() const {
626 return !m_fontFallbackList || m_fontFallbackList->isValid(); 642 return !m_fontFallbackList || m_fontFallbackList->isValid();
627 } 643 }
628 644
629 } // namespace blink 645 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698