OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 layerLocalTransform.multiply(layer->transform()); | 651 layerLocalTransform.multiply(layer->transform()); |
652 // LT = Tr[l] * M[l] * Tr[c] | 652 // LT = Tr[l] * M[l] * Tr[c] |
653 layerLocalTransform.translate3d(centerOffsetX, centerOffsetY, -layer->anchor
PointZ()); | 653 layerLocalTransform.translate3d(centerOffsetX, centerOffsetY, -layer->anchor
PointZ()); |
654 | 654 |
655 TransformationMatrix combinedTransform = parentMatrix; | 655 TransformationMatrix combinedTransform = parentMatrix; |
656 combinedTransform = combinedTransform.multiply(layerLocalTransform); | 656 combinedTransform = combinedTransform.multiply(layerLocalTransform); |
657 | 657 |
658 FloatRect layerRect(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().h
eight(), layer->bounds().width(), layer->bounds().height()); | 658 FloatRect layerRect(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().h
eight(), layer->bounds().width(), layer->bounds().height()); |
659 IntRect transformedLayerRect; | 659 IntRect transformedLayerRect; |
660 | 660 |
| 661 // FIXME: This seems like the wrong place to set this |
| 662 layer->setUsesLayerScissor(false); |
| 663 |
661 // The layer and its descendants render on a new RenderSurface if any of | 664 // The layer and its descendants render on a new RenderSurface if any of |
662 // these conditions hold: | 665 // these conditions hold: |
663 // 1. The layer clips its descendants and its transform is not a simple tran
slation. | 666 // 1. The layer clips its descendants and its transform is not a simple tran
slation. |
664 // 2. If the layer has opacity != 1 and does not have a preserves-3d transfo
rm style. | 667 // 2. If the layer has opacity != 1 and does not have a preserves-3d transfo
rm style. |
665 // 3. The layer uses a mask | 668 // 3. The layer uses a mask |
666 // 4. The layer has a replica (used for reflections) | 669 // 4. The layer has a replica (used for reflections) |
667 // 5. The layer doesn't preserve-3d but is the child of a layer which does. | 670 // 5. The layer doesn't preserve-3d but is the child of a layer which does. |
668 // If a layer preserves-3d then we don't create a RenderSurface for it to av
oid flattening | 671 // If a layer preserves-3d then we don't create a RenderSurface for it to av
oid flattening |
669 // out its children. The opacity value of the children layers is multiplied
by the opacity | 672 // out its children. The opacity value of the children layers is multiplied
by the opacity |
670 // of their parent. | 673 // of their parent. |
(...skipping 16 matching lines...) Expand all Loading... |
687 | 690 |
688 // Layer's opacity will be applied when drawing the render surface. | 691 // Layer's opacity will be applied when drawing the render surface. |
689 renderSurface->m_drawOpacity = layer->opacity(); | 692 renderSurface->m_drawOpacity = layer->opacity(); |
690 if (layer->parent() && layer->parent()->preserves3D()) | 693 if (layer->parent() && layer->parent()->preserves3D()) |
691 renderSurface->m_drawOpacity *= layer->parent()->drawOpacity(); | 694 renderSurface->m_drawOpacity *= layer->parent()->drawOpacity(); |
692 layer->setDrawOpacity(1); | 695 layer->setDrawOpacity(1); |
693 | 696 |
694 TransformationMatrix layerOriginTransform = combinedTransform; | 697 TransformationMatrix layerOriginTransform = combinedTransform; |
695 layerOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.he
ight(), 0); | 698 layerOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.he
ight(), 0); |
696 renderSurface->m_originTransform = layerOriginTransform; | 699 renderSurface->m_originTransform = layerOriginTransform; |
697 layer->setScissorRect(IntRect()); | |
698 | 700 |
699 // The render surface scissor rect is the scissor rect that needs to | 701 // The render surface scissor rect is the scissor rect that needs to |
700 // be applied before drawing the render surface onto its containing | 702 // be applied before drawing the render surface onto its containing |
701 // surface and is therefore expressed in the parent's coordinate system. | 703 // surface and is therefore expressed in the parent's coordinate system. |
702 renderSurface->m_scissorRect = layer->parent() ? layer->parent()->scisso
rRect() : layer->scissorRect(); | 704 renderSurface->m_scissorRect = layer->parent() ? layer->parent()->scisso
rRect() : layer->scissorRect(); |
703 | 705 |
704 renderSurface->m_layerList.clear(); | 706 renderSurface->m_layerList.clear(); |
705 | 707 |
706 if (layer->maskLayer()) { | 708 if (layer->maskLayer()) { |
707 renderSurface->m_maskLayer = layer->maskLayer(); | 709 renderSurface->m_maskLayer = layer->maskLayer(); |
(...skipping 11 matching lines...) Expand all Loading... |
719 transformedLayerRect = enclosingIntRect(layer->drawTransform().mapRect(l
ayerRect)); | 721 transformedLayerRect = enclosingIntRect(layer->drawTransform().mapRect(l
ayerRect)); |
720 | 722 |
721 layer->setDrawOpacity(layer->opacity()); | 723 layer->setDrawOpacity(layer->opacity()); |
722 | 724 |
723 if (layer->parent()) { | 725 if (layer->parent()) { |
724 if (layer->parent()->preserves3D()) | 726 if (layer->parent()->preserves3D()) |
725 layer->setDrawOpacity(layer->drawOpacity() * layer->parent()->dra
wOpacity()); | 727 layer->setDrawOpacity(layer->drawOpacity() * layer->parent()->dra
wOpacity()); |
726 | 728 |
727 // Layers inherit the scissor rect from their parent. | 729 // Layers inherit the scissor rect from their parent. |
728 layer->setScissorRect(layer->parent()->scissorRect()); | 730 layer->setScissorRect(layer->parent()->scissorRect()); |
| 731 if (layer->parent()->usesLayerScissor()) |
| 732 layer->setUsesLayerScissor(true); |
729 | 733 |
730 layer->setTargetRenderSurface(layer->parent()->targetRenderSurface()
); | 734 layer->setTargetRenderSurface(layer->parent()->targetRenderSurface()
); |
731 } | 735 } |
732 | 736 |
733 if (layer != m_rootCCLayerImpl.get()) | 737 if (layer != m_rootCCLayerImpl.get()) |
734 layer->clearRenderSurface(); | 738 layer->clearRenderSurface(); |
735 | 739 |
736 if (layer->masksToBounds()) { | 740 if (layer->masksToBounds()) { |
737 IntRect scissor = transformedLayerRect; | 741 IntRect scissor = transformedLayerRect; |
738 if (!layer->scissorRect().isEmpty()) | 742 if (!layer->scissorRect().isEmpty()) |
739 scissor.intersect(layer->scissorRect()); | 743 scissor.intersect(layer->scissorRect()); |
740 layer->setScissorRect(scissor); | 744 layer->setScissorRect(scissor); |
| 745 layer->setUsesLayerScissor(true); |
741 } | 746 } |
742 } | 747 } |
743 | 748 |
744 if (layer->renderSurface()) | 749 if (layer->renderSurface()) |
745 layer->setTargetRenderSurface(layer->renderSurface()); | 750 layer->setTargetRenderSurface(layer->renderSurface()); |
746 else { | 751 else { |
747 ASSERT(layer->parent()); | 752 ASSERT(layer->parent()); |
748 layer->setTargetRenderSurface(layer->parent()->targetRenderSurface()); | 753 layer->setTargetRenderSurface(layer->parent()->targetRenderSurface()); |
749 } | 754 } |
750 | 755 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 } | 971 } |
967 | 972 |
968 if (!layer->drawsContent()) | 973 if (!layer->drawsContent()) |
969 return; | 974 return; |
970 | 975 |
971 if (layer->bounds().isEmpty()) { | 976 if (layer->bounds().isEmpty()) { |
972 layer->unreserveContentsTexture(); | 977 layer->unreserveContentsTexture(); |
973 return; | 978 return; |
974 } | 979 } |
975 | 980 |
976 setScissorToRect(layer->scissorRect()); | 981 if (layer->usesLayerScissor()) |
977 | 982 setScissorToRect(layer->scissorRect()); |
| 983 else |
| 984 GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST)
); |
978 IntRect targetSurfaceRect = m_currentRenderSurface ? m_currentRenderSurface-
>contentRect() : m_defaultRenderSurface->contentRect(); | 985 IntRect targetSurfaceRect = m_currentRenderSurface ? m_currentRenderSurface-
>contentRect() : m_defaultRenderSurface->contentRect(); |
979 IntRect scissorRect = layer->scissorRect(); | |
980 if (!scissorRect.isEmpty()) | |
981 targetSurfaceRect.intersect(scissorRect); | |
982 | 986 |
983 // Check if the layer falls within the visible bounds of the page. | 987 // Check if the layer falls within the visible bounds of the page. |
984 IntRect layerRect = layer->getDrawRect(); | 988 IntRect layerRect = layer->getDrawRect(); |
985 bool isLayerVisible = targetSurfaceRect.intersects(layerRect); | 989 bool isLayerVisible = targetSurfaceRect.intersects(layerRect); |
986 if (!isLayerVisible) { | 990 if (!isLayerVisible) { |
987 layer->unreserveContentsTexture(); | 991 layer->unreserveContentsTexture(); |
988 return; | 992 return; |
989 } | 993 } |
990 | 994 |
991 // FIXME: Need to take into account the commulative render surface transform
s all the way from | 995 // FIXME: Need to take into account the commulative render surface transform
s all the way from |
(...skipping 15 matching lines...) Expand all Loading... |
1007 } | 1011 } |
1008 | 1012 |
1009 layer->draw(targetSurfaceRect); | 1013 layer->draw(targetSurfaceRect); |
1010 | 1014 |
1011 // Draw the debug border if there is one. | 1015 // Draw the debug border if there is one. |
1012 layer->drawDebugBorder(); | 1016 layer->drawDebugBorder(); |
1013 } | 1017 } |
1014 | 1018 |
1015 // Sets the scissor region to the given rectangle. The coordinate system for the | 1019 // Sets the scissor region to the given rectangle. The coordinate system for the |
1016 // scissorRect has its origin at the top left corner of the current visible rect
. | 1020 // scissorRect has its origin at the top left corner of the current visible rect
. |
1017 void LayerRendererChromium::setScissorToRect(const IntRect& requestedScissor) | 1021 void LayerRendererChromium::setScissorToRect(const IntRect& scissorRect) |
1018 { | 1022 { |
1019 IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface->m_co
ntentRect : m_defaultRenderSurface->m_contentRect); | 1023 IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface->m_co
ntentRect : m_defaultRenderSurface->m_contentRect); |
1020 | 1024 |
1021 const IntRect scissorRect = requestedScissor.isEmpty() ? contentRect : reque
stedScissor; | 1025 GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST)); |
1022 | 1026 |
1023 // The scissor coordinates must be supplied in viewport space so we need to
offset | 1027 // The scissor coordinates must be supplied in viewport space so we need to
offset |
1024 // by the relative position of the top left corner of the current render sur
face. | 1028 // by the relative position of the top left corner of the current render sur
face. |
1025 int scissorX = scissorRect.x() - contentRect.x(); | 1029 int scissorX = scissorRect.x() - contentRect.x(); |
1026 // When rendering to the default render surface we're rendering upside down
so the top | 1030 // When rendering to the default render surface we're rendering upside down
so the top |
1027 // of the GL scissor is the bottom of our layer. | 1031 // of the GL scissor is the bottom of our layer. |
1028 // But, if rendering to offscreen texture, we reverse our sense of 'upside d
own'. | 1032 // But, if rendering to offscreen texture, we reverse our sense of 'upside d
own'. |
1029 int scissorY; | 1033 int scissorY; |
1030 if (m_currentRenderSurface == m_defaultRenderSurface && !m_compositeOffscree
n) | 1034 if (m_currentRenderSurface == m_defaultRenderSurface && !m_compositeOffscree
n) |
1031 scissorY = m_currentRenderSurface->m_contentRect.height() - (scissorRect
.maxY() - m_currentRenderSurface->m_contentRect.y()); | 1035 scissorY = m_currentRenderSurface->m_contentRect.height() - (scissorRect
.maxY() - m_currentRenderSurface->m_contentRect.y()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 if (layer->ccLayerImpl()->renderSurface()) | 1190 if (layer->ccLayerImpl()->renderSurface()) |
1187 layer->ccLayerImpl()->renderSurface()->dumpSurface(ts, indent); | 1191 layer->ccLayerImpl()->renderSurface()->dumpSurface(ts, indent); |
1188 | 1192 |
1189 for (size_t i = 0; i < layer->children().size(); ++i) | 1193 for (size_t i = 0; i < layer->children().size(); ++i) |
1190 dumpRenderSurfaces(ts, indent, layer->children()[i].get()); | 1194 dumpRenderSurfaces(ts, indent, layer->children()[i].get()); |
1191 } | 1195 } |
1192 | 1196 |
1193 } // namespace WebCore | 1197 } // namespace WebCore |
1194 | 1198 |
1195 #endif // USE(ACCELERATED_COMPOSITING) | 1199 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |