From 3480672c5ed57c3e493ead97c7beb7a369210742 Mon Sep 17 00:00:00 2001 From: "piman@chromium.org" Date: Fri, 9 Aug 2013 23:51:21 +0000 Subject: cc: Add frame data to LTHI tracing This adds AddValue support to FrameData, RenderPass, *DrawQuad, FilterOperations, etc. It also adds an optional 'frame' field to the LTHI state which is the frame being produced at this point, with everything mentioned above. BUG=None R=danakj@chromium.org, nduca@chromium.org, vmpstr@chromium.org Review URL: https://codereview.chromium.org/20667002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216782 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/base/math_util.cc | 17 ++++++++++++++ cc/base/math_util.h | 2 ++ cc/debug/traced_value.cc | 9 +++++++ cc/debug/traced_value.h | 5 ++++ cc/output/filter_operation.cc | 37 +++++++++++++++++++++++++++++ cc/output/filter_operation.h | 7 ++++++ cc/output/filter_operations.cc | 11 ++++++++- cc/output/filter_operations.h | 7 ++++++ cc/quads/checkerboard_draw_quad.cc | 5 ++++ cc/quads/checkerboard_draw_quad.h | 1 + cc/quads/content_draw_quad_base.cc | 8 +++++++ cc/quads/content_draw_quad_base.h | 1 + cc/quads/debug_border_draw_quad.cc | 6 +++++ cc/quads/debug_border_draw_quad.h | 1 + cc/quads/draw_quad.cc | 48 ++++++++++++++++++++++++++++++++++++++ cc/quads/draw_quad.h | 22 ++++++++++++++--- cc/quads/io_surface_draw_quad.cc | 18 ++++++++++++++ cc/quads/io_surface_draw_quad.h | 1 + cc/quads/picture_draw_quad.cc | 12 ++++++++++ cc/quads/picture_draw_quad.h | 1 + cc/quads/render_pass.cc | 39 ++++++++++++++++++++++++++++++- cc/quads/render_pass.h | 7 ++++++ cc/quads/render_pass_draw_quad.cc | 19 +++++++++++++++ cc/quads/render_pass_draw_quad.h | 1 + cc/quads/shared_quad_state.cc | 27 ++++++++++++++++++++- cc/quads/shared_quad_state.h | 9 ++++++- cc/quads/solid_color_draw_quad.cc | 8 ++++++- cc/quads/solid_color_draw_quad.h | 1 + cc/quads/stream_video_draw_quad.cc | 7 ++++++ cc/quads/stream_video_draw_quad.h | 1 + cc/quads/texture_draw_quad.cc | 15 ++++++++++++ cc/quads/texture_draw_quad.h | 1 + cc/quads/tile_draw_quad.cc | 6 +++++ cc/quads/tile_draw_quad.h | 1 + cc/quads/yuv_video_draw_quad.cc | 10 ++++++++ cc/quads/yuv_video_draw_quad.h | 1 + cc/trees/layer_tree_host_impl.cc | 30 +++++++++++++++++++++--- cc/trees/layer_tree_host_impl.h | 4 +++- 38 files changed, 394 insertions(+), 12 deletions(-) diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc index 39a183e..fa7b21a 100644 --- a/cc/base/math_util.cc +++ b/cc/base/math_util.cc @@ -487,6 +487,13 @@ scoped_ptr MathUtil::AsValue(gfx::Size s) { return res.PassAs(); } +scoped_ptr MathUtil::AsValue(gfx::SizeF s) { + scoped_ptr res(new base::DictionaryValue()); + res->SetDouble("width", s.width()); + res->SetDouble("height", s.height()); + return res.PassAs(); +} + scoped_ptr MathUtil::AsValue(gfx::Rect r) { scoped_ptr res(new base::ListValue()); res->AppendInteger(r.x()); @@ -546,6 +553,16 @@ scoped_ptr MathUtil::AsValue(const gfx::RectF& rect) { return res.PassAs(); } +scoped_ptr MathUtil::AsValue(const gfx::Transform& transform) { + scoped_ptr res(new base::ListValue()); + const SkMatrix44& m = transform.matrix(); + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) + res->AppendDouble(m.getDouble(row, col)); + } + return res.PassAs(); +} + scoped_ptr MathUtil::AsValueSafely(double value) { return scoped_ptr(base::Value::CreateDoubleValue( std::min(value, std::numeric_limits::max()))); diff --git a/cc/base/math_util.h b/cc/base/math_util.h index 23eb20f..37f0c07 100644 --- a/cc/base/math_util.h +++ b/cc/base/math_util.h @@ -156,11 +156,13 @@ class CC_EXPORT MathUtil { // Conversion to value. static scoped_ptr AsValue(gfx::Size s); + static scoped_ptr AsValue(gfx::SizeF s); static scoped_ptr AsValue(gfx::Rect r); static bool FromValue(const base::Value*, gfx::Rect* out_rect); static scoped_ptr AsValue(gfx::PointF q); static scoped_ptr AsValue(const gfx::QuadF& q); static scoped_ptr AsValue(const gfx::RectF& rect); + static scoped_ptr AsValue(const gfx::Transform& transform); // Returns a base::Value representation of the floating point value. // If the value is inf, returns max double/float representation. diff --git a/cc/debug/traced_value.cc b/cc/debug/traced_value.cc index 637c700..fbca5c6 100644 --- a/cc/debug/traced_value.cc +++ b/cc/debug/traced_value.cc @@ -21,6 +21,15 @@ void TracedValue::MakeDictIntoImplicitSnapshot( dict->SetString("id", base::StringPrintf("%s/%p", object_name, id)); } +void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( + const char* category, + base::DictionaryValue* dict, + const char* object_name, + const void* id) { + dict->SetString("cat", category); + MakeDictIntoImplicitSnapshot(dict, object_name, id); +} + scoped_ptr TracedValue::FromValue( base::Value* value) { TracedValue* ptr = new TracedValue(value); diff --git a/cc/debug/traced_value.h b/cc/debug/traced_value.h index e5d63a1..148aca8 100644 --- a/cc/debug/traced_value.h +++ b/cc/debug/traced_value.h @@ -21,6 +21,11 @@ class TracedValue : public base::debug::ConvertableToTraceFormat { static scoped_ptr CreateIDRef(const void* id); static void MakeDictIntoImplicitSnapshot( base::DictionaryValue* dict, const char* object_name, const void* id); + static void MakeDictIntoImplicitSnapshotWithCategory( + const char* category, + base::DictionaryValue* dict, + const char* object_name, + const void* id); static scoped_ptr FromValue( base::Value* value); diff --git a/cc/output/filter_operation.cc b/cc/output/filter_operation.cc index de59cfc..6a77838 100644 --- a/cc/output/filter_operation.cc +++ b/cc/output/filter_operation.cc @@ -4,6 +4,7 @@ #include +#include "base/values.h" #include "cc/base/math_util.h" #include "cc/output/filter_operation.h" #include "third_party/skia/include/core/SkMath.h" @@ -217,4 +218,40 @@ FilterOperation FilterOperation::Blend(const FilterOperation* from, return blended_filter; } +scoped_ptr FilterOperation::AsValue() const { + scoped_ptr value(new DictionaryValue); + value->SetInteger("type", type_); + switch (type_) { + case FilterOperation::GRAYSCALE: + case FilterOperation::SEPIA: + case FilterOperation::SATURATE: + case FilterOperation::HUE_ROTATE: + case FilterOperation::INVERT: + case FilterOperation::BRIGHTNESS: + case FilterOperation::CONTRAST: + case FilterOperation::OPACITY: + case FilterOperation::BLUR: + case FilterOperation::SATURATING_BRIGHTNESS: + value->SetDouble("amount", amount_); + break; + case FilterOperation::DROP_SHADOW: + value->SetDouble("std_deviation", amount_); + value->Set("offset", MathUtil::AsValue(drop_shadow_offset_).release()); + value->SetInteger("color", drop_shadow_color_); + break; + case FilterOperation::COLOR_MATRIX: { + scoped_ptr matrix(new ListValue); + for (size_t i = 0; i < arraysize(matrix_); ++i) + matrix->AppendDouble(matrix_[i]); + value->Set("matrix", matrix.release()); + break; + } + case FilterOperation::ZOOM: + value->SetDouble("amount", amount_); + value->SetDouble("inset", zoom_inset_); + break; + } + return value.PassAs(); +} + } // namespace cc diff --git a/cc/output/filter_operation.h b/cc/output/filter_operation.h index ad25cf4..f561762 100644 --- a/cc/output/filter_operation.h +++ b/cc/output/filter_operation.h @@ -6,11 +6,16 @@ #define CC_OUTPUT_FILTER_OPERATION_H_ #include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkScalar.h" #include "ui/gfx/point.h" +namespace base { +class Value; +} + namespace cc { class CC_EXPORT FilterOperation { @@ -161,6 +166,8 @@ class CC_EXPORT FilterOperation { const FilterOperation* to, double progress); + scoped_ptr AsValue() const; + private: FilterOperation(FilterType type, float amount); diff --git a/cc/output/filter_operations.cc b/cc/output/filter_operations.cc index 4331527..2420841 100644 --- a/cc/output/filter_operations.cc +++ b/cc/output/filter_operations.cc @@ -4,9 +4,11 @@ #include -#include "cc/output/filter_operation.h" #include "cc/output/filter_operations.h" +#include "base/values.h" +#include "cc/output/filter_operation.h" + namespace cc { FilterOperations::FilterOperations() {} @@ -145,4 +147,11 @@ FilterOperations FilterOperations::Blend(const FilterOperations& from, return blended_filters; } +scoped_ptr FilterOperations::AsValue() const { + scoped_ptr value(new ListValue); + for (size_t i = 0; i < operations_.size(); ++i) + value->Append(operations_[i].AsValue().release()); + return value.PassAs(); +} + } // namespace cc diff --git a/cc/output/filter_operations.h b/cc/output/filter_operations.h index d7198d1..aa8d58d 100644 --- a/cc/output/filter_operations.h +++ b/cc/output/filter_operations.h @@ -8,8 +8,13 @@ #include #include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "cc/output/filter_operation.h" +namespace base { +class Value; +} + namespace cc { // An ordered list of filter operations. @@ -62,6 +67,8 @@ class CC_EXPORT FilterOperations { // of this. FilterOperations Blend(const FilterOperations& from, double progress) const; + scoped_ptr AsValue() const; + private: std::vector operations_; }; diff --git a/cc/quads/checkerboard_draw_quad.cc b/cc/quads/checkerboard_draw_quad.cc index fcc6dc5..5e17d88 100644 --- a/cc/quads/checkerboard_draw_quad.cc +++ b/cc/quads/checkerboard_draw_quad.cc @@ -5,6 +5,7 @@ #include "cc/quads/checkerboard_draw_quad.h" #include "base/logging.h" +#include "base/values.h" namespace cc { @@ -45,4 +46,8 @@ const CheckerboardDrawQuad* CheckerboardDrawQuad::MaterialCast( return static_cast(quad); } +void CheckerboardDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->SetInteger("color", color); +} + } // namespace cc diff --git a/cc/quads/checkerboard_draw_quad.h b/cc/quads/checkerboard_draw_quad.h index b2ed876..4f7452eb 100644 --- a/cc/quads/checkerboard_draw_quad.h +++ b/cc/quads/checkerboard_draw_quad.h @@ -35,6 +35,7 @@ class CC_EXPORT CheckerboardDrawQuad : public DrawQuad { static const CheckerboardDrawQuad* MaterialCast(const DrawQuad*); private: + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; CheckerboardDrawQuad(); }; diff --git a/cc/quads/content_draw_quad_base.cc b/cc/quads/content_draw_quad_base.cc index 2c2b4ae..947af0b 100644 --- a/cc/quads/content_draw_quad_base.cc +++ b/cc/quads/content_draw_quad_base.cc @@ -5,6 +5,8 @@ #include "cc/quads/content_draw_quad_base.h" #include "base/logging.h" +#include "base/values.h" +#include "cc/base/math_util.h" namespace cc { @@ -47,4 +49,10 @@ void ContentDrawQuadBase::SetAll(const SharedQuadState* shared_quad_state, this->swizzle_contents = swizzle_contents; } +void ContentDrawQuadBase::ExtendValue(base::DictionaryValue* value) const { + value->Set("tex_coord_rect", MathUtil::AsValue(tex_coord_rect).release()); + value->Set("texture_size", MathUtil::AsValue(texture_size).release()); + value->SetBoolean("swizzle_contents", swizzle_contents); +} + } // namespace cc diff --git a/cc/quads/content_draw_quad_base.h b/cc/quads/content_draw_quad_base.h index b2c936f..cbf18ca 100644 --- a/cc/quads/content_draw_quad_base.h +++ b/cc/quads/content_draw_quad_base.h @@ -41,6 +41,7 @@ class CC_EXPORT ContentDrawQuadBase : public DrawQuad { protected: ContentDrawQuadBase(); virtual ~ContentDrawQuadBase(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/debug_border_draw_quad.cc b/cc/quads/debug_border_draw_quad.cc index 1ebc0a6..89ee8e0 100644 --- a/cc/quads/debug_border_draw_quad.cc +++ b/cc/quads/debug_border_draw_quad.cc @@ -5,6 +5,7 @@ #include "cc/quads/debug_border_draw_quad.h" #include "base/logging.h" +#include "base/values.h" namespace cc { @@ -52,4 +53,9 @@ const DebugBorderDrawQuad* DebugBorderDrawQuad::MaterialCast( return static_cast(quad); } +void DebugBorderDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->SetInteger("color", color); + value->SetInteger("width", width); +} + } // namespace cc diff --git a/cc/quads/debug_border_draw_quad.h b/cc/quads/debug_border_draw_quad.h index 2f4b3ca..5b36951 100644 --- a/cc/quads/debug_border_draw_quad.h +++ b/cc/quads/debug_border_draw_quad.h @@ -39,6 +39,7 @@ class CC_EXPORT DebugBorderDrawQuad : public DrawQuad { private: DebugBorderDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/draw_quad.cc b/cc/quads/draw_quad.cc index 6c8d9b6..0d021d9 100644 --- a/cc/quads/draw_quad.cc +++ b/cc/quads/draw_quad.cc @@ -5,6 +5,9 @@ #include "cc/quads/draw_quad.h" #include "base/logging.h" +#include "base/values.h" +#include "cc/base/math_util.h" +#include "cc/debug/traced_value.h" #include "cc/quads/checkerboard_draw_quad.h" #include "cc/quads/debug_border_draw_quad.h" #include "cc/quads/io_surface_draw_quad.h" @@ -15,6 +18,7 @@ #include "cc/quads/texture_draw_quad.h" #include "cc/quads/tile_draw_quad.h" #include "cc/quads/yuv_video_draw_quad.h" +#include "ui/gfx/quad_f.h" namespace { template T* TypedCopy(const cc::DrawQuad* other) { @@ -90,4 +94,48 @@ scoped_ptr DrawQuad::Copy( return copy_quad.Pass(); } +scoped_ptr DrawQuad::AsValue() const { + scoped_ptr value(new base::DictionaryValue()); + value->SetInteger("material", material); + value->Set("shared_state", + TracedValue::CreateIDRef(shared_quad_state).release()); + + value->Set("content_space_rect", MathUtil::AsValue(rect).release()); + bool rect_is_clipped; + gfx::QuadF rect_as_target_space_quad = MathUtil::MapQuad( + shared_quad_state->content_to_target_transform, + gfx::QuadF(rect), + &rect_is_clipped); + value->Set("rect_as_target_space_quad", + MathUtil::AsValue(rect_as_target_space_quad).release()); + value->SetBoolean("rect_is_clipped", rect_is_clipped); + + value->Set("content_space_opaque_rect", + MathUtil::AsValue(opaque_rect).release()); + bool opaque_rect_is_clipped; + gfx::QuadF opaque_rect_as_target_space_quad = MathUtil::MapQuad( + shared_quad_state->content_to_target_transform, + gfx::QuadF(opaque_rect), + &opaque_rect_is_clipped); + value->Set("opaque_rect_as_target_space_quad", + MathUtil::AsValue(opaque_rect_as_target_space_quad).release()); + value->SetBoolean("opaque_rect_is_clipped", opaque_rect_is_clipped); + + value->Set("content_space_visible_rect", + MathUtil::AsValue(visible_rect).release()); + bool visible_rect_is_clipped; + gfx::QuadF visible_rect_as_target_space_quad = MathUtil::MapQuad( + shared_quad_state->content_to_target_transform, + gfx::QuadF(visible_rect), + &visible_rect_is_clipped); + value->Set("visible_rect_as_target_space_quad", + MathUtil::AsValue(visible_rect_as_target_space_quad).release()); + value->SetBoolean("visible_rect_is_clipped", visible_rect_is_clipped); + + value->SetBoolean("needs_blending", needs_blending); + value->SetBoolean("should_draw_with_blending", ShouldDrawWithBlending()); + ExtendValue(value.get()); + return value.PassAs(); +} + } // namespace cc diff --git a/cc/quads/draw_quad.h b/cc/quads/draw_quad.h index a92cddf..c3696d6 100644 --- a/cc/quads/draw_quad.h +++ b/cc/quads/draw_quad.h @@ -10,12 +10,24 @@ #include "cc/quads/shared_quad_state.h" #include "cc/resources/resource_provider.h" +namespace base { +class Value; +class DictionaryValue; +} + namespace cc { // DrawQuad is a bag of data used for drawing a quad. Because different // materials need different bits of per-quad data to render, classes that derive // from DrawQuad store additional data in their derived instance. The Material // enum is used to "safely" downcast to the derived class. +// Note: quads contain rects and sizes, which live in different spaces. There is +// the "content space", which is the arbitrary space in which the quad's +// geometry is defined (generally related to the layer that produced the quad, +// e.g. the content space for TiledLayerImpls, or the geometry space for +// PictureLayerImpls). There is also the "target space", which is the space, in +// "physical" pixels, of the render target where the quads is drawn. The quad's +// transform maps the content space to the target space. class CC_EXPORT DrawQuad { public: enum Material { @@ -51,14 +63,15 @@ class CC_EXPORT DrawQuad { Material material; // This rect, after applying the quad_transform(), gives the geometry that - // this quad should draw to. + // this quad should draw to. This rect lives in content space. gfx::Rect rect; - // This specifies the region of the quad that is opaque. + // This specifies the region of the quad that is opaque. This rect lives in + // content space. gfx::Rect opaque_rect; // Allows changing the rect that gets drawn to make it smaller. This value - // should be clipped to |rect|. + // should be clipped to |rect|. This rect lives in content space. gfx::Rect visible_rect; // By default blending is used when some part of the quad is not opaque. @@ -111,6 +124,8 @@ class CC_EXPORT DrawQuad { return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); } + scoped_ptr AsValue() const; + protected: DrawQuad(); @@ -120,6 +135,7 @@ class CC_EXPORT DrawQuad { gfx::Rect opaque_rect, gfx::Rect visible_rect, bool needs_blending); + virtual void ExtendValue(base::DictionaryValue* value) const = 0; }; } // namespace cc diff --git a/cc/quads/io_surface_draw_quad.cc b/cc/quads/io_surface_draw_quad.cc index 1bbf8a4..2c986dd 100644 --- a/cc/quads/io_surface_draw_quad.cc +++ b/cc/quads/io_surface_draw_quad.cc @@ -5,6 +5,8 @@ #include "cc/quads/io_surface_draw_quad.h" #include "base/logging.h" +#include "base/values.h" +#include "cc/base/math_util.h" namespace cc { @@ -58,4 +60,20 @@ const IOSurfaceDrawQuad* IOSurfaceDrawQuad::MaterialCast( return static_cast(quad); } +void IOSurfaceDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->Set("io_surface_size", MathUtil::AsValue(io_surface_size).release()); + value->SetInteger("io_surface_resource_id", io_surface_resource_id); + const char* orientation_string = NULL; + switch (orientation) { + case FLIPPED: + orientation_string = "flipped"; + break; + case UNFLIPPED: + orientation_string = "unflipped"; + break; + } + + value->SetString("orientation", orientation_string); +} + } // namespace cc diff --git a/cc/quads/io_surface_draw_quad.h b/cc/quads/io_surface_draw_quad.h index 1a30c90..fc8b501 100644 --- a/cc/quads/io_surface_draw_quad.h +++ b/cc/quads/io_surface_draw_quad.h @@ -48,6 +48,7 @@ class CC_EXPORT IOSurfaceDrawQuad : public DrawQuad { private: IOSurfaceDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/picture_draw_quad.cc b/cc/quads/picture_draw_quad.cc index 81f7913..0494764 100644 --- a/cc/quads/picture_draw_quad.cc +++ b/cc/quads/picture_draw_quad.cc @@ -4,6 +4,9 @@ #include "cc/quads/picture_draw_quad.h" +#include "base/values.h" +#include "cc/base/math_util.h" + namespace cc { PictureDrawQuad::PictureDrawQuad() { @@ -68,4 +71,13 @@ const PictureDrawQuad* PictureDrawQuad::MaterialCast(const DrawQuad* quad) { return static_cast(quad); } +void PictureDrawQuad::ExtendValue(base::DictionaryValue* value) const { + ContentDrawQuadBase::ExtendValue(value); + value->Set("content_rect", MathUtil::AsValue(content_rect).release()); + value->SetDouble("contents_scale", contents_scale); + value->SetBoolean("can_draw_direct_to_backbuffer", + can_draw_direct_to_backbuffer); + // TODO(piman): picture_pile? +} + } // namespace cc diff --git a/cc/quads/picture_draw_quad.h b/cc/quads/picture_draw_quad.h index 29af6d5..beec88c 100644 --- a/cc/quads/picture_draw_quad.h +++ b/cc/quads/picture_draw_quad.h @@ -58,6 +58,7 @@ class CC_EXPORT PictureDrawQuad : public ContentDrawQuadBase { private: PictureDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/render_pass.cc b/cc/quads/render_pass.cc index ef6308c..50d5028 100644 --- a/cc/quads/render_pass.cc +++ b/cc/quads/render_pass.cc @@ -4,12 +4,20 @@ #include "cc/quads/render_pass.h" +#include "base/values.h" +#include "cc/base/math_util.h" +#include "cc/debug/traced_value.h" #include "cc/output/copy_output_request.h" #include "cc/quads/draw_quad.h" #include "cc/quads/shared_quad_state.h" namespace cc { +void* RenderPass::Id::AsTracingId() const { + COMPILE_ASSERT(sizeof(size_t) <= sizeof(void*), size_t_bigger_than_pointer); + return reinterpret_cast(base::HashPair(layer_id, index)); +} + scoped_ptr RenderPass::Create() { return make_scoped_ptr(new RenderPass); } @@ -19,7 +27,11 @@ RenderPass::RenderPass() has_transparent_background(true), has_occlusion_from_outside_target_surface(false) {} -RenderPass::~RenderPass() {} +RenderPass::~RenderPass() { + TRACE_EVENT_OBJECT_DELETED_WITH_ID( + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), + "cc::RenderPass", id.AsTracingId()); +} scoped_ptr RenderPass::Copy(Id new_id) const { scoped_ptr copy_pass(Create()); @@ -69,4 +81,29 @@ void RenderPass::SetAll(Id id, DCHECK(shared_quad_state_list.empty()); } +scoped_ptr RenderPass::AsValue() const { + scoped_ptr value(new base::DictionaryValue()); + value->Set("output_rect", MathUtil::AsValue(output_rect).release()); + value->Set("damage_rect", MathUtil::AsValue(damage_rect).release()); + value->SetBoolean("has_transparent_background", has_transparent_background); + value->SetBoolean("has_occlusion_from_outside_target_surface", + has_occlusion_from_outside_target_surface); + value->SetInteger("copy_requests", copy_requests.size()); + scoped_ptr shared_states_value(new base::ListValue()); + for (size_t i = 0; i < shared_quad_state_list.size(); ++i) { + shared_states_value->Append(shared_quad_state_list[i]->AsValue().release()); + } + value->Set("shared_quad_state_list", shared_states_value.release()); + scoped_ptr quad_list_value(new base::ListValue()); + for (size_t i = 0; i < quad_list.size(); ++i) { + quad_list_value->Append(quad_list[i]->AsValue().release()); + } + value->Set("quad_list", quad_list_value.release()); + + TracedValue::MakeDictIntoImplicitSnapshotWithCategory( + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), + value.get(), "cc::RenderPass", id.AsTracingId()); + return value.PassAs(); +} + } // namespace cc diff --git a/cc/quads/render_pass.h b/cc/quads/render_pass.h index 3d5a37c..224a050 100644 --- a/cc/quads/render_pass.h +++ b/cc/quads/render_pass.h @@ -20,6 +20,10 @@ #include "ui/gfx/rect_f.h" #include "ui/gfx/transform.h" +namespace base { +class Value; +}; + namespace cc { class DrawQuad; @@ -47,6 +51,7 @@ class CC_EXPORT RenderPass { int index; Id(int layer_id, int index) : layer_id(layer_id), index(index) {} + void* AsTracingId() const; bool operator==(const Id& other) const { return layer_id == other.layer_id && index == other.index; @@ -79,6 +84,8 @@ class CC_EXPORT RenderPass { bool has_transparent_background, bool has_occlusion_from_outside_target_surface); + scoped_ptr AsValue() const; + // Uniquely identifies the render pass in the compositor's current frame. Id id; diff --git a/cc/quads/render_pass_draw_quad.cc b/cc/quads/render_pass_draw_quad.cc index ead3d79..0528cd5 100644 --- a/cc/quads/render_pass_draw_quad.cc +++ b/cc/quads/render_pass_draw_quad.cc @@ -4,6 +4,10 @@ #include "cc/quads/render_pass_draw_quad.h" +#include "base/values.h" +#include "cc/base/math_util.h" +#include "cc/debug/traced_value.h" + namespace cc { RenderPassDrawQuad::RenderPassDrawQuad() @@ -93,4 +97,19 @@ const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast( return static_cast(quad); } +void RenderPassDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->Set("render_pass_id", + TracedValue::CreateIDRef(render_pass_id.AsTracingId()).release()); + value->SetBoolean("is_replica", is_replica); + value->SetInteger("mask_resource_id", mask_resource_id); + value->Set("contents_changed_since_last_frame", + MathUtil::AsValue(contents_changed_since_last_frame).release()); + value->Set("mask_uv_rect", MathUtil::AsValue(mask_uv_rect).release()); + value->Set("filters", filters.AsValue().release()); + // TODO(piman): dump SkImageFilters rather than just indicating if there are + // any or not. + value->SetBoolean("has_filter", !!filter); + value->Set("background_filters", background_filters.AsValue().release()); +} + } // namespace cc diff --git a/cc/quads/render_pass_draw_quad.h b/cc/quads/render_pass_draw_quad.h index f0c76a9..e253dec 100644 --- a/cc/quads/render_pass_draw_quad.h +++ b/cc/quads/render_pass_draw_quad.h @@ -72,6 +72,7 @@ class CC_EXPORT RenderPassDrawQuad : public DrawQuad { private: RenderPassDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/shared_quad_state.cc b/cc/quads/shared_quad_state.cc index 7bfb2b4..6a53d9f 100644 --- a/cc/quads/shared_quad_state.cc +++ b/cc/quads/shared_quad_state.cc @@ -4,11 +4,19 @@ #include "cc/quads/shared_quad_state.h" +#include "base/values.h" +#include "cc/base/math_util.h" +#include "cc/debug/traced_value.h" + namespace cc { SharedQuadState::SharedQuadState() : is_clipped(false), opacity(0.f) {} -SharedQuadState::~SharedQuadState() {} +SharedQuadState::~SharedQuadState() { + TRACE_EVENT_OBJECT_DELETED_WITH_ID( + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), + "cc::SharedQuadState", this); +} scoped_ptr SharedQuadState::Create() { return make_scoped_ptr(new SharedQuadState); @@ -33,4 +41,21 @@ void SharedQuadState::SetAll( this->opacity = opacity; } +scoped_ptr SharedQuadState::AsValue() const { + scoped_ptr value(new base::DictionaryValue()); + value->Set("transform", + MathUtil::AsValue(content_to_target_transform).release()); + value->Set("layer_content_bounds", + MathUtil::AsValue(content_bounds).release()); + value->Set("layer_visible_content_rect", + MathUtil::AsValue(visible_content_rect).release()); + value->SetBoolean("is_clipped", is_clipped); + value->Set("clip_rect", MathUtil::AsValue(clip_rect).release()); + value->SetDouble("opacity", opacity); + TracedValue::MakeDictIntoImplicitSnapshotWithCategory( + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), + value.get(), "cc::SharedQuadState", this); + return value.PassAs(); +} + } // namespace cc diff --git a/cc/quads/shared_quad_state.h b/cc/quads/shared_quad_state.h index eb3e91e..79bd09b 100644 --- a/cc/quads/shared_quad_state.h +++ b/cc/quads/shared_quad_state.h @@ -10,6 +10,10 @@ #include "ui/gfx/rect.h" #include "ui/gfx/transform.h" +namespace base { +class Value; +} + namespace cc { class CC_EXPORT SharedQuadState { @@ -25,12 +29,15 @@ class CC_EXPORT SharedQuadState { gfx::Rect clip_rect, bool is_clipped, float opacity); + scoped_ptr AsValue() const; // Transforms from quad's original content space to its target content space. gfx::Transform content_to_target_transform; - // This rect lives in the content space for the quad's originating layer. + // This size lives in the content space for the quad's originating layer. gfx::Size content_bounds; + // This rect lives in the content space for the quad's originating layer. gfx::Rect visible_content_rect; + // This rect lives in the target content space. gfx::Rect clip_rect; bool is_clipped; float opacity; diff --git a/cc/quads/solid_color_draw_quad.cc b/cc/quads/solid_color_draw_quad.cc index 5575aaf..ae3b914 100644 --- a/cc/quads/solid_color_draw_quad.cc +++ b/cc/quads/solid_color_draw_quad.cc @@ -5,6 +5,7 @@ #include "cc/quads/solid_color_draw_quad.h" #include "base/logging.h" +#include "base/values.h" namespace cc { @@ -50,4 +51,9 @@ const SolidColorDrawQuad* SolidColorDrawQuad::MaterialCast( return static_cast(quad); } -} // namespacec cc +void SolidColorDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->SetInteger("color", color); + value->SetBoolean("force_anti_aliasing_off", force_anti_aliasing_off); +} + +} // namespace cc diff --git a/cc/quads/solid_color_draw_quad.h b/cc/quads/solid_color_draw_quad.h index 4d7ab9f..2c41243 100644 --- a/cc/quads/solid_color_draw_quad.h +++ b/cc/quads/solid_color_draw_quad.h @@ -39,6 +39,7 @@ class CC_EXPORT SolidColorDrawQuad : public DrawQuad { private: SolidColorDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/stream_video_draw_quad.cc b/cc/quads/stream_video_draw_quad.cc index 831304f..c239256 100644 --- a/cc/quads/stream_video_draw_quad.cc +++ b/cc/quads/stream_video_draw_quad.cc @@ -5,6 +5,8 @@ #include "cc/quads/stream_video_draw_quad.h" #include "base/logging.h" +#include "base/values.h" +#include "cc/base/math_util.h" namespace cc { @@ -51,4 +53,9 @@ const StreamVideoDrawQuad* StreamVideoDrawQuad::MaterialCast( return static_cast(quad); } +void StreamVideoDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->SetInteger("resource_id", resource_id); + value->Set("matrix", MathUtil::AsValue(matrix).release()); +} + } // namespace cc diff --git a/cc/quads/stream_video_draw_quad.h b/cc/quads/stream_video_draw_quad.h index 0ce31af..e610f43 100644 --- a/cc/quads/stream_video_draw_quad.h +++ b/cc/quads/stream_video_draw_quad.h @@ -40,6 +40,7 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad { private: StreamVideoDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/texture_draw_quad.cc b/cc/quads/texture_draw_quad.cc index c894985..ae7cfd6 100644 --- a/cc/quads/texture_draw_quad.cc +++ b/cc/quads/texture_draw_quad.cc @@ -5,6 +5,8 @@ #include "cc/quads/texture_draw_quad.h" #include "base/logging.h" +#include "base/values.h" +#include "cc/base/math_util.h" #include "ui/gfx/vector2d_f.h" namespace cc { @@ -156,4 +158,17 @@ bool TextureDrawQuad::PerformClipping() { return true; } +void TextureDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->SetInteger("resource_id", resource_id); + value->SetBoolean("premultiplied_alpha", premultiplied_alpha); + value->Set("uv_top_left", MathUtil::AsValue(uv_top_left).release()); + value->Set("uv_bottom_right", MathUtil::AsValue(uv_bottom_right).release()); + value->SetInteger("background_color", background_color); + scoped_ptr vertex_opacity_value(new ListValue); + for (size_t i = 0; i < 4; ++i) + vertex_opacity_value->AppendDouble(vertex_opacity[i]); + value->Set("vertex_opacity", vertex_opacity_value.release()); + value->SetBoolean("flipped", flipped); +} + } // namespace cc diff --git a/cc/quads/texture_draw_quad.h b/cc/quads/texture_draw_quad.h index 3db10c6..7f06618 100644 --- a/cc/quads/texture_draw_quad.h +++ b/cc/quads/texture_draw_quad.h @@ -57,6 +57,7 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad { private: TextureDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/tile_draw_quad.cc b/cc/quads/tile_draw_quad.cc index 414b320..3ff9809 100644 --- a/cc/quads/tile_draw_quad.cc +++ b/cc/quads/tile_draw_quad.cc @@ -5,6 +5,7 @@ #include "cc/quads/tile_draw_quad.h" #include "base/logging.h" +#include "base/values.h" #include "third_party/khronos/GLES2/gl2.h" namespace cc { @@ -58,4 +59,9 @@ const TileDrawQuad* TileDrawQuad::MaterialCast(const DrawQuad* quad) { return static_cast(quad); } +void TileDrawQuad::ExtendValue(base::DictionaryValue* value) const { + ContentDrawQuadBase::ExtendValue(value); + value->SetInteger("resource_id", resource_id); +} + } // namespace cc diff --git a/cc/quads/tile_draw_quad.h b/cc/quads/tile_draw_quad.h index 25957f6..6da1e54 100644 --- a/cc/quads/tile_draw_quad.h +++ b/cc/quads/tile_draw_quad.h @@ -41,6 +41,7 @@ class CC_EXPORT TileDrawQuad : public ContentDrawQuadBase { private: TileDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/yuv_video_draw_quad.cc b/cc/quads/yuv_video_draw_quad.cc index 2ac75dc..ecdc78f 100644 --- a/cc/quads/yuv_video_draw_quad.cc +++ b/cc/quads/yuv_video_draw_quad.cc @@ -5,6 +5,8 @@ #include "cc/quads/yuv_video_draw_quad.h" #include "base/logging.h" +#include "base/values.h" +#include "cc/base/math_util.h" namespace cc { @@ -72,4 +74,12 @@ const YUVVideoDrawQuad* YUVVideoDrawQuad::MaterialCast( return static_cast(quad); } +void YUVVideoDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->Set("tex_scale", MathUtil::AsValue(tex_scale).release()); + value->SetInteger("y_plane_resource_id", y_plane_resource_id); + value->SetInteger("u_plane_resource_id", u_plane_resource_id); + value->SetInteger("v_plane_resource_id", v_plane_resource_id); + value->SetInteger("a_plane_resource_id", a_plane_resource_id); +} + } // namespace cc diff --git a/cc/quads/yuv_video_draw_quad.h b/cc/quads/yuv_video_draw_quad.h index 34a0612..aa750fa 100644 --- a/cc/quads/yuv_video_draw_quad.h +++ b/cc/quads/yuv_video_draw_quad.h @@ -52,6 +52,7 @@ class CC_EXPORT YUVVideoDrawQuad : public DrawQuad { private: YUVVideoDrawQuad(); + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index cc31001..d4a9498 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -7,6 +7,7 @@ #include #include "base/basictypes.h" +#include "base/containers/hash_tables.h" #include "base/json/json_writer.h" #include "base/metrics/histogram.h" #include "base/stl_util.h" @@ -437,6 +438,25 @@ void LayerTreeHostImpl::TrackDamageForAllSurfaces( } } +scoped_ptr LayerTreeHostImpl::FrameData::AsValue() const { + scoped_ptr value(new base::DictionaryValue()); + value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); + value->SetBoolean("has_no_damage", has_no_damage); + + // Quad data can be quite large, so only dump render passes if we select + // cc.debug.quads. + bool quads_enabled; + TRACE_EVENT_CATEGORY_GROUP_ENABLED( + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); + if (quads_enabled) { + scoped_ptr render_pass_list(new base::ListValue()); + for (size_t i = 0; i < render_passes.size(); ++i) + render_pass_list->Append(render_passes[i]->AsValue().release()); + value->Set("render_passes", render_pass_list.release()); + } + return value.PassAs(); +} + void LayerTreeHostImpl::FrameData::AppendRenderPass( scoped_ptr render_pass) { render_passes_by_id[render_pass->id] = render_pass.get(); @@ -1257,8 +1277,9 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, } TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( - TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", this, - TracedValue::FromValue(AsValue().release())); + TRACE_DISABLED_BY_DEFAULT("cc.debug") "," + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), "cc::LayerTreeHostImpl", + this, TracedValue::FromValue(AsValueWithFrame(frame).release())); // Because the contents of the HUD depend on everything else in the frame, the // contents of its texture are updated as the last thing before the frame is @@ -2431,7 +2452,8 @@ base::TimeTicks LayerTreeHostImpl::CurrentPhysicalTimeTicks() const { return base::TimeTicks::Now(); } -scoped_ptr LayerTreeHostImpl::AsValue() const { +scoped_ptr LayerTreeHostImpl::AsValueWithFrame( + FrameData* frame) const { scoped_ptr state(new base::DictionaryValue()); if (this->pending_tree_) state->Set("activation_state", ActivationStateAsValue().release()); @@ -2442,6 +2464,8 @@ scoped_ptr LayerTreeHostImpl::AsValue() const { state->Set("active_tree", active_tree_->AsValue().release()); if (pending_tree_) state->Set("pending_tree", pending_tree_->AsValue().release()); + if (frame) + state->Set("frame", frame->AsValue().release()); return state.PassAs(); } diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index ae6f3c1..31870ac 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -139,6 +139,7 @@ class CC_EXPORT LayerTreeHostImpl struct CC_EXPORT FrameData : public RenderPassSink { FrameData(); virtual ~FrameData(); + scoped_ptr AsValue() const; std::vector occluding_screen_space_rects; std::vector non_occluding_screen_space_rects; @@ -371,7 +372,8 @@ class CC_EXPORT LayerTreeHostImpl virtual base::TimeTicks CurrentPhysicalTimeTicks() const; - scoped_ptr AsValue() const; + scoped_ptr AsValue() const { return AsValueWithFrame(NULL); } + scoped_ptr AsValueWithFrame(FrameData* frame) const; scoped_ptr ActivationStateAsValue() const; bool page_scale_animation_active() const { return !!page_scale_animation_; } -- cgit v1.1