Commit 71b099c3 authored by Tien-Ren Chen's avatar Tien-Ren Chen Committed by Commit Bot

[Blink] Remove ContentLayerDelegate

There is little advantage from this extra layer of indirection. Just
remove it to make GraphicsLayer implements WebContentLayerClient
directly.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I36e33a475942f6902b77dd4a92bf31579f227879
Reviewed-on: https://chromium-review.googlesource.com/616204
Commit-Queue: Tien-Ren Chen <trchen@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496528}
parent f23631fd
...@@ -3300,7 +3300,7 @@ void CompositedLayerMapping::PaintContents( ...@@ -3300,7 +3300,7 @@ void CompositedLayerMapping::PaintContents(
// https://code.google.com/p/chromium/issues/detail?id=343772 // https://code.google.com/p/chromium/issues/detail?id=343772
DisableCompositingQueryAsserts disabler; DisableCompositingQueryAsserts disabler;
// Allow throttling to make sure no painting paths (e.g., // Allow throttling to make sure no painting paths (e.g.,
// ContentLayerDelegate::paintContents) try to paint throttled content. // GraphicsLayer::PaintContents) try to paint throttled content.
DocumentLifecycle::AllowThrottlingScope allow_throttling( DocumentLifecycle::AllowThrottlingScope allow_throttling(
owning_layer_.GetLayoutObject().GetDocument().Lifecycle()); owning_layer_.GetLayoutObject().GetDocument().Lifecycle());
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
......
...@@ -54,8 +54,8 @@ class MockWebDisplayItemList : public WebDisplayItemList { ...@@ -54,8 +54,8 @@ class MockWebDisplayItemList : public WebDisplayItemList {
void PaintRecursively(GraphicsLayer* layer, WebDisplayItemList* display_items) { void PaintRecursively(GraphicsLayer* layer, WebDisplayItemList* display_items) {
if (layer->DrawsContent()) { if (layer->DrawsContent()) {
layer->SetNeedsDisplay(); layer->SetNeedsDisplay();
layer->ContentLayerDelegateForTesting()->PaintContents( layer->WebContentLayerClientForTesting().PaintContents(
display_items, ContentLayerDelegate::kPaintDefaultBehaviorForTest); display_items, WebContentLayerClient::kPaintDefaultBehaviorForTest);
} }
for (const auto& child : layer->Children()) for (const auto& child : layer->Children())
PaintRecursively(child, display_items); PaintRecursively(child, display_items);
...@@ -887,7 +887,7 @@ TEST_P(FrameThrottlingTest, DumpThrottledFrame) { ...@@ -887,7 +887,7 @@ TEST_P(FrameThrottlingTest, DumpThrottledFrame) {
EXPECT_EQ(std::string::npos, result.Utf8().find("throttled")); EXPECT_EQ(std::string::npos, result.Utf8().find("throttled"));
} }
TEST_P(FrameThrottlingTest, PaintingViaContentLayerDelegateIsThrottled) { TEST_P(FrameThrottlingTest, PaintingViaGraphicsLayerIsThrottled) {
WebView().GetSettings()->SetAcceleratedCompositingEnabled(true); WebView().GetSettings()->SetAcceleratedCompositingEnabled(true);
WebView().GetSettings()->SetPreferCompositingToLCDTextEnabled(true); WebView().GetSettings()->SetPreferCompositingToLCDTextEnabled(true);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "core/paint/compositing/CompositedLayerMapping.h" #include "core/paint/compositing/CompositedLayerMapping.h"
#include "core/paint/compositing/PaintLayerCompositor.h" #include "core/paint/compositing/PaintLayerCompositor.h"
#include "core/testing/sim/SimDisplayItemList.h" #include "core/testing/sim/SimDisplayItemList.h"
#include "platform/graphics/ContentLayerDelegate.h"
#include "platform/graphics/GraphicsLayer.h" #include "platform/graphics/GraphicsLayer.h"
#include "platform/wtf/CurrentTime.h" #include "platform/wtf/CurrentTime.h"
#include "public/platform/WebRect.h" #include "public/platform/WebRect.h"
...@@ -23,8 +22,7 @@ namespace blink { ...@@ -23,8 +22,7 @@ namespace blink {
static void PaintLayers(GraphicsLayer& layer, static void PaintLayers(GraphicsLayer& layer,
SimDisplayItemList& display_list) { SimDisplayItemList& display_list) {
if (layer.DrawsContent() && layer.HasTrackedRasterInvalidations()) { if (layer.DrawsContent() && layer.HasTrackedRasterInvalidations()) {
ContentLayerDelegate* delegate = layer.ContentLayerDelegateForTesting(); layer.WebContentLayerClientForTesting().PaintContents(&display_list);
delegate->PaintContents(&display_list);
layer.ResetTrackedRasterInvalidations(); layer.ResetTrackedRasterInvalidations();
} }
......
...@@ -896,8 +896,6 @@ component("platform") { ...@@ -896,8 +896,6 @@ component("platform") {
"graphics/CompositorMutator.h", "graphics/CompositorMutator.h",
"graphics/CompositorMutatorClient.cpp", "graphics/CompositorMutatorClient.cpp",
"graphics/CompositorMutatorClient.h", "graphics/CompositorMutatorClient.h",
"graphics/ContentLayerDelegate.cpp",
"graphics/ContentLayerDelegate.h",
"graphics/ContiguousContainer.cpp", "graphics/ContiguousContainer.cpp",
"graphics/ContiguousContainer.h", "graphics/ContiguousContainer.h",
"graphics/CrossfadeGeneratedImage.cpp", "graphics/CrossfadeGeneratedImage.cpp",
......
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#include "platform/graphics/ContentLayerDelegate.h"
#include "platform/bindings/RuntimeCallStats.h"
#include "platform/bindings/V8PerIsolateData.h"
#include "platform/geometry/IntRect.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/PaintController.h"
#include "platform/graphics/paint/PaintRecord.h"
#include "platform/image-decoders/ImageDecoder.h"
#include "platform/instrumentation/tracing/TraceEvent.h"
#include "platform/instrumentation/tracing/TracedValue.h"
#include "public/platform/WebDisplayItemList.h"
#include "public/platform/WebRect.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/rect.h"
namespace blink {
ContentLayerDelegate::ContentLayerDelegate(GraphicsLayer* graphics_layer)
: graphics_layer_(graphics_layer) {}
ContentLayerDelegate::~ContentLayerDelegate() {}
gfx::Rect ContentLayerDelegate::PaintableRegion() {
IntRect interest_rect = graphics_layer_->InterestRect();
return gfx::Rect(interest_rect.X(), interest_rect.Y(), interest_rect.Width(),
interest_rect.Height());
}
void ContentLayerDelegate::PaintContents(
WebDisplayItemList* web_display_item_list,
WebContentLayerClient::PaintingControlSetting painting_control) {
TRACE_EVENT0("blink,benchmark", "ContentLayerDelegate::paintContents");
RUNTIME_CALL_TIMER_SCOPE(V8PerIsolateData::MainThreadIsolate(),
RuntimeCallStats::CounterId::kPaintContents);
PaintController& paint_controller = graphics_layer_->GetPaintController();
paint_controller.SetDisplayItemConstructionIsDisabled(
painting_control ==
WebContentLayerClient::kDisplayListConstructionDisabled);
paint_controller.SetSubsequenceCachingIsDisabled(
painting_control == WebContentLayerClient::kSubsequenceCachingDisabled);
if (painting_control == WebContentLayerClient::kPartialInvalidation)
graphics_layer_->Client()->InvalidateTargetElementForTesting();
// We also disable caching when Painting or Construction are disabled. In both
// cases we would like to compare assuming the full cost of recording, not the
// cost of re-using cached content.
if (painting_control == WebContentLayerClient::kDisplayListCachingDisabled ||
painting_control == WebContentLayerClient::kDisplayListPaintingDisabled ||
painting_control ==
WebContentLayerClient::kDisplayListConstructionDisabled)
paint_controller.InvalidateAll();
GraphicsContext::DisabledMode disabled_mode =
GraphicsContext::kNothingDisabled;
if (painting_control == WebContentLayerClient::kDisplayListPaintingDisabled ||
painting_control ==
WebContentLayerClient::kDisplayListConstructionDisabled)
disabled_mode = GraphicsContext::kFullyDisabled;
// Anything other than PaintDefaultBehavior is for testing. In non-testing
// scenarios, it is an error to call GraphicsLayer::paint. Actual painting
// occurs in FrameView::paintTree(); this method merely copies the painted
// output to the WebDisplayItemList.
if (painting_control != kPaintDefaultBehavior)
graphics_layer_->Paint(nullptr, disabled_mode);
paint_controller.GetPaintArtifact().AppendToWebDisplayItemList(
graphics_layer_->OffsetFromLayoutObjectWithSubpixelAccumulation(),
web_display_item_list);
paint_controller.SetDisplayItemConstructionIsDisabled(false);
paint_controller.SetSubsequenceCachingIsDisabled(false);
}
size_t ContentLayerDelegate::ApproximateUnsharedMemoryUsage() const {
return graphics_layer_->GetPaintController().ApproximateUnsharedMemoryUsage();
}
} // namespace blink
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#ifndef ContentLayerDelegate_h
#define ContentLayerDelegate_h
#include "platform/PlatformExport.h"
#include "platform/geometry/IntSize.h"
#include "platform/wtf/Allocator.h"
#include "platform/wtf/Noncopyable.h"
#include "public/platform/WebContentLayerClient.h"
namespace gfx {
class Rect;
}
namespace blink {
class GraphicsLayer;
class PLATFORM_EXPORT ContentLayerDelegate : public WebContentLayerClient {
WTF_MAKE_NONCOPYABLE(ContentLayerDelegate);
USING_FAST_MALLOC(ContentLayerDelegate);
public:
explicit ContentLayerDelegate(GraphicsLayer*);
~ContentLayerDelegate() override;
gfx::Rect PaintableRegion() override;
// WebContentLayerClient implementation.
void PaintContents(WebDisplayItemList*,
WebContentLayerClient::PaintingControlSetting =
kPaintDefaultBehavior) override;
size_t ApproximateUnsharedMemoryUsage() const override;
private:
GraphicsLayer* graphics_layer_;
};
} // namespace blink
#endif // ContentLayerDelegate_h
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "base/trace_event/trace_event_argument.h" #include "base/trace_event/trace_event_argument.h"
#include "cc/layers/layer.h" #include "cc/layers/layer.h"
#include "platform/DragImage.h" #include "platform/DragImage.h"
#include "platform/bindings/RuntimeCallStats.h"
#include "platform/bindings/V8PerIsolateData.h"
#include "platform/geometry/FloatRect.h" #include "platform/geometry/FloatRect.h"
#include "platform/geometry/LayoutRect.h" #include "platform/geometry/LayoutRect.h"
#include "platform/geometry/Region.h" #include "platform/geometry/Region.h"
...@@ -114,9 +116,7 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) ...@@ -114,9 +116,7 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
if (client_) if (client_)
client_->VerifyNotPainting(); client_->VerifyNotPainting();
#endif #endif
content_layer_delegate_ = WTF::MakeUnique<ContentLayerDelegate>(this); layer_ = Platform::Current()->CompositorSupport()->CreateContentLayer(this);
layer_ = Platform::Current()->CompositorSupport()->CreateContentLayer(
content_layer_delegate_.get());
layer_->Layer()->SetDrawsContent(draws_content_ && contents_visible_); layer_->Layer()->SetDrawsContent(draws_content_ && contents_visible_);
layer_->Layer()->SetLayerClient(this); layer_->Layer()->SetLayerClient(this);
} }
...@@ -1173,7 +1173,7 @@ void GraphicsLayer::didChangeScrollbarsHidden(bool hidden) { ...@@ -1173,7 +1173,7 @@ void GraphicsLayer::didChangeScrollbarsHidden(bool hidden) {
scrollable_area_->SetScrollbarsHidden(hidden); scrollable_area_->SetScrollbarsHidden(hidden);
} }
PaintController& GraphicsLayer::GetPaintController() { PaintController& GraphicsLayer::GetPaintController() const {
CHECK(DrawsContent()); CHECK(DrawsContent());
if (!paint_controller_) if (!paint_controller_)
paint_controller_ = PaintController::Create(); paint_controller_ = PaintController::Create();
...@@ -1208,6 +1208,53 @@ sk_sp<PaintRecord> GraphicsLayer::CaptureRecord() { ...@@ -1208,6 +1208,53 @@ sk_sp<PaintRecord> GraphicsLayer::CaptureRecord() {
return graphics_context.EndRecording(); return graphics_context.EndRecording();
} }
void GraphicsLayer::PaintContents(WebDisplayItemList* web_display_item_list,
PaintingControlSetting painting_control) {
TRACE_EVENT0("blink,benchmark", "GraphicsLayer::PaintContents");
RUNTIME_CALL_TIMER_SCOPE(V8PerIsolateData::MainThreadIsolate(),
RuntimeCallStats::CounterId::kPaintContents);
PaintController& paint_controller = GetPaintController();
paint_controller.SetDisplayItemConstructionIsDisabled(
painting_control == kDisplayListConstructionDisabled);
paint_controller.SetSubsequenceCachingIsDisabled(painting_control ==
kSubsequenceCachingDisabled);
if (painting_control == kPartialInvalidation)
client_->InvalidateTargetElementForTesting();
// We also disable caching when Painting or Construction are disabled. In both
// cases we would like to compare assuming the full cost of recording, not the
// cost of re-using cached content.
if (painting_control == kDisplayListCachingDisabled ||
painting_control == kDisplayListPaintingDisabled ||
painting_control == kDisplayListConstructionDisabled)
paint_controller.InvalidateAll();
GraphicsContext::DisabledMode disabled_mode =
GraphicsContext::kNothingDisabled;
if (painting_control == kDisplayListPaintingDisabled ||
painting_control == kDisplayListConstructionDisabled)
disabled_mode = GraphicsContext::kFullyDisabled;
// Anything other than PaintDefaultBehavior is for testing. In non-testing
// scenarios, it is an error to call GraphicsLayer::paint. Actual painting
// occurs in FrameView::paintTree(); this method merely copies the painted
// output to the WebDisplayItemList.
if (painting_control != kPaintDefaultBehavior)
Paint(nullptr, disabled_mode);
paint_controller.GetPaintArtifact().AppendToWebDisplayItemList(
OffsetFromLayoutObjectWithSubpixelAccumulation(), web_display_item_list);
paint_controller.SetDisplayItemConstructionIsDisabled(false);
paint_controller.SetSubsequenceCachingIsDisabled(false);
}
size_t GraphicsLayer::ApproximateUnsharedMemoryUsage() const {
return GetPaintController().ApproximateUnsharedMemoryUsage();
}
bool ScopedSetNeedsDisplayInRectForTrackingOnly::s_enabled_ = false; bool ScopedSetNeedsDisplayInRectForTrackingOnly::s_enabled_ = false;
} // namespace blink } // namespace blink
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "platform/geometry/IntRect.h" #include "platform/geometry/IntRect.h"
#include "platform/graphics/Color.h" #include "platform/graphics/Color.h"
#include "platform/graphics/CompositorElementId.h" #include "platform/graphics/CompositorElementId.h"
#include "platform/graphics/ContentLayerDelegate.h"
#include "platform/graphics/GraphicsContext.h" #include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/GraphicsLayerClient.h" #include "platform/graphics/GraphicsLayerClient.h"
#include "platform/graphics/GraphicsLayerDebugInfo.h" #include "platform/graphics/GraphicsLayerDebugInfo.h"
...@@ -48,6 +47,7 @@ ...@@ -48,6 +47,7 @@
#include "platform/transforms/TransformationMatrix.h" #include "platform/transforms/TransformationMatrix.h"
#include "platform/wtf/Vector.h" #include "platform/wtf/Vector.h"
#include "public/platform/WebContentLayer.h" #include "public/platform/WebContentLayer.h"
#include "public/platform/WebContentLayerClient.h"
#include "public/platform/WebImageLayer.h" #include "public/platform/WebImageLayer.h"
#include "public/platform/WebLayerStickyPositionConstraint.h" #include "public/platform/WebLayerStickyPositionConstraint.h"
#include "public/platform/WebScrollBoundaryBehavior.h" #include "public/platform/WebScrollBoundaryBehavior.h"
...@@ -70,7 +70,8 @@ typedef Vector<GraphicsLayer*, 64> GraphicsLayerVector; ...@@ -70,7 +70,8 @@ typedef Vector<GraphicsLayer*, 64> GraphicsLayerVector;
// GraphicsLayer is an abstraction for a rendering surface with backing store, // GraphicsLayer is an abstraction for a rendering surface with backing store,
// which may have associated transformation and animations. // which may have associated transformation and animations.
class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient, class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
public DisplayItemClient { public DisplayItemClient,
private WebContentLayerClient {
WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_NONCOPYABLE(GraphicsLayer);
USING_FAST_MALLOC(GraphicsLayer); USING_FAST_MALLOC(GraphicsLayer);
...@@ -260,7 +261,7 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient, ...@@ -260,7 +261,7 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
void didUpdateMainThreadScrollingReasons() override; void didUpdateMainThreadScrollingReasons() override;
void didChangeScrollbarsHidden(bool); void didChangeScrollbarsHidden(bool);
PaintController& GetPaintController(); PaintController& GetPaintController() const;
// Exposed for tests. // Exposed for tests.
WebLayer* ContentsLayer() const { return contents_layer_; } WebLayer* ContentsLayer() const { return contents_layer_; }
...@@ -270,9 +271,7 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient, ...@@ -270,9 +271,7 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
void SetCompositorMutableProperties(uint32_t); void SetCompositorMutableProperties(uint32_t);
ContentLayerDelegate* ContentLayerDelegateForTesting() const { WebContentLayerClient& WebContentLayerClientForTesting() { return *this; }
return content_layer_delegate_.get();
}
// DisplayItemClient methods // DisplayItemClient methods
String DebugName() const final { return client_->DebugName(this); } String DebugName() const final { return client_->DebugName(this); }
...@@ -293,6 +292,12 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient, ...@@ -293,6 +292,12 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
friend class PaintControllerPaintTestBase; friend class PaintControllerPaintTestBase;
private: private:
// WebContentLayerClient implementation.
gfx::Rect PaintableRegion() final { return InterestRect(); }
void PaintContents(WebDisplayItemList*,
PaintingControlSetting = kPaintDefaultBehavior) final;
size_t ApproximateUnsharedMemoryUsage() const final;
// Returns true if PaintController::paintArtifact() changed and needs commit. // Returns true if PaintController::paintArtifact() changed and needs commit.
bool PaintWithoutCommit( bool PaintWithoutCommit(
const IntRect* interest_rect, const IntRect* interest_rect,
...@@ -389,13 +394,11 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient, ...@@ -389,13 +394,11 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
Vector<LinkHighlight*> link_highlights_; Vector<LinkHighlight*> link_highlights_;
std::unique_ptr<ContentLayerDelegate> content_layer_delegate_;
WeakPersistent<ScrollableArea> scrollable_area_; WeakPersistent<ScrollableArea> scrollable_area_;
GraphicsLayerDebugInfo debug_info_; GraphicsLayerDebugInfo debug_info_;
int rendering_context3d_; int rendering_context3d_;
std::unique_ptr<PaintController> paint_controller_; mutable std::unique_ptr<PaintController> paint_controller_;
IntRect previous_interest_rect_; IntRect previous_interest_rect_;
}; };
......
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