| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || | 150 if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || |
| 151 layer->drawable_content_rect().IsEmpty()) | 151 layer->drawable_content_rect().IsEmpty()) |
| 152 return gfx::Rect(); | 152 return gfx::Rect(); |
| 153 | 153 |
| 154 // Compute visible bounds in target surface space. | 154 // Compute visible bounds in target surface space. |
| 155 gfx::Rect visible_rect_in_target_surface_space = | 155 gfx::Rect visible_rect_in_target_surface_space = |
| 156 layer->drawable_content_rect(); | 156 layer->drawable_content_rect(); |
| 157 | 157 |
| 158 if (!layer->render_target()->render_surface()->clip_rect().IsEmpty()) { | 158 if (!layer->render_target()->render_surface()->clip_rect().IsEmpty()) { |
| 159 // In this case the target surface does clip layers that contribute to | 159 // In this case the target surface does clip layers that contribute to |
| 160 // it. So, we have to convert the current surface's clipRect from its | 160 // it. So, we have to convert the current surface's clip rect from its |
| 161 // ancestor surface space to the current (descendant) surface | 161 // ancestor surface space to the current (descendant) surface |
| 162 // space. This conversion is done outside this function so that it can | 162 // space. This conversion is done outside this function so that it can |
| 163 // be cached instead of computing it redundantly for every layer. | 163 // be cached instead of computing it redundantly for every layer. |
| 164 visible_rect_in_target_surface_space.Intersect( | 164 visible_rect_in_target_surface_space.Intersect( |
| 165 ancestor_clip_rect_in_descendant_surface_space); | 165 ancestor_clip_rect_in_descendant_surface_space); |
| 166 } | 166 } |
| 167 | 167 |
| 168 if (visible_rect_in_target_surface_space.IsEmpty()) | 168 if (visible_rect_in_target_surface_space.IsEmpty()) |
| 169 return gfx::Rect(); | 169 return gfx::Rect(); |
| 170 | 170 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 191 template <typename LayerType> | 191 template <typename LayerType> |
| 192 static bool LayerShouldBeSkipped(LayerType* layer) { | 192 static bool LayerShouldBeSkipped(LayerType* layer) { |
| 193 // Layers can be skipped if any of these conditions are met. | 193 // Layers can be skipped if any of these conditions are met. |
| 194 // - does not draw content. | 194 // - does not draw content. |
| 195 // - is transparent | 195 // - is transparent |
| 196 // - has empty bounds | 196 // - has empty bounds |
| 197 // - the layer is not double-sided, but its back face is visible. | 197 // - the layer is not double-sided, but its back face is visible. |
| 198 // | 198 // |
| 199 // Some additional conditions need to be computed at a later point after the | 199 // Some additional conditions need to be computed at a later point after the |
| 200 // recursion is finished. | 200 // recursion is finished. |
| 201 // - the intersection of render surface content and layer clipRect is empty | 201 // - the intersection of render_surface content and layer clip_rect is empty |
| 202 // - the visibleContentRect is empty | 202 // - the visible_content_rect is empty |
| 203 // | 203 // |
| 204 // Note, if the layer should not have been drawn due to being fully | 204 // Note, if the layer should not have been drawn due to being fully |
| 205 // transparent, we would have skipped the entire subtree and never made it | 205 // transparent, we would have skipped the entire subtree and never made it |
| 206 // into this function, so it is safe to omit this check here. | 206 // into this function, so it is safe to omit this check here. |
| 207 | 207 |
| 208 if (!layer->DrawsContent() || layer->bounds().IsEmpty()) | 208 if (!layer->DrawsContent() || layer->bounds().IsEmpty()) |
| 209 return true; | 209 return true; |
| 210 | 210 |
| 211 LayerType* backface_test_layer = layer; | 211 LayerType* backface_test_layer = layer; |
| 212 if (layer->use_parent_backface_visibility()) { | 212 if (layer->use_parent_backface_visibility()) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 237 // unreliable (since the impl thread may be using a different opacity), so it | 237 // unreliable (since the impl thread may be using a different opacity), so it |
| 238 // should not be trusted. | 238 // should not be trusted. |
| 239 // In particular, it should not cause the subtree to be skipped. | 239 // In particular, it should not cause the subtree to be skipped. |
| 240 // Similarly, for layers that might animate opacity using an impl-only | 240 // Similarly, for layers that might animate opacity using an impl-only |
| 241 // animation, their subtree should also not be skipped. | 241 // animation, their subtree should also not be skipped. |
| 242 return !layer->opacity() && !layer->OpacityIsAnimating() && | 242 return !layer->opacity() && !layer->OpacityIsAnimating() && |
| 243 !layer->OpacityCanAnimateOnImplThread(); | 243 !layer->OpacityCanAnimateOnImplThread(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 // Called on each layer that could be drawn after all information from | 246 // Called on each layer that could be drawn after all information from |
| 247 // calcDrawProperties has been updated on that layer. May have some false | 247 // CalcDrawProperties has been updated on that layer. May have some false |
| 248 // positives (e.g. layers get this called on them but don't actually get drawn). | 248 // positives (e.g. layers get this called on them but don't actually get drawn). |
| 249 static inline void UpdateTilePrioritiesForLayer(LayerImpl* layer) { | 249 static inline void UpdateTilePrioritiesForLayer(LayerImpl* layer) { |
| 250 layer->UpdateTilePriorities(); | 250 layer->UpdateTilePriorities(); |
| 251 | 251 |
| 252 // Mask layers don't get this call, so explicitly update them so they can | 252 // Mask layers don't get this call, so explicitly update them so they can |
| 253 // kick off tile rasterization. | 253 // kick off tile rasterization. |
| 254 if (layer->mask_layer()) | 254 if (layer->mask_layer()) |
| 255 layer->mask_layer()->UpdateTilePriorities(); | 255 layer->mask_layer()->UpdateTilePriorities(); |
| 256 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) | 256 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
| 257 layer->replica_layer()->mask_layer()->UpdateTilePriorities(); | 257 layer->replica_layer()->mask_layer()->UpdateTilePriorities(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // | 345 // |
| 346 // Step 1. transform from target surface space to the exact space where | 346 // Step 1. transform from target surface space to the exact space where |
| 347 // scroll_delta is actually applied. | 347 // scroll_delta is actually applied. |
| 348 // -- this is inverse of the matrix in step 3 | 348 // -- this is inverse of the matrix in step 3 |
| 349 // Step 2. undo the scroll_delta | 349 // Step 2. undo the scroll_delta |
| 350 // -- this is just a translation by scroll_delta. | 350 // -- this is just a translation by scroll_delta. |
| 351 // Step 3. transform back to target surface space. | 351 // Step 3. transform back to target surface space. |
| 352 // -- this transform is the "partial_layer_origin_transform" = | 352 // -- this transform is the "partial_layer_origin_transform" = |
| 353 // (parent_matrix * scale(layer->pageScaleDelta())); | 353 // (parent_matrix * scale(layer->pageScaleDelta())); |
| 354 // | 354 // |
| 355 // These steps create a matrix that both start and end in targetSurfaceSpace. | 355 // These steps create a matrix that both start and end in target surface |
| 356 // So this matrix can pre-multiply any fixed-position layer's draw_transform | 356 // space. So this matrix can pre-multiply any fixed-position layer's |
| 357 // to undo the scroll_deltas -- as long as that fixed position layer is fixed | 357 // draw_transform to undo the scroll_deltas -- as long as that fixed position |
| 358 // onto the same render_target as this scrolling_layer. | 358 // layer is fixed onto the same render_target as this scrolling_layer. |
| 359 // | 359 // |
| 360 | 360 |
| 361 gfx::Transform partial_layer_origin_transform = parent_matrix; | 361 gfx::Transform partial_layer_origin_transform = parent_matrix; |
| 362 partial_layer_origin_transform.PreconcatTransform( | 362 partial_layer_origin_transform.PreconcatTransform( |
| 363 scrolling_layer->impl_transform()); | 363 scrolling_layer->impl_transform()); |
| 364 | 364 |
| 365 gfx::Transform scroll_compensation_for_this_layer = | 365 gfx::Transform scroll_compensation_for_this_layer = |
| 366 partial_layer_origin_transform; // Step 3 | 366 partial_layer_origin_transform; // Step 3 |
| 367 scroll_compensation_for_this_layer.Translate( | 367 scroll_compensation_for_this_layer.Translate( |
| 368 scrolling_layer->scroll_delta().x(), | 368 scrolling_layer->scroll_delta().x(), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 // Start as identity matrix. | 424 // Start as identity matrix. |
| 425 gfx::Transform next_scroll_compensation_matrix; | 425 gfx::Transform next_scroll_compensation_matrix; |
| 426 | 426 |
| 427 // If this layer is not a container, then it inherits the existing scroll | 427 // If this layer is not a container, then it inherits the existing scroll |
| 428 // compensations. | 428 // compensations. |
| 429 if (!layer->is_container_for_fixed_position_layers()) | 429 if (!layer->is_container_for_fixed_position_layers()) |
| 430 next_scroll_compensation_matrix = current_scroll_compensation_matrix; | 430 next_scroll_compensation_matrix = current_scroll_compensation_matrix; |
| 431 | 431 |
| 432 // If the current layer has a non-zero scroll_delta, then we should compute | 432 // If the current layer has a non-zero scroll_delta, then we should compute |
| 433 // its local scrollCompensation and accumulate it to the | 433 // its local scroll compensation and accumulate it to the |
| 434 // next_scroll_compensation_matrix. | 434 // next_scroll_compensation_matrix. |
| 435 if (!layer->scroll_delta().IsZero()) { | 435 if (!layer->scroll_delta().IsZero()) { |
| 436 gfx::Transform scroll_compensation_for_this_layer = | 436 gfx::Transform scroll_compensation_for_this_layer = |
| 437 ComputeScrollCompensationForThisLayer(layer, parent_matrix); | 437 ComputeScrollCompensationForThisLayer(layer, parent_matrix); |
| 438 next_scroll_compensation_matrix.PreconcatTransform( | 438 next_scroll_compensation_matrix.PreconcatTransform( |
| 439 scroll_compensation_for_this_layer); | 439 scroll_compensation_for_this_layer); |
| 440 } | 440 } |
| 441 | 441 |
| 442 // If the layer created its own render_surface, we have to adjust | 442 // If the layer created its own render_surface, we have to adjust |
| 443 // next_scroll_compensation_matrix. The adjustment allows us to continue | 443 // next_scroll_compensation_matrix. The adjustment allows us to continue |
| 444 // using the scrollCompensation on the next surface. | 444 // using the scroll compensation on the next surface. |
| 445 // Step 1 (right-most in the math): transform from the new surface to the | 445 // Step 1 (right-most in the math): transform from the new surface to the |
| 446 // original ancestor surface | 446 // original ancestor surface |
| 447 // Step 2: apply the scroll compensation | 447 // Step 2: apply the scroll compensation |
| 448 // Step 3: transform back to the new surface. | 448 // Step 3: transform back to the new surface. |
| 449 if (layer->render_surface() && | 449 if (layer->render_surface() && |
| 450 !next_scroll_compensation_matrix.IsIdentity()) { | 450 !next_scroll_compensation_matrix.IsIdentity()) { |
| 451 gfx::Transform inverse_surface_draw_transform( | 451 gfx::Transform inverse_surface_draw_transform( |
| 452 gfx::Transform::kSkipInitialization); | 452 gfx::Transform::kSkipInitialization); |
| 453 if (!layer->render_surface()->draw_transform().GetInverse( | 453 if (!layer->render_surface()->draw_transform().GetInverse( |
| 454 &inverse_surface_draw_transform)) { | 454 &inverse_surface_draw_transform)) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } | 614 } |
| 615 | 615 |
| 616 static void RoundTranslationComponents(gfx::Transform* transform) { | 616 static void RoundTranslationComponents(gfx::Transform* transform) { |
| 617 transform->matrix(). | 617 transform->matrix(). |
| 618 setDouble(0, 3, MathUtil::Round(transform->matrix().getDouble(0, 3))); | 618 setDouble(0, 3, MathUtil::Round(transform->matrix().getDouble(0, 3))); |
| 619 transform->matrix(). | 619 transform->matrix(). |
| 620 setDouble(1, 3, MathUtil::Round(transform->matrix().getDouble(1, 3))); | 620 setDouble(1, 3, MathUtil::Round(transform->matrix().getDouble(1, 3))); |
| 621 } | 621 } |
| 622 | 622 |
| 623 // Recursively walks the layer tree starting at the given node and computes all | 623 // Recursively walks the layer tree starting at the given node and computes all |
| 624 // the necessary transformations, clipRects, render surfaces, etc. | 624 // the necessary transformations, clip rects, render surfaces, etc. |
| 625 template <typename LayerType, typename LayerList, typename RenderSurfaceType> | 625 template <typename LayerType, typename LayerList, typename RenderSurfaceType> |
| 626 static void CalculateDrawPropertiesInternal( | 626 static void CalculateDrawPropertiesInternal( |
| 627 LayerType* layer, | 627 LayerType* layer, |
| 628 const gfx::Transform& parent_matrix, | 628 const gfx::Transform& parent_matrix, |
| 629 const gfx::Transform& full_hierarchy_matrix, | 629 const gfx::Transform& full_hierarchy_matrix, |
| 630 const gfx::Transform& current_scroll_compensation_matrix, | 630 const gfx::Transform& current_scroll_compensation_matrix, |
| 631 gfx::Rect clip_rect_from_ancestor, | 631 gfx::Rect clip_rect_from_ancestor, |
| 632 gfx::Rect clip_rect_from_ancestor_in_descendant_space, | 632 gfx::Rect clip_rect_from_ancestor_in_descendant_space, |
| 633 bool ancestor_clips_subtree, | 633 bool ancestor_clips_subtree, |
| 634 RenderSurfaceType* nearest_ancestor_that_moves_pixels, | 634 RenderSurfaceType* nearest_ancestor_that_moves_pixels, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 // anchor point | 674 // anchor point |
| 675 // | 675 // |
| 676 // Tr[origin2center] is the translation from the layer's origin to its | 676 // Tr[origin2center] is the translation from the layer's origin to its |
| 677 // center | 677 // center |
| 678 // | 678 // |
| 679 // M[layer] is the layer's matrix (applied at the anchor point) | 679 // M[layer] is the layer's matrix (applied at the anchor point) |
| 680 // | 680 // |
| 681 // M[sublayer] is the layer's sublayer transform (also applied at the | 681 // M[sublayer] is the layer's sublayer transform (also applied at the |
| 682 // layer's anchor point) | 682 // layer's anchor point) |
| 683 // | 683 // |
| 684 // S[layer2content] is the ratio of a layer's ContentBounds() to its | 684 // S[layer2content] is the ratio of a layer's content_bounds() to its |
| 685 // Bounds(). | 685 // Bounds(). |
| 686 // | 686 // |
| 687 // Some composite transforms can help in understanding the sequence of | 687 // Some composite transforms can help in understanding the sequence of |
| 688 // transforms: | 688 // transforms: |
| 689 // compositeLayerTransform = Tr[origin2anchor] * M[layer] * | 689 // composite_layer_transform = Tr[origin2anchor] * M[layer] * |
| 690 // Tr[origin2anchor].inverse() | 690 // Tr[origin2anchor].inverse() |
| 691 // | 691 // |
| 692 // compositeSublayerTransform = Tr[origin2anchor] * M[sublayer] * | 692 // composite_sublayer_transform = Tr[origin2anchor] * M[sublayer] * |
| 693 // Tr[origin2anchor].inverse() | 693 // Tr[origin2anchor].inverse() |
| 694 // | 694 // |
| 695 // 4. When a layer (or render surface) is drawn, it is drawn into a "target | 695 // 4. When a layer (or render surface) is drawn, it is drawn into a "target |
| 696 // render surface". Therefore the draw transform does not necessarily | 696 // render surface". Therefore the draw transform does not necessarily |
| 697 // transform from screen space to local layer space. Instead, the draw | 697 // transform from screen space to local layer space. Instead, the draw |
| 698 // transform is the transform between the "target render surface space" and | 698 // transform is the transform between the "target render surface space" and |
| 699 // local layer space. Note that render surfaces, except for the root, also | 699 // local layer space. Note that render surfaces, except for the root, also |
| 700 // draw themselves into a different target render surface, and so their draw | 700 // draw themselves into a different target render surface, and so their draw |
| 701 // transform and origin transforms are also described with respect to the | 701 // transform and origin transforms are also described with respect to the |
| 702 // target. | 702 // target. |
| 703 // | 703 // |
| 704 // Using these definitions, then: | 704 // Using these definitions, then: |
| 705 // | 705 // |
| 706 // The draw transform for the layer is: | 706 // The draw transform for the layer is: |
| 707 // M[draw] = M[parent] * Tr[origin] * compositeLayerTransform * | 707 // M[draw] = M[parent] * Tr[origin] * composite_layer_transform * |
| 708 // S[layer2content] = M[parent] * Tr[layer->Position() + anchor] * | 708 // S[layer2content] = M[parent] * Tr[layer->position() + anchor] * |
| 709 // M[layer] * Tr[anchor2origin] * S[layer2content] | 709 // M[layer] * Tr[anchor2origin] * S[layer2content] |
| 710 // | 710 // |
| 711 // Interpreting the math left-to-right, this transforms from the | 711 // Interpreting the math left-to-right, this transforms from the |
| 712 // layer's render surface to the origin of the layer in content space. | 712 // layer's render surface to the origin of the layer in content space. |
| 713 // | 713 // |
| 714 // The screen space transform is: | 714 // The screen space transform is: |
| 715 // M[screenspace] = M[root] * Tr[origin] * compositeLayerTransform * | 715 // M[screenspace] = M[root] * Tr[origin] * composite_layer_transform * |
| 716 // S[layer2content] | 716 // S[layer2content] |
| 717 // = M[root] * Tr[layer->Position() + anchor] * M[layer] | 717 // = M[root] * Tr[layer->position() + anchor] * M[layer] |
| 718 // * Tr[anchor2origin] * S[layer2content] | 718 // * Tr[anchor2origin] * S[layer2content] |
| 719 // | 719 // |
| 720 // Interpreting the math left-to-right, this transforms from the root | 720 // Interpreting the math left-to-right, this transforms from the root |
| 721 // render surface's content space to the origin of the layer in content | 721 // render surface's content space to the origin of the layer in content |
| 722 // space. | 722 // space. |
| 723 // | 723 // |
| 724 // The transform hierarchy that is passed on to children (i.e. the child's | 724 // The transform hierarchy that is passed on to children (i.e. the child's |
| 725 // parent_matrix) is: | 725 // parent_matrix) is: |
| 726 // M[parent]_for_child = M[parent] * Tr[origin] * | 726 // M[parent]_for_child = M[parent] * Tr[origin] * |
| 727 // compositeLayerTransform * compositeSublayerTransform | 727 // composite_layer_transform * composite_sublayer_transform |
| 728 // = M[parent] * Tr[layer->Position() + anchor] * | 728 // = M[parent] * Tr[layer->position() + anchor] * |
| 729 // M[layer] * Tr[anchor2origin] * | 729 // M[layer] * Tr[anchor2origin] * |
| 730 // compositeSublayerTransform | 730 // composite_sublayer_transform |
| 731 // | 731 // |
| 732 // and a similar matrix for the full hierarchy with respect to the | 732 // and a similar matrix for the full hierarchy with respect to the |
| 733 // root. | 733 // root. |
| 734 // | 734 // |
| 735 // Finally, note that the final matrix used by the shader for the layer is P * | 735 // Finally, note that the final matrix used by the shader for the layer is P * |
| 736 // M[draw] * S . This final product is computed in drawTexturedQuad(), where: | 736 // M[draw] * S . This final product is computed in drawTexturedQuad(), where: |
| 737 // P is the projection matrix | 737 // P is the projection matrix |
| 738 // S is the scale adjustment (to scale up a canonical quad to the | 738 // S is the scale adjustment (to scale up a canonical quad to the |
| 739 // layer's size) | 739 // layer's size) |
| 740 // | 740 // |
| 741 // When a render surface has a replica layer, that layer's transform is used | 741 // When a render surface has a replica layer, that layer's transform is used |
| 742 // to draw a second copy of the surface. gfx::Transforms named here are | 742 // to draw a second copy of the surface. gfx::Transforms named here are |
| 743 // relative to the surface, unless they specify they are relative to the | 743 // relative to the surface, unless they specify they are relative to the |
| 744 // replica layer. | 744 // replica layer. |
| 745 // | 745 // |
| 746 // We will denote a scale by device scale S[deviceScale] | 746 // We will denote a scale by device scale S[deviceScale] |
| 747 // | 747 // |
| 748 // The render surface draw transform to its target surface origin is: | 748 // The render surface draw transform to its target surface origin is: |
| 749 // M[surfaceDraw] = M[owningLayer->Draw] | 749 // M[surfaceDraw] = M[owningLayer->Draw] |
| 750 // | 750 // |
| 751 // The render surface origin transform to its the root (screen space) origin | 751 // The render surface origin transform to its the root (screen space) origin |
| 752 // is: | 752 // is: |
| 753 // M[surface2root] = M[owningLayer->screenspace] * | 753 // M[surface2root] = M[owningLayer->screenspace] * |
| 754 // S[deviceScale].inverse() | 754 // S[deviceScale].inverse() |
| 755 // | 755 // |
| 756 // The replica draw transform to its target surface origin is: | 756 // The replica draw transform to its target surface origin is: |
| 757 // M[replicaDraw] = S[deviceScale] * M[surfaceDraw] * | 757 // M[replicaDraw] = S[deviceScale] * M[surfaceDraw] * |
| 758 // Tr[replica->Position() + replica->anchor()] * Tr[replica] * | 758 // Tr[replica->position() + replica->anchor()] * Tr[replica] * |
| 759 // Tr[origin2anchor].inverse() * S[contents_scale].inverse() | 759 // Tr[origin2anchor].inverse() * S[contents_scale].inverse() |
| 760 // | 760 // |
| 761 // The replica draw transform to the root (screen space) origin is: | 761 // The replica draw transform to the root (screen space) origin is: |
| 762 // M[replica2root] = M[surface2root] * Tr[replica->Position()] * | 762 // M[replica2root] = M[surface2root] * Tr[replica->position()] * |
| 763 // Tr[replica] * Tr[origin2anchor].inverse() | 763 // Tr[replica] * Tr[origin2anchor].inverse() |
| 764 // | 764 // |
| 765 | 765 |
| 766 // If we early-exit anywhere in this function, the drawableContentRect of this | 766 // If we early-exit anywhere in this function, the drawable_content_rect of th
is |
| 767 // subtree should be considered empty. | 767 // subtree should be considered empty. |
| 768 *drawable_content_rect_of_subtree = gfx::Rect(); | 768 *drawable_content_rect_of_subtree = gfx::Rect(); |
| 769 | 769 |
| 770 // The root layer cannot skip calcDrawProperties. | 770 // The root layer cannot skip CalcDrawProperties. |
| 771 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer)) | 771 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer)) |
| 772 return; | 772 return; |
| 773 | 773 |
| 774 // As this function proceeds, these are the properties for the current | 774 // As this function proceeds, these are the properties for the current |
| 775 // layer that actually get computed. To avoid unnecessary copies | 775 // layer that actually get computed. To avoid unnecessary copies |
| 776 // (particularly for matrices), we do computations directly on these values | 776 // (particularly for matrices), we do computations directly on these values |
| 777 // when possible. | 777 // when possible. |
| 778 DrawProperties<LayerType, RenderSurfaceType>& layer_draw_properties = | 778 DrawProperties<LayerType, RenderSurfaceType>& layer_draw_properties = |
| 779 layer->draw_properties(); | 779 layer->draw_properties(); |
| 780 | 780 |
| 781 gfx::Rect clip_rect_for_subtree; | 781 gfx::Rect clip_rect_for_subtree; |
| 782 bool subtree_should_be_clipped = false; | 782 bool subtree_should_be_clipped = false; |
| 783 | 783 |
| 784 // This value is cached on the stack so that we don't have to inverse-project | 784 // This value is cached on the stack so that we don't have to inverse-project |
| 785 // the surface's clipRect redundantly for every layer. This value is the | 785 // the surface's clip rect redundantly for every layer. This value is the |
| 786 // same as the surface's clipRect, except that instead of being described | 786 // same as the surface's clip rect, except that instead of being described |
| 787 // in the target surface space (i.e. the ancestor surface space), it is | 787 // in the target surface space (i.e. the ancestor surface space), it is |
| 788 // described in the current surface space. | 788 // described in the current surface space. |
| 789 gfx::Rect clip_rect_for_subtree_in_descendant_space; | 789 gfx::Rect clip_rect_for_subtree_in_descendant_space; |
| 790 | 790 |
| 791 float accumulated_draw_opacity = layer->opacity(); | 791 float accumulated_draw_opacity = layer->opacity(); |
| 792 bool animating_opacity_to_target = layer->OpacityIsAnimating(); | 792 bool animating_opacity_to_target = layer->OpacityIsAnimating(); |
| 793 bool animating_opacity_to_screen = animating_opacity_to_target; | 793 bool animating_opacity_to_screen = animating_opacity_to_target; |
| 794 if (layer->parent()) { | 794 if (layer->parent()) { |
| 795 accumulated_draw_opacity *= layer->parent()->draw_opacity(); | 795 accumulated_draw_opacity *= layer->parent()->draw_opacity(); |
| 796 animating_opacity_to_target |= layer->parent()->draw_opacity_is_animating(); | 796 animating_opacity_to_target |= layer->parent()->draw_opacity_is_animating(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 821 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] | 821 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] |
| 822 combined_transform.PreconcatTransform(layer->transform()); | 822 combined_transform.PreconcatTransform(layer->transform()); |
| 823 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] | 823 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] |
| 824 combined_transform.Translate3d(-anchor_point.x() * bounds.width(), | 824 combined_transform.Translate3d(-anchor_point.x() * bounds.width(), |
| 825 -anchor_point.y() * bounds.height(), | 825 -anchor_point.y() * bounds.height(), |
| 826 -layer->anchor_point_z()); | 826 -layer->anchor_point_z()); |
| 827 } else { | 827 } else { |
| 828 combined_transform.Translate(position.x(), position.y()); | 828 combined_transform.Translate(position.x(), position.y()); |
| 829 } | 829 } |
| 830 | 830 |
| 831 // The layer's contentsSize is determined from the combined_transform, which | 831 // The layer's contents_scale is determined from the combined_transform, which |
| 832 // then informs the layer's draw_transform. | 832 // then informs the layer's draw_transform. |
| 833 UpdateLayerContentsScale(layer, | 833 UpdateLayerContentsScale(layer, |
| 834 combined_transform, | 834 combined_transform, |
| 835 device_scale_factor, | 835 device_scale_factor, |
| 836 page_scale_factor, | 836 page_scale_factor, |
| 837 animating_transform_to_screen); | 837 animating_transform_to_screen); |
| 838 | 838 |
| 839 // If there is a transformation from the impl thread then it should be at | 839 // If there is a transformation from the impl thread then it should be at |
| 840 // the start of the combined_transform, but we don't want it to affect the | 840 // the start of the combined_transform, but we don't want it to affect the |
| 841 // computation of contents_scale above. | 841 // computation of contents_scale above. |
| 842 // Note carefully: this is Concat, not Preconcat (implTransform * | 842 // Note carefully: this is Concat, not Preconcat (impl_transform * |
| 843 // combined_transform). | 843 // combined_transform). |
| 844 combined_transform.ConcatTransform(layer->impl_transform()); | 844 combined_transform.ConcatTransform(layer->impl_transform()); |
| 845 | 845 |
| 846 if (!animating_transform_to_target && layer->scrollable() && | 846 if (!animating_transform_to_target && layer->scrollable() && |
| 847 combined_transform.IsScaleOrTranslation()) { | 847 combined_transform.IsScaleOrTranslation()) { |
| 848 // Align the scrollable layer's position to screen space pixels to avoid | 848 // Align the scrollable layer's position to screen space pixels to avoid |
| 849 // blurriness. To avoid side-effects, do this only if the transform is | 849 // blurriness. To avoid side-effects, do this only if the transform is |
| 850 // simple. | 850 // simple. |
| 851 RoundTranslationComponents(&combined_transform); | 851 RoundTranslationComponents(&combined_transform); |
| 852 } | 852 } |
| 853 | 853 |
| 854 if (layer->fixed_to_container_layer()) { | 854 if (layer->fixed_to_container_layer()) { |
| 855 // Special case: this layer is a composited fixed-position layer; we need to | 855 // Special case: this layer is a composited fixed-position layer; we need to |
| 856 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep | 856 // explicitly compensate for all ancestors' nonzero scroll_deltas to keep |
| 857 // this layer fixed correctly. | 857 // this layer fixed correctly. |
| 858 // Note carefully: this is Concat, not Preconcat | 858 // Note carefully: this is Concat, not Preconcat |
| 859 // (current_scroll_compensation * combined_transform). | 859 // (current_scroll_compensation * combined_transform). |
| 860 combined_transform.ConcatTransform(current_scroll_compensation_matrix); | 860 combined_transform.ConcatTransform(current_scroll_compensation_matrix); |
| 861 } | 861 } |
| 862 | 862 |
| 863 // The draw_transform that gets computed below is effectively the layer's | 863 // The draw_transform that gets computed below is effectively the layer's |
| 864 // draw_transform, unless the layer itself creates a render_surface. In that | 864 // draw_transform, unless the layer itself creates a render_surface. In that |
| 865 // case, the render_surface re-parents the transforms. | 865 // case, the render_surface re-parents the transforms. |
| 866 layer_draw_properties.target_space_transform = combined_transform; | 866 layer_draw_properties.target_space_transform = combined_transform; |
| 867 // M[draw] = M[parent] * LT * S[layer2content] | 867 // M[draw] = M[parent] * LT * S[layer2content] |
| 868 layer_draw_properties.target_space_transform.Scale | 868 layer_draw_properties.target_space_transform.Scale |
| 869 (1.f / layer->contents_scale_x(), 1.f / layer->contents_scale_y()); | 869 (1.f / layer->contents_scale_x(), 1.f / layer->contents_scale_y()); |
| 870 | 870 |
| 871 // layerScreenSpaceTransform represents the transform between root layer's | 871 // The layer's screen_space_transform represents the transform between root |
| 872 // "screen space" and local content space. | 872 // layer's "screen space" and local content space. |
| 873 layer_draw_properties.screen_space_transform = full_hierarchy_matrix; | 873 layer_draw_properties.screen_space_transform = full_hierarchy_matrix; |
| 874 if (!layer->preserves_3d()) | 874 if (!layer->preserves_3d()) |
| 875 layer_draw_properties.screen_space_transform.FlattenTo2d(); | 875 layer_draw_properties.screen_space_transform.FlattenTo2d(); |
| 876 layer_draw_properties.screen_space_transform.PreconcatTransform | 876 layer_draw_properties.screen_space_transform.PreconcatTransform |
| 877 (layer_draw_properties.target_space_transform); | 877 (layer_draw_properties.target_space_transform); |
| 878 | 878 |
| 879 // Adjusting text AA method during animation may cause repaints, which in-turn | 879 // Adjusting text AA method during animation may cause repaints, which in-turn |
| 880 // causes jank. | 880 // causes jank. |
| 881 bool adjust_text_aa = | 881 bool adjust_text_aa = |
| 882 !animating_opacity_to_screen && !animating_transform_to_screen; | 882 !animating_opacity_to_screen && !animating_transform_to_screen; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 animating_transform_to_target; | 956 animating_transform_to_target; |
| 957 layer_draw_properties.screen_space_transform_is_animating = | 957 layer_draw_properties.screen_space_transform_is_animating = |
| 958 animating_transform_to_screen; | 958 animating_transform_to_screen; |
| 959 | 959 |
| 960 // Update the aggregate hierarchy matrix to include the transform of the | 960 // Update the aggregate hierarchy matrix to include the transform of the |
| 961 // newly created RenderSurfaceImpl. | 961 // newly created RenderSurfaceImpl. |
| 962 next_hierarchy_matrix.PreconcatTransform(render_surface->draw_transform()); | 962 next_hierarchy_matrix.PreconcatTransform(render_surface->draw_transform()); |
| 963 | 963 |
| 964 // The new render_surface here will correctly clip the entire subtree. So, | 964 // The new render_surface here will correctly clip the entire subtree. So, |
| 965 // we do not need to continue propagating the clipping state further down | 965 // we do not need to continue propagating the clipping state further down |
| 966 // the tree. This way, we can avoid transforming clipRects from ancestor | 966 // the tree. This way, we can avoid transforming clip rects from ancestor |
| 967 // target surface space to current target surface space that could cause | 967 // target surface space to current target surface space that could cause |
| 968 // more w < 0 headaches. | 968 // more w < 0 headaches. |
| 969 subtree_should_be_clipped = false; | 969 subtree_should_be_clipped = false; |
| 970 | 970 |
| 971 if (layer->mask_layer()) { | 971 if (layer->mask_layer()) { |
| 972 DrawProperties<LayerType, RenderSurfaceType>& mask_layer_draw_properties = | 972 DrawProperties<LayerType, RenderSurfaceType>& mask_layer_draw_properties = |
| 973 layer->mask_layer()->draw_properties(); | 973 layer->mask_layer()->draw_properties(); |
| 974 mask_layer_draw_properties.render_target = layer; | 974 mask_layer_draw_properties.render_target = layer; |
| 975 mask_layer_draw_properties.visible_content_rect = | 975 mask_layer_draw_properties.visible_content_rect = |
| 976 gfx::Rect(gfx::Point(), layer->content_bounds()); | 976 gfx::Rect(gfx::Point(), layer->content_bounds()); |
| 977 } | 977 } |
| 978 | 978 |
| 979 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { | 979 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { |
| 980 DrawProperties<LayerType, RenderSurfaceType>& | 980 DrawProperties<LayerType, RenderSurfaceType>& |
| 981 replica_mask_draw_properties = | 981 replica_mask_draw_properties = |
| 982 layer->replica_layer()->mask_layer()->draw_properties(); | 982 layer->replica_layer()->mask_layer()->draw_properties(); |
| 983 replica_mask_draw_properties.render_target = layer; | 983 replica_mask_draw_properties.render_target = layer; |
| 984 replica_mask_draw_properties.visible_content_rect = | 984 replica_mask_draw_properties.visible_content_rect = |
| 985 gfx::Rect(gfx::Point(), layer->content_bounds()); | 985 gfx::Rect(gfx::Point(), layer->content_bounds()); |
| 986 } | 986 } |
| 987 | 987 |
| 988 // TODO(senorblanco): make this smarter for the SkImageFilter case (check | 988 // TODO(senorblanco): make this smarter for the SkImageFilter case (check |
| 989 // for pixel-moving filters) | 989 // for pixel-moving filters) |
| 990 if (layer->filters().hasFilterThatMovesPixels() || layer->filter()) | 990 if (layer->filters().hasFilterThatMovesPixels() || layer->filter()) |
| 991 nearest_ancestor_that_moves_pixels = render_surface; | 991 nearest_ancestor_that_moves_pixels = render_surface; |
| 992 | 992 |
| 993 // The render surface clipRect is expressed in the space where this surface | 993 // The render surface clip rect is expressed in the space where this surface |
| 994 // draws, i.e. the same space as clip_rect_from_ancestor. | 994 // draws, i.e. the same space as clip_rect_from_ancestor. |
| 995 render_surface->SetIsClipped(ancestor_clips_subtree); | 995 render_surface->SetIsClipped(ancestor_clips_subtree); |
| 996 if (ancestor_clips_subtree) { | 996 if (ancestor_clips_subtree) { |
| 997 render_surface->SetClipRect(clip_rect_from_ancestor); | 997 render_surface->SetClipRect(clip_rect_from_ancestor); |
| 998 | 998 |
| 999 gfx::Transform inverse_surface_draw_transform( | 999 gfx::Transform inverse_surface_draw_transform( |
| 1000 gfx::Transform::kSkipInitialization); | 1000 gfx::Transform::kSkipInitialization); |
| 1001 if (!render_surface->draw_transform().GetInverse( | 1001 if (!render_surface->draw_transform().GetInverse( |
| 1002 &inverse_surface_draw_transform)) { | 1002 &inverse_surface_draw_transform)) { |
| 1003 // TODO(shawnsingh): Either we need to handle uninvertible transforms | 1003 // TODO(shawnsingh): Either we need to handle uninvertible transforms |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 sublayer_matrix = combined_transform; | 1037 sublayer_matrix = combined_transform; |
| 1038 | 1038 |
| 1039 layer->ClearRenderSurface(); | 1039 layer->ClearRenderSurface(); |
| 1040 | 1040 |
| 1041 // Layers without render_surfaces directly inherit the ancestor's clip | 1041 // Layers without render_surfaces directly inherit the ancestor's clip |
| 1042 // status. | 1042 // status. |
| 1043 subtree_should_be_clipped = ancestor_clips_subtree; | 1043 subtree_should_be_clipped = ancestor_clips_subtree; |
| 1044 if (ancestor_clips_subtree) | 1044 if (ancestor_clips_subtree) |
| 1045 clip_rect_for_subtree = clip_rect_from_ancestor; | 1045 clip_rect_for_subtree = clip_rect_from_ancestor; |
| 1046 | 1046 |
| 1047 // The surface's cached clipRect value propagates regardless of what | 1047 // The surface's cached clip rect value propagates regardless of what |
| 1048 // clipping goes on between layers here. | 1048 // clipping goes on between layers here. |
| 1049 clip_rect_for_subtree_in_descendant_space = | 1049 clip_rect_for_subtree_in_descendant_space = |
| 1050 clip_rect_from_ancestor_in_descendant_space; | 1050 clip_rect_from_ancestor_in_descendant_space; |
| 1051 | 1051 |
| 1052 // Layers that are not their own render_target will render into the target | 1052 // Layers that are not their own render_target will render into the target |
| 1053 // of their nearest ancestor. | 1053 // of their nearest ancestor. |
| 1054 layer_draw_properties.render_target = layer->parent()->render_target(); | 1054 layer_draw_properties.render_target = layer->parent()->render_target(); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 if (adjust_text_aa) | 1057 if (adjust_text_aa) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 descendants.push_back(child); | 1128 descendants.push_back(child); |
| 1129 } | 1129 } |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 if (layer->render_surface() && !IsRootLayer(layer) && | 1132 if (layer->render_surface() && !IsRootLayer(layer) && |
| 1133 layer->render_surface()->layer_list().empty()) { | 1133 layer->render_surface()->layer_list().empty()) { |
| 1134 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 1134 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
| 1135 return; | 1135 return; |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 // Compute the total drawableContentRect for this subtree (the rect is in | 1138 // Compute the total drawable_content_rect for this subtree (the rect is in |
| 1139 // targetSurface space). | 1139 // target surface space). |
| 1140 gfx::Rect local_drawable_content_rect_of_subtree = | 1140 gfx::Rect local_drawable_content_rect_of_subtree = |
| 1141 accumulated_drawable_content_rect_of_children; | 1141 accumulated_drawable_content_rect_of_children; |
| 1142 if (layer->DrawsContent()) | 1142 if (layer->DrawsContent()) |
| 1143 local_drawable_content_rect_of_subtree.Union(rect_in_target_space); | 1143 local_drawable_content_rect_of_subtree.Union(rect_in_target_space); |
| 1144 if (subtree_should_be_clipped) | 1144 if (subtree_should_be_clipped) |
| 1145 local_drawable_content_rect_of_subtree.Intersect(clip_rect_for_subtree); | 1145 local_drawable_content_rect_of_subtree.Intersect(clip_rect_for_subtree); |
| 1146 | 1146 |
| 1147 // Compute the layer's drawable content rect (the rect is in targetSurface | 1147 // Compute the layer's drawable content rect (the rect is in target surface |
| 1148 // space). | 1148 // space). |
| 1149 layer_draw_properties.drawable_content_rect = rect_in_target_space; | 1149 layer_draw_properties.drawable_content_rect = rect_in_target_space; |
| 1150 if (subtree_should_be_clipped) { | 1150 if (subtree_should_be_clipped) { |
| 1151 layer_draw_properties.drawable_content_rect. | 1151 layer_draw_properties.drawable_content_rect. |
| 1152 Intersect(clip_rect_for_subtree); | 1152 Intersect(clip_rect_for_subtree); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 // Tell the layer the rect that is clipped by. In theory we could use a | 1155 // Tell the layer the rect that is clipped by. In theory we could use a |
| 1156 // tighter clipRect here (drawableContentRect), but that actually does not | 1156 // tighter clip rect here (drawable_content_rect), but that actually does not |
| 1157 // reduce how much would be drawn, and instead it would create unnecessary | 1157 // reduce how much would be drawn, and instead it would create unnecessary |
| 1158 // changes to scissor state affecting GPU performance. | 1158 // changes to scissor state affecting GPU performance. |
| 1159 layer_draw_properties.is_clipped = subtree_should_be_clipped; | 1159 layer_draw_properties.is_clipped = subtree_should_be_clipped; |
| 1160 if (subtree_should_be_clipped) { | 1160 if (subtree_should_be_clipped) { |
| 1161 layer_draw_properties.clip_rect = clip_rect_for_subtree; | 1161 layer_draw_properties.clip_rect = clip_rect_for_subtree; |
| 1162 } else { | 1162 } else { |
| 1163 // Initialize the clipRect to a safe value that will not clip the | 1163 // Initialize the clip rect to a safe value that will not clip the |
| 1164 // layer, just in case clipping is still accidentally used. | 1164 // layer, just in case clipping is still accidentally used. |
| 1165 layer_draw_properties.clip_rect = rect_in_target_space; | 1165 layer_draw_properties.clip_rect = rect_in_target_space; |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 // Compute the layer's visible content rect (the rect is in content space) | 1168 // Compute the layer's visible content rect (the rect is in content space) |
| 1169 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( | 1169 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( |
| 1170 layer, clip_rect_for_subtree_in_descendant_space, rect_in_target_space); | 1170 layer, clip_rect_for_subtree_in_descendant_space, rect_in_target_space); |
| 1171 | 1171 |
| 1172 // Compute the remaining properties for the render surface, if the layer has | 1172 // Compute the remaining properties for the render surface, if the layer has |
| 1173 // one. | 1173 // one. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 float page_scale_factor, | 1292 float page_scale_factor, |
| 1293 int max_texture_size, | 1293 int max_texture_size, |
| 1294 bool can_use_lcd_text, | 1294 bool can_use_lcd_text, |
| 1295 std::vector<scoped_refptr<Layer> >* render_surface_layer_list) { | 1295 std::vector<scoped_refptr<Layer> >* render_surface_layer_list) { |
| 1296 gfx::Rect total_drawable_content_rect; | 1296 gfx::Rect total_drawable_content_rect; |
| 1297 gfx::Transform identity_matrix; | 1297 gfx::Transform identity_matrix; |
| 1298 gfx::Transform device_scale_transform; | 1298 gfx::Transform device_scale_transform; |
| 1299 device_scale_transform.Scale(device_scale_factor, device_scale_factor); | 1299 device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
| 1300 std::vector<scoped_refptr<Layer> > dummy_layer_list; | 1300 std::vector<scoped_refptr<Layer> > dummy_layer_list; |
| 1301 | 1301 |
| 1302 // The root layer's render_surface should receive the deviceViewport as the | 1302 // The root layer's render_surface should receive the device viewport as the |
| 1303 // initial clipRect. | 1303 // initial clip rect. |
| 1304 bool subtree_should_be_clipped = true; | 1304 bool subtree_should_be_clipped = true; |
| 1305 gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); | 1305 gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); |
| 1306 bool update_tile_priorities = false; | 1306 bool update_tile_priorities = false; |
| 1307 | 1307 |
| 1308 // This function should have received a root layer. | 1308 // This function should have received a root layer. |
| 1309 DCHECK(IsRootLayer(root_layer)); | 1309 DCHECK(IsRootLayer(root_layer)); |
| 1310 | 1310 |
| 1311 PreCalculateMetaInformation<Layer>(root_layer); | 1311 PreCalculateMetaInformation<Layer>(root_layer); |
| 1312 CalculateDrawPropertiesInternal<Layer, | 1312 CalculateDrawPropertiesInternal<Layer, |
| 1313 std::vector<scoped_refptr<Layer> >, | 1313 std::vector<scoped_refptr<Layer> >, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1325 max_texture_size, | 1325 max_texture_size, |
| 1326 device_scale_factor, | 1326 device_scale_factor, |
| 1327 page_scale_factor, | 1327 page_scale_factor, |
| 1328 can_use_lcd_text, | 1328 can_use_lcd_text, |
| 1329 &total_drawable_content_rect, | 1329 &total_drawable_content_rect, |
| 1330 update_tile_priorities); | 1330 update_tile_priorities); |
| 1331 | 1331 |
| 1332 // The dummy layer list should not have been used. | 1332 // The dummy layer list should not have been used. |
| 1333 DCHECK_EQ(dummy_layer_list.size(), 0); | 1333 DCHECK_EQ(dummy_layer_list.size(), 0); |
| 1334 // A root layer render_surface should always exist after | 1334 // A root layer render_surface should always exist after |
| 1335 // calculateDrawProperties. | 1335 // CalculateDrawProperties. |
| 1336 DCHECK(root_layer->render_surface()); | 1336 DCHECK(root_layer->render_surface()); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 void LayerTreeHostCommon::CalculateDrawProperties( | 1339 void LayerTreeHostCommon::CalculateDrawProperties( |
| 1340 LayerImpl* root_layer, | 1340 LayerImpl* root_layer, |
| 1341 gfx::Size device_viewport_size, | 1341 gfx::Size device_viewport_size, |
| 1342 float device_scale_factor, | 1342 float device_scale_factor, |
| 1343 float page_scale_factor, | 1343 float page_scale_factor, |
| 1344 int max_texture_size, | 1344 int max_texture_size, |
| 1345 bool can_use_lcd_text, | 1345 bool can_use_lcd_text, |
| 1346 std::vector<LayerImpl*>* render_surface_layer_list, | 1346 std::vector<LayerImpl*>* render_surface_layer_list, |
| 1347 bool update_tile_priorities) { | 1347 bool update_tile_priorities) { |
| 1348 gfx::Rect total_drawable_content_rect; | 1348 gfx::Rect total_drawable_content_rect; |
| 1349 gfx::Transform identity_matrix; | 1349 gfx::Transform identity_matrix; |
| 1350 gfx::Transform device_scale_transform; | 1350 gfx::Transform device_scale_transform; |
| 1351 device_scale_transform.Scale(device_scale_factor, device_scale_factor); | 1351 device_scale_transform.Scale(device_scale_factor, device_scale_factor); |
| 1352 std::vector<LayerImpl*> dummy_layer_list; | 1352 std::vector<LayerImpl*> dummy_layer_list; |
| 1353 LayerSorter layer_sorter; | 1353 LayerSorter layer_sorter; |
| 1354 | 1354 |
| 1355 // The root layer's render_surface should receive the deviceViewport as the | 1355 // The root layer's render_surface should receive the device viewport as the |
| 1356 // initial clipRect. | 1356 // initial clip rect. |
| 1357 bool subtree_should_be_clipped = true; | 1357 bool subtree_should_be_clipped = true; |
| 1358 gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); | 1358 gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); |
| 1359 | 1359 |
| 1360 // This function should have received a root layer. | 1360 // This function should have received a root layer. |
| 1361 DCHECK(IsRootLayer(root_layer)); | 1361 DCHECK(IsRootLayer(root_layer)); |
| 1362 | 1362 |
| 1363 PreCalculateMetaInformation<LayerImpl>(root_layer); | 1363 PreCalculateMetaInformation<LayerImpl>(root_layer); |
| 1364 CalculateDrawPropertiesInternal<LayerImpl, | 1364 CalculateDrawPropertiesInternal<LayerImpl, |
| 1365 std::vector<LayerImpl*>, | 1365 std::vector<LayerImpl*>, |
| 1366 RenderSurfaceImpl>( | 1366 RenderSurfaceImpl>( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1378 max_texture_size, | 1378 max_texture_size, |
| 1379 device_scale_factor, | 1379 device_scale_factor, |
| 1380 page_scale_factor, | 1380 page_scale_factor, |
| 1381 can_use_lcd_text, | 1381 can_use_lcd_text, |
| 1382 &total_drawable_content_rect, | 1382 &total_drawable_content_rect, |
| 1383 update_tile_priorities); | 1383 update_tile_priorities); |
| 1384 | 1384 |
| 1385 // The dummy layer list should not have been used. | 1385 // The dummy layer list should not have been used. |
| 1386 DCHECK_EQ(dummy_layer_list.size(), 0); | 1386 DCHECK_EQ(dummy_layer_list.size(), 0); |
| 1387 // A root layer render_surface should always exist after | 1387 // A root layer render_surface should always exist after |
| 1388 // calculateDrawProperties. | 1388 // CalculateDrawProperties. |
| 1389 DCHECK(root_layer->render_surface()); | 1389 DCHECK(root_layer->render_surface()); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 static bool PointHitsRect( | 1392 static bool PointHitsRect( |
| 1393 gfx::PointF screen_space_point, | 1393 gfx::PointF screen_space_point, |
| 1394 const gfx::Transform& local_space_to_screen_space_transform, | 1394 const gfx::Transform& local_space_to_screen_space_transform, |
| 1395 gfx::RectF local_space_rect) { | 1395 gfx::RectF local_space_rect) { |
| 1396 // If the transform is not invertible, then assume that this point doesn't hit | 1396 // If the transform is not invertible, then assume that this point doesn't hit |
| 1397 // this rect. | 1397 // this rect. |
| 1398 gfx::Transform inverse_local_space_to_screen_space( | 1398 gfx::Transform inverse_local_space_to_screen_space( |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 // At this point, we think the point does hit the touch event handler region | 1574 // At this point, we think the point does hit the touch event handler region |
| 1575 // on the layer, but we need to walk up the parents to ensure that the layer | 1575 // on the layer, but we need to walk up the parents to ensure that the layer |
| 1576 // was not clipped in such a way that the hit point actually should not hit | 1576 // was not clipped in such a way that the hit point actually should not hit |
| 1577 // the layer. | 1577 // the layer. |
| 1578 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 1578 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 1579 return false; | 1579 return false; |
| 1580 | 1580 |
| 1581 return true; | 1581 return true; |
| 1582 } | 1582 } |
| 1583 } // namespace cc | 1583 } // namespace cc |
| OLD | NEW |