Chromium Code Reviews| 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 template <class Type1, class Type2> size_t hash(Type1 value1, Type2 value2) { | |
| 17 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
| |
| 18 return hash_functor(std::make_pair(value1, value2)); | |
| 19 } | |
| 20 | |
| 21 void* RenderPass::Id::AsTracingId() const { | |
| 22 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?
| |
| 23 } | |
| 24 | |
| 13 scoped_ptr<RenderPass> RenderPass::Create() { | 25 scoped_ptr<RenderPass> RenderPass::Create() { |
| 14 return make_scoped_ptr(new RenderPass); | 26 return make_scoped_ptr(new RenderPass); |
| 15 } | 27 } |
| 16 | 28 |
| 17 RenderPass::RenderPass() | 29 RenderPass::RenderPass() |
| 18 : id(Id(-1, -1)), | 30 : id(Id(-1, -1)), |
| 19 has_transparent_background(true), | 31 has_transparent_background(true), |
| 20 has_occlusion_from_outside_target_surface(false) {} | 32 has_occlusion_from_outside_target_surface(false) {} |
| 21 | 33 |
| 22 RenderPass::~RenderPass() {} | 34 RenderPass::~RenderPass() { |
| 35 // Snapshot was created in cc.debug category, but only if cc.debug.quads is on | |
| 36 // as well. | |
| 37 bool enabled; | |
| 38 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | |
| 39 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &enabled); | |
| 40 if (enabled) { | |
| 41 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
| |
| 42 "cc::RenderPass", | |
| 43 id.AsTracingId()); | |
| 44 } | |
| 45 } | |
| 23 | 46 |
| 24 scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const { | 47 scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const { |
| 25 scoped_ptr<RenderPass> copy_pass(Create()); | 48 scoped_ptr<RenderPass> copy_pass(Create()); |
| 26 copy_pass->SetAll(new_id, | 49 copy_pass->SetAll(new_id, |
| 27 output_rect, | 50 output_rect, |
| 28 damage_rect, | 51 damage_rect, |
| 29 transform_to_root_target, | 52 transform_to_root_target, |
| 30 has_transparent_background, | 53 has_transparent_background, |
| 31 has_occlusion_from_outside_target_surface); | 54 has_occlusion_from_outside_target_surface); |
| 32 return copy_pass.Pass(); | 55 return copy_pass.Pass(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 62 this->damage_rect = damage_rect; | 85 this->damage_rect = damage_rect; |
| 63 this->transform_to_root_target = transform_to_root_target; | 86 this->transform_to_root_target = transform_to_root_target; |
| 64 this->has_transparent_background = has_transparent_background; | 87 this->has_transparent_background = has_transparent_background; |
| 65 this->has_occlusion_from_outside_target_surface = | 88 this->has_occlusion_from_outside_target_surface = |
| 66 has_occlusion_from_outside_target_surface; | 89 has_occlusion_from_outside_target_surface; |
| 67 | 90 |
| 68 DCHECK(quad_list.empty()); | 91 DCHECK(quad_list.empty()); |
| 69 DCHECK(shared_quad_state_list.empty()); | 92 DCHECK(shared_quad_state_list.empty()); |
| 70 } | 93 } |
| 71 | 94 |
| 95 scoped_ptr<base::Value> RenderPass::AsValue() const { | |
| 96 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | |
| 97 value->Set("output_rect", MathUtil::AsValue(output_rect).release()); | |
| 98 value->Set("damage_rect", MathUtil::AsValue(damage_rect).release()); | |
| 99 value->SetBoolean("has_transparent_background", has_transparent_background); | |
| 100 value->SetBoolean("has_occlusion_from_outside_target_surface", | |
| 101 has_occlusion_from_outside_target_surface); | |
| 102 value->SetInteger("copy_requests", copy_requests.size()); | |
| 103 scoped_ptr<base::ListValue> shared_states_value(new base::ListValue()); | |
| 104 for (size_t i = 0; i < shared_quad_state_list.size(); ++i) { | |
| 105 shared_states_value->Append(shared_quad_state_list[i]->AsValue().release()); | |
| 106 } | |
| 107 value->Set("shared_quad_state_list", shared_states_value.release()); | |
| 108 scoped_ptr<base::ListValue> quad_list_value(new base::ListValue()); | |
| 109 for (size_t i = 0; i < quad_list.size(); ++i) { | |
| 110 quad_list_value->Append(quad_list[i]->AsValue().release()); | |
| 111 } | |
| 112 value->Set("quad_list", quad_list_value.release()); | |
| 113 | |
| 114 TracedValue::MakeDictIntoImplicitSnapshot( | |
| 115 value.get(), "cc::RenderPass", id.AsTracingId()); | |
| 116 return value.PassAs<base::Value>(); | |
| 117 } | |
| 118 | |
| 72 } // namespace cc | 119 } // namespace cc |
| OLD | NEW |