Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_client.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // Ensure that this translation is truly 2d. 154 // Ensure that this translation is truly 2d.
155 DCHECK(trans.IsIdentityOrTranslation()); 155 DCHECK(trans.IsIdentityOrTranslation());
156 DCHECK_EQ(0.f, trans.matrix().get(2, 3)); 156 DCHECK_EQ(0.f, trans.matrix().get(2, 3));
157 translation += trans.To2dTranslation(); 157 translation += trans.To2dTranslation();
158 } 158 }
159 159
160 return translation; 160 return translation;
161 } 161 }
162 162
163 enum TranslateRectDirection { 163 enum TranslateRectDirection {
164 TRANSLATE_RECT_DIRECTION_TO_ANCESTOR, 164 TranslateRectDirectionToAncestor,
165 TRANSLATE_RECT_DIRECTION_TO_DESCENDANT 165 TranslateRectDirectionToDescendant
166 }; 166 };
167 167
168 template <typename LayerType> 168 template <typename LayerType>
169 static gfx::Rect TranslateRectToTargetSpace(const LayerType& ancestor_layer, 169 static gfx::Rect TranslateRectToTargetSpace(const LayerType& ancestor_layer,
170 const LayerType& descendant_layer, 170 const LayerType& descendant_layer,
171 const gfx::Rect& rect, 171 const gfx::Rect& rect,
172 TranslateRectDirection direction) { 172 TranslateRectDirection direction) {
173 gfx::Vector2dF translation = ComputeChangeOfBasisTranslation<LayerType>( 173 gfx::Vector2dF translation = ComputeChangeOfBasisTranslation<LayerType>(
174 ancestor_layer, descendant_layer); 174 ancestor_layer, descendant_layer);
175 if (direction == TRANSLATE_RECT_DIRECTION_TO_DESCENDANT) 175 if (direction == TranslateRectDirectionToDescendant)
176 translation.Scale(-1.f); 176 translation.Scale(-1.f);
177 return gfx::ToEnclosingRect( 177 return gfx::ToEnclosingRect(
178 gfx::RectF(rect.origin() + translation, rect.size())); 178 gfx::RectF(rect.origin() + translation, rect.size()));
179 } 179 }
180 180
181 // Attempts to update the clip rects for the given layer. If the layer has a 181 // Attempts to update the clip rects for the given layer. If the layer has a
182 // clip_parent, it may not inherit its immediate ancestor's clip. 182 // clip_parent, it may not inherit its immediate ancestor's clip.
183 template <typename LayerType> 183 template <typename LayerType>
184 static void UpdateClipRectsForClipChild( 184 static void UpdateClipRectsForClipChild(
185 const LayerType* layer, 185 const LayerType* layer,
(...skipping 18 matching lines...) Expand all
204 *subtree_should_be_clipped = clip_parent->is_clipped(); 204 *subtree_should_be_clipped = clip_parent->is_clipped();
205 205
206 // We may have to project the clip rect into our parent's target space. Note, 206 // We may have to project the clip rect into our parent's target space. Note,
207 // it must be our parent's target space, not ours. For one, we haven't 207 // it must be our parent's target space, not ours. For one, we haven't
208 // computed our transforms, so we couldn't put it in our space yet even if we 208 // computed our transforms, so we couldn't put it in our space yet even if we
209 // wanted to. But more importantly, this matches the expectations of 209 // wanted to. But more importantly, this matches the expectations of
210 // CalculateDrawPropertiesInternal. If we, say, create a render surface, these 210 // CalculateDrawPropertiesInternal. If we, say, create a render surface, these
211 // clip rects will want to be in its target space, not ours. 211 // clip rects will want to be in its target space, not ours.
212 if (clip_parent == layer->clip_parent()) { 212 if (clip_parent == layer->clip_parent()) {
213 *clip_rect_in_parent_target_space = TranslateRectToTargetSpace<LayerType>( 213 *clip_rect_in_parent_target_space = TranslateRectToTargetSpace<LayerType>(
214 *clip_parent, *layer->parent(), *clip_rect_in_parent_target_space, 214 *clip_parent,
215 TRANSLATE_RECT_DIRECTION_TO_DESCENDANT); 215 *layer->parent(),
216 *clip_rect_in_parent_target_space,
217 TranslateRectDirectionToDescendant);
216 } else { 218 } else {
217 // If we're being clipped by our scroll parent, we must translate through 219 // If we're being clipped by our scroll parent, we must translate through
218 // our common ancestor. This happens to be our parent, so it is sufficent to 220 // our common ancestor. This happens to be our parent, so it is sufficent to
219 // translate from our clip parent's space to the space of its ancestor (our 221 // translate from our clip parent's space to the space of its ancestor (our
220 // parent). 222 // parent).
221 *clip_rect_in_parent_target_space = TranslateRectToTargetSpace<LayerType>( 223 *clip_rect_in_parent_target_space =
222 *layer->parent(), *clip_parent, *clip_rect_in_parent_target_space, 224 TranslateRectToTargetSpace<LayerType>(*layer->parent(),
223 TRANSLATE_RECT_DIRECTION_TO_ANCESTOR); 225 *clip_parent,
226 *clip_rect_in_parent_target_space,
227 TranslateRectDirectionToAncestor);
224 } 228 }
225 } 229 }
226 230
227 // We collect an accumulated drawable content rect per render surface. 231 // We collect an accumulated drawable content rect per render surface.
228 // Typically, a layer will contribute to only one surface, the surface 232 // Typically, a layer will contribute to only one surface, the surface
229 // associated with its render target. Clip children, however, may affect 233 // associated with its render target. Clip children, however, may affect
230 // several surfaces since there may be several surfaces between the clip child 234 // several surfaces since there may be several surfaces between the clip child
231 // and its parent. 235 // and its parent.
232 // 236 //
233 // NB: we accumulate the layer's *clipped* drawable content rect. 237 // NB: we accumulate the layer's *clipped* drawable content rect.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 target_rect = 279 target_rect =
276 gfx::ToEnclosedRect(layer->render_surface()->DrawableContentRect()); 280 gfx::ToEnclosedRect(layer->render_surface()->DrawableContentRect());
277 } 281 }
278 282
279 if (render_target->is_clipped()) { 283 if (render_target->is_clipped()) {
280 gfx::Rect clip_rect = render_target->clip_rect(); 284 gfx::Rect clip_rect = render_target->clip_rect();
281 // If the layer has a clip parent, the clip rect may be in the wrong space, 285 // If the layer has a clip parent, the clip rect may be in the wrong space,
282 // so we'll need to transform it before it is applied. 286 // so we'll need to transform it before it is applied.
283 if (layer->clip_parent()) { 287 if (layer->clip_parent()) {
284 clip_rect = TranslateRectToTargetSpace<LayerType>( 288 clip_rect = TranslateRectToTargetSpace<LayerType>(
285 *layer->clip_parent(), *layer, clip_rect, 289 *layer->clip_parent(),
286 TRANSLATE_RECT_DIRECTION_TO_DESCENDANT); 290 *layer,
291 clip_rect,
292 TranslateRectDirectionToDescendant);
287 } 293 }
288 target_rect.Intersect(clip_rect); 294 target_rect.Intersect(clip_rect);
289 } 295 }
290 296
291 // We must have at least one entry in the vector for the root. 297 // We must have at least one entry in the vector for the root.
292 DCHECK_LT(0ul, accumulated_surface_state->size()); 298 DCHECK_LT(0ul, accumulated_surface_state->size());
293 299
294 typedef typename std::vector<AccumulatedSurfaceState<LayerType>> 300 typedef typename std::vector<AccumulatedSurfaceState<LayerType>>
295 AccumulatedSurfaceStateVector; 301 AccumulatedSurfaceStateVector;
296 typedef typename AccumulatedSurfaceStateVector::reverse_iterator 302 typedef typename AccumulatedSurfaceStateVector::reverse_iterator
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 void Merge(const PreCalculateMetaInformationRecursiveData& data) { 1196 void Merge(const PreCalculateMetaInformationRecursiveData& data) {
1191 layer_or_descendant_has_copy_request |= 1197 layer_or_descendant_has_copy_request |=
1192 data.layer_or_descendant_has_copy_request; 1198 data.layer_or_descendant_has_copy_request;
1193 layer_or_descendant_has_input_handler |= 1199 layer_or_descendant_has_input_handler |=
1194 data.layer_or_descendant_has_input_handler; 1200 data.layer_or_descendant_has_input_handler;
1195 num_unclipped_descendants += 1201 num_unclipped_descendants +=
1196 data.num_unclipped_descendants; 1202 data.num_unclipped_descendants;
1197 } 1203 }
1198 }; 1204 };
1199 1205
1200 static bool ValidateRenderSurface(LayerImpl* layer) {
1201 // This test verifies that there are no cases where a LayerImpl needs
1202 // a render surface, but doesn't have one.
1203 if (layer->render_surface())
1204 return true;
1205
1206 return layer->filters().IsEmpty() && layer->background_filters().IsEmpty() &&
1207 !layer->mask_layer() && !layer->replica_layer() &&
1208 !IsRootLayer(layer) && !layer->is_root_for_isolated_group() &&
1209 !layer->HasCopyRequest();
1210 }
1211
1212 static bool ValidateRenderSurface(Layer* layer) {
1213 return true;
1214 }
1215
1216 // Recursively walks the layer tree to compute any information that is needed 1206 // Recursively walks the layer tree to compute any information that is needed
1217 // before doing the main recursion. 1207 // before doing the main recursion.
1218 template <typename LayerType> 1208 template <typename LayerType>
1219 static void PreCalculateMetaInformation( 1209 static void PreCalculateMetaInformation(
1220 LayerType* layer, 1210 LayerType* layer,
1221 PreCalculateMetaInformationRecursiveData* recursive_data) { 1211 PreCalculateMetaInformationRecursiveData* recursive_data) {
1222 DCHECK(ValidateRenderSurface(layer));
1223
1224 layer->draw_properties().sorted_for_recursion = false; 1212 layer->draw_properties().sorted_for_recursion = false;
1225 layer->draw_properties().has_child_with_a_scroll_parent = false; 1213 layer->draw_properties().has_child_with_a_scroll_parent = false;
1226 1214
1227 if (!HasInvertibleOrAnimatedTransform(layer)) { 1215 if (!HasInvertibleOrAnimatedTransform(layer)) {
1228 // Layers with singular transforms should not be drawn, the whole subtree 1216 // Layers with singular transforms should not be drawn, the whole subtree
1229 // can be skipped. 1217 // can be skipped.
1230 return; 1218 return;
1231 } 1219 }
1232 1220
1233 if (layer->clip_parent()) 1221 if (layer->clip_parent())
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 inputs->current_render_surface_layer_list_id); 2558 inputs->current_render_surface_layer_list_id);
2571 2559
2572 // The dummy layer list should not have been used. 2560 // The dummy layer list should not have been used.
2573 DCHECK_EQ(0u, dummy_layer_list.size()); 2561 DCHECK_EQ(0u, dummy_layer_list.size());
2574 // A root layer render_surface should always exist after 2562 // A root layer render_surface should always exist after
2575 // CalculateDrawProperties. 2563 // CalculateDrawProperties.
2576 DCHECK(inputs->root_layer->render_surface()); 2564 DCHECK(inputs->root_layer->render_surface());
2577 } 2565 }
2578 2566
2579 } // namespace cc 2567 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_client.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698