summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h
blob: 358c3be505f43c086d1e82daa0d40aa6c84ac8c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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"
#include "wtf/Vector.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();

    // 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:
    class ContentLayerClientImpl;

    scoped_refptr<cc::Layer> m_rootLayer;
    OwnPtr<WebLayer> m_webLayer;
    Vector<OwnPtr<ContentLayerClientImpl>> m_contentLayerClients;

    // For ~PaintArtifactCompositor on MSVC.
    friend struct WTF::OwnedPtrDeleter<ContentLayerClientImpl>;
};

} // namespace blink

#endif // PaintArtifactCompositor_h