diff options
author | jbroman <jbroman@chromium.org> | 2015-12-09 16:31:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-10 00:32:24 +0000 |
commit | 7392034748230b0367bc2e68f430f96be8aaeabd (patch) | |
tree | 94265c893eb4b12aff6e6811334349ce5d14b889 /third_party/WebKit/Source/platform/graphics | |
parent | 1b420f0553d192ca0712b985bec7042836887dee (diff) | |
download | chromium_src-7392034748230b0367bc2e68f430f96be8aaeabd.zip chromium_src-7392034748230b0367bc2e68f430f96be8aaeabd.tar.gz chromium_src-7392034748230b0367bc2e68f430f96be8aaeabd.tar.bz2 |
[SPv2] Prepare to composite in terms of PaintArtifact.
This adds plumbing from the FrameView, which runs the document lifecycle, to a
new class, PaintArtifactCompositor, which is responsible for updating the layer
tree to reflect the new content of the paint artifact.
This replaces PaintLayerCompositor, which updates the layer tree to reflect the
PaintLayer hierarchy.
This CL is almost purely plumbing -- only an empty layer is created at present.
As a result, all that renders it the body's background color when
--enable-slimming-paint-v2 is provided. This will be improved in subsequent CLs.
Review URL: https://codereview.chromium.org/1479753003
Cr-Commit-Position: refs/heads/master@{#364230}
Diffstat (limited to 'third_party/WebKit/Source/platform/graphics')
-rw-r--r-- | third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp | 42 | ||||
-rw-r--r-- | third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h | 58 |
2 files changed, 100 insertions, 0 deletions
diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp new file mode 100644 index 0000000..dde06b2 --- /dev/null +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp @@ -0,0 +1,42 @@ +// 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/compositing/PaintArtifactCompositor.h" + +#include "cc/layers/layer.h" +#include "cc/layers/layer_settings.h" +#include "platform/RuntimeEnabledFeatures.h" +#include "public/platform/Platform.h" +#include "public/platform/WebCompositorSupport.h" +#include "public/platform/WebLayer.h" +#include "wtf/PassOwnPtr.h" + +namespace blink { + +PaintArtifactCompositor::PaintArtifactCompositor() +{ +} + +PaintArtifactCompositor::~PaintArtifactCompositor() +{ +} + +void PaintArtifactCompositor::initializeIfNeeded() +{ + ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); + if (m_rootLayer) + return; + + m_rootLayer = cc::Layer::Create(cc::LayerSettings()); + m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerFromCCLayer(m_rootLayer.get())); +} + +void PaintArtifactCompositor::update(const PaintArtifact& paintArtifact) +{ + initializeIfNeeded(); + ASSERT(m_rootLayer); +} + +} // namespace blink diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h new file mode 100644 index 0000000..6f6f001 --- /dev/null +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h @@ -0,0 +1,58 @@ +// 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. + +#ifndef PaintArtifactCompositor_h +#define PaintArtifactCompositor_h + +#include "base/memory/ref_counted.h" +#include "platform/PlatformExport.h" +#include "wtf/Noncopyable.h" +#include "wtf/OwnPtr.h" + +namespace cc { +class Layer; +} + +namespace blink { + +class PaintArtifact; +class WebLayer; + +// Responsible for managing compositing in terms of a PaintArtifact. +// +// Owns a subtree of the compositor layer tree, and updates it in response to +// changes in the paint artifact. +// +// PaintArtifactCompositor is the successor to PaintLayerCompositor, reflecting +// the new home of compositing decisions after paint in Slimming Paint v2. +class PLATFORM_EXPORT PaintArtifactCompositor { + WTF_MAKE_NONCOPYABLE(PaintArtifactCompositor); +public: + PaintArtifactCompositor(); + ~PaintArtifactCompositor(); + + // Creates at least a root layer to be managed by this controller. Can't be + // done in the constructor, since RuntimeEnabledFeatures may not be + // initialized yet. + void initializeIfNeeded(); + + // Updates the layer tree to match the provided paint artifact. + // Creates the root layer if not already done. + void update(const PaintArtifact&); + + // The root layer of the tree managed by this object. + cc::Layer* rootLayer() const { return m_rootLayer.get(); } + + // Wraps rootLayer(), so that it can be attached as a child of another + // WebLayer. + WebLayer* webLayer() const { return m_webLayer.get(); } + +private: + scoped_refptr<cc::Layer> m_rootLayer; + OwnPtr<WebLayer> m_webLayer; +}; + +} // namespace blink + +#endif // PaintArtifactCompositor_h |