Index: src/core/SkBBoxRecord.cpp |
diff --git a/src/core/SkBBoxRecord.cpp b/src/core/SkBBoxRecord.cpp |
index 366808703f6a97ef74987fde48a4a7d7f1bac818..e91628e9429d58c3af961d499e518a4ec859eca3 100644 |
--- a/src/core/SkBBoxRecord.cpp |
+++ b/src/core/SkBBoxRecord.cpp |
@@ -181,10 +181,12 @@ void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca |
SkScalar constY, const SkPaint& paint) { |
SkRect bbox; |
size_t numChars = paint.countText(text, byteLength); |
+ |
+ const SkFlatData* flatPaintData = this->getFlatPaintData(paint); |
+ |
if (numChars > 0) { |
reed1
2013/08/20 17:59:23
minor: if numChars == 0, we should abort everythin
|
bbox.fLeft = xpos[0]; |
bbox.fRight = xpos[numChars - 1]; |
- // if we had a guarantee that these will be monotonically increasing, this could be sped up |
for (size_t i = 1; i < numChars; ++i) { |
if (xpos[i] < bbox.fLeft) { |
bbox.fLeft = xpos[i]; |
@@ -193,21 +195,36 @@ void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca |
bbox.fRight = xpos[i]; |
} |
} |
- SkPaint::FontMetrics metrics; |
- paint.getFontMetrics(&metrics); |
// pad horizontally by max glyph height |
- SkScalar pad = (metrics.fTop - metrics.fBottom); |
+ SkScalar pad = 0; |
+ SkScalar top = 0; |
+ SkScalar bottom = 0; |
caryclark
2013/08/20 20:11:34
no need to initialize top, bottom
|
+ if (flatPaintData->isTopBotWritten()) { |
reed1
2013/08/20 17:59:23
Is there (can there be) a common helper method, pe
sglez
2013/08/21 16:09:35
Added helper method WriteTopBot that wraps what th
|
+ top = flatPaintData->topBot()[0]; |
+ bottom = flatPaintData->topBot()[1]; |
+ pad = top - bottom; |
caryclark
2013/08/20 20:11:34
move pad declaration + assignment below 'if'
|
+ } else { // I have not seen a case where this path is taken, but just in case... |
+ SkPaint::FontMetrics metrics; |
+ paint.getFontMetrics(&metrics); |
+ pad = (metrics.fTop - metrics.fBottom); |
+ top = metrics.fTop; |
+ bottom = metrics.fBottom; |
+ } |
bbox.fLeft += pad; |
bbox.fRight -= pad; |
- bbox.fTop = metrics.fTop + constY; |
- bbox.fBottom = metrics.fBottom + constY; |
+ bbox.fTop = top + constY; |
+ bbox.fBottom = bottom + constY; |
+ |
if (!this->transformBounds(bbox, &paint)) { |
return; |
} |
} |
- INHERITED::drawPosTextH(text, byteLength, xpos, constY, paint); |
+ // This is the equivalent of calling: |
+ // INHERITED::drawPosTextH(text, byteLength, xpos, constY, paint); |
+ // but we filled our flat paint beforehand so that we could get font metrics. |
+ drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData); |
} |
void SkBBoxRecord::drawSprite(const SkBitmap& bitmap, int left, int top, |