summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-06-26 11:50:07 -0700
committerJohn Reck <jreck@google.com>2012-07-02 14:21:44 -0700
commitcd037d9094659dcb6f998997d7f32e99fc6b7697 (patch)
treebbf4537e5416c2d81029247195fb9346a3855fe8 /Source
parent1b43964f81390be14c5db26dc8934479588254c8 (diff)
downloadexternal_webkit-cd037d9094659dcb6f998997d7f32e99fc6b7697.zip
external_webkit-cd037d9094659dcb6f998997d7f32e99fc6b7697.tar.gz
external_webkit-cd037d9094659dcb6f998997d7f32e99fc6b7697.tar.bz2
Filter out empty save/restores
WebKit will sometimes produce graphics context calls that result in GC::Save, GC::SetClip, GC::Restore - as they don't do any drawing, we can detect and filter those out which saves on the amount of state management done. Change-Id: I61715b0a14adb39521c605e2562fc4ac4e70a327
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.cpp60
-rw-r--r--Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.h3
2 files changed, 61 insertions, 2 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.cpp b/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.cpp
index 03a0d8f..c5be59f 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.cpp
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.cpp
@@ -13,6 +13,31 @@
namespace WebCore {
+using namespace GraphicsOperation;
+
+static bool isDrawingOperation(GraphicsOperation::Operation* operation) {
+ switch (operation->type()) {
+ case Operation::DrawBitmapPatternOperation:
+ case Operation::DrawBitmapRectOperation:
+ case Operation::DrawEllipseOperation:
+ case Operation::DrawLineOperation:
+ case Operation::DrawLineForTextOperation:
+ case Operation::DrawLineForTextCheckingOperation:
+ case Operation::DrawRectOperation:
+ case Operation::FillPathOperation:
+ case Operation::FillRectOperation:
+ case Operation::FillRoundedRectOperation:
+ case Operation::StrokeArcOperation:
+ case Operation::StrokePathOperation:
+ case Operation::StrokeRectOperation:
+ case Operation::DrawComplexTextOperation:
+ case Operation::DrawTextOperation:
+ return true;
+ default:
+ return false;
+ }
+}
+
GraphicsOperationCollection::GraphicsOperationCollection()
{
}
@@ -23,20 +48,51 @@ GraphicsOperationCollection::~GraphicsOperationCollection()
void GraphicsOperationCollection::apply(PlatformGraphicsContext* context)
{
+ flush();
for (unsigned int i = 0; i < m_operations.size(); i++)
m_operations[i]->apply(context);
}
-void GraphicsOperationCollection::adoptAndAppend(GraphicsOperation::Operation* operation)
+void GraphicsOperationCollection::adoptAndAppend(GraphicsOperation::Operation* rawOp)
{
- m_operations.append(adoptRef(operation));
+ PassRefPtr<GraphicsOperation::Operation> operation = adoptRef(rawOp);
+ if (operation->type() == Operation::SaveOperation) {
+ // TODO: Support nested Save/Restore checking?
+ flush();
+ m_pendingOperations.append(operation);
+ return;
+ }
+ if (m_pendingOperations.size()) {
+ if (operation->type() == Operation::RestoreOperation) {
+ // We hit a Save/Restore pair without any drawing, discard
+ m_pendingOperations.clear();
+ return;
+ }
+ if (!isDrawingOperation(operation.get())) {
+ // Isn't a drawing operation, so append to pending and return
+ m_pendingOperations.append(operation);
+ return;
+ }
+ // Hit a drawing operation, so flush the pending and append to m_operations
+ flush();
+ }
+ m_operations.append(operation);
}
bool GraphicsOperationCollection::isEmpty()
{
+ flush();
return !m_operations.size();
}
+void GraphicsOperationCollection::flush()
+{
+ if (m_pendingOperations.size()) {
+ m_operations.append(m_pendingOperations);
+ m_pendingOperations.clear();
+ }
+}
+
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.h
index 246e784..e7e4ccc 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.h
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.h
@@ -48,6 +48,9 @@ public:
bool isEmpty();
private:
+ void flush();
+
+ Vector< RefPtr<GraphicsOperation::Operation> > m_pendingOperations;
Vector< RefPtr<GraphicsOperation::Operation> > m_operations;
};