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" | 7 #include "base/values.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/debug/traced_value.h" | 9 #include "cc/debug/traced_value.h" |
10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 scoped_ptr<RenderPass> RenderPass::Create() { | 28 scoped_ptr<RenderPass> RenderPass::Create() { |
29 return make_scoped_ptr(new RenderPass()); | 29 return make_scoped_ptr(new RenderPass()); |
30 } | 30 } |
31 | 31 |
32 scoped_ptr<RenderPass> RenderPass::Create(size_t num_layers) { | 32 scoped_ptr<RenderPass> RenderPass::Create(size_t num_layers) { |
33 return make_scoped_ptr(new RenderPass(num_layers)); | 33 return make_scoped_ptr(new RenderPass(num_layers)); |
34 } | 34 } |
35 | 35 |
36 RenderPass::RenderPass() | 36 RenderPass::RenderPass() : id(Id(-1, -1)), has_transparent_background(true) { |
37 : id(Id(-1, -1)), | |
38 has_transparent_background(true), | |
39 overlay_state(NO_OVERLAY) { | |
40 shared_quad_state_list.reserve(kDefaultNumSharedQuadStatesToReserve); | 37 shared_quad_state_list.reserve(kDefaultNumSharedQuadStatesToReserve); |
41 quad_list.reserve(kDefaultNumQuadsToReserve); | 38 quad_list.reserve(kDefaultNumQuadsToReserve); |
42 } | 39 } |
43 | 40 |
44 RenderPass::RenderPass(size_t num_layers) | 41 RenderPass::RenderPass(size_t num_layers) |
45 : id(Id(-1, -1)), | 42 : id(Id(-1, -1)), has_transparent_background(true) { |
46 has_transparent_background(true), | |
47 overlay_state(NO_OVERLAY) { | |
48 // Each layer usually produces one shared quad state, so the number of layers | 43 // Each layer usually produces one shared quad state, so the number of layers |
49 // is a good hint for what to reserve here. | 44 // is a good hint for what to reserve here. |
50 shared_quad_state_list.reserve(num_layers); | 45 shared_quad_state_list.reserve(num_layers); |
51 quad_list.reserve(kDefaultNumQuadsToReserve); | 46 quad_list.reserve(kDefaultNumQuadsToReserve); |
52 } | 47 } |
53 | 48 |
54 RenderPass::~RenderPass() { | 49 RenderPass::~RenderPass() { |
55 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 50 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
56 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), | 51 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
57 "cc::RenderPass", id.AsTracingId()); | 52 "cc::RenderPass", id.AsTracingId()); |
58 } | 53 } |
59 | 54 |
60 scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const { | 55 scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const { |
61 scoped_ptr<RenderPass> copy_pass(Create()); | 56 scoped_ptr<RenderPass> copy_pass(Create()); |
62 copy_pass->SetAll(new_id, | 57 copy_pass->SetAll(new_id, |
63 output_rect, | 58 output_rect, |
64 damage_rect, | 59 damage_rect, |
65 transform_to_root_target, | 60 transform_to_root_target, |
66 has_transparent_background, | 61 has_transparent_background); |
67 overlay_state); | |
68 return copy_pass.Pass(); | 62 return copy_pass.Pass(); |
69 } | 63 } |
70 | 64 |
71 // static | 65 // static |
72 void RenderPass::CopyAll(const ScopedPtrVector<RenderPass>& in, | 66 void RenderPass::CopyAll(const ScopedPtrVector<RenderPass>& in, |
73 ScopedPtrVector<RenderPass>* out) { | 67 ScopedPtrVector<RenderPass>* out) { |
74 for (size_t i = 0; i < in.size(); ++i) { | 68 for (size_t i = 0; i < in.size(); ++i) { |
75 RenderPass* source = in[i]; | 69 RenderPass* source = in[i]; |
76 | 70 |
77 // Since we can't copy these, it's wrong to use CopyAll in a situation where | 71 // Since we can't copy these, it's wrong to use CopyAll in a situation where |
78 // you may have copy_requests present. | 72 // you may have copy_requests present. |
79 DCHECK_EQ(source->copy_requests.size(), 0u); | 73 DCHECK_EQ(source->copy_requests.size(), 0u); |
80 | 74 |
81 scoped_ptr<RenderPass> copy_pass(Create()); | 75 scoped_ptr<RenderPass> copy_pass(Create()); |
82 copy_pass->SetAll(source->id, | 76 copy_pass->SetAll(source->id, |
83 source->output_rect, | 77 source->output_rect, |
84 source->damage_rect, | 78 source->damage_rect, |
85 source->transform_to_root_target, | 79 source->transform_to_root_target, |
86 source->has_transparent_background, | 80 source->has_transparent_background); |
87 source->overlay_state); | |
88 for (size_t i = 0; i < source->shared_quad_state_list.size(); ++i) { | 81 for (size_t i = 0; i < source->shared_quad_state_list.size(); ++i) { |
89 copy_pass->shared_quad_state_list.push_back( | 82 copy_pass->shared_quad_state_list.push_back( |
90 source->shared_quad_state_list[i]->Copy()); | 83 source->shared_quad_state_list[i]->Copy()); |
91 } | 84 } |
92 for (size_t i = 0, sqs_i = 0; i < source->quad_list.size(); ++i) { | 85 for (size_t i = 0, sqs_i = 0; i < source->quad_list.size(); ++i) { |
93 while (source->quad_list[i]->shared_quad_state != | 86 while (source->quad_list[i]->shared_quad_state != |
94 source->shared_quad_state_list[sqs_i]) { | 87 source->shared_quad_state_list[sqs_i]) { |
95 ++sqs_i; | 88 ++sqs_i; |
96 DCHECK_LT(sqs_i, source->shared_quad_state_list.size()); | 89 DCHECK_LT(sqs_i, source->shared_quad_state_list.size()); |
97 } | 90 } |
(...skipping 30 matching lines...) Expand all Loading... |
128 this->transform_to_root_target = transform_to_root_target; | 121 this->transform_to_root_target = transform_to_root_target; |
129 | 122 |
130 DCHECK(quad_list.empty()); | 123 DCHECK(quad_list.empty()); |
131 DCHECK(shared_quad_state_list.empty()); | 124 DCHECK(shared_quad_state_list.empty()); |
132 } | 125 } |
133 | 126 |
134 void RenderPass::SetAll(Id id, | 127 void RenderPass::SetAll(Id id, |
135 const gfx::Rect& output_rect, | 128 const gfx::Rect& output_rect, |
136 const gfx::RectF& damage_rect, | 129 const gfx::RectF& damage_rect, |
137 const gfx::Transform& transform_to_root_target, | 130 const gfx::Transform& transform_to_root_target, |
138 bool has_transparent_background, | 131 bool has_transparent_background) { |
139 OverlayState overlay_state) { | |
140 DCHECK_GT(id.layer_id, 0); | 132 DCHECK_GT(id.layer_id, 0); |
141 DCHECK_GE(id.index, 0); | 133 DCHECK_GE(id.index, 0); |
142 | 134 |
143 this->id = id; | 135 this->id = id; |
144 this->output_rect = output_rect; | 136 this->output_rect = output_rect; |
145 this->damage_rect = damage_rect; | 137 this->damage_rect = damage_rect; |
146 this->transform_to_root_target = transform_to_root_target; | 138 this->transform_to_root_target = transform_to_root_target; |
147 this->has_transparent_background = has_transparent_background; | 139 this->has_transparent_background = has_transparent_background; |
148 this->overlay_state = overlay_state; | |
149 | 140 |
150 DCHECK(quad_list.empty()); | 141 DCHECK(quad_list.empty()); |
151 DCHECK(shared_quad_state_list.empty()); | 142 DCHECK(shared_quad_state_list.empty()); |
152 } | 143 } |
153 | 144 |
154 scoped_ptr<base::Value> RenderPass::AsValue() const { | 145 scoped_ptr<base::Value> RenderPass::AsValue() const { |
155 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 146 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
156 value->Set("output_rect", MathUtil::AsValue(output_rect).release()); | 147 value->Set("output_rect", MathUtil::AsValue(output_rect).release()); |
157 value->Set("damage_rect", MathUtil::AsValue(damage_rect).release()); | 148 value->Set("damage_rect", MathUtil::AsValue(damage_rect).release()); |
158 value->SetBoolean("has_transparent_background", has_transparent_background); | 149 value->SetBoolean("has_transparent_background", has_transparent_background); |
159 value->SetInteger("copy_requests", copy_requests.size()); | 150 value->SetInteger("copy_requests", copy_requests.size()); |
160 scoped_ptr<base::ListValue> shared_states_value(new base::ListValue()); | 151 scoped_ptr<base::ListValue> shared_states_value(new base::ListValue()); |
161 for (size_t i = 0; i < shared_quad_state_list.size(); ++i) { | 152 for (size_t i = 0; i < shared_quad_state_list.size(); ++i) { |
162 shared_states_value->Append(shared_quad_state_list[i]->AsValue().release()); | 153 shared_states_value->Append(shared_quad_state_list[i]->AsValue().release()); |
163 } | 154 } |
164 value->Set("shared_quad_state_list", shared_states_value.release()); | 155 value->Set("shared_quad_state_list", shared_states_value.release()); |
165 scoped_ptr<base::ListValue> quad_list_value(new base::ListValue()); | 156 scoped_ptr<base::ListValue> quad_list_value(new base::ListValue()); |
166 for (size_t i = 0; i < quad_list.size(); ++i) { | 157 for (size_t i = 0; i < quad_list.size(); ++i) { |
167 quad_list_value->Append(quad_list[i]->AsValue().release()); | 158 quad_list_value->Append(quad_list[i]->AsValue().release()); |
168 } | 159 } |
169 value->Set("quad_list", quad_list_value.release()); | 160 value->Set("quad_list", quad_list_value.release()); |
170 | 161 |
171 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( | 162 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( |
172 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), | 163 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), |
173 value.get(), "cc::RenderPass", id.AsTracingId()); | 164 value.get(), "cc::RenderPass", id.AsTracingId()); |
174 return value.PassAs<base::Value>(); | 165 return value.PassAs<base::Value>(); |
175 } | 166 } |
176 | 167 |
177 } // namespace cc | 168 } // namespace cc |
OLD | NEW |