OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/debug/trace_event_argument.h" | 11 #include "base/debug/trace_event_argument.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "cc/base/math_util.h" | 13 #include "cc/base/math_util.h" |
14 #include "cc/base/util.h" | 14 #include "cc/base/util.h" |
15 #include "cc/debug/debug_colors.h" | 15 #include "cc/debug/debug_colors.h" |
16 #include "cc/debug/micro_benchmark_impl.h" | 16 #include "cc/debug/micro_benchmark_impl.h" |
17 #include "cc/debug/traced_value.h" | 17 #include "cc/debug/traced_value.h" |
18 #include "cc/layers/append_quads_data.h" | 18 #include "cc/layers/append_quads_data.h" |
19 #include "cc/layers/solid_color_layer_impl.h" | 19 #include "cc/layers/solid_color_layer_impl.h" |
20 #include "cc/output/begin_frame_args.h" | 20 #include "cc/output/begin_frame_args.h" |
21 #include "cc/quads/checkerboard_draw_quad.h" | 21 #include "cc/quads/checkerboard_draw_quad.h" |
22 #include "cc/quads/debug_border_draw_quad.h" | 22 #include "cc/quads/debug_border_draw_quad.h" |
23 #include "cc/quads/picture_draw_quad.h" | 23 #include "cc/quads/picture_draw_quad.h" |
24 #include "cc/quads/solid_color_draw_quad.h" | 24 #include "cc/quads/solid_color_draw_quad.h" |
25 #include "cc/quads/tile_draw_quad.h" | 25 #include "cc/quads/tile_draw_quad.h" |
26 #include "cc/resources/tile_manager.h" | 26 #include "cc/resources/tile_manager.h" |
27 #include "cc/trees/layer_tree_impl.h" | 27 #include "cc/trees/layer_tree_impl.h" |
28 #include "cc/trees/occlusion_tracker.h" | 28 #include "cc/trees/occlusion.h" |
29 #include "ui/gfx/quad_f.h" | 29 #include "ui/gfx/quad_f.h" |
30 #include "ui/gfx/rect_conversions.h" | 30 #include "ui/gfx/rect_conversions.h" |
31 #include "ui/gfx/size_conversions.h" | 31 #include "ui/gfx/size_conversions.h" |
32 | 32 |
33 namespace { | 33 namespace { |
34 const float kMaxScaleRatioDuringPinch = 2.0f; | 34 const float kMaxScaleRatioDuringPinch = 2.0f; |
35 | 35 |
36 // When creating a new tiling during pinch, snap to an existing | 36 // When creating a new tiling during pinch, snap to an existing |
37 // tiling's scale if the desired scale is within this ratio. | 37 // tiling's scale if the desired scale is within this ratio. |
38 const float kSnapToExistingTilingRatio = 1.2f; | 38 const float kSnapToExistingTilingRatio = 1.2f; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 // in case push properties is skipped. | 143 // in case push properties is skipped. |
144 layer_impl->invalidation_.Swap(&invalidation_); | 144 layer_impl->invalidation_.Swap(&invalidation_); |
145 invalidation_.Clear(); | 145 invalidation_.Clear(); |
146 needs_post_commit_initialization_ = true; | 146 needs_post_commit_initialization_ = true; |
147 | 147 |
148 // We always need to push properties. | 148 // We always need to push properties. |
149 // See http://crbug.com/303943 | 149 // See http://crbug.com/303943 |
150 needs_push_properties_ = true; | 150 needs_push_properties_ = true; |
151 } | 151 } |
152 | 152 |
153 void PictureLayerImpl::AppendQuads( | 153 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, |
154 RenderPass* render_pass, | 154 const Occlusion& occlusion_in_content_space, |
155 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 155 AppendQuadsData* append_quads_data) { |
156 AppendQuadsData* append_quads_data) { | |
157 DCHECK(!needs_post_commit_initialization_); | 156 DCHECK(!needs_post_commit_initialization_); |
158 | 157 |
159 SharedQuadState* shared_quad_state = | 158 SharedQuadState* shared_quad_state = |
160 render_pass->CreateAndAppendSharedQuadState(); | 159 render_pass->CreateAndAppendSharedQuadState(); |
161 | 160 |
162 if (pile_->is_solid_color()) { | 161 if (pile_->is_solid_color()) { |
163 PopulateSharedQuadState(shared_quad_state); | 162 PopulateSharedQuadState(shared_quad_state); |
164 | 163 |
165 AppendDebugBorderQuad( | 164 AppendDebugBorderQuad( |
166 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 165 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
167 | 166 |
168 SolidColorLayerImpl::AppendSolidQuads( | 167 SolidColorLayerImpl::AppendSolidQuads(render_pass, |
169 render_pass, | 168 occlusion_in_content_space, |
170 occlusion_tracker, | 169 shared_quad_state, |
171 shared_quad_state, | 170 content_bounds(), |
172 content_bounds(), | 171 pile_->solid_color(), |
173 draw_properties().target_space_transform, | 172 append_quads_data); |
vmpstr
2014/10/07 06:44:35
Transform here went away.
| |
174 pile_->solid_color(), | |
175 append_quads_data); | |
176 return; | 173 return; |
177 } | 174 } |
178 | 175 |
179 float max_contents_scale = MaximumTilingContentsScale(); | 176 float max_contents_scale = MaximumTilingContentsScale(); |
180 gfx::Transform scaled_draw_transform = draw_transform(); | 177 gfx::Transform scaled_draw_transform = draw_transform(); |
181 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 178 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
182 SK_MScalar1 / max_contents_scale); | 179 SK_MScalar1 / max_contents_scale); |
183 gfx::Size scaled_content_bounds = | 180 gfx::Size scaled_content_bounds = |
184 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); | 181 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); |
185 gfx::Rect scaled_visible_content_rect = | 182 gfx::Rect scaled_visible_content_rect = |
186 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); | 183 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); |
187 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); | 184 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); |
188 | 185 |
189 Occlusion occlusion = | 186 Occlusion scaled_occlusion = |
190 occlusion_tracker.GetCurrentOcclusionForLayer(scaled_draw_transform); | 187 occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( |
188 scaled_draw_transform); | |
191 | 189 |
192 shared_quad_state->SetAll(scaled_draw_transform, | 190 shared_quad_state->SetAll(scaled_draw_transform, |
193 scaled_content_bounds, | 191 scaled_content_bounds, |
194 scaled_visible_content_rect, | 192 scaled_visible_content_rect, |
195 draw_properties().clip_rect, | 193 draw_properties().clip_rect, |
196 draw_properties().is_clipped, | 194 draw_properties().is_clipped, |
197 draw_properties().opacity, | 195 draw_properties().opacity, |
198 blend_mode(), | 196 blend_mode(), |
199 sorting_context_id_); | 197 sorting_context_id_); |
200 | 198 |
201 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 199 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
202 AppendDebugBorderQuad( | 200 AppendDebugBorderQuad( |
203 render_pass, | 201 render_pass, |
204 scaled_content_bounds, | 202 scaled_content_bounds, |
205 shared_quad_state, | 203 shared_quad_state, |
206 append_quads_data, | 204 append_quads_data, |
207 DebugColors::DirectPictureBorderColor(), | 205 DebugColors::DirectPictureBorderColor(), |
208 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 206 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
209 | 207 |
210 gfx::Rect geometry_rect = scaled_visible_content_rect; | 208 gfx::Rect geometry_rect = scaled_visible_content_rect; |
211 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 209 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
212 gfx::Rect visible_geometry_rect = | 210 gfx::Rect visible_geometry_rect = |
213 occlusion.GetUnoccludedContentRect(geometry_rect); | 211 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); |
214 if (visible_geometry_rect.IsEmpty()) | 212 if (visible_geometry_rect.IsEmpty()) |
215 return; | 213 return; |
216 | 214 |
217 gfx::Size texture_size = scaled_visible_content_rect.size(); | 215 gfx::Size texture_size = scaled_visible_content_rect.size(); |
218 gfx::RectF texture_rect = gfx::RectF(texture_size); | 216 gfx::RectF texture_rect = gfx::RectF(texture_size); |
219 gfx::Rect quad_content_rect = scaled_visible_content_rect; | 217 gfx::Rect quad_content_rect = scaled_visible_content_rect; |
220 | 218 |
221 PictureDrawQuad* quad = | 219 PictureDrawQuad* quad = |
222 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 220 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
223 quad->SetNew(shared_quad_state, | 221 quad->SetNew(shared_quad_state, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 size_t on_demand_missing_tile_count = 0u; | 296 size_t on_demand_missing_tile_count = 0u; |
299 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), | 297 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), |
300 max_contents_scale, | 298 max_contents_scale, |
301 scaled_visible_content_rect, | 299 scaled_visible_content_rect, |
302 ideal_contents_scale_); | 300 ideal_contents_scale_); |
303 iter; | 301 iter; |
304 ++iter) { | 302 ++iter) { |
305 gfx::Rect geometry_rect = iter.geometry_rect(); | 303 gfx::Rect geometry_rect = iter.geometry_rect(); |
306 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 304 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
307 gfx::Rect visible_geometry_rect = | 305 gfx::Rect visible_geometry_rect = |
308 occlusion.GetUnoccludedContentRect(geometry_rect); | 306 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); |
309 if (visible_geometry_rect.IsEmpty()) | 307 if (visible_geometry_rect.IsEmpty()) |
310 continue; | 308 continue; |
311 | 309 |
312 append_quads_data->visible_content_area += | 310 append_quads_data->visible_content_area += |
313 visible_geometry_rect.width() * visible_geometry_rect.height(); | 311 visible_geometry_rect.width() * visible_geometry_rect.height(); |
314 | 312 |
315 bool has_draw_quad = false; | 313 bool has_draw_quad = false; |
316 if (*iter && iter->IsReadyToDraw()) { | 314 if (*iter && iter->IsReadyToDraw()) { |
317 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); | 315 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); |
318 switch (draw_info.mode()) { | 316 switch (draw_info.mode()) { |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1793 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1791 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1794 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1792 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1795 return tiling_range.end - 1 - current_tiling_range_offset; | 1793 return tiling_range.end - 1 - current_tiling_range_offset; |
1796 } | 1794 } |
1797 } | 1795 } |
1798 NOTREACHED(); | 1796 NOTREACHED(); |
1799 return 0; | 1797 return 0; |
1800 } | 1798 } |
1801 | 1799 |
1802 } // namespace cc | 1800 } // namespace cc |
OLD | NEW |