diff options
Diffstat (limited to 'Source/WebCore/platform/graphics/android/context')
-rw-r--r-- | Source/WebCore/platform/graphics/android/context/GraphicsOperation.h | 17 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp | 11 |
2 files changed, 14 insertions, 14 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h index c70c295..edcdc35 100644 --- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h +++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h @@ -587,25 +587,20 @@ class DrawPosText : public Operation { public: DrawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint* paint) - : m_byteLength(byteLength) + : m_text(text) + , m_byteLength(byteLength) + , m_pos(pos) , m_paint(paint) - { - size_t points = m_paint->countText(text, byteLength); - m_pos = new SkPoint[points]; - memcpy(m_pos, pos, sizeof(SkPoint) * points); - m_text = malloc(byteLength); - memcpy(m_text, text, byteLength); - } - ~DrawPosText() { delete m_pos; free(m_text); } + {} virtual bool applyImpl(PlatformGraphicsContext* context) { context->drawPosText(m_text, m_byteLength, m_pos, *m_paint); return true; } TYPE(DrawPosTextOperation) private: - void* m_text; + const void* m_text; size_t m_byteLength; - SkPoint* m_pos; + const SkPoint* m_pos; const SkPaint* m_paint; }; diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index 24ee47e..464224a 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -891,15 +891,20 @@ void PlatformGraphicsContextRecording::strokeRect(const FloatRect& rect, float l appendDrawingOperation(NEW_OP(StrokeRect)(rect, lineWidth), bounds); } -void PlatformGraphicsContextRecording::drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& inPaint) +void PlatformGraphicsContextRecording::drawPosText(const void* inText, size_t byteLength, + const SkPoint inPos[], const SkPaint& inPaint) { if (inPaint.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) { ALOGE("Unsupported text encoding! %d", inPaint.getTextEncoding()); return; } - FloatRect bounds = approximateTextBounds(byteLength / sizeof(uint16_t), pos, inPaint); + FloatRect bounds = approximateTextBounds(byteLength / sizeof(uint16_t), inPos, inPaint); const SkPaint* paint = mRecording->recording()->getSkPaint(inPaint); + int posSize = sizeof(SkPoint) * paint->countText(inText, byteLength); + void* text = operationHeap()->alloc(posSize + byteLength); + SkPoint* pos = (SkPoint*) ((char*)text + byteLength); + memcpy(text, inText, byteLength); + memcpy(pos, inPos, posSize); appendDrawingOperation(NEW_OP(DrawPosText)(text, byteLength, pos, paint), bounds); } |