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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright 2016 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_FOREIGN_LAYER_DISPLAY_ITEM_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_FOREIGN_LAYER_DISPLAY_ITEM_H_
#include "cc/layers/layer.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/property_tree_state.h"
#include "third_party/blink/renderer/platform/platform_export.h"
namespace blink {
class GraphicsContext;
class LayerAsJSONClient;
// Represents foreign content (produced outside Blink) which draws to a layer.
// A client supplies a layer which can be unwrapped and inserted into the full
// layer tree.
//
// Before CAP, this content is not painted, but is instead inserted into the
// GraphicsLayer tree.
class PLATFORM_EXPORT ForeignLayerDisplayItem : public DisplayItem {
public:
ForeignLayerDisplayItem(const DisplayItemClient& client,
Type,
scoped_refptr<cc::Layer>,
const FloatPoint& offset,
const LayerAsJSONClient*);
~ForeignLayerDisplayItem() override;
cc::Layer* GetLayer() const;
const LayerAsJSONClient* GetLayerAsJSONClient() const;
// DisplayItem
bool Equals(const DisplayItem&) const final;
#if DCHECK_IS_ON()
void PropertiesAsJSON(JSONObject&) const final;
#endif
FloatPoint Offset() const { return offset_; }
private:
FloatPoint offset_;
const LayerAsJSONClient* json_client_;
};
// When a foreign layer's debug name is a literal string, define a instance of
// LiteralDebugNameClient with DEFINE_STATIC_LOCAL() and pass the instance as
// client to RecordForeignLayer().
class LiteralDebugNameClient : public DisplayItemClient {
public:
LiteralDebugNameClient(const char* name) : name_(name) {}
String DebugName() const override { return name_; }
IntRect VisualRect() const override {
NOTREACHED();
return IntRect();
}
private:
const char* name_;
};
// Records a foreign layer into a GraphicsContext.
// Use this where you would use a recorder class.
// |client| provides DebugName and optionally DOMNodeId, while VisualRect will
// be calculated automatically based on layer bounds and offset.
PLATFORM_EXPORT void RecordForeignLayer(
GraphicsContext& context,
const DisplayItemClient& client,
DisplayItem::Type type,
scoped_refptr<cc::Layer> layer,
const FloatPoint& offset,
const PropertyTreeState* properties = nullptr);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_PAINT_FOREIGN_LAYER_DISPLAY_ITEM_H_
|