| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 void RenderLayer::updateTransformationMatrix() | 173 void RenderLayer::updateTransformationMatrix() |
| 174 { | 174 { |
| 175 if (m_transform) { | 175 if (m_transform) { |
| 176 RenderBox* box = renderBox(); | 176 RenderBox* box = renderBox(); |
| 177 ASSERT(box); | 177 ASSERT(box); |
| 178 m_transform->makeIdentity(); | 178 m_transform->makeIdentity(); |
| 179 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec
t().size(), RenderStyle::IncludeTransformOrigin); | 179 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec
t().size(), RenderStyle::IncludeTransformOrigin); |
| 180 makeMatrixRenderable(*m_transform); | 180 // FIXME(sky): We shouldn't need to do this once Skia has 4x4 matrix sup
port. |
| 181 // Until then, 3d transforms don't work right. |
| 182 m_transform->makeAffine(); |
| 181 } | 183 } |
| 182 } | 184 } |
| 183 | 185 |
| 184 void RenderLayer::updateTransform(const RenderStyle* oldStyle, RenderStyle* newS
tyle) | 186 void RenderLayer::updateTransform(const RenderStyle* oldStyle, RenderStyle* newS
tyle) |
| 185 { | 187 { |
| 186 if (oldStyle && newStyle->transformDataEquivalent(*oldStyle)) | 188 if (oldStyle && newStyle->transformDataEquivalent(*oldStyle)) |
| 187 return; | 189 return; |
| 188 | 190 |
| 189 // hasTransform() on the renderer is also true when there is transform-style
: preserve-3d or perspective set, | 191 // hasTransform() on the renderer is also true when there is transform-style
: preserve-3d or perspective set, |
| 190 // so check style too. | 192 // so check style too. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 225 |
| 224 if (shouldPreserve3D()) | 226 if (shouldPreserve3D()) |
| 225 renderingContext = this; | 227 renderingContext = this; |
| 226 | 228 |
| 227 for (RenderLayer* current = enclosingLayerForContainingBlock(this); current
&& current->shouldPreserve3D(); current = enclosingLayerForContainingBlock(curre
nt)) | 229 for (RenderLayer* current = enclosingLayerForContainingBlock(this); current
&& current->shouldPreserve3D(); current = enclosingLayerForContainingBlock(curre
nt)) |
| 228 renderingContext = current; | 230 renderingContext = current; |
| 229 | 231 |
| 230 return renderingContext; | 232 return renderingContext; |
| 231 } | 233 } |
| 232 | 234 |
| 233 TransformationMatrix RenderLayer::currentTransform(RenderStyle::ApplyTransformOr
igin applyOrigin) const | |
| 234 { | |
| 235 if (!m_transform) | |
| 236 return TransformationMatrix(); | |
| 237 | |
| 238 // m_transform includes transform-origin, so we need to recompute the transf
orm here. | |
| 239 if (applyOrigin == RenderStyle::ExcludeTransformOrigin) { | |
| 240 RenderBox* box = renderBox(); | |
| 241 TransformationMatrix currTransform; | |
| 242 box->style()->applyTransform(currTransform, box->pixelSnappedBorderBoxRe
ct().size(), RenderStyle::ExcludeTransformOrigin); | |
| 243 makeMatrixRenderable(currTransform); | |
| 244 return currTransform; | |
| 245 } | |
| 246 | |
| 247 return *m_transform; | |
| 248 } | |
| 249 | |
| 250 TransformationMatrix RenderLayer::renderableTransform() const | |
| 251 { | |
| 252 return m_transform ? *m_transform : TransformationMatrix(); | |
| 253 } | |
| 254 | |
| 255 RenderLayer* RenderLayer::enclosingOverflowClipLayer(IncludeSelfOrNot includeSel
f) const | 235 RenderLayer* RenderLayer::enclosingOverflowClipLayer(IncludeSelfOrNot includeSel
f) const |
| 256 { | 236 { |
| 257 const RenderLayer* layer = (includeSelf == IncludeSelf) ? this : parent(); | 237 const RenderLayer* layer = (includeSelf == IncludeSelf) ? this : parent(); |
| 258 while (layer) { | 238 while (layer) { |
| 259 if (layer->renderer()->hasOverflowClip()) | 239 if (layer->renderer()->hasOverflowClip()) |
| 260 return const_cast<RenderLayer*>(layer); | 240 return const_cast<RenderLayer*>(layer); |
| 261 | 241 |
| 262 layer = layer->parent(); | 242 layer = layer->parent(); |
| 263 } | 243 } |
| 264 return 0; | 244 return 0; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 clipRect.unite(transparencyClipBox(curr, rootLayer, transparencyBehavior
, DescendantsOfTransparencyClipBox, subPixelAccumulation)); | 441 clipRect.unite(transparencyClipBox(curr, rootLayer, transparencyBehavior
, DescendantsOfTransparencyClipBox, subPixelAccumulation)); |
| 462 } | 442 } |
| 463 | 443 |
| 464 static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLaye
r* rootLayer, TransparencyClipBoxBehavior transparencyBehavior, | 444 static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLaye
r* rootLayer, TransparencyClipBoxBehavior transparencyBehavior, |
| 465 TransparencyClipBoxMode transparencyMode, const LayoutSize& subPixelAccumula
tion) | 445 TransparencyClipBoxMode transparencyMode, const LayoutSize& subPixelAccumula
tion) |
| 466 { | 446 { |
| 467 // FIXME: Although this function completely ignores CSS-imposed clipping, we
did already intersect with the | 447 // FIXME: Although this function completely ignores CSS-imposed clipping, we
did already intersect with the |
| 468 // paintDirtyRect, and that should cut down on the amount we have to paint.
Still it | 448 // paintDirtyRect, and that should cut down on the amount we have to paint.
Still it |
| 469 // would be better to respect clips. | 449 // would be better to respect clips. |
| 470 | 450 |
| 471 if (rootLayer != layer && ((transparencyBehavior == PaintingTransparencyClip
Box && layer->paintsWithTransform()) | 451 if (rootLayer != layer && ((transparencyBehavior == PaintingTransparencyClip
Box && layer->transform()) |
| 472 || (transparencyBehavior == HitTestingTransparencyClipBox && layer->hasT
ransform()))) { | 452 || (transparencyBehavior == HitTestingTransparencyClipBox && layer->hasT
ransform()))) { |
| 473 // The best we can do here is to use enclosed bounding boxes to establis
h a "fuzzy" enough clip to encompass | 453 // The best we can do here is to use enclosed bounding boxes to establis
h a "fuzzy" enough clip to encompass |
| 474 // the transformed layer and all of its children. | 454 // the transformed layer and all of its children. |
| 475 const RenderLayer* rootLayerForTransform = rootLayer; | 455 const RenderLayer* rootLayerForTransform = rootLayer; |
| 476 LayoutPoint delta; | 456 LayoutPoint delta; |
| 477 layer->convertToLayerCoords(rootLayerForTransform, delta); | 457 layer->convertToLayerCoords(rootLayerForTransform, delta); |
| 478 | 458 |
| 479 delta.move(subPixelAccumulation); | 459 delta.move(subPixelAccumulation); |
| 480 IntPoint pixelSnappedDelta = roundedIntPoint(delta); | 460 IntPoint pixelSnappedDelta = roundedIntPoint(delta); |
| 481 TransformationMatrix transform; | 461 TransformationMatrix transform; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 if (!isSelfPaintingLayer()) | 839 if (!isSelfPaintingLayer()) |
| 860 return LayoutRect(); | 840 return LayoutRect(); |
| 861 | 841 |
| 862 if (!ancestorLayer) | 842 if (!ancestorLayer) |
| 863 ancestorLayer = this; | 843 ancestorLayer = this; |
| 864 | 844 |
| 865 // The root layer is always just the size of the document. | 845 // The root layer is always just the size of the document. |
| 866 if (isRootLayer()) | 846 if (isRootLayer()) |
| 867 return m_renderer->view()->unscaledDocumentRect(); | 847 return m_renderer->view()->unscaledDocumentRect(); |
| 868 | 848 |
| 869 const bool shouldIncludeTransform = paintsWithTransform(); | |
| 870 | |
| 871 LayoutRect localClipRect = clipper().localClipRect(); | 849 LayoutRect localClipRect = clipper().localClipRect(); |
| 872 if (localClipRect != PaintInfo::infiniteRect()) { | 850 if (localClipRect != PaintInfo::infiniteRect()) { |
| 873 if (shouldIncludeTransform) | 851 if (transform()) |
| 874 localClipRect = transform()->mapRect(localClipRect); | 852 localClipRect = transform()->mapRect(localClipRect); |
| 875 | 853 |
| 876 LayoutPoint delta; | 854 LayoutPoint delta; |
| 877 convertToLayerCoords(ancestorLayer, delta); | 855 convertToLayerCoords(ancestorLayer, delta); |
| 878 localClipRect.moveBy(delta); | 856 localClipRect.moveBy(delta); |
| 879 return localClipRect; | 857 return localClipRect; |
| 880 } | 858 } |
| 881 | 859 |
| 882 LayoutPoint origin; | 860 LayoutPoint origin; |
| 883 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); | 861 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); |
| 884 | 862 |
| 885 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); | 863 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); |
| 886 | 864 |
| 887 expandRectForReflectionAndStackingChildren(this, result); | 865 expandRectForReflectionAndStackingChildren(this, result); |
| 888 | 866 |
| 889 // FIXME: We can optimize the size of the composited layers, by not enlargin
g | 867 // FIXME: We can optimize the size of the composited layers, by not enlargin
g |
| 890 // filtered areas with the outsets if we know that the filter is going to re
nder in hardware. | 868 // filtered areas with the outsets if we know that the filter is going to re
nder in hardware. |
| 891 // https://bugs.webkit.org/show_bug.cgi?id=81239 | 869 // https://bugs.webkit.org/show_bug.cgi?id=81239 |
| 892 m_renderer->style()->filterOutsets().expandRect(result); | 870 m_renderer->style()->filterOutsets().expandRect(result); |
| 893 | 871 |
| 894 if (shouldIncludeTransform) | 872 if (transform()) |
| 895 result = transform()->mapRect(result); | 873 result = transform()->mapRect(result); |
| 896 | 874 |
| 897 LayoutPoint delta; | 875 LayoutPoint delta; |
| 898 convertToLayerCoords(ancestorLayer, delta); | 876 convertToLayerCoords(ancestorLayer, delta); |
| 899 result.moveBy(delta); | 877 result.moveBy(delta); |
| 900 return result; | 878 return result; |
| 901 } | 879 } |
| 902 | 880 |
| 903 bool RenderLayer::paintsWithTransform() const | |
| 904 { | |
| 905 // FIXME(sky): Remove | |
| 906 return transform(); | |
| 907 } | |
| 908 | |
| 909 bool RenderLayer::shouldBeSelfPaintingLayer() const | 881 bool RenderLayer::shouldBeSelfPaintingLayer() const |
| 910 { | 882 { |
| 911 return m_layerType == NormalLayer; | 883 return m_layerType == NormalLayer; |
| 912 } | 884 } |
| 913 | 885 |
| 914 void RenderLayer::updateSelfPaintingLayer() | 886 void RenderLayer::updateSelfPaintingLayer() |
| 915 { | 887 { |
| 916 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer(); | 888 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer(); |
| 917 if (this->isSelfPaintingLayer() == isSelfPaintingLayer) | 889 if (this->isSelfPaintingLayer() == isSelfPaintingLayer) |
| 918 return; | 890 return; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 } | 1021 } |
| 1050 } | 1022 } |
| 1051 | 1023 |
| 1052 void showLayerTree(const blink::RenderObject* renderer) | 1024 void showLayerTree(const blink::RenderObject* renderer) |
| 1053 { | 1025 { |
| 1054 if (!renderer) | 1026 if (!renderer) |
| 1055 return; | 1027 return; |
| 1056 showLayerTree(renderer->enclosingLayer()); | 1028 showLayerTree(renderer->enclosingLayer()); |
| 1057 } | 1029 } |
| 1058 #endif | 1030 #endif |
| OLD | NEW |