Commit 9f3be435 authored by chrishtr@gmail.com's avatar chrishtr@gmail.com

Plumbing for layout rectangle debug info. Companion to

https://code.google.com/p/chromium/issues/detail?id=314945

Patch from Chris Harrelson <chrishtr@gmail.com>

BUG=314945
..


..


Plumbing for for layout rectangle debug information.

BUG=

Review URL: https://codereview.chromium.org/61883006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238297 0039d316-1c4b-4281-b951-d872f2087c98
parent 35ecbac2
......@@ -52,6 +52,7 @@ Chamal De Silva <chamalsl@yahoo.com>
Chandra Shekar Vallala <brk376@motorola.com>
Changbin Shao <changbin.shao@intel.com>
Chaobin Zhang <zhchbin@gmail.com>
Chris Harrelson <chrishtr@gmail.com>
Christophe Dumez <ch.dumez@samsung.com>
Christopher Dale <chrelad@gmail.com>
Clemens Fruhwirth <clemens@endorphin.org>
......
......@@ -876,10 +876,12 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
bool is_tracing;
TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
&is_tracing);
if (is_tracing)
layer->SetDebugName(DebugName());
else
layer->SetDebugName(std::string());
if (is_tracing) {
layer->SetDebugName(DebugName());
layer->SetDebugInfo(TakeDebugInfo());
} else {
layer->SetDebugName(std::string());
}
layer->SetCompositingReasons(compositing_reasons_);
layer->SetDoubleSided(double_sided_);
......@@ -1037,6 +1039,14 @@ std::string Layer::DebugName() {
return client_ ? client_->DebugName() : std::string();
}
scoped_refptr<base::debug::ConvertableToTraceFormat> Layer::TakeDebugInfo() {
if (client_)
return client_->TakeDebugInfo();
else
return NULL;
}
void Layer::SetCompositingReasons(CompositingReasons reasons) {
compositing_reasons_ = reasons;
}
......
......@@ -39,6 +39,12 @@ namespace gfx {
class BoxF;
}
namespace base {
namespace debug {
class ConvertableToTraceFormat;
}
}
namespace cc {
class Animation;
......@@ -358,6 +364,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
virtual void OnOutputSurfaceCreated() {}
virtual std::string DebugName();
virtual scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo();
void SetLayerClient(LayerClient* client) { client_ = client; }
......
......@@ -7,14 +7,27 @@
#include <string>
#include "base/memory/ref_counted.h"
#include "cc/base/cc_export.h"
namespace base {
namespace debug {
class ConvertableToTraceFormat;
}
}
namespace cc {
class CC_EXPORT LayerClient {
public:
virtual std::string DebugName() = 0;
// Returns a pointer to a debug info object, if one has been computed.
// If not, returns NULL. If the returned pointer is non-NULL, the caller takes
// ownership of the pointer.
virtual scoped_refptr<base::debug::ConvertableToTraceFormat>
TakeDebugInfo() = 0;
protected:
virtual ~LayerClient() {}
};
......
......@@ -5,6 +5,7 @@
#include "cc/layers/layer_impl.h"
#include "base/debug/trace_event.h"
#include "base/json/json_reader.h"
#include "base/strings/stringprintf.h"
#include "cc/animation/animation_registrar.h"
#include "cc/animation/scrollbar_animation_controller.h"
......@@ -159,6 +160,11 @@ void LayerImpl::SetScrollParent(LayerImpl* parent) {
scroll_parent_ = parent;
}
void LayerImpl::SetDebugInfo(
scoped_refptr<base::debug::ConvertableToTraceFormat> other) {
debug_info_ = other;
}
void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) {
if (scroll_children_.get() == children)
return;
......@@ -594,6 +600,8 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
// Reset any state that should be cleared for the next update.
stacking_order_changed_ = false;
update_rect_ = gfx::RectF();
layer->SetDebugInfo(debug_info_);
}
base::DictionaryValue* LayerImpl::LayerTreeAsJson() const {
......@@ -1384,6 +1392,19 @@ void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
if (layer_animation_controller_->AnimatedBoundsForBox(box, &inflated))
state->Set("animated_bounds", MathUtil::AsValue(inflated).release());
}
if (debug_info_.get()) {
std::string str;
debug_info_->AppendAsTraceFormat(&str);
base::JSONReader json_reader;
// Parsing the JSON and re-encoding it is not very efficient,
// but it's the simplest way to achieve the desired effect, which
// is to output:
// {..., layout_rects: [{geometry_rect: ...}, ...], ...}
// rather than:
// {layout_rects: "[{geometry_rect: ...}, ...]", ...}
state->Set("layout_rects", json_reader.ReadToValue(str));
}
}
size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
......
......@@ -36,6 +36,10 @@
#include "ui/gfx/transform.h"
namespace base {
namespace debug {
class ConvertableToTraceFormat;
}
class DictionaryValue;
}
......@@ -511,6 +515,9 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
virtual void SetDebugInfo(
scoped_refptr<base::debug::ConvertableToTraceFormat> other);
protected:
LayerImpl(LayerTreeImpl* layer_impl, int id);
......@@ -651,6 +658,8 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
// hierarchy before layers can be drawn.
DrawProperties<LayerImpl> draw_properties_;
scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_;
DISALLOW_COPY_AND_ASSIGN(LayerImpl);
};
......
......@@ -667,6 +667,11 @@ std::string Layer::DebugName() {
return name_;
}
scoped_refptr<base::debug::ConvertableToTraceFormat> Layer::TakeDebugInfo() {
// TODO: return something useful here.
return NULL;
}
void Layer::OnAnimationStarted(const cc::AnimationEvent& event) {
if (animator_.get())
animator_->OnThreadedAnimationStarted(event);
......
......@@ -336,6 +336,9 @@ class COMPOSITOR_EXPORT Layer
// LayerClient
virtual std::string DebugName() OVERRIDE;
virtual scoped_refptr<base::debug::ConvertableToTraceFormat>
TakeDebugInfo() OVERRIDE;
// LayerAnimationEventObserver
virtual void OnAnimationStarted(const cc::AnimationEvent& event) OVERRIDE;
......
......@@ -5,7 +5,9 @@
#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
#include "base/bind.h"
#include "base/debug/trace_event_impl.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_checker.h"
#include "cc/animation/animation.h"
#include "cc/base/region.h"
#include "cc/layers/layer.h"
......@@ -13,6 +15,7 @@
#include "third_party/WebKit/public/platform/WebCompositingReasons.h"
#include "third_party/WebKit/public/platform/WebFloatPoint.h"
#include "third_party/WebKit/public/platform/WebFloatRect.h"
#include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h"
#include "third_party/WebKit/public/platform/WebLayerClient.h"
#include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h"
#include "third_party/WebKit/public/platform/WebLayerScrollClient.h"
......@@ -372,6 +375,37 @@ void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) {
web_layer_client_ = client;
}
// TODO(chrishtr): move DebugName into this class.
class TracedDebugInfo : public base::debug::ConvertableToTraceFormat {
public:
// This object takes ownership of the debug_info object.
explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) :
debug_info_(debug_info) {}
virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE {
DCHECK(thread_checker_.CalledOnValidThread());
blink::WebString web_string;
debug_info_->appendAsTraceFormat(&web_string);
out->append(web_string.utf8());
}
private:
virtual ~TracedDebugInfo() {}
scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_;
base::ThreadChecker thread_checker_;
};
scoped_refptr<base::debug::ConvertableToTraceFormat>
WebLayerImpl::TakeDebugInfo() {
if (!web_layer_client_)
return NULL;
blink::WebGraphicsLayerDebugInfo* debug_info =
web_layer_client_->takeDebugInfo();
if (debug_info)
return new TracedDebugInfo(debug_info);
else
return NULL;
}
std::string WebLayerImpl::DebugName() {
if (!web_layer_client_)
return std::string();
......
......@@ -35,6 +35,12 @@ class WebLayerClient;
struct WebFloatRect;
}
namespace base {
namespace debug {
class ConvertableToTraceFormat;
}
}
namespace webkit {
class WebToCCAnimationDelegateAdapter;
......@@ -125,6 +131,8 @@ class WebLayerImpl : public blink::WebLayer, public cc::LayerClient {
// LayerClient implementation.
virtual std::string DebugName() OVERRIDE;
virtual scoped_refptr<base::debug::ConvertableToTraceFormat>
TakeDebugInfo() OVERRIDE;
virtual void setScrollParent(blink::WebLayer* parent);
virtual void setClipParent(blink::WebLayer* parent);
......
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