summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-07-20 14:20:57 -0700
committerJohn Reck <jreck@google.com>2012-07-20 14:20:57 -0700
commit297e0a10e071c3389212e4be467e4833bc3717ef (patch)
tree041316bf7684770b6e2649d555570a211a381a7a /Source
parentf762138fb2c8ec33fe3dec8e6bfd47e459f8f6c8 (diff)
downloadexternal_webkit-297e0a10e071c3389212e4be467e4833bc3717ef.zip
external_webkit-297e0a10e071c3389212e4be467e4833bc3717ef.tar.gz
external_webkit-297e0a10e071c3389212e4be467e4833bc3717ef.tar.bz2
Fix bounds for shadows
Change-Id: I304c6e78e9e570dd4e67fa101697ca3b2f17acd7
Diffstat (limited to 'Source')
-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;