Commit 67e4d54c authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Add cc::LayerClient::LayerDebugName()

Previously cc::Layer::DebugName() called LayerClient::TakeDebugInfo()
which has side-effect to clear some debug information (e.g. raster
invalidation tracking), causing layer name dump to interfere with
raster invalidation tracking.

Add the new method to avoid the problem.

R=pdr@chromium.org
TBR= # trivial change under ui/compositor.

Change-Id: Ia4850298f8bc5a2a003dc92a00bda903a3b099d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850964
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704711}
parent e7c0e4d9
...@@ -1215,11 +1215,7 @@ void Layer::SetPropertyTreesNeedRebuild() { ...@@ -1215,11 +1215,7 @@ void Layer::SetPropertyTreesNeedRebuild() {
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
std::string Layer::DebugName() const { std::string Layer::DebugName() const {
if (inputs_.client) { return inputs_.client ? inputs_.client->LayerDebugName(this) : "";
if (auto debug_info = inputs_.client->TakeDebugInfo(this))
return debug_info->ToBaseValue()->FindKey("layer_name")->GetString();
}
return "";
} }
#endif #endif
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CC_LAYERS_LAYER_CLIENT_H_ #define CC_LAYERS_LAYER_CLIENT_H_
#include <memory> #include <memory>
#include <string>
#include "cc/cc_export.h" #include "cc/cc_export.h"
...@@ -31,6 +32,8 @@ class CC_EXPORT LayerClient { ...@@ -31,6 +32,8 @@ class CC_EXPORT LayerClient {
virtual std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( virtual std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo(
const Layer* layer) = 0; const Layer* layer) = 0;
virtual std::string LayerDebugName(const Layer* layer) const = 0;
virtual void DidChangeScrollbarsHiddenIfOverlay(bool) = 0; virtual void DidChangeScrollbarsHiddenIfOverlay(bool) = 0;
protected: protected:
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "third_party/blink/renderer/platform/graphics/paint/paint_chunk_subset.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_chunk_subset.h"
#include "third_party/blink/renderer/platform/graphics/paint/raster_invalidation_tracking.h" #include "third_party/blink/renderer/platform/graphics/paint/raster_invalidation_tracking.h"
#include "third_party/blink/renderer/platform/json/json_values.h" #include "third_party/blink/renderer/platform/json/json_values.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
namespace blink { namespace blink {
...@@ -149,8 +148,7 @@ std::unique_ptr<base::trace_event::TracedValue> ...@@ -149,8 +148,7 @@ std::unique_ptr<base::trace_event::TracedValue>
ContentLayerClientImpl::TakeDebugInfo(const cc::Layer* layer) { ContentLayerClientImpl::TakeDebugInfo(const cc::Layer* layer) {
DCHECK_EQ(layer, cc_picture_layer_.get()); DCHECK_EQ(layer, cc_picture_layer_.get());
auto traced_value = std::make_unique<base::trace_event::TracedValue>(); auto traced_value = std::make_unique<base::trace_event::TracedValue>();
traced_value->SetString("layer_name", traced_value->SetString("layer_name", LayerDebugName(layer));
WTF::StringUTF8Adaptor(debug_name_).AsStringPiece());
if (auto* tracking = raster_invalidator_.GetTracking()) { if (auto* tracking = raster_invalidator_.GetTracking()) {
tracking->AddToTracedValue(*traced_value); tracking->AddToTracedValue(*traced_value);
tracking->ClearInvalidations(); tracking->ClearInvalidations();
...@@ -160,6 +158,12 @@ ContentLayerClientImpl::TakeDebugInfo(const cc::Layer* layer) { ...@@ -160,6 +158,12 @@ ContentLayerClientImpl::TakeDebugInfo(const cc::Layer* layer) {
return traced_value; return traced_value;
} }
std::string ContentLayerClientImpl::LayerDebugName(
const cc::Layer* layer) const {
DCHECK_EQ(layer, cc_picture_layer_.get());
return debug_name_.Utf8();
}
scoped_refptr<cc::PictureLayer> ContentLayerClientImpl::UpdateCcPictureLayer( scoped_refptr<cc::PictureLayer> ContentLayerClientImpl::UpdateCcPictureLayer(
scoped_refptr<const PaintArtifact> paint_artifact, scoped_refptr<const PaintArtifact> paint_artifact,
const PaintChunkSubset& paint_chunks, const PaintChunkSubset& paint_chunks,
......
...@@ -47,6 +47,7 @@ class PLATFORM_EXPORT ContentLayerClientImpl : public cc::ContentLayerClient, ...@@ -47,6 +47,7 @@ class PLATFORM_EXPORT ContentLayerClientImpl : public cc::ContentLayerClient,
// cc::LayerClient // cc::LayerClient
std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo(
const cc::Layer*) override; const cc::Layer*) override;
std::string LayerDebugName(const cc::Layer*) const override;
void DidChangeScrollbarsHiddenIfOverlay(bool) override {} void DidChangeScrollbarsHiddenIfOverlay(bool) override {}
bool Matches(const PaintChunk& paint_chunk) const { bool Matches(const PaintChunk& paint_chunk) const {
......
...@@ -61,7 +61,6 @@ ...@@ -61,7 +61,6 @@
#include "third_party/blink/renderer/platform/wtf/hash_map.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h" #include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/blink/renderer/platform/wtf/text/text_stream.h" #include "third_party/blink/renderer/platform/wtf/text/text_stream.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -808,8 +807,7 @@ std::unique_ptr<base::trace_event::TracedValue> GraphicsLayer::TakeDebugInfo( ...@@ -808,8 +807,7 @@ std::unique_ptr<base::trace_event::TracedValue> GraphicsLayer::TakeDebugInfo(
const cc::Layer* layer) { const cc::Layer* layer) {
auto traced_value = std::make_unique<base::trace_event::TracedValue>(); auto traced_value = std::make_unique<base::trace_event::TracedValue>();
traced_value->SetString( traced_value->SetString("layer_name", LayerDebugName(layer));
"layer_name", WTF::StringUTF8Adaptor(DebugName(layer)).AsStringPiece());
traced_value->BeginArray("compositing_reasons"); traced_value->BeginArray("compositing_reasons");
for (const char* description : for (const char* description :
...@@ -834,6 +832,10 @@ std::unique_ptr<base::trace_event::TracedValue> GraphicsLayer::TakeDebugInfo( ...@@ -834,6 +832,10 @@ std::unique_ptr<base::trace_event::TracedValue> GraphicsLayer::TakeDebugInfo(
return traced_value; return traced_value;
} }
std::string GraphicsLayer::LayerDebugName(const cc::Layer* layer) const {
return DebugName(layer).Utf8();
}
void GraphicsLayer::DidChangeScrollbarsHiddenIfOverlay(bool hidden) { void GraphicsLayer::DidChangeScrollbarsHiddenIfOverlay(bool hidden) {
client_.SetOverlayScrollbarsHidden(hidden); client_.SetOverlayScrollbarsHidden(hidden);
} }
......
...@@ -236,6 +236,7 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient, ...@@ -236,6 +236,7 @@ class PLATFORM_EXPORT GraphicsLayer : public cc::LayerClient,
// cc::LayerClient implementation. // cc::LayerClient implementation.
std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo(
const cc::Layer*) override; const cc::Layer*) override;
std::string LayerDebugName(const cc::Layer*) const override;
void DidChangeScrollbarsHiddenIfOverlay(bool) override; void DidChangeScrollbarsHiddenIfOverlay(bool) override;
PaintController& GetPaintController() const; PaintController& GetPaintController() const;
......
...@@ -1292,6 +1292,10 @@ std::unique_ptr<base::trace_event::TracedValue> Layer::TakeDebugInfo( ...@@ -1292,6 +1292,10 @@ std::unique_ptr<base::trace_event::TracedValue> Layer::TakeDebugInfo(
return value; return value;
} }
std::string Layer::LayerDebugName(const cc::Layer* layer) const {
return name_;
}
void Layer::DidChangeScrollbarsHiddenIfOverlay(bool) {} void Layer::DidChangeScrollbarsHiddenIfOverlay(bool) {}
void Layer::CollectAnimators( void Layer::CollectAnimators(
......
...@@ -466,6 +466,7 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate, ...@@ -466,6 +466,7 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
// LayerClient implementation. // LayerClient implementation.
std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo(
const cc::Layer* layer) override; const cc::Layer* layer) override;
std::string LayerDebugName(const cc::Layer* layer) const override;
void DidChangeScrollbarsHiddenIfOverlay(bool) override; void DidChangeScrollbarsHiddenIfOverlay(bool) override;
// Triggers a call to SwitchToLayer. // Triggers a call to SwitchToLayer.
......
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