summaryrefslogtreecommitdiffstats
path: root/cc/layers
diff options
context:
space:
mode:
authorqiankun.miao@intel.com <qiankun.miao@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 13:04:24 +0000
committerqiankun.miao@intel.com <qiankun.miao@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 13:04:24 +0000
commitae716cec88d2e69f9bb6428fa24acbe33504c8ba (patch)
treed99e951d4ad479f9d6c8f49be85da67019645968 /cc/layers
parentbbe2f5108bd428abd67f63dc855333a576a41d8d (diff)
downloadchromium_src-ae716cec88d2e69f9bb6428fa24acbe33504c8ba.zip
chromium_src-ae716cec88d2e69f9bb6428fa24acbe33504c8ba.tar.gz
chromium_src-ae716cec88d2e69f9bb6428fa24acbe33504c8ba.tar.bz2
Add layer name into frame viewer
Layer name is useful for web developer to identify different layers. Layer name is pulled from blink. There is a blink side patch provides debugName() API in GraphicsLayer. BUG=269258 Review URL: https://chromiumcodereview.appspot.com/16903005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218007 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers')
-rw-r--r--cc/layers/heads_up_display_layer.cc4
-rw-r--r--cc/layers/heads_up_display_layer.h4
-rw-r--r--cc/layers/layer.cc20
-rw-r--r--cc/layers/layer.h8
-rw-r--r--cc/layers/layer_client.h24
-rw-r--r--cc/layers/layer_impl.cc1
-rw-r--r--cc/layers/layer_unittest.cc1
7 files changed, 55 insertions, 7 deletions
diff --git a/cc/layers/heads_up_display_layer.cc b/cc/layers/heads_up_display_layer.cc
index 92486cc..d9fab90 100644
--- a/cc/layers/heads_up_display_layer.cc
+++ b/cc/layers/heads_up_display_layer.cc
@@ -55,4 +55,8 @@ scoped_ptr<LayerImpl> HeadsUpDisplayLayer::CreateLayerImpl(
PassAs<LayerImpl>();
}
+std::string HeadsUpDisplayLayer::DebugName() {
+ return std::string("Heads Up Display Layer");
+}
+
} // namespace cc
diff --git a/cc/layers/heads_up_display_layer.h b/cc/layers/heads_up_display_layer.h
index 7038cd4..f13d56b 100644
--- a/cc/layers/heads_up_display_layer.h
+++ b/cc/layers/heads_up_display_layer.h
@@ -5,6 +5,8 @@
#ifndef CC_LAYERS_HEADS_UP_DISPLAY_LAYER_H_
#define CC_LAYERS_HEADS_UP_DISPLAY_LAYER_H_
+#include <string>
+
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
#include "cc/layers/contents_scaling_layer.h"
@@ -23,6 +25,8 @@ class CC_EXPORT HeadsUpDisplayLayer : public ContentsScalingLayer {
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
OVERRIDE;
+ virtual std::string DebugName() OVERRIDE;
+
protected:
HeadsUpDisplayLayer();
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index aa4a002..97fcdc8 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -6,12 +6,14 @@
#include <algorithm>
+#include "base/debug/trace_event.h"
#include "base/location.h"
#include "base/metrics/histogram.h"
#include "base/single_thread_task_runner.h"
#include "cc/animation/animation.h"
#include "cc/animation/animation_events.h"
#include "cc/animation/layer_animation_controller.h"
+#include "cc/layers/layer_client.h"
#include "cc/layers/layer_impl.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
@@ -55,7 +57,8 @@ Layer::Layer()
draw_checkerboard_for_missing_tiles_(false),
force_render_surface_(false),
replica_layer_(NULL),
- raster_scale_(0.f) {
+ raster_scale_(0.f),
+ client_(NULL) {
if (layer_id_ < 0) {
s_next_layer_id = 1;
layer_id_ = s_next_layer_id++;
@@ -742,7 +745,15 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
: bounds_);
layer->SetContentBounds(content_bounds());
layer->SetContentsScale(contents_scale_x(), contents_scale_y());
- layer->SetDebugName(debug_name_);
+
+ 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());
+
layer->SetCompositingReasons(compositing_reasons_);
layer->SetDoubleSided(double_sided_);
layer->SetDrawCheckerboardForMissingTiles(
@@ -868,9 +879,8 @@ bool Layer::NeedMoreUpdates() {
return false;
}
-void Layer::SetDebugName(const std::string& debug_name) {
- debug_name_ = debug_name;
- SetNeedsCommit();
+std::string Layer::DebugName() {
+ return client_ ? client_->DebugName() : std::string();
}
void Layer::SetCompositingReasons(CompositingReasons reasons) {
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 6c08071..1643817 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -42,6 +42,7 @@ struct AnimationEvent;
class CopyOutputRequest;
class LayerAnimationDelegate;
class LayerAnimationEventObserver;
+class LayerClient;
class LayerImpl;
class LayerTreeHost;
class LayerTreeImpl;
@@ -296,7 +297,10 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
virtual void SetIsMask(bool is_mask) {}
virtual void ReduceMemoryUsage() {}
- void SetDebugName(const std::string& debug_name);
+ virtual std::string DebugName();
+
+ void SetLayerClient(LayerClient* client) { client_ = client; }
+
void SetCompositingReasons(CompositingReasons reasons);
virtual void PushPropertiesTo(LayerImpl* layer);
@@ -522,6 +526,8 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
// Transient properties.
float raster_scale_;
+ LayerClient* client_;
+
ScopedPtrVector<CopyOutputRequest> copy_requests_;
base::Closure did_scroll_callback_;
diff --git a/cc/layers/layer_client.h b/cc/layers/layer_client.h
new file mode 100644
index 0000000..73c0fd2
--- /dev/null
+++ b/cc/layers/layer_client.h
@@ -0,0 +1,24 @@
+// Copyright 2013 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 CC_LAYERS_LAYER_CLIENT_H_
+#define CC_LAYERS_LAYER_CLIENT_H_
+
+#include <string>
+
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+class CC_EXPORT LayerClient {
+ public:
+ virtual std::string DebugName() = 0;
+
+ protected:
+ virtual ~LayerClient() {}
+};
+
+} // namespace cc
+
+#endif // CC_LAYERS_LAYER_CLIENT_H_
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index b78cf1a..6e9a515 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -1115,6 +1115,7 @@ CompositingReasonsAsValue(CompositingReasons reasons) {
void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this);
state->SetInteger("layer_id", id());
+ state->SetString("layer_name", debug_name());
state->Set("bounds", MathUtil::AsValue(bounds()).release());
state->SetInteger("draws_content", DrawsContent());
state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index bd1e16f..613f822 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -559,7 +559,6 @@ TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(
gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetDoubleSided(false));
- EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetDebugName("Test Layer"));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetDrawCheckerboardForMissingTiles(
!test_layer->DrawCheckerboardForMissingTiles()));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetForceRenderSurface(true));