Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: Source/core/paint/DeprecatedPaintLayer.cpp

Issue 1304503002: Fix sub-pixel handling of transparency boxes in DPL (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons t DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* rootLayer, 996 static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons t DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* rootLayer,
997 DeprecatedPaintLayer::TransparencyClipBoxBehavior transparencyBehavior, cons t LayoutSize& subPixelAccumulation, GlobalPaintFlags globalPaintFlags) 997 DeprecatedPaintLayer::TransparencyClipBoxBehavior transparencyBehavior, cons t LayoutSize& subPixelAccumulation, GlobalPaintFlags globalPaintFlags)
998 { 998 {
999 // If we have a mask, then the clip is limited to the border box area (and t here is 999 // If we have a mask, then the clip is limited to the border box area (and t here is
1000 // no need to examine child layers). 1000 // no need to examine child layers).
1001 if (!layer->layoutObject()->hasMask()) { 1001 if (!layer->layoutObject()->hasMask()) {
1002 // Note: we don't have to walk z-order lists since transparent elements always establish 1002 // Note: we don't have to walk z-order lists since transparent elements always establish
1003 // a stacking container. This means we can just walk the layer tree dire ctly. 1003 // a stacking container. This means we can just walk the layer tree dire ctly.
1004 for (DeprecatedPaintLayer* curr = layer->firstChild(); curr; curr = curr ->nextSibling()) { 1004 for (DeprecatedPaintLayer* curr = layer->firstChild(); curr; curr = curr ->nextSibling()) {
1005 if (!layer->reflectionInfo() || layer->reflectionInfo()->reflectionL ayer() != curr) 1005 if (!layer->reflectionInfo() || layer->reflectionInfo()->reflectionL ayer() != curr)
1006 clipRect.unite(DeprecatedPaintLayer::transparencyClipBox(curr, r ootLayer, transparencyBehavior, DeprecatedPaintLayer::DescendantsOfTransparencyC lipBox, subPixelAccumulation, globalPaintFlags)); 1006 clipRect.unite(DeprecatedPaintLayer::transparencyClipBox(curr, r ootLayer, transparencyBehavior, DeprecatedPaintLayer::DescendantsOfTransparencyC lipBox, globalPaintFlags));
1007 } 1007 }
1008 } 1008 }
1009 1009
1010 // If we have a reflection, then we need to account for that when we push th e clip. Reflect our entire 1010 // If we have a reflection, then we need to account for that when we push th e clip. Reflect our entire
1011 // current transparencyClipBox to catch all child layers. 1011 // current transparencyClipBox to catch all child layers.
1012 // FIXME: Accelerated compositing will eventually want to do something smart here to avoid incorporating this 1012 // FIXME: Accelerated compositing will eventually want to do something smart here to avoid incorporating this
1013 // size into the parent layer. 1013 // size into the parent layer.
1014 if (layer->layoutObject()->hasReflection()) { 1014 if (layer->layoutObject()->hasReflection()) {
1015 LayoutPoint delta; 1015 LayoutPoint delta;
1016 layer->convertToLayerCoords(rootLayer, delta); 1016 layer->convertToLayerCoords(rootLayer, delta);
1017 clipRect.move(-delta.x(), -delta.y()); 1017 clipRect.move(-delta.x(), -delta.y());
1018 clipRect.unite(layer->layoutBox()->reflectedRect(clipRect)); 1018 clipRect.unite(layer->layoutBox()->reflectedRect(clipRect));
1019 clipRect.moveBy(delta); 1019 clipRect.moveBy(delta);
1020 } 1020 }
1021 } 1021 }
1022 1022
1023 LayoutRect DeprecatedPaintLayer::transparencyClipBox(const DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* rootLayer, TransparencyClipBoxBehavior trans parencyBehavior, 1023 LayoutRect DeprecatedPaintLayer::transparencyClipBox(const DeprecatedPaintLayer* layer, const DeprecatedPaintLayer* rootLayer, TransparencyClipBoxBehavior trans parencyBehavior,
1024 TransparencyClipBoxMode transparencyMode, const LayoutSize& subPixelAccumula tion, GlobalPaintFlags globalPaintFlags) 1024 TransparencyClipBoxMode transparencyMode, GlobalPaintFlags globalPaintFlags)
1025 { 1025 {
1026 // FIXME: Although this function completely ignores CSS-imposed clipping, we did already intersect with the 1026 // FIXME: Although this function completely ignores CSS-imposed clipping, we did already intersect with the
1027 // paintDirtyRect, and that should cut down on the amount we have to paint. Still it 1027 // paintDirtyRect, and that should cut down on the amount we have to paint. Still it
1028 // would be better to respect clips. 1028 // would be better to respect clips.
1029 1029
1030 if (rootLayer != layer && ((transparencyBehavior == PaintingTransparencyClip Box && layer->paintsWithTransform(globalPaintFlags)) 1030 if (rootLayer != layer && ((transparencyBehavior == PaintingTransparencyClip Box && layer->paintsWithTransform(globalPaintFlags))
1031 || (transparencyBehavior == HitTestingTransparencyClipBox && layer->hasT ransformRelatedProperty()))) { 1031 || (transparencyBehavior == HitTestingTransparencyClipBox && layer->hasT ransformRelatedProperty()))) {
1032 // The best we can do here is to use enclosed bounding boxes to establis h a "fuzzy" enough clip to encompass 1032 // The best we can do here is to use enclosed bounding boxes to establis h a "fuzzy" enough clip to encompass
1033 // the transformed layer and all of its children. 1033 // the transformed layer and all of its children.
1034 const DeprecatedPaintLayer* paginationLayer = transparencyMode == Descen dantsOfTransparencyClipBox ? layer->enclosingPaginationLayer() : 0; 1034 const DeprecatedPaintLayer* paginationLayer = transparencyMode == Descen dantsOfTransparencyClipBox ? layer->enclosingPaginationLayer() : 0;
1035 const DeprecatedPaintLayer* rootLayerForTransform = paginationLayer ? pa ginationLayer : rootLayer; 1035 const DeprecatedPaintLayer* rootLayerForTransform = paginationLayer ? pa ginationLayer : rootLayer;
1036 LayoutPoint delta; 1036 LayoutPoint delta;
1037 layer->convertToLayerCoords(rootLayerForTransform, delta); 1037 layer->convertToLayerCoords(rootLayerForTransform, delta);
1038 1038
1039 delta.move(subPixelAccumulation); 1039 delta.move(layer->subpixelAccumulation());
1040 IntPoint pixelSnappedDelta = roundedIntPoint(delta); 1040 IntPoint pixelSnappedDelta = roundedIntPoint(delta);
1041 TransformationMatrix transform; 1041 TransformationMatrix transform;
1042 transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y()); 1042 transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y());
1043 if (layer->transform()) 1043 if (layer->transform())
1044 transform = transform * *layer->transform(); 1044 transform = transform * *layer->transform();
1045 1045
1046 // We don't use fragment boxes when collecting a transformed layer's bou nding box, since it always 1046 // We don't use fragment boxes when collecting a transformed layer's bou nding box, since it always
1047 // paints unfragmented. 1047 // paints unfragmented.
1048 LayoutRect clipRect = layer->physicalBoundingBox(layer); 1048 LayoutRect clipRect = layer->physicalBoundingBox(layer);
1049 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, transp arencyBehavior, subPixelAccumulation, globalPaintFlags); 1049 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, transp arencyBehavior, layer->subpixelAccumulation(), globalPaintFlags);
1050 clipRect.expand(layer->layoutObject()->style()->filterOutsets()); 1050 clipRect.expand(layer->layoutObject()->style()->filterOutsets());
1051 LayoutRect result = transform.mapRect(clipRect); 1051 LayoutRect result = transform.mapRect(clipRect);
1052 if (!paginationLayer) 1052 if (!paginationLayer)
1053 return result; 1053 return result;
1054 1054
1055 // We have to break up the transformed extent across our columns. 1055 // We have to break up the transformed extent across our columns.
1056 // Split our box up into the actual fragment boxes that layout in the co lumns/pages and unite those together to 1056 // Split our box up into the actual fragment boxes that layout in the co lumns/pages and unite those together to
1057 // get our true bounding box. 1057 // get our true bounding box.
1058 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(paginationLay er->layoutObject()); 1058 LayoutFlowThread* enclosingFlowThread = toLayoutFlowThread(paginationLay er->layoutObject());
1059 result = enclosingFlowThread->fragmentsBoundingBox(result); 1059 result = enclosingFlowThread->fragmentsBoundingBox(result);
1060 1060
1061 LayoutPoint rootLayerDelta; 1061 LayoutPoint rootLayerDelta;
1062 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta); 1062 paginationLayer->convertToLayerCoords(rootLayer, rootLayerDelta);
1063 result.moveBy(rootLayerDelta); 1063 result.moveBy(rootLayerDelta);
1064 return result; 1064 return result;
1065 } 1065 }
1066 1066
1067 LayoutRect clipRect = layer->fragmentsBoundingBox(rootLayer); 1067 LayoutRect clipRect = layer->fragmentsBoundingBox(rootLayer);
1068 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, transp arencyBehavior, subPixelAccumulation, globalPaintFlags); 1068 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, transp arencyBehavior, layer->subpixelAccumulation(), globalPaintFlags);
1069 clipRect.expand(layer->layoutObject()->style()->filterOutsets()); 1069 clipRect.expand(layer->layoutObject()->style()->filterOutsets());
1070 clipRect.move(subPixelAccumulation); 1070 clipRect.move(layer->subpixelAccumulation());
1071 return clipRect; 1071 return clipRect;
1072 } 1072 }
1073 1073
1074 LayoutRect DeprecatedPaintLayer::paintingExtent(const DeprecatedPaintLayer* root Layer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAccumulation, GlobalPaintFlags globalPaintFlags) 1074 LayoutRect DeprecatedPaintLayer::paintingExtent(const DeprecatedPaintLayer* root Layer, const LayoutRect& paintDirtyRect, GlobalPaintFlags globalPaintFlags)
1075 { 1075 {
1076 return intersection(transparencyClipBox(this, rootLayer, PaintingTransparenc yClipBox, RootOfTransparencyClipBox, subPixelAccumulation, globalPaintFlags), pa intDirtyRect); 1076 return intersection(transparencyClipBox(this, rootLayer, PaintingTransparenc yClipBox, RootOfTransparencyClipBox, globalPaintFlags), paintDirtyRect);
1077 } 1077 }
1078 1078
1079 void* DeprecatedPaintLayer::operator new(size_t sz) 1079 void* DeprecatedPaintLayer::operator new(size_t sz)
1080 { 1080 {
1081 return partitionAlloc(WTF::Partitions::layoutPartition(), sz); 1081 return partitionAlloc(WTF::Partitions::layoutPartition(), sz);
1082 } 1082 }
1083 1083
1084 void DeprecatedPaintLayer::operator delete(void* ptr) 1084 void DeprecatedPaintLayer::operator delete(void* ptr)
1085 { 1085 {
1086 partitionFree(ptr); 1086 partitionFree(ptr);
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 1790
1791 return false; 1791 return false;
1792 } 1792 }
1793 1793
1794 DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestTransformedLayerInFragments(D eprecatedPaintLayer* rootLayer, DeprecatedPaintLayer* containerLayer, HitTestRes ult& result, 1794 DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestTransformedLayerInFragments(D eprecatedPaintLayer* rootLayer, DeprecatedPaintLayer* containerLayer, HitTestRes ult& result,
1795 const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const HitTestingTransformState* transformState, double* zOffset, ClipRectsCacheSlot c lipRectsCacheSlot) 1795 const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const HitTestingTransformState* transformState, double* zOffset, ClipRectsCacheSlot c lipRectsCacheSlot)
1796 { 1796 {
1797 DeprecatedPaintLayerFragments enclosingPaginationFragments; 1797 DeprecatedPaintLayerFragments enclosingPaginationFragments;
1798 LayoutPoint offsetOfPaginationLayerFromRoot; 1798 LayoutPoint offsetOfPaginationLayerFromRoot;
1799 // FIXME: We're missing a sub-pixel offset here crbug.com/348728 1799 // FIXME: We're missing a sub-pixel offset here crbug.com/348728
1800 LayoutRect transformedExtent = transparencyClipBox(this, enclosingPagination Layer(), HitTestingTransparencyClipBox, DeprecatedPaintLayer::RootOfTransparency ClipBox, LayoutSize()); 1800 LayoutRect transformedExtent = transparencyClipBox(this, enclosingPagination Layer(), HitTestingTransparencyClipBox, DeprecatedPaintLayer::RootOfTransparency ClipBox);
1801 enclosingPaginationLayer()->collectFragments(enclosingPaginationFragments, r ootLayer, hitTestRect, 1801 enclosingPaginationLayer()->collectFragments(enclosingPaginationFragments, r ootLayer, hitTestRect,
1802 clipRectsCacheSlot, IncludeOverlayScrollbarSize, RespectOverflowClip, &o ffsetOfPaginationLayerFromRoot, LayoutSize(), &transformedExtent); 1802 clipRectsCacheSlot, IncludeOverlayScrollbarSize, RespectOverflowClip, &o ffsetOfPaginationLayerFromRoot, LayoutSize(), &transformedExtent);
1803 1803
1804 for (int i = enclosingPaginationFragments.size() - 1; i >= 0; --i) { 1804 for (int i = enclosingPaginationFragments.size() - 1; i >= 0; --i) {
1805 const DeprecatedPaintLayerFragment& fragment = enclosingPaginationFragme nts.at(i); 1805 const DeprecatedPaintLayerFragment& fragment = enclosingPaginationFragme nts.at(i);
1806 1806
1807 // Apply the page/column clip for this fragment, as well as any clips es tablished by layers in between us and 1807 // Apply the page/column clip for this fragment, as well as any clips es tablished by layers in between us and
1808 // the enclosing pagination layer. 1808 // the enclosing pagination layer.
1809 LayoutRect clipRect = fragment.backgroundRect.rect(); 1809 LayoutRect clipRect = fragment.backgroundRect.rect();
1810 1810
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 2671
2672 void showLayerTree(const blink::LayoutObject* layoutObject) 2672 void showLayerTree(const blink::LayoutObject* layoutObject)
2673 { 2673 {
2674 if (!layoutObject) { 2674 if (!layoutObject) {
2675 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2675 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2676 return; 2676 return;
2677 } 2677 }
2678 showLayerTree(layoutObject->enclosingLayer()); 2678 showLayerTree(layoutObject->enclosingLayer());
2679 } 2679 }
2680 #endif 2680 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698