| 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 "SkTSort.h" | 9 #include "SkTSort.h" |
| 10 | 10 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 const SkScalar yPad = 1.5f * paint.getTextSize(), // In practice, this
seems to be enough. | 319 const SkScalar yPad = 1.5f * paint.getTextSize(), // In practice, this
seems to be enough. |
| 320 xPad = 4.0f * yPad; // Hack for very wide
Github logo font. | 320 xPad = 4.0f * yPad; // Hack for very wide
Github logo font. |
| 321 rect->outset(xPad, yPad); | 321 rect->outset(xPad, yPad); |
| 322 #ifdef SK_DEBUG | 322 #ifdef SK_DEBUG |
| 323 SkPaint::FontMetrics metrics; | 323 SkPaint::FontMetrics metrics; |
| 324 paint.getFontMetrics(&metrics); | 324 paint.getFontMetrics(&metrics); |
| 325 correct.fLeft += metrics.fXMin; | 325 correct.fLeft += metrics.fXMin; |
| 326 correct.fTop += metrics.fTop; | 326 correct.fTop += metrics.fTop; |
| 327 correct.fRight += metrics.fXMax; | 327 correct.fRight += metrics.fXMax; |
| 328 correct.fBottom += metrics.fBottom; | 328 correct.fBottom += metrics.fBottom; |
| 329 SkASSERTF(rect->contains(correct), "%f %f %f %f vs. %f %f %f %f\n", | 329 // See skia:2862 for why we ignore small text sizes. |
| 330 SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct), |
| 331 "%f %f %f %f vs. %f %f %f %f\n", |
| 330 -xPad, -yPad, +xPad, +yPad, | 332 -xPad, -yPad, +xPad, +yPad, |
| 331 metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); | 333 metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); |
| 332 #endif | 334 #endif |
| 333 } | 335 } |
| 334 | 336 |
| 335 // Returns true if rect was meaningfully adjusted for the effects of paint, | 337 // Returns true if rect was meaningfully adjusted for the effects of paint, |
| 336 // false if the paint could affect the rect in unknown ways. | 338 // false if the paint could affect the rect in unknown ways. |
| 337 static bool AdjustForPaint(const SkPaint* paint, SkRect* rect) { | 339 static bool AdjustForPaint(const SkPaint* paint, SkRect* rect) { |
| 338 if (paint) { | 340 if (paint) { |
| 339 if (paint->canComputeFastBounds()) { | 341 if (paint->canComputeFastBounds()) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. | 390 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. |
| 389 SkTDArray<SaveBounds> fSaveStack; | 391 SkTDArray<SaveBounds> fSaveStack; |
| 390 SkTDArray<unsigned> fControlIndices; | 392 SkTDArray<unsigned> fControlIndices; |
| 391 }; | 393 }; |
| 392 | 394 |
| 393 } // namespace SkRecords | 395 } // namespace SkRecords |
| 394 | 396 |
| 395 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 397 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
| 396 SkRecords::FillBounds(record, bbh); | 398 SkRecords::FillBounds(record, bbh); |
| 397 } | 399 } |
| OLD | NEW |