| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #include "sky/engine/wtf/StdLibExtras.h" | 76 #include "sky/engine/wtf/StdLibExtras.h" |
| 77 #include "sky/engine/wtf/text/CString.h" | 77 #include "sky/engine/wtf/text/CString.h" |
| 78 | 78 |
| 79 namespace blink { | 79 namespace blink { |
| 80 | 80 |
| 81 RenderLayer::RenderLayer(RenderBox* renderer, LayerType type) | 81 RenderLayer::RenderLayer(RenderBox* renderer, LayerType type) |
| 82 : m_layerType(type) | 82 : m_layerType(type) |
| 83 , m_hasSelfPaintingLayerDescendant(false) | 83 , m_hasSelfPaintingLayerDescendant(false) |
| 84 , m_hasSelfPaintingLayerDescendantDirty(false) | 84 , m_hasSelfPaintingLayerDescendantDirty(false) |
| 85 , m_isRootLayer(renderer->isRenderView()) | 85 , m_isRootLayer(renderer->isRenderView()) |
| 86 , m_usedTransparency(false) | |
| 87 , m_3DTransformedDescendantStatusDirty(true) | 86 , m_3DTransformedDescendantStatusDirty(true) |
| 88 , m_has3DTransformedDescendant(false) | 87 , m_has3DTransformedDescendant(false) |
| 89 , m_hasFilterInfo(false) | 88 , m_hasFilterInfo(false) |
| 90 , m_renderer(renderer) | 89 , m_renderer(renderer) |
| 91 , m_parent(0) | 90 , m_parent(0) |
| 92 , m_previous(0) | 91 , m_previous(0) |
| 93 , m_next(0) | 92 , m_next(0) |
| 94 , m_first(0) | 93 , m_first(0) |
| 95 , m_last(0) | 94 , m_last(0) |
| 96 , m_clipper(*renderer) | 95 , m_clipper(*renderer) |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 bool RenderLayer::hasAncestorWithFilterOutsets() const | 403 bool RenderLayer::hasAncestorWithFilterOutsets() const |
| 405 { | 404 { |
| 406 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { | 405 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { |
| 407 RenderBox* renderer = curr->renderer(); | 406 RenderBox* renderer = curr->renderer(); |
| 408 if (renderer->style()->hasFilterOutsets()) | 407 if (renderer->style()->hasFilterOutsets()) |
| 409 return true; | 408 return true; |
| 410 } | 409 } |
| 411 return false; | 410 return false; |
| 412 } | 411 } |
| 413 | 412 |
| 414 RenderLayer* RenderLayer::transparentPaintingAncestor() | |
| 415 { | |
| 416 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { | |
| 417 if (curr->isTransparent()) | |
| 418 return curr; | |
| 419 } | |
| 420 return 0; | |
| 421 } | |
| 422 | |
| 423 enum TransparencyClipBoxBehavior { | 413 enum TransparencyClipBoxBehavior { |
| 424 PaintingTransparencyClipBox, | 414 PaintingTransparencyClipBox, |
| 425 HitTestingTransparencyClipBox | 415 HitTestingTransparencyClipBox |
| 426 }; | 416 }; |
| 427 | 417 |
| 428 enum TransparencyClipBoxMode { | 418 static LayoutRect transparencyClipBox(const RenderLayer*, const RenderLayer* roo
tLayer, const LayoutSize& subPixelAccumulation); |
| 429 DescendantsOfTransparencyClipBox, | |
| 430 RootOfTransparencyClipBox | |
| 431 }; | |
| 432 | |
| 433 static LayoutRect transparencyClipBox(const RenderLayer*, const RenderLayer* roo
tLayer, TransparencyClipBoxBehavior, TransparencyClipBoxMode, const LayoutSize&
subPixelAccumulation); | |
| 434 | 419 |
| 435 static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons
t RenderLayer* layer, const RenderLayer* rootLayer, | 420 static void expandClipRectForDescendantsAndReflection(LayoutRect& clipRect, cons
t RenderLayer* layer, const RenderLayer* rootLayer, |
| 436 TransparencyClipBoxBehavior transparencyBehavior, const LayoutSize& subPixel
Accumulation) | 421 const LayoutSize& subPixelAccumulation) |
| 437 { | 422 { |
| 438 // Note: we don't have to walk z-order lists since transparent elements alwa
ys establish | 423 // Note: we don't have to walk z-order lists since transparent elements alwa
ys establish |
| 439 // a stacking container. This means we can just walk the layer tree directly
. | 424 // a stacking container. This means we can just walk the layer tree directly
. |
| 440 for (RenderLayer* curr = layer->firstChild(); curr; curr = curr->nextSibling
()) | 425 for (RenderLayer* curr = layer->firstChild(); curr; curr = curr->nextSibling
()) |
| 441 clipRect.unite(transparencyClipBox(curr, rootLayer, transparencyBehavior
, DescendantsOfTransparencyClipBox, subPixelAccumulation)); | 426 clipRect.unite(transparencyClipBox(curr, rootLayer, subPixelAccumulation
)); |
| 442 } | 427 } |
| 443 | 428 |
| 444 static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLaye
r* rootLayer, TransparencyClipBoxBehavior transparencyBehavior, | 429 static LayoutRect transparencyClipBox(const RenderLayer* layer, const RenderLaye
r* rootLayer, |
| 445 TransparencyClipBoxMode transparencyMode, const LayoutSize& subPixelAccumula
tion) | 430 const LayoutSize& subPixelAccumulation) |
| 446 { | 431 { |
| 447 // FIXME: Although this function completely ignores CSS-imposed clipping, we
did already intersect with the | 432 // FIXME: Although this function completely ignores CSS-imposed clipping, we
did already intersect with the |
| 448 // paintDirtyRect, and that should cut down on the amount we have to paint.
Still it | 433 // paintDirtyRect, and that should cut down on the amount we have to paint.
Still it |
| 449 // would be better to respect clips. | 434 // would be better to respect clips. |
| 450 | 435 |
| 451 if (rootLayer != layer && ((transparencyBehavior == PaintingTransparencyClip
Box && layer->transform()) | 436 if (rootLayer != layer && layer->transform()) { |
| 452 || (transparencyBehavior == HitTestingTransparencyClipBox && layer->hasT
ransform()))) { | |
| 453 // The best we can do here is to use enclosed bounding boxes to establis
h a "fuzzy" enough clip to encompass | 437 // The best we can do here is to use enclosed bounding boxes to establis
h a "fuzzy" enough clip to encompass |
| 454 // the transformed layer and all of its children. | 438 // the transformed layer and all of its children. |
| 455 const RenderLayer* rootLayerForTransform = rootLayer; | 439 const RenderLayer* rootLayerForTransform = rootLayer; |
| 456 LayoutPoint delta; | 440 LayoutPoint delta; |
| 457 layer->convertToLayerCoords(rootLayerForTransform, delta); | 441 layer->convertToLayerCoords(rootLayerForTransform, delta); |
| 458 | 442 |
| 459 delta.move(subPixelAccumulation); | 443 delta.move(subPixelAccumulation); |
| 460 IntPoint pixelSnappedDelta = roundedIntPoint(delta); | 444 IntPoint pixelSnappedDelta = roundedIntPoint(delta); |
| 461 TransformationMatrix transform; | 445 TransformationMatrix transform; |
| 462 transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y()); | 446 transform.translate(pixelSnappedDelta.x(), pixelSnappedDelta.y()); |
| 463 transform = transform * *layer->transform(); | 447 transform = transform * *layer->transform(); |
| 464 | 448 |
| 465 // We don't use fragment boxes when collecting a transformed layer's bou
nding box, since it always | 449 // We don't use fragment boxes when collecting a transformed layer's bou
nding box, since it always |
| 466 // paints unfragmented. | 450 // paints unfragmented.y |
| 467 LayoutRect clipRect = layer->physicalBoundingBox(layer); | 451 LayoutRect clipRect = layer->physicalBoundingBox(layer); |
| 468 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, transp
arencyBehavior, subPixelAccumulation); | 452 expandClipRectForDescendantsAndReflection(clipRect, layer, layer, subPix
elAccumulation); |
| 469 layer->renderer()->style()->filterOutsets().expandRect(clipRect); | 453 layer->renderer()->style()->filterOutsets().expandRect(clipRect); |
| 470 LayoutRect result = transform.mapRect(clipRect); | 454 LayoutRect result = transform.mapRect(clipRect); |
| 471 return result; | 455 return result; |
| 472 } | 456 } |
| 473 | 457 |
| 474 LayoutRect clipRect = layer->physicalBoundingBox(rootLayer); | 458 LayoutRect clipRect = layer->physicalBoundingBox(rootLayer); |
| 475 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, transp
arencyBehavior, subPixelAccumulation); | 459 expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, subPix
elAccumulation); |
| 476 layer->renderer()->style()->filterOutsets().expandRect(clipRect); | 460 layer->renderer()->style()->filterOutsets().expandRect(clipRect); |
| 477 clipRect.move(subPixelAccumulation); | 461 clipRect.move(subPixelAccumulation); |
| 478 return clipRect; | 462 return clipRect; |
| 479 } | 463 } |
| 480 | 464 |
| 481 LayoutRect RenderLayer::paintingExtent(const RenderLayer* rootLayer, const Layou
tRect& paintDirtyRect, const LayoutSize& subPixelAccumulation) | |
| 482 { | |
| 483 return intersection(transparencyClipBox(this, rootLayer, PaintingTransparenc
yClipBox, RootOfTransparencyClipBox, subPixelAccumulation), paintDirtyRect); | |
| 484 } | |
| 485 | |
| 486 void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const Render
Layer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAc
cumulation) | 465 void RenderLayer::beginTransparencyLayers(GraphicsContext* context, const Render
Layer* rootLayer, const LayoutRect& paintDirtyRect, const LayoutSize& subPixelAc
cumulation) |
| 487 { | 466 { |
| 488 if (isTransparent() && m_usedTransparency) | 467 ASSERT(isTransparent()); |
| 489 return; | 468 context->save(); |
| 490 | 469 LayoutRect clipRect = intersection(paintDirtyRect, |
| 491 RenderLayer* ancestor = transparentPaintingAncestor(); | 470 transparencyClipBox(this, rootLayer, subPixelAccumulation)); |
| 492 if (ancestor) | 471 context->clip(clipRect); |
| 493 ancestor->beginTransparencyLayers(context, rootLayer, paintDirtyRect, su
bPixelAccumulation); | 472 context->beginTransparencyLayer(renderer()->opacity()); |
| 494 | |
| 495 if (isTransparent()) { | |
| 496 m_usedTransparency = true; | |
| 497 context->save(); | |
| 498 LayoutRect clipRect = paintingExtent(rootLayer, paintDirtyRect, subPixel
Accumulation); | |
| 499 context->clip(clipRect); | |
| 500 | |
| 501 context->beginTransparencyLayer(renderer()->opacity()); | |
| 502 | |
| 503 #ifdef REVEAL_TRANSPARENCY_LAYERS | |
| 504 context->setFillColor(Color(0.0f, 0.0f, 0.5f, 0.2f)); | |
| 505 context->fillRect(clipRect); | |
| 506 #endif | |
| 507 } | |
| 508 } | 473 } |
| 509 | 474 |
| 510 void* RenderLayer::operator new(size_t sz) | 475 void* RenderLayer::operator new(size_t sz) |
| 511 { | 476 { |
| 512 return partitionAlloc(Partitions::getRenderingPartition(), sz); | 477 return partitionAlloc(Partitions::getRenderingPartition(), sz); |
| 513 } | 478 } |
| 514 | 479 |
| 515 void RenderLayer::operator delete(void* ptr) | 480 void RenderLayer::operator delete(void* ptr) |
| 516 { | 481 { |
| 517 partitionFree(ptr); | 482 partitionFree(ptr); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 } | 986 } |
| 1022 } | 987 } |
| 1023 | 988 |
| 1024 void showLayerTree(const blink::RenderObject* renderer) | 989 void showLayerTree(const blink::RenderObject* renderer) |
| 1025 { | 990 { |
| 1026 if (!renderer) | 991 if (!renderer) |
| 1027 return; | 992 return; |
| 1028 showLayerTree(renderer->enclosingLayer()); | 993 showLayerTree(renderer->enclosingLayer()); |
| 1029 } | 994 } |
| 1030 #endif | 995 #endif |
| OLD | NEW |