Changeset 91322 in webkit
- Timestamp:
- Jul 19, 2011 5:07:39 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r91320 r91322 1 2011-07-19 James Robinson <jamesr@chromium.org> 2 3 [chromium] LayerRendererChromium shouldn't be a friend of RenderSurfaceChromium 4 https://bugs.webkit.org/show_bug.cgi?id=64834 5 6 Reviewed by Kenneth Russell. 7 8 Uses setters and getters to access RenderSurfaceChromium's private member variables instead of directly 9 accessing them via a friend declaration. This cleans up a minor code smell and will be helpful for future 10 refactoring. 11 12 Refactor only, no change in behavior. Tested by compositing/ tests. 13 14 * platform/graphics/chromium/LayerRendererChromium.cpp: 15 (WebCore::LayerRendererChromium::updateLayers): 16 (WebCore::LayerRendererChromium::paintLayerContents): 17 (WebCore::LayerRendererChromium::drawLayers): 18 (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces): 19 (WebCore::LayerRendererChromium::updateCompositorResources): 20 (WebCore::LayerRendererChromium::getOffscreenLayerTexture): 21 (WebCore::LayerRendererChromium::copyOffscreenTextureToDisplay): 22 (WebCore::LayerRendererChromium::useRenderSurface): 23 (WebCore::LayerRendererChromium::drawLayer): 24 (WebCore::LayerRendererChromium::setScissorToRect): 25 * platform/graphics/chromium/RenderSurfaceChromium.cpp: 26 (WebCore::RenderSurfaceChromium::clearLayerList): 27 * platform/graphics/chromium/RenderSurfaceChromium.h: 28 (WebCore::RenderSurfaceChromium::layerList): 29 (WebCore::RenderSurfaceChromium::contentRect): 30 (WebCore::RenderSurfaceChromium::setContentRect): 31 (WebCore::RenderSurfaceChromium::drawOpacity): 32 (WebCore::RenderSurfaceChromium::setDrawOpacity): 33 (WebCore::RenderSurfaceChromium::drawTransform): 34 (WebCore::RenderSurfaceChromium::setDrawTransform): 35 (WebCore::RenderSurfaceChromium::maskLayer): 36 (WebCore::RenderSurfaceChromium::setMaskLayer): 37 (WebCore::RenderSurfaceChromium::originTransform): 38 (WebCore::RenderSurfaceChromium::setOriginTransform): 39 (WebCore::RenderSurfaceChromium::replicaDrawTransform): 40 (WebCore::RenderSurfaceChromium::setReplicaDrawTransform): 41 (WebCore::RenderSurfaceChromium::scissorRect): 42 (WebCore::RenderSurfaceChromium::setScissorRect): 43 (WebCore::RenderSurfaceChromium::skipsDraw): 44 (WebCore::RenderSurfaceChromium::setSkipsDraw): 45 (WebCore::RenderSurfaceChromium::contentsTexture): 46 1 47 2011-07-19 Jessie Berlin <jberlin@apple.com> 2 48 -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r90963 r91322 338 338 ASSERT(rootDrawLayer->renderSurface()); 339 339 340 rootDrawLayer->renderSurface()-> m_contentRect = IntRect(IntPoint(0, 0), m_viewportVisibleRect.size());340 rootDrawLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size())); 341 341 342 342 IntRect rootScissorRect(m_viewportVisibleRect); … … 350 350 351 351 TransformationMatrix identityMatrix; 352 m_defaultRenderSurface-> m_layerList.clear();352 m_defaultRenderSurface->clearLayerList(); 353 353 // Unfortunately, updatePropertiesAndRenderSurfaces() currently both updates the layers and updates the draw state 354 354 // (transforms, etc). It'd be nicer if operations on the presentation layers happened later, but the draw 355 355 // transforms are needed by large layers to determine visibility. Tiling will fix this by eliminating the 356 356 // concept of a large content layer. 357 updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface-> m_layerList);357 updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList()); 358 358 359 359 #ifndef NDEBUG … … 433 433 // Render surfaces whose drawable area has zero width or height 434 434 // will have no layers associated with them and should be skipped. 435 if (!renderSurface-> m_layerList.size())435 if (!renderSurface->layerList().size()) 436 436 continue; 437 437 438 if (!renderSurface-> m_drawOpacity)438 if (!renderSurface->drawOpacity()) 439 439 continue; 440 440 441 LayerList& layerList = renderSurface-> m_layerList;441 LayerList& layerList = renderSurface->layerList(); 442 442 ASSERT(layerList.size()); 443 443 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { … … 538 538 ASSERT(renderSurface); 539 539 540 renderSurface-> m_skipsDraw = true;540 renderSurface->setSkipsDraw(true); 541 541 542 542 // Render surfaces whose drawable area has zero width or height 543 543 // will have no layers associated with them and should be skipped. 544 if (!renderSurface-> m_layerList.size())544 if (!renderSurface->layerList().size()) 545 545 continue; 546 546 547 547 // Skip completely transparent render surfaces. 548 if (!renderSurface-> m_drawOpacity)548 if (!renderSurface->drawOpacity()) 549 549 continue; 550 550 551 551 if (useRenderSurface(renderSurface)) { 552 renderSurface-> m_skipsDraw = false;552 renderSurface->setSkipsDraw(false); 553 553 554 554 if (renderSurfaceLayer != rootDrawLayer) { … … 559 559 } 560 560 561 LayerList& layerList = renderSurface-> m_layerList;561 LayerList& layerList = renderSurface->layerList(); 562 562 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) 563 563 drawLayer(layerList[layerIndex].get(), renderSurface); … … 751 751 752 752 // Layer's opacity will be applied when drawing the render surface. 753 renderSurface->m_drawOpacity = layer->opacity();753 float drawOpacity = layer->opacity(); 754 754 if (layer->parent() && layer->parent()->preserves3D()) 755 renderSurface->m_drawOpacity *= layer->parent()->drawOpacity(); 755 drawOpacity *= layer->parent()->drawOpacity(); 756 renderSurface->setDrawOpacity(drawOpacity); 756 757 layer->setDrawOpacity(1); 757 758 758 759 TransformationMatrix layerOriginTransform = combinedTransform; 759 760 layerOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0); 760 renderSurface-> m_originTransform = layerOriginTransform;761 renderSurface->setOriginTransform(layerOriginTransform); 761 762 762 763 // The render surface scissor rect is the scissor rect that needs to 763 764 // be applied before drawing the render surface onto its containing 764 765 // surface and is therefore expressed in the parent's coordinate system. 765 renderSurface-> m_scissorRect = layer->parent() ? layer->parent()->scissorRect() : layer->scissorRect();766 767 renderSurface-> m_layerList.clear();766 renderSurface->setScissorRect(layer->parent() ? layer->parent()->scissorRect() : layer->scissorRect()); 767 768 renderSurface->clearLayerList(); 768 769 769 770 if (layer->maskLayer()) { 770 renderSurface-> m_maskLayer = layer->maskLayer();771 renderSurface->setMaskLayer(layer->maskLayer()); 771 772 layer->maskLayer()->setTargetRenderSurface(renderSurface); 772 773 } else 773 renderSurface-> m_maskLayer = 0;774 renderSurface->setMaskLayer(0); 774 775 775 776 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) … … 846 847 sublayerMatrix.translate3d(-bounds.width() * 0.5, -bounds.height() * 0.5, 0); 847 848 848 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()-> m_layerList: layerList);849 LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->layerList() : layerList); 849 850 descendants.append(layer); 850 851 … … 876 877 if (layer->renderSurface() && layer != m_rootCCLayerImpl.get()) { 877 878 RenderSurfaceChromium* renderSurface = layer->renderSurface(); 878 renderSurface->m_contentRect = layer->drawableContentRect();879 FloatPoint surfaceCenter = renderSurface->contentRectCenter();879 IntRect renderSurfaceContentRect = layer->drawableContentRect(); 880 FloatPoint surfaceCenter = FloatRect(renderSurfaceContentRect).center(); 880 881 881 882 // Restrict the RenderSurface size to the portion that's visible. … … 885 886 // clipped. 886 887 if (!layer->replicaLayer()) { 887 if (!renderSurface-> m_scissorRect.isEmpty() && !renderSurface->m_contentRect.isEmpty()) {888 IntRect surfaceScissorRect = calculateVisibleRect(renderSurface-> m_scissorRect, renderSurface->m_contentRect, renderSurface->m_originTransform);889 renderSurface ->m_contentRect.intersect(surfaceScissorRect);888 if (!renderSurface->scissorRect().isEmpty() && !renderSurfaceContentRect.isEmpty()) { 889 IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->scissorRect(), renderSurfaceContentRect, renderSurface->originTransform()); 890 renderSurfaceContentRect.intersect(surfaceScissorRect); 890 891 } 891 FloatPoint clippedSurfaceCenter = renderSurface->contentRectCenter();892 FloatPoint clippedSurfaceCenter = FloatRect(renderSurfaceContentRect).center(); 892 893 centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter; 893 894 } … … 895 896 // The RenderSurface backing texture cannot exceed the maximum supported 896 897 // texture size. 897 renderSurface->m_contentRect.setWidth(std::min(renderSurface->m_contentRect.width(), m_maxTextureSize)); 898 renderSurface->m_contentRect.setHeight(std::min(renderSurface->m_contentRect.height(), m_maxTextureSize)); 899 900 if (renderSurface->m_contentRect.isEmpty()) 901 renderSurface->m_layerList.clear(); 898 renderSurfaceContentRect.setWidth(std::min(renderSurfaceContentRect.width(), m_maxTextureSize)); 899 renderSurfaceContentRect.setHeight(std::min(renderSurfaceContentRect.height(), m_maxTextureSize)); 900 901 if (renderSurfaceContentRect.isEmpty()) 902 renderSurface->clearLayerList(); 903 renderSurface->setContentRect(renderSurfaceContentRect); 902 904 903 905 // Since the layer starts a new render surface we need to adjust its … … 906 908 907 909 // Adjust the origin of the transform to be the center of the render surface. 908 renderSurface->m_drawTransform = renderSurface->m_originTransform; 909 renderSurface->m_drawTransform.translate3d(surfaceCenter.x() + centerOffsetDueToClipping.width(), surfaceCenter.y() + centerOffsetDueToClipping.height(), 0); 910 TransformationMatrix drawTransform = renderSurface->originTransform(); 911 drawTransform.translate3d(surfaceCenter.x() + centerOffsetDueToClipping.width(), surfaceCenter.y() + centerOffsetDueToClipping.height(), 0); 912 renderSurface->setDrawTransform(drawTransform); 910 913 911 914 // Compute the transformation matrix used to draw the replica of the render 912 915 // surface. 913 916 if (layer->replicaLayer()) { 914 renderSurface->m_replicaDrawTransform = renderSurface->m_originTransform; 915 renderSurface->m_replicaDrawTransform.translate3d(layer->replicaLayer()->position().x(), layer->replicaLayer()->position().y(), 0); 916 renderSurface->m_replicaDrawTransform.multiply(layer->replicaLayer()->transform()); 917 renderSurface->m_replicaDrawTransform.translate3d(surfaceCenter.x() - anchorPoint.x() * bounds.width(), surfaceCenter.y() - anchorPoint.y() * bounds.height(), 0); 917 TransformationMatrix replicaDrawTransform = renderSurface->originTransform(); 918 replicaDrawTransform.translate3d(layer->replicaLayer()->position().x(), layer->replicaLayer()->position().y(), 0); 919 replicaDrawTransform.multiply(layer->replicaLayer()->transform()); 920 replicaDrawTransform.translate3d(surfaceCenter.x() - anchorPoint.x() * bounds.width(), surfaceCenter.y() - anchorPoint.y() * bounds.height(), 0); 921 renderSurface->setReplicaDrawTransform(replicaDrawTransform); 918 922 } 919 923 } … … 933 937 ASSERT(renderSurface); 934 938 935 if (!renderSurface-> m_layerList.size() || !renderSurface->m_drawOpacity)939 if (!renderSurface->layerList().size() || !renderSurface->drawOpacity()) 936 940 continue; 937 941 938 LayerList& layerList = renderSurface->m_layerList;942 const LayerList& layerList = renderSurface->layerList(); 939 943 ASSERT(layerList.size()); 940 944 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { … … 982 986 LayerTexture* LayerRendererChromium::getOffscreenLayerTexture() 983 987 { 984 return m_compositeOffscreen ? m_rootLayer->ccLayerImpl()->renderSurface()-> m_contentsTexture.get() : 0;988 return m_compositeOffscreen ? m_rootLayer->ccLayerImpl()->renderSurface()->contentsTexture() : 0; 985 989 } 986 990 … … 991 995 992 996 useRenderSurface(0); 993 m_defaultRenderSurface->m_drawTransform.makeIdentity();994 m_defaultRenderSurface->m_drawTransform.translate3d(0.5 * m_defaultRenderSurface->m_contentRect.width(),995 0.5 * m_defaultRenderSurface->m_contentRect.height(), 0);996 m_defaultRenderSurface-> m_drawOpacity = 1;997 m_defaultRenderSurface->draw(m_defaultRenderSurface-> m_contentRect);997 TransformationMatrix drawTransform; 998 drawTransform.translate3d(0.5 * m_defaultRenderSurface->contentRect().width(), 0.5 * m_defaultRenderSurface->contentRect().height(), 0); 999 m_defaultRenderSurface->setDrawTransform(drawTransform); 1000 m_defaultRenderSurface->setDrawOpacity(1); 1001 m_defaultRenderSurface->draw(m_defaultRenderSurface->contentRect()); 998 1002 } 999 1003 } … … 1009 1013 GLC(m_context.get(), m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)); 1010 1014 if (renderSurface) 1011 setDrawViewportRect(renderSurface-> m_contentRect, true);1015 setDrawViewportRect(renderSurface->contentRect(), true); 1012 1016 else 1013 setDrawViewportRect(m_defaultRenderSurface-> m_contentRect, true);1017 setDrawViewportRect(m_defaultRenderSurface->contentRect(), true); 1014 1018 return true; 1015 1019 } … … 1020 1024 return false; 1021 1025 1022 renderSurface-> m_contentsTexture->framebufferTexture2D();1026 renderSurface->contentsTexture()->framebufferTexture2D(); 1023 1027 1024 1028 #if !defined ( NDEBUG ) … … 1029 1033 #endif 1030 1034 1031 setDrawViewportRect(renderSurface-> m_contentRect, false);1035 setDrawViewportRect(renderSurface->contentRect(), false); 1032 1036 return true; 1033 1037 } … … 1061 1065 1062 1066 1063 // FIXME: Need to take into account the commulative render surface transforms all the way from1064 // the default render surface in order to determine visibility.1065 TransformationMatrix combinedDrawMatrix = (layer->targetRenderSurface() ? layer->targetRenderSurface()->drawTransform().multiply(layer->drawTransform()) : layer->drawTransform());1066 1067 1067 if (!layer->doubleSided()) { 1068 // FIXME: Need to take into account the cumulative render surface transforms all the way from 1069 // the default render surface in order to determine visibility. 1070 TransformationMatrix combinedDrawMatrix; 1071 if (layer->targetRenderSurface()) { 1072 combinedDrawMatrix = layer->targetRenderSurface()->drawTransform(); 1073 combinedDrawMatrix.multiply(layer->drawTransform()); 1074 } else 1075 combinedDrawMatrix = layer->drawTransform(); 1076 1068 1077 FloatRect layerRect(FloatPoint(0, 0), FloatSize(layer->bounds())); 1069 1078 FloatQuad mappedLayer = combinedDrawMatrix.mapQuad(FloatQuad(layerRect)); … … 1087 1096 void LayerRendererChromium::setScissorToRect(const IntRect& scissorRect) 1088 1097 { 1089 IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface-> m_contentRect : m_defaultRenderSurface->m_contentRect);1098 IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface->contentRect() : m_defaultRenderSurface->contentRect()); 1090 1099 1091 1100 GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST)); … … 1099 1108 int scissorY; 1100 1109 if (m_currentRenderSurface == m_defaultRenderSurface && !m_compositeOffscreen) 1101 scissorY = m_currentRenderSurface-> m_contentRect.height() - (scissorRect.maxY() - m_currentRenderSurface->m_contentRect.y());1110 scissorY = m_currentRenderSurface->contentRect().height() - (scissorRect.maxY() - m_currentRenderSurface->contentRect().y()); 1102 1111 else 1103 1112 scissorY = scissorRect.y() - contentRect.y(); -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp
r90589 r91322 174 174 } 175 175 176 void RenderSurfaceChromium::clearLayerList() 177 { 178 m_layerList.clear(); 179 } 180 176 181 String RenderSurfaceChromium::name() const 177 182 { -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
r90260 r91322 46 46 class RenderSurfaceChromium { 47 47 WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium); 48 friend class LayerRendererChromium;49 48 public: 50 49 explicit RenderSurfaceChromium(CCLayerImpl*); … … 59 58 void dumpSurface(TextStream&, int indent) const; 60 59 61 FloatPoint contentRectCenter() const { return FloatRect(m_contentRect).center(); }62 IntRect contentRect() const { return m_contentRect; }63 64 60 // Returns the rect that encloses the RenderSurface including any reflection. 65 61 FloatRect drawableContentRect() const; 66 62 67 TransformationMatrix drawTransform() const { return m_drawTransform; } 63 Vector<RefPtr<CCLayerImpl> >& layerList() { return m_layerList; } 64 void clearLayerList(); 65 66 const IntRect& contentRect() const { return m_contentRect; } 67 void setContentRect(const IntRect& contentRect) { m_contentRect = contentRect; } 68 69 float drawOpacity() const { return m_drawOpacity; } 70 void setDrawOpacity(float drawOpacity) { m_drawOpacity = drawOpacity; } 71 72 const TransformationMatrix& drawTransform() const { return m_drawTransform; } 73 void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; } 74 75 CCLayerImpl* maskLayer() const { return m_maskLayer; } 76 void setMaskLayer(CCLayerImpl* maskLayer) { m_maskLayer = maskLayer; } 77 78 const TransformationMatrix& originTransform() const { return m_originTransform; } 79 void setOriginTransform(const TransformationMatrix& originTransform) { m_originTransform = originTransform; } 80 81 const TransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; } 82 void setReplicaDrawTransform(const TransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; } 83 84 const IntRect& scissorRect() const { return m_scissorRect; } 85 void setScissorRect(const IntRect& scissorRect) { m_scissorRect = scissorRect; } 86 87 bool skipsDraw() const { return m_skipsDraw; } 88 void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; } 89 90 LayerTexture* contentsTexture() const { return m_contentsTexture.get(); } 68 91 69 92 typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
Note: See TracChangeset
for help on using the changeset viewer.