提交 78691e3c 编写于 作者: O Ojan Vafai

Inline RenderLayer::beginTransparencyLayers into RenderBox::paintLayerContents.

This is the only remaining caller.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/954913002
上级 82ab56a8
......@@ -741,6 +741,53 @@ void RenderBox::paintLayer(GraphicsContext* context, const LayerPaintingInfo& pa
layer()->parent()->restoreClip(context, paintingInfo.paintDirtyRect, clipRect);
}
static LayoutRect transparencyClipBox(const RenderLayer*, const RenderLayer* rootLayer, const LayoutSize& subPixelAccumulation);
static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, const RenderLayer* layer, const RenderLayer* rootLayer,
const LayoutSize& subPixelAccumulation)
{
// Note: we don't have to walk z-order lists since transparent elements always establish
// a stacking container. This means we can just walk the layer tree directly.
for (RenderLayer* curr = layer->firstChild(); curr; curr = curr->nextSibling())
clipRect.unite(transparencyClipBox(curr, rootLayer, subPixelAccumulation));
}
static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLayer* rootLayer,
const LayoutSize& subPixelAccumulation)
{
// FIXME: Although this function completely ignores CSS-imposed clipping, we did already intersect with the
// paintDirtyRect, and that should cut down on the amount we have to paint. Still it
// would be better to respect clips.
if (rootLayer != layer && layer->transform()) {
// The best we can do here is to use enclosed bounding boxes to establish a "fuzzy" enough clip to encompass
// the transformed layer and all of its children.
const RenderLayer* rootLayerForTransform = rootLayer;
LayoutPoint delta;
layer->convertToLayerCoords(rootLayerForTransform, delta);
delta.move(subPixelAccumulation);
IntPoint pixelSnappedDelta = roundedIntPoint(delta);
TransformationMatrix transform;
transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y());
transform = transform * *layer->transform();
// We don't use fragment boxes when collecting a transformed layer's bounding box, since it always
// paints unfragmented.y
LayoutRect clipRect = layer->physicalBoundingBox(layer);
expandClipRectForDescendantsAndReflection(clipRect, layer, layer, subPixelAccumulation);
layer->renderer()->style()->filterOutsets().expandRect(clipRect);
LayoutRect result = transform.mapRect(clipRect);
return result;
}
LayoutRect clipRect = layer->physicalBoundingBox(rootLayer);
expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, subPixelAccumulation);
layer->renderer()->style()->filterOutsets().expandRect(clipRect);
clipRect.move(subPixelAccumulation);
return clipRect;
}
void RenderBox::paintLayerContents(GraphicsContext* context, const LayerPaintingInfo& paintingInfo)
{
float deviceScaleFactor = blink::deviceScaleFactor(frame());
......@@ -788,8 +835,13 @@ void RenderBox::paintLayerContents(GraphicsContext* context, const LayerPainting
}
}
if (layer()->isTransparent())
layer()->beginTransparencyLayers(context, localPaintingInfo.rootLayer, paintingInfo.paintDirtyRect, localPaintingInfo.subPixelAccumulation);
if (layer()->isTransparent()) {
context->save();
LayoutRect clipRect = intersection(paintingInfo.paintDirtyRect,
transparencyClipBox(layer(), localPaintingInfo.rootLayer, localPaintingInfo.subPixelAccumulation));
context->clip(clipRect);
context->beginTransparencyLayer(opacity());
}
layer()->clipToRect(localPaintingInfo, context, contentRect);
......
......@@ -389,68 +389,6 @@ const RenderLayer* RenderLayer::compositingContainer() const
return 0;
}
enum TransparencyClipBoxBehavior {
PaintingTransparencyClipBox,
HitTestingTransparencyClipBox
};
static LayoutRect transparencyClipBox(const RenderLayer*, const RenderLayer* rootLayer, const LayoutSize& subPixelAccumulation);
static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, const RenderLayer* layer, const RenderLayer* rootLayer,
const LayoutSize& subPixelAccumulation)
{
// Note: we don't have to walk z-order lists since transparent elements always establish
// a stacking container. This means we can just walk the layer tree directly.
for (RenderLayer* curr = layer->firstChild(); curr; curr = curr->nextSibling())
clipRect.unite(transparencyClipBox(curr, rootLayer, subPixelAccumulation));
}
static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLayer* rootLayer,
const LayoutSize& subPixelAccumulation)
{
// FIXME: Although this function completely ignores CSS-imposed clipping, we did already intersect with the
// paintDirtyRect, and that should cut down on the amount we have to paint. Still it
// would be better to respect clips.
if (rootLayer != layer && layer->transform()) {
// The best we can do here is to use enclosed bounding boxes to establish a "fuzzy" enough clip to encompass
// the transformed layer and all of its children.
const RenderLayer* rootLayerForTransform = rootLayer;
LayoutPoint delta;
layer->convertToLayerCoords(rootLayerForTransform, delta);
delta.move(subPixelAccumulation);
IntPoint pixelSnappedDelta = roundedIntPoint(delta);
TransformationMatrix transform;
transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y());
transform = transform * *layer->transform();
// We don't use fragment boxes when collecting a transformed layer's bounding box, since it always
// paints unfragmented.y
LayoutRect clipRect = layer->physicalBoundingBox(layer);
expandClipRectForDescendantsAndReflection(clipRect, layer, layer, subPixelAccumulation);
layer->renderer()->style()->filterOutsets().expandRect(clipRect);
LayoutRect result = transform.mapRect(clipRect);
return result;
}
LayoutRect clipRect = layer->physicalBoundingBox(rootLayer);
expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, subPixelAccumulation);
layer->renderer()->style()->filterOutsets().expandRect(clipRect);
clipRect.move(subPixelAccumulation);
return clipRect;
}
void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAccumulation)
{
ASSERT(isTransparent());
context->save();
LayoutRect clipRect = intersection(paintDirtyRect,
transparencyClipBox(this, rootLayer, subPixelAccumulation));
context->clip(clipRect);
context->beginTransparencyLayer(renderer()->opacity());
}
void* RenderLayer::operator new(size_t sz)
{
return partitionAlloc(Partitions::getRenderingPartition(), sz);
......
......@@ -98,8 +98,6 @@ public:
void setLayerType(LayerType layerType) { m_layerType = layerType; }
bool isTransparent() const { return renderer()->isTransparent(); }
RenderLayer* transparentPaintingAncestor();
void beginTransparencyLayers(GraphicsContext*, const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAccumulation);
const RenderLayer* root() const
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册