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

Side by Side Diff: src/core/SkRecordDraw.cpp

Issue 665103002: Dilate approximated text bounds to squelch recent assertion failure. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update unit test Created 6 years, 2 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
« no previous file with comments | « no previous file | tests/RecordDrawTest.cpp » ('j') | 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 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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698