| 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(render_pass, | 167 SolidColorLayerImpl::AppendSolidQuads(render_pass, |
| 169 occlusion_tracker, | 168 occlusion_in_content_space, |
| 170 shared_quad_state, | 169 shared_quad_state, |
| 171 content_bounds(), | 170 content_bounds(), |
| 172 draw_transform(), | |
| 173 pile_->solid_color(), | 171 pile_->solid_color(), |
| 174 append_quads_data); | 172 append_quads_data); |
| 175 return; | 173 return; |
| 176 } | 174 } |
| 177 | 175 |
| 178 Occlusion occlusion = | |
| 179 occlusion_tracker.GetCurrentOcclusionForLayer(draw_transform()); | |
| 180 | |
| 181 float max_contents_scale = MaximumTilingContentsScale(); | 176 float max_contents_scale = MaximumTilingContentsScale(); |
| 182 gfx::Transform scaled_draw_transform = draw_transform(); | 177 gfx::Transform scaled_draw_transform = draw_transform(); |
| 183 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 178 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
| 184 SK_MScalar1 / max_contents_scale); | 179 SK_MScalar1 / max_contents_scale); |
| 185 gfx::Size scaled_content_bounds = | 180 gfx::Size scaled_content_bounds = |
| 186 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); | 181 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); |
| 187 gfx::Rect scaled_visible_content_rect = | 182 gfx::Rect scaled_visible_content_rect = |
| 188 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); | 183 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); |
| 189 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); | 184 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); |
| 190 Occlusion scaled_occlusion = | 185 Occlusion scaled_occlusion = |
| 191 occlusion.GetOcclusionWithGivenDrawTransform(scaled_draw_transform); | 186 occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( |
| 187 scaled_draw_transform); |
| 192 | 188 |
| 193 shared_quad_state->SetAll(scaled_draw_transform, | 189 shared_quad_state->SetAll(scaled_draw_transform, |
| 194 scaled_content_bounds, | 190 scaled_content_bounds, |
| 195 scaled_visible_content_rect, | 191 scaled_visible_content_rect, |
| 196 draw_properties().clip_rect, | 192 draw_properties().clip_rect, |
| 197 draw_properties().is_clipped, | 193 draw_properties().is_clipped, |
| 198 draw_properties().opacity, | 194 draw_properties().opacity, |
| 199 blend_mode(), | 195 blend_mode(), |
| 200 sorting_context_id_); | 196 sorting_context_id_); |
| 201 | 197 |
| (...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1794 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
| 1799 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1795 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
| 1800 return tiling_range.end - 1 - current_tiling_range_offset; | 1796 return tiling_range.end - 1 - current_tiling_range_offset; |
| 1801 } | 1797 } |
| 1802 } | 1798 } |
| 1803 NOTREACHED(); | 1799 NOTREACHED(); |
| 1804 return 0; | 1800 return 0; |
| 1805 } | 1801 } |
| 1806 | 1802 |
| 1807 } // namespace cc | 1803 } // namespace cc |
| OLD | NEW |