Commit 6aab988d authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CI] Remove client, location and size parameters of ForeignLayerDisplayItem

ForeignLayerDisplayItem's location and size should always equal to
the cc layer's offset_to_transform_parent and bounds, respectively.
Removing them can simplify logic and reduce duplicated data.

Let ForeignLayerDisplayItem create its client by itself. The
client returns VisualRect based on the geometry of the cc layer.

Let ForeignLayerDisplayItem::DrawsContent() return false because it
doesn't issue paint operations.

This enables us not to repaint a foreign layer display item when
the cc layer changes geometry, though this is not the case for now
because we need to update the geometry of the cc layers during paint.
However, with the duplicated data removed, we can decouple cc layer
geometry update from paint if needed.

Change-Id: Idac393608467933bf1eda3691aa4f4cd6379f27e
Reviewed-on: https://chromium-review.googlesource.com/c/1352971
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612010}
parent 3271838d
...@@ -173,13 +173,13 @@ void WebPluginContainerImpl::Paint(GraphicsContext& context, ...@@ -173,13 +173,13 @@ void WebPluginContainerImpl::Paint(GraphicsContext& context,
return; return;
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled() && layer_) { if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled() && layer_) {
layer_->SetBounds(static_cast<gfx::Size>(frame_rect_.Size())); layer_->SetOffsetToTransformParent(
gfx::Vector2dF(frame_rect_.X(), frame_rect_.Y()));
layer_->SetBounds(gfx::Size(frame_rect_.Size()));
layer_->SetIsDrawable(true); layer_->SetIsDrawable(true);
// With Slimming Paint v2, composited plugins should have their layers // With Slimming Paint v2, composited plugins should have their layers
// inserted rather than invoking WebPlugin::paint. // inserted rather than invoking WebPlugin::paint.
RecordForeignLayer(context, *element_->GetLayoutObject(), RecordForeignLayer(context, DisplayItem::kForeignLayerPlugin, layer_);
DisplayItem::kForeignLayerPlugin, layer_,
FloatPoint(FrameRect().Location()), frame_rect_.Size());
return; return;
} }
......
...@@ -1414,7 +1414,6 @@ TEST_F(WebPluginContainerTest, CompositedPluginSPv2) { ...@@ -1414,7 +1414,6 @@ TEST_F(WebPluginContainerTest, CompositedPluginSPv2) {
WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>( WebPluginContainerImpl* container = static_cast<WebPluginContainerImpl*>(
GetWebPluginContainer(web_view, WebString::FromUTF8("plugin"))); GetWebPluginContainer(web_view, WebString::FromUTF8("plugin")));
ASSERT_TRUE(container); ASSERT_TRUE(container);
Element* element = static_cast<Element*>(container->GetElement());
const auto* plugin = const auto* plugin =
static_cast<const CompositedPlugin*>(container->Plugin()); static_cast<const CompositedPlugin*>(container->Plugin());
...@@ -1429,7 +1428,6 @@ TEST_F(WebPluginContainerTest, CompositedPluginSPv2) { ...@@ -1429,7 +1428,6 @@ TEST_F(WebPluginContainerTest, CompositedPluginSPv2) {
const auto& display_items = const auto& display_items =
paint_controller->GetPaintArtifact().GetDisplayItemList(); paint_controller->GetPaintArtifact().GetDisplayItemList();
ASSERT_EQ(1u, display_items.size()); ASSERT_EQ(1u, display_items.size());
EXPECT_EQ(element->GetLayoutObject(), &display_items[0].Client());
ASSERT_EQ(DisplayItem::kForeignLayerPlugin, display_items[0].GetType()); ASSERT_EQ(DisplayItem::kForeignLayerPlugin, display_items[0].GetType());
const auto& foreign_layer_display_item = const auto& foreign_layer_display_item =
static_cast<const ForeignLayerDisplayItem&>(display_items[0]); static_cast<const ForeignLayerDisplayItem&>(display_items[0]);
......
...@@ -2688,10 +2688,8 @@ static void CollectViewportLayersForLayerList(GraphicsContext& context, ...@@ -2688,10 +2688,8 @@ static void CollectViewportLayersForLayerList(GraphicsContext& context,
// layers are still attached. In future we will disable all those layer // layers are still attached. In future we will disable all those layer
// hierarchy code so we won't need this line. // hierarchy code so we won't need this line.
container_layer->CcLayer()->RemoveAllChildren(); container_layer->CcLayer()->RemoveAllChildren();
RecordForeignLayer(context, *container_layer, RecordForeignLayer(context, DisplayItem::kForeignLayerWrapper,
DisplayItem::kForeignLayerWrapper, container_layer->CcLayer());
container_layer->CcLayer(), FloatPoint(),
IntSize(container_layer->CcLayer()->bounds()));
} }
// Collect the page scale layer. // Collect the page scale layer.
...@@ -2702,8 +2700,8 @@ static void CollectViewportLayersForLayerList(GraphicsContext& context, ...@@ -2702,8 +2700,8 @@ static void CollectViewportLayersForLayerList(GraphicsContext& context,
*scale_layer, DisplayItem::kForeignLayerWrapper); *scale_layer, DisplayItem::kForeignLayerWrapper);
scale_layer->CcLayer()->RemoveAllChildren(); scale_layer->CcLayer()->RemoveAllChildren();
RecordForeignLayer(context, *scale_layer, DisplayItem::kForeignLayerWrapper, RecordForeignLayer(context, DisplayItem::kForeignLayerWrapper,
scale_layer->CcLayer(), FloatPoint(), IntSize()); scale_layer->CcLayer());
} }
// Collect the visual viewport scroll layer. // Collect the visual viewport scroll layer.
...@@ -2714,10 +2712,8 @@ static void CollectViewportLayersForLayerList(GraphicsContext& context, ...@@ -2714,10 +2712,8 @@ static void CollectViewportLayersForLayerList(GraphicsContext& context,
*scroll_layer, DisplayItem::kForeignLayerWrapper); *scroll_layer, DisplayItem::kForeignLayerWrapper);
scroll_layer->CcLayer()->RemoveAllChildren(); scroll_layer->CcLayer()->RemoveAllChildren();
RecordForeignLayer(context, *scroll_layer, RecordForeignLayer(context, DisplayItem::kForeignLayerWrapper,
DisplayItem::kForeignLayerWrapper, scroll_layer->CcLayer());
scroll_layer->CcLayer(), FloatPoint(),
IntSize(scroll_layer->CcLayer()->bounds()));
} }
} }
...@@ -2742,22 +2738,16 @@ static void CollectDrawableLayersForLayerListRecursively( ...@@ -2742,22 +2738,16 @@ static void CollectDrawableLayersForLayerListRecursively(
// extraneous layers are still attached. In future we will disable all // extraneous layers are still attached. In future we will disable all
// those layer hierarchy code so we won't need this line. // those layer hierarchy code so we won't need this line.
layer->CcLayer()->RemoveAllChildren(); layer->CcLayer()->RemoveAllChildren();
RecordForeignLayer(context, *layer, DisplayItem::kForeignLayerWrapper, RecordForeignLayer(context, DisplayItem::kForeignLayerWrapper,
layer->CcLayer(), layer->CcLayer());
FloatPoint(layer->GetOffsetFromTransformNode()),
IntSize(layer->Size()));
} }
if (scoped_refptr<cc::Layer> contents_layer = layer->ContentsLayer()) { if (auto* contents_layer = layer->ContentsLayer()) {
ScopedPaintChunkProperties scope( ScopedPaintChunkProperties scope(
context.GetPaintController(), layer->GetContentsPropertyTreeState(), context.GetPaintController(), layer->GetContentsPropertyTreeState(),
*layer, DisplayItem::kForeignLayerContentsWrapper); *layer, DisplayItem::kForeignLayerContentsWrapper);
auto size = contents_layer->bounds(); RecordForeignLayer(context, DisplayItem::kForeignLayerContentsWrapper,
RecordForeignLayer(context, *layer, contents_layer);
DisplayItem::kForeignLayerContentsWrapper,
std::move(contents_layer),
FloatPoint(layer->GetContentsOffsetFromTransformNode()),
IntSize(size.width(), size.height()));
} }
DCHECK(!layer->ContentsClippingMaskLayer()); DCHECK(!layer->ContentsClippingMaskLayer());
...@@ -2783,13 +2773,8 @@ static void CollectLinkHighlightLayersForLayerListRecursively( ...@@ -2783,13 +2773,8 @@ static void CollectLinkHighlightLayersForLayerListRecursively(
ScopedPaintChunkProperties scope(context.GetPaintController(), ScopedPaintChunkProperties scope(context.GetPaintController(),
property_tree_state, *highlight, property_tree_state, *highlight,
DisplayItem::kForeignLayerLinkHighlight); DisplayItem::kForeignLayerLinkHighlight);
auto position = highlight_layer->position(); RecordForeignLayer(context, DisplayItem::kForeignLayerLinkHighlight,
auto size = highlight_layer->bounds(); highlight_layer);
RecordForeignLayer(context, *highlight,
DisplayItem::kForeignLayerLinkHighlight, highlight_layer,
layer->GetOffsetFromTransformNode() +
FloatSize(position.x(), position.y()),
IntSize(size.width(), size.height()));
} }
for (const auto* child : layer->Children()) for (const auto* child : layer->Children())
......
...@@ -44,11 +44,11 @@ void HTMLCanvasPainter::PaintReplaced(const PaintInfo& paint_info, ...@@ -44,11 +44,11 @@ void HTMLCanvasPainter::PaintReplaced(const PaintInfo& paint_info,
canvas->RenderingContext()->IsComposited()) { canvas->RenderingContext()->IsComposited()) {
if (cc::Layer* layer = canvas->RenderingContext()->CcLayer()) { if (cc::Layer* layer = canvas->RenderingContext()->CcLayer()) {
IntRect pixel_snapped_rect = PixelSnappedIntRect(paint_rect); IntRect pixel_snapped_rect = PixelSnappedIntRect(paint_rect);
layer->SetBounds(static_cast<gfx::Size>(pixel_snapped_rect.Size())); layer->SetOffsetToTransformParent(
gfx::Vector2dF(pixel_snapped_rect.X(), pixel_snapped_rect.Y()));
layer->SetBounds(gfx::Size(pixel_snapped_rect.Size()));
layer->SetIsDrawable(true); layer->SetIsDrawable(true);
RecordForeignLayer( RecordForeignLayer(context, DisplayItem::kForeignLayerCanvas, layer);
context, layout_html_canvas_, DisplayItem::kForeignLayerCanvas, layer,
FloatPoint(pixel_snapped_rect.Location()), pixel_snapped_rect.Size());
return; return;
} }
} }
......
...@@ -246,6 +246,13 @@ bool LinkHighlightImpl::ComputeHighlightLayerPathAndPosition( ...@@ -246,6 +246,13 @@ bool LinkHighlightImpl::ComputeHighlightLayerPathAndPosition(
content_layer_->SetPosition(bounding_rect.Location()); content_layer_->SetPosition(bounding_rect.Location());
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
FloatPoint offset(current_graphics_layer_->GetOffsetFromTransformNode());
offset.MoveBy(bounding_rect.Location());
content_layer_->SetOffsetToTransformParent(
gfx::Vector2dF(offset.X(), offset.Y()));
}
return path_has_changed; return path_has_changed;
} }
......
...@@ -52,11 +52,11 @@ void VideoPainter::PaintReplaced(const PaintInfo& paint_info, ...@@ -52,11 +52,11 @@ void VideoPainter::PaintReplaced(const PaintInfo& paint_info,
if (paint_with_foreign_layer) { if (paint_with_foreign_layer) {
if (cc::Layer* layer = layout_video_.MediaElement()->CcLayer()) { if (cc::Layer* layer = layout_video_.MediaElement()->CcLayer()) {
IntRect pixel_snapped_rect = PixelSnappedIntRect(content_rect); IntRect pixel_snapped_rect = PixelSnappedIntRect(content_rect);
layer->SetBounds(static_cast<gfx::Size>(pixel_snapped_rect.Size())); layer->SetOffsetToTransformParent(
gfx::Vector2dF(pixel_snapped_rect.X(), pixel_snapped_rect.Y()));
layer->SetBounds(gfx::Size(pixel_snapped_rect.Size()));
layer->SetIsDrawable(true); layer->SetIsDrawable(true);
RecordForeignLayer( RecordForeignLayer(context, DisplayItem::kForeignLayerVideo, layer);
context, layout_video_, DisplayItem::kForeignLayerVideo, layer,
FloatPoint(pixel_snapped_rect.Location()), pixel_snapped_rect.Size());
return; return;
} }
} }
......
...@@ -132,13 +132,8 @@ static scoped_refptr<cc::Layer> ForeignLayerForPaintChunk( ...@@ -132,13 +132,8 @@ static scoped_refptr<cc::Layer> ForeignLayerForPaintChunk(
const auto& foreign_layer_display_item = const auto& foreign_layer_display_item =
static_cast<const ForeignLayerDisplayItem&>(display_item); static_cast<const ForeignLayerDisplayItem&>(display_item);
layer_offset = gfx::Vector2dF(foreign_layer_display_item.Location().X(), auto* layer = foreign_layer_display_item.GetLayer();
foreign_layer_display_item.Location().Y()); layer_offset = layer->offset_to_transform_parent();
scoped_refptr<cc::Layer> layer = foreign_layer_display_item.GetLayer();
DCHECK(layer->bounds() ==
static_cast<gfx::Size>(foreign_layer_display_item.Bounds()))
<< "\n layer bounds: " << layer->bounds().ToString()
<< "\n display item bounds: " << foreign_layer_display_item.Bounds();
return layer; return layer;
} }
......
...@@ -167,13 +167,13 @@ class PaintArtifactCompositorTest : public testing::Test, ...@@ -167,13 +167,13 @@ class PaintArtifactCompositorTest : public testing::Test,
const auto* scroll_node = scroll_offset.ScrollNode(); const auto* scroll_node = scroll_offset.ScrollNode();
scoped_refptr<cc::Layer> layer = cc::Layer::Create(); scoped_refptr<cc::Layer> layer = cc::Layer::Create();
auto rect = scroll_node->ContainerRect(); auto rect = scroll_node->ContainerRect();
layer->SetScrollable(gfx::Size(rect.Width(), rect.Height())); layer->SetOffsetToTransformParent(gfx::Vector2dF(rect.X(), rect.Y()));
layer->SetBounds(gfx::Size(rect.Width(), rect.Height())); layer->SetScrollable(gfx::Size(rect.Size()));
layer->SetBounds(gfx::Size(rect.Size()));
layer->SetElementId(scroll_node->GetCompositorElementId()); layer->SetElementId(scroll_node->GetCompositorElementId());
layer->set_did_scroll_callback( layer->set_did_scroll_callback(
paint_artifact_compositor_->scroll_callback_); paint_artifact_compositor_->scroll_callback_);
artifact.Chunk(scroll_offset, clip, effect) artifact.Chunk(scroll_offset, clip, effect).ForeignLayer(layer);
.ForeignLayer(FloatPoint(rect.Location()), rect.Size(), layer);
return; return;
} }
// Scroll hit test layers are marked as scrollable for hit testing but are // Scroll hit test layers are marked as scrollable for hit testing but are
...@@ -904,12 +904,12 @@ TEST_P(PaintArtifactCompositorTest, SiblingClipsWithAlias) { ...@@ -904,12 +904,12 @@ TEST_P(PaintArtifactCompositorTest, SiblingClipsWithAlias) {
TEST_P(PaintArtifactCompositorTest, ForeignLayerPassesThrough) { TEST_P(PaintArtifactCompositorTest, ForeignLayerPassesThrough) {
scoped_refptr<cc::Layer> layer = cc::Layer::Create(); scoped_refptr<cc::Layer> layer = cc::Layer::Create();
layer->SetIsDrawable(true); layer->SetIsDrawable(true);
layer->SetOffsetToTransformParent(gfx::Vector2dF(50, 60));
layer->SetBounds(gfx::Size(400, 300)); layer->SetBounds(gfx::Size(400, 300));
TestPaintArtifact test_artifact; TestPaintArtifact test_artifact;
test_artifact.Chunk().RectDrawing(FloatRect(0, 0, 100, 100), Color::kWhite); test_artifact.Chunk().RectDrawing(FloatRect(0, 0, 100, 100), Color::kWhite);
test_artifact.Chunk().ForeignLayer(FloatPoint(50, 60), IntSize(400, 300), test_artifact.Chunk().ForeignLayer(layer);
layer);
test_artifact.Chunk().RectDrawing(FloatRect(0, 0, 100, 100), Color::kGray); test_artifact.Chunk().RectDrawing(FloatRect(0, 0, 100, 100), Color::kGray);
auto artifact = test_artifact.Build(); auto artifact = test_artifact.Build();
......
...@@ -1022,27 +1022,44 @@ sk_sp<PaintRecord> GraphicsLayer::CapturePaintRecord() const { ...@@ -1022,27 +1022,44 @@ sk_sp<PaintRecord> GraphicsLayer::CapturePaintRecord() const {
void GraphicsLayer::SetLayerState(const PropertyTreeState& layer_state, void GraphicsLayer::SetLayerState(const PropertyTreeState& layer_state,
const IntPoint& layer_offset) { const IntPoint& layer_offset) {
if (!layer_state_) { DCHECK(layer_state.Transform() && layer_state.Clip() && layer_state.Effect());
if (layer_state_) {
layer_state_->state = layer_state;
layer_state_->offset = layer_offset;
} else {
layer_state_ = layer_state_ =
std::make_unique<LayerState>(LayerState{layer_state, layer_offset}); std::make_unique<LayerState>(LayerState{layer_state, layer_offset});
return;
} }
layer_state_->state = layer_state;
layer_state_->offset = layer_offset;
CHECK(layer_state_->state.Transform() && layer_state_->state.Clip() && if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
layer_state_->state.Effect()); CcLayer()->SetOffsetToTransformParent(
gfx::Vector2dF(layer_offset.X(), layer_offset.Y()));
if (!contents_layer_state_ && ContentsLayer()) {
ContentsLayer()->SetOffsetToTransformParent(
gfx::Vector2dF(layer_offset.X(), layer_offset.Y()));
}
}
} }
void GraphicsLayer::SetContentsLayerState(const PropertyTreeState& layer_state, void GraphicsLayer::SetContentsLayerState(const PropertyTreeState& layer_state,
const IntPoint& layer_offset) { const IntPoint& layer_offset) {
if (!contents_layer_state_) { DCHECK(layer_state.Transform() && layer_state.Clip() && layer_state.Effect());
DCHECK(ContentsLayer());
if (contents_layer_state_) {
contents_layer_state_->state = layer_state;
contents_layer_state_->offset = layer_offset;
} else {
contents_layer_state_ = contents_layer_state_ =
std::make_unique<LayerState>(LayerState{layer_state, layer_offset}); std::make_unique<LayerState>(LayerState{layer_state, layer_offset});
return;
} }
contents_layer_state_->state = layer_state;
contents_layer_state_->offset = layer_offset; if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) {
ContentsLayer()->SetOffsetToTransformParent(
gfx::Vector2dF(layer_offset.X(), layer_offset.Y()));
}
} }
scoped_refptr<cc::DisplayItemList> GraphicsLayer::PaintContentsToDisplayList( scoped_refptr<cc::DisplayItemList> GraphicsLayer::PaintContentsToDisplayList(
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "third_party/blink/renderer/platform/graphics/contiguous_container.h" #include "third_party/blink/renderer/platform/graphics/contiguous_container.h"
#include "third_party/blink/renderer/platform/graphics/paint/display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item.h"
#include "third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/hit_test_display_item.h"
#include "third_party/blink/renderer/platform/wtf/alignment.h" #include "third_party/blink/renderer/platform/wtf/alignment.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/assertions.h"
...@@ -20,8 +20,8 @@ struct PaintChunk; ...@@ -20,8 +20,8 @@ struct PaintChunk;
// each derived display item; the ideal value is the least common multiple. // each derived display item; the ideal value is the least common multiple.
// The validity of kDisplayItemAlignment and kMaximumDisplayItemSize are checked // The validity of kDisplayItemAlignment and kMaximumDisplayItemSize are checked
// in PaintController::CreateAndAppend(). // in PaintController::CreateAndAppend().
static const size_t kDisplayItemAlignment = alignof(ForeignLayerDisplayItem); static const size_t kDisplayItemAlignment = alignof(HitTestDisplayItem);
static const size_t kMaximumDisplayItemSize = sizeof(ForeignLayerDisplayItem); static const size_t kMaximumDisplayItemSize = sizeof(HitTestDisplayItem);
// A container for a list of display items. // A container for a list of display items.
class PLATFORM_EXPORT DisplayItemList class PLATFORM_EXPORT DisplayItemList
......
...@@ -13,23 +13,47 @@ ...@@ -13,23 +13,47 @@
namespace blink { namespace blink {
ForeignLayerDisplayItem::ForeignLayerDisplayItem( namespace {
const DisplayItemClient& client,
Type type, class ForeignLayerDisplayItemClient final : public DisplayItemClient {
scoped_refptr<cc::Layer> layer, public:
const FloatPoint& location, ForeignLayerDisplayItemClient(scoped_refptr<cc::Layer> layer)
const IntSize& bounds) : layer_(std::move(layer)) {}
: DisplayItem(client, type, sizeof(*this)),
layer_(std::move(layer)), String DebugName() const final { return "ForeignLayer"; }
location_(location),
bounds_(bounds) { LayoutRect VisualRect() const final {
const auto& offset = layer_->offset_to_transform_parent();
return LayoutRect(LayoutPoint(offset.x(), offset.y()),
LayoutSize(IntSize(layer_->bounds())));
}
cc::Layer* GetLayer() const { return layer_.get(); }
private:
scoped_refptr<cc::Layer> layer_;
};
} // anonymous namespace
ForeignLayerDisplayItem::ForeignLayerDisplayItem(Type type,
scoped_refptr<cc::Layer> layer)
: DisplayItem(*new ForeignLayerDisplayItemClient(std::move(layer)),
type,
sizeof(*this)) {
DCHECK(RuntimeEnabledFeatures::SlimmingPaintV2Enabled() || DCHECK(RuntimeEnabledFeatures::SlimmingPaintV2Enabled() ||
RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()); RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled());
DCHECK(IsForeignLayerType(type)); DCHECK(IsForeignLayerType(type));
DCHECK(layer_); DCHECK(GetLayer());
} }
ForeignLayerDisplayItem::~ForeignLayerDisplayItem() = default; ForeignLayerDisplayItem::~ForeignLayerDisplayItem() {
delete &Client();
}
cc::Layer* ForeignLayerDisplayItem::GetLayer() const {
return static_cast<const ForeignLayerDisplayItemClient&>(Client()).GetLayer();
}
void ForeignLayerDisplayItem::Replay(GraphicsContext&) const { void ForeignLayerDisplayItem::Replay(GraphicsContext&) const {
NOTREACHED(); NOTREACHED();
...@@ -42,33 +66,31 @@ void ForeignLayerDisplayItem::AppendToDisplayItemList( ...@@ -42,33 +66,31 @@ void ForeignLayerDisplayItem::AppendToDisplayItemList(
} }
bool ForeignLayerDisplayItem::DrawsContent() const { bool ForeignLayerDisplayItem::DrawsContent() const {
return true; return false;
} }
bool ForeignLayerDisplayItem::Equals(const DisplayItem& other) const { bool ForeignLayerDisplayItem::Equals(const DisplayItem& other) const {
return DisplayItem::Equals(other) && return DisplayItem::Equals(other) &&
layer_ == static_cast<const ForeignLayerDisplayItem&>(other).layer_; GetLayer() ==
static_cast<const ForeignLayerDisplayItem&>(other).GetLayer();
} }
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
void ForeignLayerDisplayItem::PropertiesAsJSON(JSONObject& json) const { void ForeignLayerDisplayItem::PropertiesAsJSON(JSONObject& json) const {
DisplayItem::PropertiesAsJSON(json); DisplayItem::PropertiesAsJSON(json);
json.SetInteger("layer", layer_->id()); json.SetInteger("layer", GetLayer()->id());
} }
#endif #endif
void RecordForeignLayer(GraphicsContext& context, void RecordForeignLayer(GraphicsContext& context,
const DisplayItemClient& client,
DisplayItem::Type type, DisplayItem::Type type,
scoped_refptr<cc::Layer> layer, scoped_refptr<cc::Layer> layer) {
const FloatPoint& location,
const IntSize& bounds) {
PaintController& paint_controller = context.GetPaintController(); PaintController& paint_controller = context.GetPaintController();
if (paint_controller.DisplayItemConstructionIsDisabled()) if (paint_controller.DisplayItemConstructionIsDisabled())
return; return;
paint_controller.CreateAndAppend<ForeignLayerDisplayItem>( paint_controller.CreateAndAppend<ForeignLayerDisplayItem>(type,
client, type, std::move(layer), location, bounds); std::move(layer));
} }
} // namespace blink } // namespace blink
...@@ -21,16 +21,10 @@ class GraphicsContext; ...@@ -21,16 +21,10 @@ class GraphicsContext;
// GraphicsLayer tree. // GraphicsLayer tree.
class PLATFORM_EXPORT ForeignLayerDisplayItem final : public DisplayItem { class PLATFORM_EXPORT ForeignLayerDisplayItem final : public DisplayItem {
public: public:
ForeignLayerDisplayItem(const DisplayItemClient&, ForeignLayerDisplayItem(Type, scoped_refptr<cc::Layer>);
Type,
scoped_refptr<cc::Layer>,
const FloatPoint& location,
const IntSize& bounds);
~ForeignLayerDisplayItem() override; ~ForeignLayerDisplayItem() override;
cc::Layer* GetLayer() const { return layer_.get(); } cc::Layer* GetLayer() const;
const FloatPoint& Location() const { return location_; }
const IntSize& Bounds() const { return bounds_; }
// DisplayItem // DisplayItem
void Replay(GraphicsContext&) const override; void Replay(GraphicsContext&) const override;
...@@ -41,21 +35,13 @@ class PLATFORM_EXPORT ForeignLayerDisplayItem final : public DisplayItem { ...@@ -41,21 +35,13 @@ class PLATFORM_EXPORT ForeignLayerDisplayItem final : public DisplayItem {
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
void PropertiesAsJSON(JSONObject&) const override; void PropertiesAsJSON(JSONObject&) const override;
#endif #endif
private:
scoped_refptr<cc::Layer> layer_;
FloatPoint location_;
IntSize bounds_;
}; };
// Records a foreign layer into a GraphicsContext. // Records a foreign layer into a GraphicsContext.
// Use this where you would use a recorder class. // Use this where you would use a recorder class.
PLATFORM_EXPORT void RecordForeignLayer(GraphicsContext&, PLATFORM_EXPORT void RecordForeignLayer(GraphicsContext&,
const DisplayItemClient&,
DisplayItem::Type, DisplayItem::Type,
scoped_refptr<cc::Layer>, scoped_refptr<cc::Layer>);
const FloatPoint& location,
const IntSize& bounds);
} // namespace blink } // namespace blink
......
...@@ -78,12 +78,6 @@ TestPaintArtifact& TestPaintArtifact::RectDrawing(const FloatRect& bounds, ...@@ -78,12 +78,6 @@ TestPaintArtifact& TestPaintArtifact::RectDrawing(const FloatRect& bounds,
return RectDrawing(NewClient(), bounds, color); return RectDrawing(NewClient(), bounds, color);
} }
TestPaintArtifact& TestPaintArtifact::ForeignLayer(
const FloatPoint& location,
const IntSize& size,
scoped_refptr<cc::Layer> layer) {
return ForeignLayer(NewClient(), location, size, std::move(layer));
}
TestPaintArtifact& TestPaintArtifact::ScrollHitTest( TestPaintArtifact& TestPaintArtifact::ScrollHitTest(
const TransformPaintPropertyNode& scroll_offset) { const TransformPaintPropertyNode& scroll_offset) {
return ScrollHitTest(NewClient(), scroll_offset); return ScrollHitTest(NewClient(), scroll_offset);
...@@ -99,15 +93,9 @@ TestPaintArtifact& TestPaintArtifact::RectDrawing(FakeDisplayItemClient& client, ...@@ -99,15 +93,9 @@ TestPaintArtifact& TestPaintArtifact::RectDrawing(FakeDisplayItemClient& client,
} }
TestPaintArtifact& TestPaintArtifact::ForeignLayer( TestPaintArtifact& TestPaintArtifact::ForeignLayer(
FakeDisplayItemClient& client,
const FloatPoint& location,
const IntSize& size,
scoped_refptr<cc::Layer> layer) { scoped_refptr<cc::Layer> layer) {
static_cast<DummyRectClient&>(client).SetVisualRect(
FloatRect(location, FloatSize(size)));
display_item_list_.AllocateAndConstruct<ForeignLayerDisplayItem>( display_item_list_.AllocateAndConstruct<ForeignLayerDisplayItem>(
client, DisplayItem::kForeignLayerFirst, std::move(layer), location, DisplayItem::kForeignLayerFirst, std::move(layer));
size);
return *this; return *this;
} }
......
...@@ -93,20 +93,15 @@ class TestPaintArtifact { ...@@ -93,20 +93,15 @@ class TestPaintArtifact {
// Add display item in the chunk. Each display item will have a different // Add display item in the chunk. Each display item will have a different
// automatically created client. // automatically created client.
TestPaintArtifact& RectDrawing(const FloatRect& bounds, Color color); TestPaintArtifact& RectDrawing(const FloatRect& bounds, Color color);
TestPaintArtifact& ForeignLayer(const FloatPoint& location,
const IntSize& size,
scoped_refptr<cc::Layer> layer);
TestPaintArtifact& ScrollHitTest( TestPaintArtifact& ScrollHitTest(
const TransformPaintPropertyNode& scroll_offset); const TransformPaintPropertyNode& scroll_offset);
TestPaintArtifact& ForeignLayer(scoped_refptr<cc::Layer> layer);
// Add display item with the specified client in the chunk. // Add display item with the specified client in the chunk.
TestPaintArtifact& RectDrawing(FakeDisplayItemClient&, TestPaintArtifact& RectDrawing(FakeDisplayItemClient&,
const FloatRect& bounds, const FloatRect& bounds,
Color); Color);
TestPaintArtifact& ForeignLayer(FakeDisplayItemClient&,
const FloatPoint&,
const IntSize&,
scoped_refptr<cc::Layer>);
TestPaintArtifact& ScrollHitTest( TestPaintArtifact& ScrollHitTest(
FakeDisplayItemClient&, FakeDisplayItemClient&,
const TransformPaintPropertyNode& scroll_offset); const TransformPaintPropertyNode& scroll_offset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment