OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkRecordDraw.h" | 8 #include "SkRecordDraw.h" |
9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
10 | 10 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 Bounds bounds(const DrawTextBlob& op) const { | 466 Bounds bounds(const DrawTextBlob& op) const { |
467 SkRect dst = op.blob->bounds(); | 467 SkRect dst = op.blob->bounds(); |
468 dst.offset(op.x, op.y); | 468 dst.offset(op.x, op.y); |
469 return this->adjustAndMap(dst, &op.paint); | 469 return this->adjustAndMap(dst, &op.paint); |
470 } | 470 } |
471 | 471 |
472 static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { | 472 static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { |
473 #ifdef SK_DEBUG | 473 #ifdef SK_DEBUG |
474 SkRect correct = *rect; | 474 SkRect correct = *rect; |
475 #endif | 475 #endif |
476 const SkScalar yPad = 2.0f * paint.getTextSize(), // In practice, this
seems to be enough. | 476 // crbug.com/373785 ~~> xPad = 4x yPad |
477 xPad = 4.0f * yPad; // Hack for very wide
Github logo font. | 477 // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x |
| 478 const SkScalar yPad = 2.5f * paint.getTextSize(), |
| 479 xPad = 4.0f * yPad; |
478 rect->outset(xPad, yPad); | 480 rect->outset(xPad, yPad); |
479 #ifdef SK_DEBUG | 481 #ifdef SK_DEBUG |
480 SkPaint::FontMetrics metrics; | 482 SkPaint::FontMetrics metrics; |
481 paint.getFontMetrics(&metrics); | 483 paint.getFontMetrics(&metrics); |
482 correct.fLeft += metrics.fXMin; | 484 correct.fLeft += metrics.fXMin; |
483 correct.fTop += metrics.fTop; | 485 correct.fTop += metrics.fTop; |
484 correct.fRight += metrics.fXMax; | 486 correct.fRight += metrics.fXMax; |
485 correct.fBottom += metrics.fBottom; | 487 correct.fBottom += metrics.fBottom; |
486 // See skia:2862 for why we ignore small text sizes. | 488 // See skia:2862 for why we ignore small text sizes. |
487 SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct), | 489 SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. | 554 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. |
553 SkTDArray<SaveBounds> fSaveStack; | 555 SkTDArray<SaveBounds> fSaveStack; |
554 SkTDArray<unsigned> fControlIndices; | 556 SkTDArray<unsigned> fControlIndices; |
555 }; | 557 }; |
556 | 558 |
557 } // namespace SkRecords | 559 } // namespace SkRecords |
558 | 560 |
559 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 561 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
560 SkRecords::FillBounds(record, bbh); | 562 SkRecords::FillBounds(record, bbh); |
561 } | 563 } |
OLD | NEW |