| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 for (int i = 1; i < N; i++) { | 305 for (int i = 1; i < N; i++) { |
| 306 left = SkMinScalar(left, op.xpos[i]); | 306 left = SkMinScalar(left, op.xpos[i]); |
| 307 right = SkMaxScalar(right, op.xpos[i]); | 307 right = SkMaxScalar(right, op.xpos[i]); |
| 308 } | 308 } |
| 309 SkRect dst = { left, op.y, right, op.y }; | 309 SkRect dst = { left, op.y, right, op.y }; |
| 310 AdjustTextForFontMetrics(&dst, op.paint); | 310 AdjustTextForFontMetrics(&dst, op.paint); |
| 311 return this->adjustAndMap(dst, &op.paint); | 311 return this->adjustAndMap(dst, &op.paint); |
| 312 } | 312 } |
| 313 | 313 |
| 314 static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { | 314 static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { |
| 315 #if SK_DEBUG | 315 #ifdef SK_DEBUG |
| 316 SkRect correct = *rect; | 316 SkRect correct = *rect; |
| 317 #endif | 317 #endif |
| 318 const SkScalar yPad = 1.5f * paint.getTextSize(), // In practice, this
seems to be enough. | 318 const SkScalar yPad = 1.5f * paint.getTextSize(), // In practice, this
seems to be enough. |
| 319 xPad = 4.0f * yPad; // Hack for very wide
Github logo font. | 319 xPad = 4.0f * yPad; // Hack for very wide
Github logo font. |
| 320 rect->outset(xPad, yPad); | 320 rect->outset(xPad, yPad); |
| 321 #if SK_DEBUG | 321 #ifdef SK_DEBUG |
| 322 SkPaint::FontMetrics metrics; | 322 SkPaint::FontMetrics metrics; |
| 323 paint.getFontMetrics(&metrics); | 323 paint.getFontMetrics(&metrics); |
| 324 correct.fLeft += metrics.fXMin; | 324 correct.fLeft += metrics.fXMin; |
| 325 correct.fTop += metrics.fTop; | 325 correct.fTop += metrics.fTop; |
| 326 correct.fRight += metrics.fXMax; | 326 correct.fRight += metrics.fXMax; |
| 327 correct.fBottom += metrics.fBottom; | 327 correct.fBottom += metrics.fBottom; |
| 328 SkASSERTF(rect->contains(correct), "%f %f %f %f vs. %f %f %f %f\n", | 328 SkASSERTF(rect->contains(correct), "%f %f %f %f vs. %f %f %f %f\n", |
| 329 -xPad, -yPad, +xPad, +yPad, | 329 -xPad, -yPad, +xPad, +yPad, |
| 330 metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); | 330 metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); |
| 331 #endif | 331 #endif |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. | 387 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. |
| 388 SkTDArray<SaveBounds> fSaveStack; | 388 SkTDArray<SaveBounds> fSaveStack; |
| 389 SkTDArray<unsigned> fControlIndices; | 389 SkTDArray<unsigned> fControlIndices; |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 } // namespace SkRecords | 392 } // namespace SkRecords |
| 393 | 393 |
| 394 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 394 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
| 395 SkRecords::FillBounds(record, bbh); | 395 SkRecords::FillBounds(record, bbh); |
| 396 } | 396 } |
| OLD | NEW |