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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 1407543003: Preliminary paint property walk implementation for SPv2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address the feedback 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/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 33ebe5d70e5514d82cfa6dbdc943c3469146d4cd..445c40c5becce72c87841d44957e43f561c6fc1b 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -74,6 +74,7 @@
#include "core/layout/compositing/PaintLayerCompositor.h"
#include "core/page/AutoscrollController.h"
#include "core/page/Page.h"
+#include "core/paint/ObjectPaintProperties.h"
#include "core/paint/ObjectPainter.h"
#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayer.h"
@@ -148,6 +149,16 @@ bool LayoutObject::s_affectsParentBlock = false;
typedef HashMap<const LayoutObject*, LayoutRect> SelectionPaintInvalidationMap;
static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = nullptr;
+// The pointer to paint properties is implemented as a global hash map temporarily,
+// to avoid memory regression during the transition towards SPv2.
+typedef HashMap<const LayoutObject*, OwnPtr<ObjectPaintProperties>> ObjectPaintPropertiesMap;
+static ObjectPaintPropertiesMap& objectPaintPropertiesMap()
+{
+ DEFINE_STATIC_LOCAL(ObjectPaintPropertiesMap,
+staticObjectPaintPropertiesMap, ());
pdr. 2015/10/21 21:02:45 Oops, I think this fell off the line before it.
trchen 2015/10/21 22:21:14 Done.
+ return staticObjectPaintPropertiesMap;
+}
+
void* LayoutObject::operator new(size_t sz)
{
ASSERT(isMainThread());
@@ -2513,6 +2524,9 @@ void LayoutObject::willBeDestroyed()
if (selectionPaintInvalidationMap)
selectionPaintInvalidationMap->remove(this);
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
+ clearObjectPaintProperties();
+
clearLayoutRootIfNeeded();
if (m_style) {
@@ -3458,6 +3472,26 @@ void LayoutObject::setIsBackgroundAttachmentFixedObject(bool isBackgroundAttachm
frameView()->removeBackgroundAttachmentFixedObject(this);
}
+ObjectPaintProperties* LayoutObject::objectPaintProperties() const
+{
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ return objectPaintPropertiesMap().get(this);
+}
+
+ObjectPaintProperties& LayoutObject::ensureObjectPaintProperties()
+{
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ if (ObjectPaintProperties* properties = objectPaintProperties())
+ return *properties;
+ return *objectPaintPropertiesMap().set(this, ObjectPaintProperties::create()).storedValue->value.get();
+}
+
+void LayoutObject::clearObjectPaintProperties()
+{
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+ objectPaintPropertiesMap().remove(this);
+}
+
} // namespace blink
#ifndef NDEBUG

Powered by Google App Engine
This is Rietveld 408576698