Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1011)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/PaintChunker.cpp

Issue 1379883003: Create PaintChunk and begin writing code to build paint chunks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enable RuntimeEnabledFeature for PaintChunkerTest Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/paint/PaintChunker.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintChunker.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintChunker.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2616ccaef8dbd931ed3f7f535544cd743ad9600c
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunker.cpp
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "platform/graphics/paint/PaintChunker.h"
+
+#include "platform/RuntimeEnabledFeatures.h"
+
+namespace blink {
+
+PaintChunker::PaintChunker()
+{
+}
+
+PaintChunker::~PaintChunker()
+{
+}
+
+void PaintChunker::updateCurrentPaintProperties(const PaintProperties& properties)
+{
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+
+ m_currentProperties = properties;
+}
+
+void PaintChunker::incrementDisplayItemIndex()
+{
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+
+ if (m_chunks.isEmpty()) {
+ PaintChunk newChunk(0, 1, m_currentProperties);
+ m_chunks.append(newChunk);
+ return;
+ }
+
+ auto& lastChunk = m_chunks.last();
+ if (m_currentProperties == lastChunk.properties) {
+ lastChunk.endIndex++;
+ return;
+ }
+
+ PaintChunk newChunk(lastChunk.endIndex, lastChunk.endIndex + 1, m_currentProperties);
+ m_chunks.append(newChunk);
+}
+
+void PaintChunker::decrementDisplayItemIndex()
+{
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ ASSERT(!m_chunks.isEmpty());
+
+ auto& lastChunk = m_chunks.last();
+ if ((lastChunk.endIndex - lastChunk.beginIndex) > 1)
+ lastChunk.endIndex--;
+ else
+ m_chunks.removeLast();
+}
+
+Vector<PaintChunk> PaintChunker::releasePaintChunks()
+{
+ Vector<PaintChunk> chunks;
+ chunks.swap(m_chunks);
+ m_currentProperties = PaintProperties();
+ return chunks;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698