summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-06-26 08:19:53 -0700
committerJohn Reck <jreck@google.com>2012-06-26 11:24:01 -0700
commit53f84f58d9ffe86a4932c979b9863acadb5769ef (patch)
tree98675690fa67c9ad99362d666d1fca07b44d44ff /Source
parent92ce173b5580cd3aaee405de2b9b9e930de62f82 (diff)
downloadexternal_webkit-53f84f58d9ffe86a4932c979b9863acadb5769ef.zip
external_webkit-53f84f58d9ffe86a4932c979b9863acadb5769ef.tar.gz
external_webkit-53f84f58d9ffe86a4932c979b9863acadb5769ef.tar.bz2
Reduce number of operations
Don't record state changes that didn't actually change state Due to GraphicsContextAndroid::syncPlatformContext these 4 states are set before every draw call. This is cheap for PlatformContextSkia, as it detects that nothing has changed and so doesn't do anything. However, PlatformGraphicsContextRecording would always record these same 4 commands over and over again, which isn't efficient Change-Id: I386bcb91c7851824ed01de1856ce6f6a358f8eb4
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/context/GraphicsOperation.h2
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp38
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h8
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp36
-rw-r--r--Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h8
5 files changed, 61 insertions, 31 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
index 4a27fe9..978e087 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
@@ -105,7 +105,7 @@ public:
virtual ~Operation() {}
virtual OperationType type() { return UndefinedOperation; }
virtual String parameters() { return ""; }
- String name()
+ const char* name()
{
switch (type()) {
TYPE_CASE(UndefinedOperation)
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp
index 3b37693..f9d7f21 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.cpp
@@ -246,22 +246,31 @@ void PlatformGraphicsContext::setCompositeOperation(CompositeOperator op)
m_state->mode = WebCoreCompositeToSkiaComposite(op);
}
-void PlatformGraphicsContext::setFillColor(const Color& c)
+bool PlatformGraphicsContext::setFillColor(const Color& c)
{
- m_state->fillColor = c.rgb();
- setFillShader(0);
+ bool dirty = false;
+ if (m_state->fillColor != c.rgb()) {
+ m_state->fillColor = c.rgb();
+ dirty = true;
+ }
+ return setFillShader(0) || dirty;
}
-void PlatformGraphicsContext::setFillShader(SkShader* fillShader)
+bool PlatformGraphicsContext::setFillShader(SkShader* fillShader)
{
- if (fillShader)
+ bool dirty = false;
+ if (fillShader && m_state->fillColor != Color::black) {
m_state->fillColor = Color::black;
+ dirty = true;
+ }
if (fillShader != m_state->fillShader) {
SkSafeUnref(m_state->fillShader);
m_state->fillShader = fillShader;
SkSafeRef(m_state->fillShader);
+ dirty = true;
}
+ return dirty;
}
void PlatformGraphicsContext::setLineCap(LineCap cap)
@@ -333,22 +342,31 @@ void PlatformGraphicsContext::setShouldAntialias(bool useAA)
m_state->useAA = useAA;
}
-void PlatformGraphicsContext::setStrokeColor(const Color& c)
+bool PlatformGraphicsContext::setStrokeColor(const Color& c)
{
- m_state->strokeColor = c.rgb();
- setStrokeShader(0);
+ bool dirty = false;
+ if (m_state->strokeColor != c.rgb()) {
+ m_state->strokeColor = c.rgb();
+ dirty = true;
+ }
+ return setStrokeShader(0) || dirty;
}
-void PlatformGraphicsContext::setStrokeShader(SkShader* strokeShader)
+bool PlatformGraphicsContext::setStrokeShader(SkShader* strokeShader)
{
- if (strokeShader)
+ bool dirty = false;
+ if (strokeShader && m_state->strokeColor != Color::black) {
m_state->strokeColor = Color::black;
+ dirty = true;
+ }
if (strokeShader != m_state->strokeShader) {
SkSafeUnref(m_state->strokeShader);
m_state->strokeShader = strokeShader;
SkSafeRef(m_state->strokeShader);
+ dirty = true;
}
+ return dirty;
}
void PlatformGraphicsContext::setStrokeStyle(StrokeStyle style)
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h
index 1916014..69ccdaf 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h
@@ -61,16 +61,16 @@ public:
virtual void setAlpha(float alpha);
int getNormalizedAlpha() const;
virtual void setCompositeOperation(CompositeOperator op);
- virtual void setFillColor(const Color& c);
- virtual void setFillShader(SkShader* fillShader);
+ virtual bool setFillColor(const Color& c);
+ virtual bool setFillShader(SkShader* fillShader);
virtual void setLineCap(LineCap cap);
virtual void setLineDash(const DashArray& dashes, float dashOffset);
virtual void setLineJoin(LineJoin join);
virtual void setMiterLimit(float limit);
virtual void setShadow(int radius, int dx, int dy, SkColor c);
virtual void setShouldAntialias(bool useAA);
- virtual void setStrokeColor(const Color& c);
- virtual void setStrokeShader(SkShader* strokeShader);
+ virtual bool setStrokeColor(const Color& c);
+ virtual bool setStrokeShader(SkShader* strokeShader);
virtual void setStrokeStyle(StrokeStyle style);
virtual void setStrokeThickness(float f);
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
index d96124d..39194a0 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
@@ -88,16 +88,22 @@ void PlatformGraphicsContextRecording::setCompositeOperation(CompositeOperator o
mGraphicsOperationCollection->append(new GraphicsOperation::SetCompositeOperation(op));
}
-void PlatformGraphicsContextRecording::setFillColor(const Color& c)
+bool PlatformGraphicsContextRecording::setFillColor(const Color& c)
{
- PlatformGraphicsContext::setFillColor(c);
- mGraphicsOperationCollection->append(new GraphicsOperation::SetFillColor(c));
+ if (PlatformGraphicsContext::setFillColor(c)) {
+ mGraphicsOperationCollection->append(new GraphicsOperation::SetFillColor(c));
+ return true;
+ }
+ return false;
}
-void PlatformGraphicsContextRecording::setFillShader(SkShader* fillShader)
+bool PlatformGraphicsContextRecording::setFillShader(SkShader* fillShader)
{
- PlatformGraphicsContext::setFillShader(fillShader);
- mGraphicsOperationCollection->append(new GraphicsOperation::SetFillShader(fillShader));
+ if (PlatformGraphicsContext::setFillShader(fillShader)) {
+ mGraphicsOperationCollection->append(new GraphicsOperation::SetFillShader(fillShader));
+ return true;
+ }
+ return false;
}
void PlatformGraphicsContextRecording::setLineCap(LineCap cap)
@@ -137,16 +143,22 @@ void PlatformGraphicsContextRecording::setShouldAntialias(bool useAA)
mGraphicsOperationCollection->append(new GraphicsOperation::SetShouldAntialias(useAA));
}
-void PlatformGraphicsContextRecording::setStrokeColor(const Color& c)
+bool PlatformGraphicsContextRecording::setStrokeColor(const Color& c)
{
- PlatformGraphicsContext::setStrokeColor(c);
- mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeColor(c));
+ if (PlatformGraphicsContext::setStrokeColor(c)) {
+ mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeColor(c));
+ return true;
+ }
+ return false;
}
-void PlatformGraphicsContextRecording::setStrokeShader(SkShader* strokeShader)
+bool PlatformGraphicsContextRecording::setStrokeShader(SkShader* strokeShader)
{
- PlatformGraphicsContext::setStrokeShader(strokeShader);
- mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeShader(strokeShader));
+ if (PlatformGraphicsContext::setStrokeShader(strokeShader)) {
+ mGraphicsOperationCollection->append(new GraphicsOperation::SetStrokeShader(strokeShader));
+ return true;
+ }
+ return false;
}
void PlatformGraphicsContextRecording::setStrokeStyle(StrokeStyle style)
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
index ebb0075..82f9446 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
@@ -55,16 +55,16 @@ public:
// State values
virtual void setAlpha(float alpha);
virtual void setCompositeOperation(CompositeOperator op);
- virtual void setFillColor(const Color& c);
- virtual void setFillShader(SkShader* fillShader);
+ virtual bool setFillColor(const Color& c);
+ virtual bool setFillShader(SkShader* fillShader);
virtual void setLineCap(LineCap cap);
virtual void setLineDash(const DashArray& dashes, float dashOffset);
virtual void setLineJoin(LineJoin join);
virtual void setMiterLimit(float limit);
virtual void setShadow(int radius, int dx, int dy, SkColor c);
virtual void setShouldAntialias(bool useAA);
- virtual void setStrokeColor(const Color& c);
- virtual void setStrokeShader(SkShader* strokeShader);
+ virtual bool setStrokeColor(const Color& c);
+ virtual bool setStrokeShader(SkShader* strokeShader);
virtual void setStrokeStyle(StrokeStyle style);
virtual void setStrokeThickness(float f);