Chromium Code Reviews| 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 // 2) the glyph buffer is encoded as a single blob, and | 400 // 2) the glyph buffer is encoded as a single blob, and |
| 401 // 3) the blob is not upright/rotated | 401 // 3) the blob is not upright/rotated |
| 402 if (runInfo.cachedTextBlob && bloberizer.blobCount() == 1 && | 402 if (runInfo.cachedTextBlob && bloberizer.blobCount() == 1 && |
| 403 blob.second == NoRotation) { | 403 blob.second == NoRotation) { |
| 404 ASSERT(!*runInfo.cachedTextBlob); | 404 ASSERT(!*runInfo.cachedTextBlob); |
| 405 *runInfo.cachedTextBlob = std::move(blob.first); | 405 *runInfo.cachedTextBlob = std::move(blob.first); |
| 406 ASSERT(*runInfo.cachedTextBlob); | 406 ASSERT(*runInfo.cachedTextBlob); |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 static int getInterceptsFromBloberizer(const GlyphBuffer& glyphBuffer, | |
| 411 const Font* font, | |
| 412 const SkPaint& paint, | |
| 413 float deviceScaleFactor, | |
| 414 const std::tuple<float, float>& bounds, | |
| 415 SkScalar* interceptsBuffer) { | |
| 416 SkScalar boundsArray[2] = {std::get<0>(bounds), std::get<1>(bounds)}; | |
| 417 GlyphBufferBloberizer bloberizer(glyphBuffer, font, deviceScaleFactor); | |
| 418 std::pair<sk_sp<SkTextBlob>, BlobRotation> blob; | |
| 419 | |
| 420 int numIntervals = 0; | |
| 421 while (!bloberizer.done()) { | |
| 422 blob = bloberizer.next(); | |
| 423 DCHECK(blob.first); | |
| 424 | |
| 425 // GlyphBufferBloberizer splits for a new blob rotation, but does not split | |
| 426 // for a change in font. A TextBlob can contain runs with differing fonts | |
| 427 // and the getTextBlobIntercepts method handles multiple fonts for us. For | |
| 428 // upright in vertical blobs we currently have to bail, see crbug.com/655154 | |
| 429 if (blob.second == BlobRotation::CCWRotation) | |
| 430 continue; | |
| 431 | |
| 432 SkScalar* offsetInterceptsBuffer = nullptr; | |
| 433 if (interceptsBuffer) | |
| 434 offsetInterceptsBuffer = &interceptsBuffer[numIntervals]; | |
| 435 numIntervals += paint.getTextBlobIntercepts(blob.first.get(), boundsArray, | |
| 436 interceptsBuffer); | |
|
f(malita)
2016/10/14 15:39:21
Ah, the bots caught this one: I think we want offs
| |
| 437 } | |
| 438 return numIntervals; | |
| 439 } | |
| 440 | |
| 441 void Font::getTextIntercepts(const TextRunPaintInfo& runInfo, | |
| 442 float deviceScaleFactor, | |
| 443 const SkPaint& paint, | |
| 444 const std::tuple<float, float>& bounds, | |
| 445 Vector<TextIntercept>& intercepts) const { | |
| 446 if (shouldSkipDrawing()) | |
| 447 return; | |
| 448 | |
| 449 int numIntervals = 0; | |
|
f(malita)
2016/10/14 15:36:48
nit: no need to decl/initialize numIntervals here
drott
2016/10/14 16:36:45
Yes, moved the second declaration down to line 468
| |
| 450 | |
| 451 if (runInfo.cachedTextBlob && runInfo.cachedTextBlob->get()) { | |
| 452 SkScalar boundsArray[2] = {std::get<0>(bounds), std::get<1>(bounds)}; | |
| 453 int numIntervals = paint.getTextBlobIntercepts( | |
| 454 runInfo.cachedTextBlob->get(), boundsArray, nullptr); | |
| 455 DCHECK_EQ(numIntervals % 2, 0); | |
| 456 intercepts.resize(numIntervals / 2); | |
| 457 paint.getTextBlobIntercepts(runInfo.cachedTextBlob->get(), boundsArray, | |
|
f(malita)
2016/10/14 15:36:48
nit: not sure how common this is in practice, but
drott
2016/10/14 16:36:45
Done.
| |
| 458 reinterpret_cast<SkScalar*>(intercepts.data())); | |
| 459 return; | |
| 460 } | |
| 461 | |
| 462 GlyphBuffer glyphBuffer; | |
| 463 buildGlyphBuffer(runInfo, glyphBuffer); | |
| 464 | |
| 465 // Get the number of intervals, without copying the actual values by | |
| 466 // specifying nullptr for the buffer, following the Skia allocation model for | |
| 467 // retrieving text intercepts. | |
| 468 numIntervals = getInterceptsFromBloberizer( | |
| 469 glyphBuffer, this, paint, deviceScaleFactor, bounds, nullptr); | |
| 470 DCHECK_EQ(numIntervals % 2, 0); | |
| 471 intercepts.resize(numIntervals / 2); | |
| 472 | |
| 473 getInterceptsFromBloberizer(glyphBuffer, this, paint, deviceScaleFactor, | |
|
f(malita)
2016/10/14 15:36:48
nit: ditto
drott
2016/10/14 16:36:46
Done here as well.
| |
| 474 bounds, | |
| 475 reinterpret_cast<SkScalar*>(intercepts.data())); | |
| 476 } | |
| 477 | |
| 410 static inline FloatRect pixelSnappedSelectionRect(FloatRect rect) { | 478 static inline FloatRect pixelSnappedSelectionRect(FloatRect rect) { |
| 411 // Using roundf() rather than ceilf() for the right edge as a compromise to | 479 // Using roundf() rather than ceilf() for the right edge as a compromise to |
| 412 // ensure correct caret positioning. | 480 // ensure correct caret positioning. |
| 413 float roundedX = roundf(rect.x()); | 481 float roundedX = roundf(rect.x()); |
| 414 return FloatRect(roundedX, rect.y(), roundf(rect.maxX() - roundedX), | 482 return FloatRect(roundedX, rect.y(), roundf(rect.maxX() - roundedX), |
| 415 rect.height()); | 483 rect.height()); |
| 416 } | 484 } |
| 417 | 485 |
| 418 FloatRect Font::selectionRectForText(const TextRun& run, | 486 FloatRect Font::selectionRectForText(const TextRun& run, |
| 419 const FloatPoint& point, | 487 const FloatPoint& point, |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 | 1006 |
| 939 bool Font::loadingCustomFonts() const { | 1007 bool Font::loadingCustomFonts() const { |
| 940 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); | 1008 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); |
| 941 } | 1009 } |
| 942 | 1010 |
| 943 bool Font::isFallbackValid() const { | 1011 bool Font::isFallbackValid() const { |
| 944 return !m_fontFallbackList || m_fontFallbackList->isValid(); | 1012 return !m_fontFallbackList || m_fontFallbackList->isValid(); |
| 945 } | 1013 } |
| 946 | 1014 |
| 947 } // namespace blink | 1015 } // namespace blink |
| OLD | NEW |