1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768
|
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsLayer.h"
#include "FloatPoint.h"
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "LayoutRect.h"
#include "RotateTransformOperation.h"
#include "TextStream.h"
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
#ifndef NDEBUG
#include <stdio.h>
#endif
namespace WebCore {
typedef HashMap<const GraphicsLayer*, Vector<FloatRect> > RepaintMap;
static RepaintMap& repaintRectMap()
{
DEFINE_STATIC_LOCAL(RepaintMap, map, ());
return map;
}
void KeyframeValueList::insert(PassOwnPtr<const AnimationValue> value)
{
for (size_t i = 0; i < m_values.size(); ++i) {
const AnimationValue* curValue = m_values[i].get();
if (curValue->keyTime() == value->keyTime()) {
ASSERT_NOT_REACHED();
// insert after
m_values.insert(i + 1, value);
return;
}
if (curValue->keyTime() > value->keyTime()) {
// insert before
m_values.insert(i, value);
return;
}
}
m_values.append(value);
}
GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
: m_client(client)
, m_anchorPoint(0.5f, 0.5f, 0)
, m_opacity(1)
, m_zPosition(0)
, m_contentsOpaque(false)
, m_preserves3D(false)
, m_backfaceVisibility(true)
, m_usingTiledBacking(false)
, m_masksToBounds(false)
, m_drawsContent(false)
, m_contentsVisible(true)
, m_acceleratesDrawing(false)
, m_maintainsPixelAlignment(false)
, m_appliesPageScale(false)
, m_showDebugBorder(false)
, m_showRepaintCounter(false)
, m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip)
, m_contentsOrientation(CompositingCoordinatesTopDown)
, m_parent(0)
, m_maskLayer(0)
, m_replicaLayer(0)
, m_replicatedLayer(0)
, m_repaintCount(0)
{
#ifndef NDEBUG
if (m_client)
m_client->verifyNotPainting();
#endif
}
GraphicsLayer::~GraphicsLayer()
{
resetTrackedRepaints();
ASSERT(!m_parent); // willBeDestroyed should have been called already.
}
void GraphicsLayer::willBeDestroyed()
{
#ifndef NDEBUG
if (m_client)
m_client->verifyNotPainting();
#endif
if (m_replicaLayer)
m_replicaLayer->setReplicatedLayer(0);
if (m_replicatedLayer)
m_replicatedLayer->setReplicatedByLayer(0);
removeAllChildren();
removeFromParent();
}
void GraphicsLayer::setParent(GraphicsLayer* layer)
{
ASSERT(!layer || !layer->hasAncestor(this));
m_parent = layer;
}
bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const
{
for (GraphicsLayer* curr = parent(); curr; curr = curr->parent()) {
if (curr == ancestor)
return true;
}
return false;
}
bool GraphicsLayer::setChildren(const Vector<GraphicsLayer*>& newChildren)
{
// If the contents of the arrays are the same, nothing to do.
if (newChildren == m_children)
return false;
removeAllChildren();
size_t listSize = newChildren.size();
for (size_t i = 0; i < listSize; ++i)
addChild(newChildren[i]);
return true;
}
void GraphicsLayer::addChild(GraphicsLayer* childLayer)
{
ASSERT(childLayer != this);
if (childLayer->parent())
childLayer->removeFromParent();
childLayer->setParent(this);
m_children.append(childLayer);
}
void GraphicsLayer::addChildAtIndex(GraphicsLayer* childLayer, int index)
{
ASSERT(childLayer != this);
if (childLayer->parent())
childLayer->removeFromParent();
childLayer->setParent(this);
m_children.insert(index, childLayer);
}
void GraphicsLayer::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
{
ASSERT(childLayer != this);
childLayer->removeFromParent();
bool found = false;
for (unsigned i = 0; i < m_children.size(); i++) {
if (sibling == m_children[i]) {
m_children.insert(i, childLayer);
found = true;
break;
}
}
childLayer->setParent(this);
if (!found)
m_children.append(childLayer);
}
void GraphicsLayer::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer* sibling)
{
childLayer->removeFromParent();
ASSERT(childLayer != this);
bool found = false;
for (unsigned i = 0; i < m_children.size(); i++) {
if (sibling == m_children[i]) {
m_children.insert(i+1, childLayer);
found = true;
break;
}
}
childLayer->setParent(this);
if (!found)
m_children.append(childLayer);
}
bool GraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
{
ASSERT(!newChild->parent());
bool found = false;
for (unsigned i = 0; i < m_children.size(); i++) {
if (oldChild == m_children[i]) {
m_children[i] = newChild;
found = true;
break;
}
}
if (found) {
oldChild->setParent(0);
newChild->removeFromParent();
newChild->setParent(this);
return true;
}
return false;
}
void GraphicsLayer::removeAllChildren()
{
while (m_children.size()) {
GraphicsLayer* curLayer = m_children[0];
ASSERT(curLayer->parent());
curLayer->removeFromParent();
}
}
void GraphicsLayer::removeFromParent()
{
if (m_parent) {
unsigned i;
for (i = 0; i < m_parent->m_children.size(); i++) {
if (this == m_parent->m_children[i]) {
m_parent->m_children.remove(i);
break;
}
}
setParent(0);
}
}
void GraphicsLayer::noteDeviceOrPageScaleFactorChangedIncludingDescendants()
{
deviceOrPageScaleFactorChanged();
if (m_maskLayer)
m_maskLayer->deviceOrPageScaleFactorChanged();
if (m_replicaLayer)
m_replicaLayer->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
const Vector<GraphicsLayer*>& childLayers = children();
size_t numChildren = childLayers.size();
for (size_t i = 0; i < numChildren; ++i)
childLayers[i]->noteDeviceOrPageScaleFactorChangedIncludingDescendants();
}
void GraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer)
{
if (m_replicaLayer == layer)
return;
if (m_replicaLayer)
m_replicaLayer->setReplicatedLayer(0);
if (layer)
layer->setReplicatedLayer(this);
m_replicaLayer = layer;
}
void GraphicsLayer::setOffsetFromRenderer(const IntSize& offset, ShouldSetNeedsDisplay shouldSetNeedsDisplay)
{
if (offset == m_offsetFromRenderer)
return;
m_offsetFromRenderer = offset;
// If the compositing layer offset changes, we need to repaint.
if (shouldSetNeedsDisplay == SetNeedsDisplay)
setNeedsDisplay();
}
void GraphicsLayer::setBackgroundColor(const Color& color)
{
m_backgroundColor = color;
}
void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const IntRect& clip)
{
if (m_client) {
IntSize offset = offsetFromRenderer();
context.translate(-offset);
IntRect clipRect(clip);
clipRect.move(offset);
m_client->paintContents(this, context, m_paintingPhase, clipRect);
}
}
String GraphicsLayer::animationNameForTransition(AnimatedPropertyID property)
{
// | is not a valid identifier character in CSS, so this can never conflict with a keyframe identifier.
StringBuilder id;
id.appendLiteral("-|transition");
id.appendNumber(static_cast<int>(property));
id.append('-');
return id.toString();
}
void GraphicsLayer::suspendAnimations(double)
{
}
void GraphicsLayer::resumeAnimations()
{
}
void GraphicsLayer::getDebugBorderInfo(Color& color, float& width) const
{
if (drawsContent()) {
if (m_usingTiledBacking) {
color = Color(255, 128, 0, 128); // tiled layer: orange
width = 2;
return;
}
color = Color(0, 128, 32, 128); // normal layer: green
width = 2;
return;
}
if (masksToBounds()) {
color = Color(128, 255, 255, 48); // masking layer: pale blue
width = 20;
return;
}
color = Color(255, 255, 0, 192); // container: yellow
width = 2;
}
void GraphicsLayer::updateDebugIndicators()
{
if (!isShowingDebugBorder())
return;
Color borderColor;
float width = 0;
getDebugBorderInfo(borderColor, width);
setDebugBorder(borderColor, width);
}
void GraphicsLayer::setZPosition(float position)
{
m_zPosition = position;
}
float GraphicsLayer::accumulatedOpacity() const
{
if (!preserves3D())
return 1;
return m_opacity * (parent() ? parent()->accumulatedOpacity() : 1);
}
void GraphicsLayer::distributeOpacity(float accumulatedOpacity)
{
// If this is a transform layer we need to distribute our opacity to all our children
// Incoming accumulatedOpacity is the contribution from our parent(s). We mutiply this by our own
// opacity to get the total contribution
accumulatedOpacity *= m_opacity;
setOpacityInternal(accumulatedOpacity);
if (preserves3D()) {
size_t numChildren = children().size();
for (size_t i = 0; i < numChildren; ++i)
children()[i]->distributeOpacity(accumulatedOpacity);
}
}
#if ENABLE(CSS_FILTERS)
static inline const FilterOperations& filterOperationsAt(const KeyframeValueList& valueList, size_t index)
{
return static_cast<const FilterAnimationValue&>(valueList.at(index)).value();
}
int GraphicsLayer::validateFilterOperations(const KeyframeValueList& valueList)
{
ASSERT(valueList.property() == AnimatedPropertyWebkitFilter);
if (valueList.size() < 2)
return -1;
// Empty filters match anything, so find the first non-empty entry as the reference
size_t firstIndex = 0;
for ( ; firstIndex < valueList.size(); ++firstIndex) {
if (!filterOperationsAt(valueList, firstIndex).operations().isEmpty())
break;
}
if (firstIndex >= valueList.size())
return -1;
const FilterOperations& firstVal = filterOperationsAt(valueList, firstIndex);
for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
const FilterOperations& val = filterOperationsAt(valueList, i);
// An emtpy filter list matches anything.
if (val.operations().isEmpty())
continue;
if (!firstVal.operationsMatch(val))
return -1;
}
return firstIndex;
}
#endif
// An "invalid" list is one whose functions don't match, and therefore has to be animated as a Matrix
// The hasBigRotation flag will always return false if isValid is false. Otherwise hasBigRotation is
// true if the rotation between any two keyframes is >= 180 degrees.
static inline const TransformOperations& operationsAt(const KeyframeValueList& valueList, size_t index)
{
return static_cast<const TransformAnimationValue&>(valueList.at(index)).value();
}
int GraphicsLayer::validateTransformOperations(const KeyframeValueList& valueList, bool& hasBigRotation)
{
ASSERT(valueList.property() == AnimatedPropertyWebkitTransform);
hasBigRotation = false;
if (valueList.size() < 2)
return -1;
// Empty transforms match anything, so find the first non-empty entry as the reference.
size_t firstIndex = 0;
for ( ; firstIndex < valueList.size(); ++firstIndex) {
if (!operationsAt(valueList, firstIndex).operations().isEmpty())
break;
}
if (firstIndex >= valueList.size())
return -1;
const TransformOperations& firstVal = operationsAt(valueList, firstIndex);
// See if the keyframes are valid.
for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
const TransformOperations& val = operationsAt(valueList, i);
// An empty transform list matches anything.
if (val.operations().isEmpty())
continue;
if (!firstVal.operationsMatch(val))
return -1;
}
// Keyframes are valid, check for big rotations.
double lastRotAngle = 0.0;
double maxRotAngle = -1.0;
for (size_t j = 0; j < firstVal.operations().size(); ++j) {
TransformOperation::OperationType type = firstVal.operations().at(j)->getOperationType();
// if this is a rotation entry, we need to see if any angle differences are >= 180 deg
if (type == TransformOperation::ROTATE_X ||
type == TransformOperation::ROTATE_Y ||
type == TransformOperation::ROTATE_Z ||
type == TransformOperation::ROTATE_3D) {
lastRotAngle = static_cast<RotateTransformOperation*>(firstVal.operations().at(j).get())->angle();
if (maxRotAngle < 0)
maxRotAngle = fabs(lastRotAngle);
for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
const TransformOperations& val = operationsAt(valueList, i);
double rotAngle = val.operations().isEmpty() ? 0 : (static_cast<RotateTransformOperation*>(val.operations().at(j).get())->angle());
double diffAngle = fabs(rotAngle - lastRotAngle);
if (diffAngle > maxRotAngle)
maxRotAngle = diffAngle;
lastRotAngle = rotAngle;
}
}
}
hasBigRotation = maxRotAngle >= 180.0;
return firstIndex;
}
double GraphicsLayer::backingStoreMemoryEstimate() const
{
if (!drawsContent())
return 0;
// Effects of page and device scale are ignored; subclasses should override to take these into account.
return static_cast<double>(4 * size().width()) * size().height();
}
void GraphicsLayer::resetTrackedRepaints()
{
repaintRectMap().remove(this);
}
void GraphicsLayer::addRepaintRect(const FloatRect& repaintRect)
{
if (m_client->isTrackingRepaints()) {
FloatRect largestRepaintRect(FloatPoint(), m_size);
largestRepaintRect.intersect(repaintRect);
RepaintMap::iterator repaintIt = repaintRectMap().find(this);
if (repaintIt == repaintRectMap().end()) {
Vector<FloatRect> repaintRects;
repaintRects.append(largestRepaintRect);
repaintRectMap().set(this, repaintRects);
} else {
Vector<FloatRect>& repaintRects = repaintIt->value;
repaintRects.append(largestRepaintRect);
}
}
}
void GraphicsLayer::writeIndent(TextStream& ts, int indent)
{
for (int i = 0; i != indent; ++i)
ts << " ";
}
void GraphicsLayer::dumpLayer(TextStream& ts, int indent, LayerTreeAsTextBehavior behavior) const
{
writeIndent(ts, indent);
ts << "(" << "GraphicsLayer";
if (behavior & LayerTreeAsTextDebug) {
ts << " " << static_cast<void*>(const_cast<GraphicsLayer*>(this));
ts << " \"" << m_name << "\"";
}
ts << "\n";
dumpProperties(ts, indent, behavior);
writeIndent(ts, indent);
ts << ")\n";
}
void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeAsTextBehavior behavior) const
{
if (m_position != FloatPoint()) {
writeIndent(ts, indent + 1);
ts << "(position " << m_position.x() << " " << m_position.y() << ")\n";
}
if (m_boundsOrigin != FloatPoint()) {
writeIndent(ts, indent + 1);
ts << "(bounds origin " << m_boundsOrigin.x() << " " << m_boundsOrigin.y() << ")\n";
}
if (m_anchorPoint != FloatPoint3D(0.5f, 0.5f, 0)) {
writeIndent(ts, indent + 1);
ts << "(anchor " << m_anchorPoint.x() << " " << m_anchorPoint.y() << ")\n";
}
if (m_size != IntSize()) {
writeIndent(ts, indent + 1);
ts << "(bounds " << m_size.width() << " " << m_size.height() << ")\n";
}
if (m_opacity != 1) {
writeIndent(ts, indent + 1);
ts << "(opacity " << m_opacity << ")\n";
}
if (m_usingTiledBacking) {
writeIndent(ts, indent + 1);
ts << "(usingTiledLayer " << m_usingTiledBacking << ")\n";
}
if (m_contentsOpaque) {
writeIndent(ts, indent + 1);
ts << "(contentsOpaque " << m_contentsOpaque << ")\n";
}
if (m_preserves3D) {
writeIndent(ts, indent + 1);
ts << "(preserves3D " << m_preserves3D << ")\n";
}
if (m_drawsContent) {
writeIndent(ts, indent + 1);
ts << "(drawsContent " << m_drawsContent << ")\n";
}
if (!m_contentsVisible) {
writeIndent(ts, indent + 1);
ts << "(contentsVisible " << m_contentsVisible << ")\n";
}
if (!m_backfaceVisibility) {
writeIndent(ts, indent + 1);
ts << "(backfaceVisibility " << (m_backfaceVisibility ? "visible" : "hidden") << ")\n";
}
if (behavior & LayerTreeAsTextDebug) {
writeIndent(ts, indent + 1);
ts << "(";
if (m_client)
ts << "client " << static_cast<void*>(m_client);
else
ts << "no client";
ts << ")\n";
}
if (m_backgroundColor.isValid()) {
writeIndent(ts, indent + 1);
ts << "(backgroundColor " << m_backgroundColor.nameForRenderTreeAsText() << ")\n";
}
if (!m_transform.isIdentity()) {
writeIndent(ts, indent + 1);
ts << "(transform ";
ts << "[" << m_transform.m11() << " " << m_transform.m12() << " " << m_transform.m13() << " " << m_transform.m14() << "] ";
ts << "[" << m_transform.m21() << " " << m_transform.m22() << " " << m_transform.m23() << " " << m_transform.m24() << "] ";
ts << "[" << m_transform.m31() << " " << m_transform.m32() << " " << m_transform.m33() << " " << m_transform.m34() << "] ";
ts << "[" << m_transform.m41() << " " << m_transform.m42() << " " << m_transform.m43() << " " << m_transform.m44() << "])\n";
}
// Avoid dumping the sublayer transform on the root layer, because it's used for geometry flipping, whose behavior
// differs between platforms.
if (parent() && !m_childrenTransform.isIdentity()) {
writeIndent(ts, indent + 1);
ts << "(childrenTransform ";
ts << "[" << m_childrenTransform.m11() << " " << m_childrenTransform.m12() << " " << m_childrenTransform.m13() << " " << m_childrenTransform.m14() << "] ";
ts << "[" << m_childrenTransform.m21() << " " << m_childrenTransform.m22() << " " << m_childrenTransform.m23() << " " << m_childrenTransform.m24() << "] ";
ts << "[" << m_childrenTransform.m31() << " " << m_childrenTransform.m32() << " " << m_childrenTransform.m33() << " " << m_childrenTransform.m34() << "] ";
ts << "[" << m_childrenTransform.m41() << " " << m_childrenTransform.m42() << " " << m_childrenTransform.m43() << " " << m_childrenTransform.m44() << "])\n";
}
if (m_replicaLayer) {
writeIndent(ts, indent + 1);
ts << "(replica layer";
if (behavior & LayerTreeAsTextDebug)
ts << " " << m_replicaLayer;
ts << ")\n";
m_replicaLayer->dumpLayer(ts, indent + 2, behavior);
}
if (m_replicatedLayer) {
writeIndent(ts, indent + 1);
ts << "(replicated layer";
if (behavior & LayerTreeAsTextDebug)
ts << " " << m_replicatedLayer;
ts << ")\n";
}
if (behavior & LayerTreeAsTextIncludeRepaintRects && repaintRectMap().contains(this) && !repaintRectMap().get(this).isEmpty()) {
writeIndent(ts, indent + 1);
ts << "(repaint rects\n";
for (size_t i = 0; i < repaintRectMap().get(this).size(); ++i) {
if (repaintRectMap().get(this)[i].isEmpty())
continue;
writeIndent(ts, indent + 2);
ts << "(rect ";
ts << repaintRectMap().get(this)[i].x() << " ";
ts << repaintRectMap().get(this)[i].y() << " ";
ts << repaintRectMap().get(this)[i].width() << " ";
ts << repaintRectMap().get(this)[i].height();
ts << ")\n";
}
writeIndent(ts, indent + 1);
ts << ")\n";
}
if (behavior & LayerTreeAsTextIncludePaintingPhases && paintingPhase()) {
writeIndent(ts, indent + 1);
ts << "(paintingPhases\n";
if (paintingPhase() & GraphicsLayerPaintBackground) {
writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintBackground\n";
}
if (paintingPhase() & GraphicsLayerPaintForeground) {
writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintForeground\n";
}
if (paintingPhase() & GraphicsLayerPaintMask) {
writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintMask\n";
}
if (paintingPhase() & GraphicsLayerPaintOverflowContents) {
writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintOverflowContents\n";
}
if (paintingPhase() & GraphicsLayerPaintCompositedScroll) {
writeIndent(ts, indent + 2);
ts << "GraphicsLayerPaintCompositedScroll\n";
}
writeIndent(ts, indent + 1);
ts << ")\n";
}
dumpAdditionalProperties(ts, indent, behavior);
if (m_children.size()) {
writeIndent(ts, indent + 1);
ts << "(children " << m_children.size() << "\n";
unsigned i;
for (i = 0; i < m_children.size(); i++)
m_children[i]->dumpLayer(ts, indent + 2, behavior);
writeIndent(ts, indent + 1);
ts << ")\n";
}
}
String GraphicsLayer::layerTreeAsText(LayerTreeAsTextBehavior behavior) const
{
TextStream ts;
dumpLayer(ts, 0, behavior);
return ts.release();
}
} // namespace WebCore
#ifndef NDEBUG
void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
{
if (!layer)
return;
String output = layer->layerTreeAsText(LayerTreeAsTextDebug | LayerTreeAsTextIncludeVisibleRects | LayerTreeAsTextIncludeTileCaches);
fprintf(stderr, "%s\n", output.utf8().data());
}
#endif
#endif // USE(ACCELERATED_COMPOSITING)
|