Chromium Code Reviews| 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/layer_tree_host_common.h" | 5 #include "cc/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/heads_up_display_layer_impl.h" | 10 #include "cc/heads_up_display_layer_impl.h" |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 !childLayer->drawProperties().descendants_can_clip_selves || | 533 !childLayer->drawProperties().descendants_can_clip_selves || |
| 534 sublayerTransformPreventsClip || | 534 sublayerTransformPreventsClip || |
| 535 !childLayer->transform().IsPositiveScaleOrTranslation()) | 535 !childLayer->transform().IsPositiveScaleOrTranslation()) |
| 536 descendantsCanClipSelves = false; | 536 descendantsCanClipSelves = false; |
| 537 } | 537 } |
| 538 | 538 |
| 539 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; | 539 layer->drawProperties().num_descendants_that_draw_content = numDescendantsTh atDrawContent; |
| 540 layer->drawProperties().descendants_can_clip_selves = descendantsCanClipSelv es; | 540 layer->drawProperties().descendants_can_clip_selves = descendantsCanClipSelv es; |
| 541 } | 541 } |
| 542 | 542 |
| 543 static void roundTranslates(gfx::Transform* transform) | |
|
danakj
2013/03/06 01:49:28
nit: roundTranslationComponents()
Xianzhu
2013/03/06 02:11:00
Done.
| |
| 544 { | |
| 545 transform->matrix().setDouble(0, 3, round(transform->matrix().getDouble(0, 3 ))); | |
| 546 transform->matrix().setDouble(1, 3, round(transform->matrix().getDouble(1, 3 ))); | |
| 547 } | |
| 548 | |
| 543 // Recursively walks the layer tree starting at the given node and computes all the | 549 // Recursively walks the layer tree starting at the given node and computes all the |
| 544 // necessary transformations, clipRects, render surfaces, etc. | 550 // necessary transformations, clipRects, render surfaces, etc. |
| 545 template<typename LayerType, typename LayerList, typename RenderSurfaceType> | 551 template<typename LayerType, typename LayerList, typename RenderSurfaceType> |
| 546 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, | 552 static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo rm& parentMatrix, |
| 547 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, | 553 const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScro llCompensationMatrix, |
| 548 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, | 554 const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestor InDescendantSpace, bool ancestorClipsSubtree, |
| 549 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, | 555 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL ayerList, LayerList& layerList, |
| 550 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, | 556 LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, |
| 551 gfx::Rect& drawableContentRectOfSubtree, bool updateTilePriorities) | 557 gfx::Rect& drawableContentRectOfSubtree, bool updateTilePriorities) |
| 552 { | 558 { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 // The layer's contentsSize is determined from the combinedTransform, which then informs the | 693 // The layer's contentsSize is determined from the combinedTransform, which then informs the |
| 688 // layer's drawTransform. | 694 // layer's drawTransform. |
| 689 updateLayerContentsScale(layer, combinedTransform, deviceScaleFactor, pageSc aleFactor, animatingTransformToScreen); | 695 updateLayerContentsScale(layer, combinedTransform, deviceScaleFactor, pageSc aleFactor, animatingTransformToScreen); |
| 690 | 696 |
| 691 // If there is a transformation from the impl thread then it should be at | 697 // If there is a transformation from the impl thread then it should be at |
| 692 // the start of the combinedTransform, but we don't want it to affect the | 698 // the start of the combinedTransform, but we don't want it to affect the |
| 693 // computation of contentsScale above. | 699 // computation of contentsScale above. |
| 694 // Note carefully: this is Concat, not Preconcat (implTransform * combinedTr ansform). | 700 // Note carefully: this is Concat, not Preconcat (implTransform * combinedTr ansform). |
| 695 combinedTransform.ConcatTransform(layer->implTransform()); | 701 combinedTransform.ConcatTransform(layer->implTransform()); |
| 696 | 702 |
| 703 if (!animatingTransformToTarget && layer->scrollable() && combinedTransform. IsScaleOrTranslation()) { | |
| 704 // Align the scrollable layer's position to screen space pixels to avoid blurriness. | |
| 705 // To avoid side-effects, do this only if the transform is simple. | |
| 706 roundTranslates(&combinedTransform); | |
| 707 } | |
| 708 | |
| 697 if (layer->fixedToContainerLayer()) { | 709 if (layer->fixedToContainerLayer()) { |
| 698 // Special case: this layer is a composited fixed-position layer; we nee d to | 710 // Special case: this layer is a composited fixed-position layer; we nee d to |
| 699 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep this layer | 711 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep this layer |
| 700 // fixed correctly. | 712 // fixed correctly. |
| 701 // Note carefully: this is Concat, not Preconcat (currentScrollCompensat ion * combinedTransform). | 713 // Note carefully: this is Concat, not Preconcat (currentScrollCompensat ion * combinedTransform). |
| 702 combinedTransform.ConcatTransform(currentScrollCompensationMatrix); | 714 combinedTransform.ConcatTransform(currentScrollCompensationMatrix); |
| 703 } | 715 } |
| 704 | 716 |
| 705 // The drawTransform that gets computed below is effectively the layer's dra wTransform, unless | 717 // The drawTransform that gets computed below is effectively the layer's dra wTransform, unless |
| 706 // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms. | 718 // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms. |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1202 | 1214 |
| 1203 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up | 1215 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up |
| 1204 // the parents to ensure that the layer was not clipped in such a way that the | 1216 // the parents to ensure that the layer was not clipped in such a way that the |
| 1205 // hit point actually should not hit the layer. | 1217 // hit point actually should not hit the layer. |
| 1206 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) | 1218 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) |
| 1207 return false; | 1219 return false; |
| 1208 | 1220 |
| 1209 return true; | 1221 return true; |
| 1210 } | 1222 } |
| 1211 } // namespace cc | 1223 } // namespace cc |
| OLD | NEW |