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

Side by Side Diff: sky/engine/core/rendering/RenderLayer.cpp

Issue 954913002: Inline RenderLayer::beginTransparencyLayers into RenderBox::paintLayerContents. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/engine/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 const RenderLayer* RenderLayer::compositingContainer() const 383 const RenderLayer* RenderLayer::compositingContainer() const
384 { 384 {
385 if (stackingNode()->isNormalFlowOnly()) 385 if (stackingNode()->isNormalFlowOnly())
386 return parent(); 386 return parent();
387 if (RenderLayerStackingNode* ancestorStackingNode = stackingNode()->ancestor StackingContextNode()) 387 if (RenderLayerStackingNode* ancestorStackingNode = stackingNode()->ancestor StackingContextNode())
388 return ancestorStackingNode->layer(); 388 return ancestorStackingNode->layer();
389 return 0; 389 return 0;
390 } 390 }
391 391
392 enum TransparencyClipBoxBehavior {
393 PaintingTransparencyClipBox,
394 HitTestingTransparencyClipBox
395 };
396
397 static LayoutRect transparencyClipBox(const RenderLayer*, const RenderLayer* roo tLayer, const LayoutSize& subPixelAccumulation);
398
399 static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons t RenderLayer* layer, const RenderLayer* rootLayer,
400 const LayoutSize& subPixelAccumulation)
401 {
402 // Note: we don't have to walk z-order lists since transparent elements alwa ys establish
403 // a stacking container. This means we can just walk the layer tree directly .
404 for (RenderLayer* curr = layer->firstChild(); curr; curr = curr->nextSibling ())
405 clipRect.unite(transparencyClipBox(curr, rootLayer, subPixelAccumulation ));
406 }
407
408 static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLaye r* rootLayer,
409 const LayoutSize& subPixelAccumulation)
410 {
411 // FIXME: Although this function completely ignores CSS-imposed clipping, we did already intersect with the
412 // paintDirtyRect, and that should cut down on the amount we have to paint. Still it
413 // would be better to respect clips.
414
415 if (rootLayer != layer && layer->transform()) {
416 // The best we can do here is to use enclosed bounding boxes to establis h a "fuzzy" enough clip to encompass
417 // the transformed layer and all of its children.
418 const RenderLayer* rootLayerForTransform = rootLayer;
419 LayoutPoint delta;
420 layer->convertToLayerCoords(rootLayerForTransform, delta);
421
422 delta.move(subPixelAccumulation);
423 IntPoint pixelSnappedDelta = roundedIntPoint(delta);
424 TransformationMatrix transform;
425 transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y());
426 transform = transform * *layer->transform();
427
428 // We don't use fragment boxes when collecting a transformed layer's bou nding box, since it always
429 // paints unfragmented.y
430 LayoutRect clipRect = layer->physicalBoundingBox(layer);
431 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, subPix elAccumulation);
432 layer->renderer()->style()->filterOutsets().expandRect(clipRect);
433 LayoutRect result = transform.mapRect(clipRect);
434 return result;
435 }
436
437 LayoutRect clipRect = layer->physicalBoundingBox(rootLayer);
438 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, subPix elAccumulation);
439 layer->renderer()->style()->filterOutsets().expandRect(clipRect);
440 clipRect.move(subPixelAccumulation);
441 return clipRect;
442 }
443
444 void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const Render Layer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAc cumulation)
445 {
446 ASSERT(isTransparent());
447 context->save();
448 LayoutRect clipRect = intersection(paintDirtyRect,
449 transparencyClipBox(this, rootLayer, subPixelAccumulation));
450 context->clip(clipRect);
451 context->beginTransparencyLayer(renderer()->opacity());
452 }
453
454 void* RenderLayer::operator new(size_t sz) 392 void* RenderLayer::operator new(size_t sz)
455 { 393 {
456 return partitionAlloc(Partitions::getRenderingPartition(), sz); 394 return partitionAlloc(Partitions::getRenderingPartition(), sz);
457 } 395 }
458 396
459 void RenderLayer::operator delete(void* ptr) 397 void RenderLayer::operator delete(void* ptr)
460 { 398 {
461 partitionFree(ptr); 399 partitionFree(ptr);
462 } 400 }
463 401
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 } 903 }
966 } 904 }
967 905
968 void showLayerTree(const blink::RenderObject* renderer) 906 void showLayerTree(const blink::RenderObject* renderer)
969 { 907 {
970 if (!renderer) 908 if (!renderer)
971 return; 909 return;
972 showLayerTree(renderer->enclosingLayer()); 910 showLayerTree(renderer->enclosingLayer());
973 } 911 }
974 #endif 912 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698