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/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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 static LayerImpl* NextTargetSurface(LayerImpl* layer) { | 360 static LayerImpl* NextTargetSurface(LayerImpl* layer) { |
361 return layer->parent() ? layer->parent()->render_target() : 0; | 361 return layer->parent() ? layer->parent()->render_target() : 0; |
362 } | 362 } |
363 | 363 |
364 // This function returns a translation matrix that can be applied on a vector | 364 // This function returns a translation matrix that can be applied on a vector |
365 // that's in the layer's target surface coordinate, while the position offset is | 365 // that's in the layer's target surface coordinate, while the position offset is |
366 // specified in some ancestor layer's coordinate. | 366 // specified in some ancestor layer's coordinate. |
367 gfx::Transform ComputeSizeDeltaCompensation( | 367 gfx::Transform ComputeSizeDeltaCompensation( |
368 LayerImpl* layer, | 368 LayerImpl* layer, |
369 LayerImpl* container, | 369 LayerImpl* container, |
370 const gfx::Vector2dF& position_offset) { | 370 gfx::Vector2dF position_offset) { |
371 gfx::Transform result_transform; | 371 gfx::Transform result_transform; |
372 | 372 |
373 // To apply a translate in the container's layer space, | 373 // To apply a translate in the container's layer space, |
374 // the following steps need to be done: | 374 // the following steps need to be done: |
375 // Step 1a. transform from target surface space to the container's target | 375 // Step 1a. transform from target surface space to the container's target |
376 // surface space | 376 // surface space |
377 // Step 1b. transform from container's target surface space to the | 377 // Step 1b. transform from container's target surface space to the |
378 // container's layer space | 378 // container's layer space |
379 // Step 2. apply the compensation | 379 // Step 2. apply the compensation |
380 // Step 3. transform back to target surface space | 380 // Step 3. transform back to target surface space |
(...skipping 24 matching lines...) Expand all Loading... |
405 // Note: Again, Concat is used to conver the result coordinate space from | 405 // Note: Again, Concat is used to conver the result coordinate space from |
406 // the container render surface to the container layer. | 406 // the container render surface to the container layer. |
407 target_surface_space_to_container_layer_space.ConcatTransform( | 407 target_surface_space_to_container_layer_space.ConcatTransform( |
408 container_target_surface_space_to_container_layer_space); | 408 container_target_surface_space_to_container_layer_space); |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 // Apply step 3 | 412 // Apply step 3 |
413 gfx::Transform container_layer_space_to_target_surface_space; | 413 gfx::Transform container_layer_space_to_target_surface_space; |
414 if (target_surface_space_to_container_layer_space.GetInverse( | 414 if (target_surface_space_to_container_layer_space.GetInverse( |
415 &container_layer_space_to_target_surface_space)) | 415 &container_layer_space_to_target_surface_space)) { |
416 result_transform.PreconcatTransform( | 416 result_transform.PreconcatTransform( |
417 container_layer_space_to_target_surface_space); | 417 container_layer_space_to_target_surface_space); |
418 else { | 418 } else { |
419 // FIXME: A non-invertible matrix could still make meaningful projection. | 419 // FIXME: A non-invertible matrix could still make meaningful projection. |
420 // For example ScaleZ(0) is non-invertible but the layer is still visible. | 420 // For example ScaleZ(0) is non-invertible but the layer is still visible. |
421 return gfx::Transform(); | 421 return gfx::Transform(); |
422 } | 422 } |
423 | 423 |
424 // Apply step 2 | 424 // Apply step 2 |
425 result_transform.Translate(position_offset.x(), position_offset.y()); | 425 result_transform.Translate(position_offset.x(), position_offset.y()); |
426 | 426 |
427 // Apply step 1 | 427 // Apply step 1 |
428 result_transform.PreconcatTransform( | 428 result_transform.PreconcatTransform( |
429 target_surface_space_to_container_layer_space); | 429 target_surface_space_to_container_layer_space); |
430 | 430 |
431 return result_transform; | 431 return result_transform; |
432 } | 432 } |
433 | 433 |
434 void ApplyPositionAdjustment( | 434 void ApplyPositionAdjustment( |
435 Layer* layer, | 435 Layer* layer, |
436 Layer* container, | 436 Layer* container, |
437 const gfx::Transform& scroll_compensation, | 437 const gfx::Transform& scroll_compensation, |
438 gfx::Transform* combined_transform) { } | 438 gfx::Transform* combined_transform) {} |
439 void ApplyPositionAdjustment( | 439 void ApplyPositionAdjustment( |
440 LayerImpl* layer, | 440 LayerImpl* layer, |
441 LayerImpl* container, | 441 LayerImpl* container, |
442 const gfx::Transform& scroll_compensation, | 442 const gfx::Transform& scroll_compensation, |
443 gfx::Transform* combined_transform) | 443 gfx::Transform* combined_transform) { |
444 { | |
445 if (!layer->position_constraint().is_fixed_position()) | 444 if (!layer->position_constraint().is_fixed_position()) |
446 return; | 445 return; |
447 | 446 |
448 // Special case: this layer is a composited fixed-position layer; we need to | 447 // Special case: this layer is a composited fixed-position layer; we need to |
449 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep | 448 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep |
450 // this layer fixed correctly. | 449 // this layer fixed correctly. |
451 // Note carefully: this is Concat, not Preconcat | 450 // Note carefully: this is Concat, not Preconcat |
452 // (current_scroll_compensation * combined_transform). | 451 // (current_scroll_compensation * combined_transform). |
453 combined_transform->ConcatTransform(scroll_compensation); | 452 combined_transform->ConcatTransform(scroll_compensation); |
454 | 453 |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 // At this point, we think the point does hit the touch event handler region | 1714 // At this point, we think the point does hit the touch event handler region |
1716 // on the layer, but we need to walk up the parents to ensure that the layer | 1715 // on the layer, but we need to walk up the parents to ensure that the layer |
1717 // was not clipped in such a way that the hit point actually should not hit | 1716 // was not clipped in such a way that the hit point actually should not hit |
1718 // the layer. | 1717 // the layer. |
1719 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1718 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
1720 return false; | 1719 return false; |
1721 | 1720 |
1722 return true; | 1721 return true; |
1723 } | 1722 } |
1724 } // namespace cc | 1723 } // namespace cc |
OLD | NEW |