summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-08-13 09:32:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-13 09:32:06 -0700
commit5b762b05d1ca3f7f73b0b017aeeceda544a82bb6 (patch)
tree35564705afee626aadc8f6a9519b0a6ecde66b8b /Source/WebCore/platform/graphics/android
parent4c7e6e151b9c49fec439974383c1ba87079e934d (diff)
parent86d531673b8322996025b5ea70ab370e02dcd659 (diff)
downloadexternal_webkit-5b762b05d1ca3f7f73b0b017aeeceda544a82bb6.zip
external_webkit-5b762b05d1ca3f7f73b0b017aeeceda544a82bb6.tar.gz
external_webkit-5b762b05d1ca3f7f73b0b017aeeceda544a82bb6.tar.bz2
Merge "Improve in-canvas pure color checking" into jb-mr1-dev
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
-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);
}