summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp29
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h1
2 files changed, 26 insertions, 4 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
index f11154d..6b9d27f 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
@@ -596,6 +596,28 @@ void PlatformGraphicsContextRecording::popMatrix()
mCurrentMatrix = &(mMatrixStack.last());
}
+IntRect PlatformGraphicsContextRecording::calculateFinalBounds(FloatRect bounds)
+{
+ if (m_gc->hasShadow()) {
+ const ShadowRec& shadow = m_state->shadow;
+ if (shadow.blur > 0)
+ bounds.inflate(ceilf(shadow.blur));
+ bounds.setWidth(bounds.width() + abs(shadow.dx));
+ bounds.setHeight(bounds.height() + abs(shadow.dy));
+ if (shadow.dx < 0)
+ bounds.move(shadow.dx, 0);
+ if (shadow.dy < 0)
+ bounds.move(0, shadow.dy);
+ // Add a bit extra to deal with rounding and blurring
+ bounds.inflate(4);
+ }
+ if (m_state->strokeStyle != NoStroke)
+ bounds.inflate(std::min(1.0f, m_state->strokeThickness));
+ SkRect translated;
+ mCurrentMatrix->mapRect(&translated, bounds);
+ return enclosingIntRect(translated);
+}
+
void PlatformGraphicsContextRecording::appendDrawingOperation(
GraphicsOperation::Operation* operation, const FloatRect& untranslatedBounds)
{
@@ -604,12 +626,11 @@ void PlatformGraphicsContextRecording::appendDrawingOperation(
return;
}
m_isEmpty = false;
- SkRect bounds;
- mCurrentMatrix->mapRect(&bounds, untranslatedBounds);
if (mRecordingStateStack.size()) {
RecordingState& state = mRecordingStateStack.last();
state.mHasDrawing = true;
- state.addBounds(bounds);
+ if (!state.mHasClip)
+ state.addBounds(calculateFinalBounds(untranslatedBounds));
state.mSaveOperation->operations()->adoptAndAppend(operation);
return;
}
@@ -621,7 +642,7 @@ void PlatformGraphicsContextRecording::appendDrawingOperation(
operation->m_matrix = mOperationMatrix;
RecordingData* data = new RecordingData(operation, mRecording->recording()->m_nodeCount++);
- WebCore::IntRect ibounds = enclosingIntRect(bounds);
+ WebCore::IntRect ibounds = calculateFinalBounds(untranslatedBounds);
mRecording->recording()->m_tree.insert(ibounds, data);
}
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
index 89f9bbb..fd6fb5e 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
@@ -152,6 +152,7 @@ private:
void popSaveOperation();
void pushMatrix();
void popMatrix();
+ IntRect calculateFinalBounds(FloatRect bounds);
SkPicture* mPicture;
SkMatrix* mCurrentMatrix;