summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform')
-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;
};