Chromium Code Reviews| Index: cc/quads/render_pass.cc |
| diff --git a/cc/quads/render_pass.cc b/cc/quads/render_pass.cc |
| index ef6308cff2c997920073a52f2e43faf02e1a3c34..6f1f6302e2ec1832930b9559c18fc057541a0541 100644 |
| --- a/cc/quads/render_pass.cc |
| +++ b/cc/quads/render_pass.cc |
| @@ -4,12 +4,24 @@ |
| #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 { |
| +template <class Type1, class Type2> size_t hash(Type1 value1, Type2 value2) { |
| + BASE_HASH_NAMESPACE::hash<std::pair<Type1, Type2> > hash_functor; |
|
piman
2013/07/31 00:49:40
Ah, hold on, this doesn't work on MSVC, I'll have
|
| + return hash_functor(std::make_pair(value1, value2)); |
| +} |
| + |
| +void* RenderPass::Id::AsTracingId() const { |
| + return reinterpret_cast<void*>(hash(layer_id, index)); |
|
piman
2013/07/31 00:36:43
Note: nothing ensures that this won't collide with
vmpstr
2013/07/31 16:23:25
I think that's fine, but Nat might say otherwise?
|
| +} |
| + |
| scoped_ptr<RenderPass> RenderPass::Create() { |
| return make_scoped_ptr(new RenderPass); |
| } |
| @@ -19,7 +31,18 @@ RenderPass::RenderPass() |
| has_transparent_background(true), |
| has_occlusion_from_outside_target_surface(false) {} |
| -RenderPass::~RenderPass() {} |
| +RenderPass::~RenderPass() { |
| + // Snapshot was created in cc.debug category, but only if cc.debug.quads is on |
| + // as well. |
| + bool enabled; |
| + TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| + TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &enabled); |
| + if (enabled) { |
| + TRACE_EVENT_OBJECT_DELETED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
|
piman
2013/07/31 00:36:43
I find this a bit awkward... The snapshot is assoc
|
| + "cc::RenderPass", |
| + id.AsTracingId()); |
| + } |
| +} |
| scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const { |
| scoped_ptr<RenderPass> copy_pass(Create()); |
| @@ -69,4 +92,28 @@ void RenderPass::SetAll(Id id, |
| DCHECK(shared_quad_state_list.empty()); |
| } |
| +scoped_ptr<base::Value> RenderPass::AsValue() const { |
| + scoped_ptr<base::DictionaryValue> 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<base::ListValue> 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<base::ListValue> 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::MakeDictIntoImplicitSnapshot( |
| + value.get(), "cc::RenderPass", id.AsTracingId()); |
| + return value.PassAs<base::Value>(); |
| +} |
| + |
| } // namespace cc |