From 7853e9d8b1baa5eac14017534d445e04694a0d58 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Tue, 17 Jul 2012 13:55:50 -0700 Subject: Fix bounding box calculations Change-Id: I71b309c96cedefee66b9b7100e483c934e198085 --- .../context/PlatformGraphicsContextRecording.cpp | 26 +++++++++++++--------- .../context/PlatformGraphicsContextRecording.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'Source/WebCore/platform') diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index 001e1de..ba7f1a9 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -219,14 +219,14 @@ void PlatformGraphicsContextRecording::restore() PlatformGraphicsContext::restore(); RecordingState state = mRecordingStateStack.last(); mRecordingStateStack.removeLast(); - if (state.mHasDrawing) - appendDrawingOperation(state.mSaveOperation, state.mBounds); - else - delete state.mSaveOperation; if (mRecordingStateStack.size()) mCurrentMatrix = &(mRecordingStateStack.last().mMatrix); else mCurrentMatrix = &mRootMatrix; + if (state.mHasDrawing) + appendDrawingOperation(state.mSaveOperation, state.mBounds); + else + delete state.mSaveOperation; } //************************************** @@ -392,16 +392,14 @@ void PlatformGraphicsContextRecording::canvasClip(const Path& path) bool PlatformGraphicsContextRecording::clip(const FloatRect& rect) { - if (mRecordingStateStack.size()) - mRecordingStateStack.last().clip(rect); + clipState(rect); appendStateOperation(new GraphicsOperation::Clip(rect)); return true; } bool PlatformGraphicsContextRecording::clip(const Path& path) { - if (mRecordingStateStack.size()) - mRecordingStateStack.last().clip(path.boundingRect()); + clipState(path.boundingRect()); appendStateOperation(new GraphicsOperation::ClipPath(path)); return true; } @@ -427,8 +425,7 @@ bool PlatformGraphicsContextRecording::clipOut(const Path& path) bool PlatformGraphicsContextRecording::clipPath(const Path& pathToClip, WindRule clipRule) { - if (mRecordingStateStack.size()) - mRecordingStateStack.last().clip(pathToClip.boundingRect()); + clipState(pathToClip.boundingRect()); GraphicsOperation::ClipPath* operation = new GraphicsOperation::ClipPath(pathToClip); operation->setWindRule(clipRule); appendStateOperation(operation); @@ -571,6 +568,15 @@ void PlatformGraphicsContextRecording::strokeRect(const FloatRect& rect, float l appendDrawingOperation(new GraphicsOperation::StrokeRect(rect, lineWidth), bounds); } +void PlatformGraphicsContextRecording::clipState(const FloatRect& clip) +{ + if (mRecordingStateStack.size()) { + SkRect mapBounds; + mCurrentMatrix->mapRect(&mapBounds, clip); + mRecordingStateStack.last().clip(mapBounds); + } +} + void PlatformGraphicsContextRecording::appendDrawingOperation( GraphicsOperation::Operation* operation, const FloatRect& untranslatedBounds) { diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h index 38eb58f..3affff3 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h @@ -142,6 +142,7 @@ private: return false; } + void clipState(const FloatRect& clip); void appendDrawingOperation(GraphicsOperation::Operation* operation, const FloatRect& bounds); void appendStateOperation(GraphicsOperation::Operation* operation); void onCurrentMatrixChanged(); -- cgit v1.1