From 839203b35a55ec16675b15767cb242038b9a5132 Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 20 Jul 2012 17:40:29 -0700 Subject: Implement missing recording draws Change-Id: I15a9c63d7aed9f54095763499d3ffff2e17872b7 --- .../graphics/android/context/GraphicsOperation.h | 41 ++++++++++++++++++++++ .../context/PlatformGraphicsContextRecording.cpp | 19 ++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) (limited to 'Source') diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h index fc3b8bc..1cfb094 100644 --- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h +++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h @@ -82,7 +82,9 @@ public: // Drawing , DrawBitmapPatternOperation , DrawBitmapRectOperation + , DrawConvexPolygonQuadOperation , DrawEllipseOperation + , DrawFocusRingOperation , DrawLineOperation , DrawLineForTextOperation , DrawLineForTextCheckingOperation @@ -153,7 +155,9 @@ public: // Drawing TYPE_CASE(DrawBitmapPatternOperation) TYPE_CASE(DrawBitmapRectOperation) + TYPE_CASE(DrawConvexPolygonQuadOperation) TYPE_CASE(DrawEllipseOperation) + TYPE_CASE(DrawFocusRingOperation) TYPE_CASE(DrawLineOperation) TYPE_CASE(DrawLineForTextOperation) TYPE_CASE(DrawLineForTextCheckingOperation) @@ -577,6 +581,23 @@ private: CompositeOperator m_operator; }; +class DrawConvexPolygonQuad : public Operation { +public: + DrawConvexPolygonQuad(const FloatPoint* points, bool shouldAntiAlias) + : m_shouldAntiAlias(shouldAntiAlias) + { + memcpy(m_points, points, 4 * sizeof(FloatPoint)); + } + virtual bool applyImpl(PlatformGraphicsContext* context) { + context->drawConvexPolygon(4, m_points, m_shouldAntiAlias); + return true; + } + virtual OperationType type() { return DrawConvexPolygonQuadOperation; } +private: + bool m_shouldAntiAlias; + FloatPoint m_points[4]; +}; + class DrawEllipse : public Operation { public: DrawEllipse(const IntRect& rect) : m_rect(rect) {} @@ -589,6 +610,26 @@ private: IntRect m_rect; }; +class DrawFocusRing : public Operation { +public: + DrawFocusRing(const Vector& rects, int width, int offset, const Color& color) + : m_rects(rects) + , m_width(width) + , m_offset(offset) + , m_color(color) + {} + virtual bool applyImpl(PlatformGraphicsContext* context) { + context->drawFocusRing(m_rects, m_width, m_offset, m_color); + return true; + } + virtual OperationType type() { return DrawFocusRingOperation; } +private: + Vector m_rects; + int m_width; + int m_offset; + Color m_color; +}; + class DrawLine : public Operation { public: DrawLine(const IntPoint& point1, const IntPoint& point2) diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index 6b9d27f..4a14513 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -449,7 +449,15 @@ void PlatformGraphicsContextRecording::drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool shouldAntialias) { - // TODO + if (numPoints < 1) return; + if (numPoints != 4) { + // TODO: Build a path and call draw on that (webkit currently never calls this) + ALOGW("drawConvexPolygon with numPoints != 4 is not supported!"); + return; + } + FloatRect bounds; + bounds.fitToPoints(points[0], points[1], points[2], points[3]); + appendDrawingOperation(new GraphicsOperation::DrawConvexPolygonQuad(points, shouldAntialias), bounds); } void PlatformGraphicsContextRecording::drawEllipse(const IntRect& rect) @@ -458,10 +466,15 @@ void PlatformGraphicsContextRecording::drawEllipse(const IntRect& rect) } void PlatformGraphicsContextRecording::drawFocusRing(const Vector& rects, - int /* width */, int /* offset */, + int width, int offset, const Color& color) { - // TODO + if (!rects.size()) + return; + IntRect bounds = rects[0]; + for (size_t i = 1; i < rects.size(); i++) + bounds.unite(rects[i]); + appendDrawingOperation(new GraphicsOperation::DrawFocusRing(rects, width, offset, color), bounds); } void PlatformGraphicsContextRecording::drawHighlightForText( -- cgit v1.1