OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/quads/render_pass.h" | 5 #include "cc/quads/render_pass.h" |
6 | 6 |
| 7 #include "base/values.h" |
| 8 #include "cc/base/math_util.h" |
| 9 #include "cc/debug/traced_value.h" |
7 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
8 #include "cc/quads/draw_quad.h" | 11 #include "cc/quads/draw_quad.h" |
9 #include "cc/quads/shared_quad_state.h" | 12 #include "cc/quads/shared_quad_state.h" |
10 | 13 |
11 namespace cc { | 14 namespace cc { |
12 | 15 |
| 16 void* RenderPass::Id::AsTracingId() const { |
| 17 COMPILE_ASSERT(sizeof(size_t) <= sizeof(void*), size_t_bigger_than_pointer); |
| 18 return reinterpret_cast<void*>(base::HashPair(layer_id, index)); |
| 19 } |
| 20 |
13 scoped_ptr<RenderPass> RenderPass::Create() { | 21 scoped_ptr<RenderPass> RenderPass::Create() { |
14 return make_scoped_ptr(new RenderPass); | 22 return make_scoped_ptr(new RenderPass); |
15 } | 23 } |
16 | 24 |
17 RenderPass::RenderPass() | 25 RenderPass::RenderPass() |
18 : id(Id(-1, -1)), | 26 : id(Id(-1, -1)), |
19 has_transparent_background(true), | 27 has_transparent_background(true), |
20 has_occlusion_from_outside_target_surface(false) {} | 28 has_occlusion_from_outside_target_surface(false) {} |
21 | 29 |
22 RenderPass::~RenderPass() {} | 30 RenderPass::~RenderPass() { |
| 31 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 32 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
| 33 "cc::RenderPass", id.AsTracingId()); |
| 34 } |
23 | 35 |
24 scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const { | 36 scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const { |
25 scoped_ptr<RenderPass> copy_pass(Create()); | 37 scoped_ptr<RenderPass> copy_pass(Create()); |
26 copy_pass->SetAll(new_id, | 38 copy_pass->SetAll(new_id, |
27 output_rect, | 39 output_rect, |
28 damage_rect, | 40 damage_rect, |
29 transform_to_root_target, | 41 transform_to_root_target, |
30 has_transparent_background, | 42 has_transparent_background, |
31 has_occlusion_from_outside_target_surface); | 43 has_occlusion_from_outside_target_surface); |
32 return copy_pass.Pass(); | 44 return copy_pass.Pass(); |
(...skipping 29 matching lines...) Expand all Loading... |
62 this->damage_rect = damage_rect; | 74 this->damage_rect = damage_rect; |
63 this->transform_to_root_target = transform_to_root_target; | 75 this->transform_to_root_target = transform_to_root_target; |
64 this->has_transparent_background = has_transparent_background; | 76 this->has_transparent_background = has_transparent_background; |
65 this->has_occlusion_from_outside_target_surface = | 77 this->has_occlusion_from_outside_target_surface = |
66 has_occlusion_from_outside_target_surface; | 78 has_occlusion_from_outside_target_surface; |
67 | 79 |
68 DCHECK(quad_list.empty()); | 80 DCHECK(quad_list.empty()); |
69 DCHECK(shared_quad_state_list.empty()); | 81 DCHECK(shared_quad_state_list.empty()); |
70 } | 82 } |
71 | 83 |
| 84 scoped_ptr<base::Value> RenderPass::AsValue() const { |
| 85 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 86 value->Set("output_rect", MathUtil::AsValue(output_rect).release()); |
| 87 value->Set("damage_rect", MathUtil::AsValue(damage_rect).release()); |
| 88 value->SetBoolean("has_transparent_background", has_transparent_background); |
| 89 value->SetBoolean("has_occlusion_from_outside_target_surface", |
| 90 has_occlusion_from_outside_target_surface); |
| 91 value->SetInteger("copy_requests", copy_requests.size()); |
| 92 scoped_ptr<base::ListValue> shared_states_value(new base::ListValue()); |
| 93 for (size_t i = 0; i < shared_quad_state_list.size(); ++i) { |
| 94 shared_states_value->Append(shared_quad_state_list[i]->AsValue().release()); |
| 95 } |
| 96 value->Set("shared_quad_state_list", shared_states_value.release()); |
| 97 scoped_ptr<base::ListValue> quad_list_value(new base::ListValue()); |
| 98 for (size_t i = 0; i < quad_list.size(); ++i) { |
| 99 quad_list_value->Append(quad_list[i]->AsValue().release()); |
| 100 } |
| 101 value->Set("quad_list", quad_list_value.release()); |
| 102 |
| 103 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
| 104 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
| 105 value.get(), "cc::RenderPass", id.AsTracingId()); |
| 106 return value.PassAs<base::Value>(); |
| 107 } |
| 108 |
72 } // namespace cc | 109 } // namespace cc |
OLD | NEW |