summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp33
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h51
2 files changed, 49 insertions, 35 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
index 355e52c..5efecd8 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
@@ -317,9 +317,7 @@ public:
{}
void draw(const SkIRect& bounds) {
- SkRegion coveredArea(bounds);
-
- drawWithClipRecursive(static_cast<int>(m_nodes.size()) - 1, coveredArea);
+ drawWithClipRecursive(static_cast<int>(m_nodes.size()) - 1, bounds, 0);
while (m_currState) {
m_currState->exitState(&m_context);
@@ -328,7 +326,7 @@ public:
}
private:
- void drawOperation(RecordingData* node, const SkRegion& covered)
+ void drawOperation(RecordingData* node, const SkRegion* uncovered)
{
GraphicsOperation::Operation* op = node->m_operation;
m_recording->applyState(&m_context, m_currState,
@@ -338,16 +336,16 @@ private:
// if other opaque operations will cover the current one, clip that area out
// (and restore the clip immediately after drawing)
- if (!covered.isEmpty()) {
+ if (uncovered) {
m_context.save();
- m_context.canvas()->clipRegion(covered, SkRegion::kIntersect_Op);
+ m_context.canvas()->clipRegion(*uncovered, SkRegion::kIntersect_Op);
}
op->apply(&(m_context));
- if (!covered.isEmpty())
+ if (uncovered)
m_context.restore();
}
- void drawWithClipRecursive(int index, const SkRegion& covered)
+ void drawWithClipRecursive(int index, const SkIRect& bounds, const SkRegion* uncovered)
{
if (index < 0)
return;
@@ -356,17 +354,24 @@ private:
if (index != 0) {
const IntRect* opaqueRect = op->opaqueRect();
if (!opaqueRect || opaqueRect->isEmpty()) {
- drawWithClipRecursive(index - 1, covered);
+ drawWithClipRecursive(index - 1, bounds, uncovered);
} else {
- SkRegion newCovered = covered;
+ SkRegion newUncovered;
+ if (uncovered)
+ newUncovered = *uncovered;
+ else
+ newUncovered = SkRegion(bounds);
+
SkRect mappedRect = *opaqueRect;
m_initialMatrix.mapRect(&mappedRect);
- newCovered.op(enclosedIntRect(mappedRect), SkRegion::kDifference_Op);
- if (!newCovered.isEmpty())
- drawWithClipRecursive(index - 1, newCovered);
+ newUncovered.op(enclosedIntRect(mappedRect), SkRegion::kDifference_Op);
+ if (!newUncovered.isEmpty())
+ drawWithClipRecursive(index - 1, bounds, &newUncovered);
}
}
- drawOperation(recordingData, covered);
+
+ if (!uncovered || !uncovered->isEmpty())
+ drawOperation(recordingData, uncovered);
}
RecordingImpl* m_recording;
diff --git a/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h b/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h
index 508795a..cc3ef55 100644
--- a/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h
+++ b/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h
@@ -23,11 +23,9 @@
#define DEBUG_SKIA_DRAWING 0
#if DEBUG_SKIA_DRAWING
-#define WRAPCANVAS_LOG_ENTRY(...) do { \
- fprintf(stderr, "%s ", __FUNCTION__); \
- fprintf(stderr, __VA_ARGS__); \
- fprintf(stderr, "\n"); \
-} while (0)
+#include "AndroidLog.h" // NOTE: AndroidLog.h normally shouldn't be included in a header
+#include "FloatRect.h"
+#define WRAPCANVAS_LOG_ENTRY(...) {ALOGD("non-rect %s, m_isSolidColor %d", __FUNCTION__, m_isSolidColor);}
#else
#define WRAPCANVAS_LOG_ENTRY(...) ((void)0)
#endif
@@ -120,7 +118,8 @@ public:
virtual bool clipRegion(const SkRegion& region, SkRegion::Op op)
{
WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
+ if (!region.isRect())
+ m_isSolidColor = false;
return SkCanvas::clipRegion(region, op);
}
@@ -147,27 +146,37 @@ public:
SkCanvas::drawPoints(mode, count, pts, paint);
}
- virtual void drawRect(const SkRect& rect, const SkPaint& paint)
+ bool rectFullyOverlaps(const SkRect& rect)
{
-#if DEBUG_SKIA_DRAWING
- IntRect rectToDraw(rect);
- WRAPCANVAS_LOG_ENTRY("rect = (x=%d,y=%d,width=%d,height=%d)", INT_RECT_ARGS(rectToDraw);
-#endif
IntRect canvasRect(IntPoint(), m_size);
- if (m_isSolidColor
- && getTotalMatrix().rectStaysRect()
+ if (getTotalMatrix().rectStaysRect()
&& getTotalClip().contains(canvasRect)) {
const SkMatrix& matrix = getTotalMatrix();
SkRect mapped;
matrix.mapRect(&mapped, rect);
- if (mapped.contains(canvasRect)) {
- Color color = solidColor(paint);
- m_isSolidColor = color.isValid();
- m_solidColor = color;
- } else
- m_isSolidColor = false;
- } else
- m_isSolidColor = false;
+ return mapped.contains(canvasRect);
+ }
+ return false;
+ }
+
+ virtual void drawRect(const SkRect& rect, const SkPaint& paint)
+ {
+
+#if DEBUG_SKIA_DRAWING
+ FloatRect rectToDraw = rect;
+ ALOGD("drawrect " FLOAT_RECT_FORMAT ", is solid %d", FLOAT_RECT_ARGS(rectToDraw), m_isSolidColor);
+#endif
+
+ if (m_isSolidColor) {
+ Color color = solidColor(paint);
+ if (color != m_solidColor) {
+ if (color.isValid() && rectFullyOverlaps(rect))
+ m_solidColor = color;
+ else
+ m_isSolidColor = false;
+ }
+ }
+
SkCanvas::drawRect(rect, paint);
}