Chromium Code Reviews| Index: src/core/SkPictureRecord.cpp |
| diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp |
| index 7a853816ae72b702b0915c5829587a593bf933a0..c05123edfd39a9f5bf22b9c7ff0a075113610293 100644 |
| --- a/src/core/SkPictureRecord.cpp |
| +++ b/src/core/SkPictureRecord.cpp |
| @@ -1106,6 +1106,12 @@ void SkPictureRecord::drawPosText(const void* text, size_t byteLength, |
| void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength, |
| const SkScalar xpos[], SkScalar constY, |
| const SkPaint& paint) { |
| + drawPosTextHImpl(text, byteLength, xpos, constY, paint, NULL); |
|
reed1
2013/08/20 17:59:23
Might be clearer if we called getFlatPaintData her
|
| + |
| +} |
| +void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength, |
| + const SkScalar xpos[], SkScalar constY, |
| + const SkPaint& paint, const SkFlatData* flatPaintData) { |
| size_t points = paint.countText(text, byteLength); |
| if (0 == points) |
| return; |
| @@ -1119,11 +1125,15 @@ void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength, |
| } |
| // + y + the actual points |
| size += 1 * kUInt32Size + points * sizeof(SkScalar); |
| - |
| uint32_t initialOffset = this->addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : DRAW_POS_TEXT_H, |
| &size); |
| - const SkFlatData* flatPaintData = addPaint(paint); |
| + if (NULL == flatPaintData) { |
| + flatPaintData = addPaint(paint); |
| + } else { |
| + addFlatPaint(flatPaintData); |
| + } |
| SkASSERT(flatPaintData); |
| + |
| addText(text, byteLength); |
| addInt(points); |
| @@ -1268,13 +1278,21 @@ void SkPictureRecord::addMatrixPtr(const SkMatrix* matrix) { |
| this->addInt(matrix ? fMatrices.find(*matrix) : 0); |
| } |
| +const SkFlatData* SkPictureRecord::getFlatPaintData(const SkPaint& paint) { |
| + return fPaints.findAndReturnFlat(paint); |
| +} |
| + |
| const SkFlatData* SkPictureRecord::addPaintPtr(const SkPaint* paint) { |
| - const SkFlatData* data = paint ? fPaints.findAndReturnFlat(*paint) : NULL; |
| - int index = data ? data->index() : 0; |
| - this->addInt(index); |
| + const SkFlatData* data = paint ? getFlatPaintData(*paint) : NULL; |
| + this->addFlatPaint(data); |
| return data; |
| } |
| +void SkPictureRecord::addFlatPaint(const SkFlatData* flatPaint) { |
| + int index = flatPaint ? flatPaint->index() : 0; |
| + this->addInt(index); |
| +} |
| + |
| void SkPictureRecord::addPath(const SkPath& path) { |
| if (NULL == fPathHeap) { |
| fPathHeap = SkNEW(SkPathHeap); |