OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 int dummyMaxTextureSize = 512; | 502 int dummyMaxTextureSize = 512; |
503 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), pa
rent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerLi
st, dummyMaxTextureSize); | 503 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), pa
rent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerLi
st, dummyMaxTextureSize); |
504 | 504 |
505 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. | 505 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. |
506 // Also, the drawable content rect should not have been extended by the chil
dren. | 506 // Also, the drawable content rect should not have been extended by the chil
dren. |
507 EXPECT_EQ(parent->renderSurface()->layerList().size(), 0U); | 507 EXPECT_EQ(parent->renderSurface()->layerList().size(), 0U); |
508 EXPECT_EQ(renderSurfaceLayerList.size(), 0U); | 508 EXPECT_EQ(renderSurfaceLayerList.size(), 0U); |
509 EXPECT_EQ(parent->drawableContentRect(), IntRect()); | 509 EXPECT_EQ(parent->drawableContentRect(), IntRect()); |
510 } | 510 } |
511 | 511 |
| 512 TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) |
| 513 { |
| 514 // The entire subtree of layers that are outside the clipRect should be cull
ed away, |
| 515 // and should not affect the renderSurfaceLayerList. |
| 516 // |
| 517 // The test tree is set up as follows: |
| 518 // - all layers except the leafNodes are forced to be a new renderSurface t
hat have something to draw. |
| 519 // - parent is a large container layer. |
| 520 // - child has masksToBounds=true to cause clipping. |
| 521 // - grandChild is positioned outside of the child's bounds |
| 522 // - greatGrandChild is also kept outside child's bounds. |
| 523 // |
| 524 // In this configuration, grandChild and greatGrandChild are completely outs
ide the |
| 525 // clipRect, and they should never get scheduled on the list of renderSurfac
es. |
| 526 // |
| 527 |
| 528 const TransformationMatrix identityMatrix; |
| 529 RefPtr<LayerChromium> parent = LayerChromium::create(0); |
| 530 RefPtr<LayerChromium> child = LayerChromium::create(0); |
| 531 RefPtr<LayerChromium> grandChild = LayerChromium::create(0); |
| 532 RefPtr<LayerChromium> greatGrandChild = LayerChromium::create(0); |
| 533 RefPtr<LayerChromiumWithForcedDrawsContent> leafNode1 = adoptRef(new LayerCh
romiumWithForcedDrawsContent(0)); |
| 534 RefPtr<LayerChromiumWithForcedDrawsContent> leafNode2 = adoptRef(new LayerCh
romiumWithForcedDrawsContent(0)); |
| 535 parent->createRenderSurface(); |
| 536 parent->addChild(child); |
| 537 child->addChild(grandChild); |
| 538 grandChild->addChild(greatGrandChild); |
| 539 |
| 540 // leafNode1 ensures that parent and child are kept on the renderSurfaceLaye
rList, |
| 541 // even though grandChild and greatGrandChild should be clipped. |
| 542 child->addChild(leafNode1); |
| 543 greatGrandChild->addChild(leafNode2); |
| 544 |
| 545 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, F
loatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); |
| 546 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, Fl
oatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
| 547 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, FloatPoint(0, 0), FloatPoint(45, 45), IntSize(10, 10), false); |
| 548 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity
Matrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 10), false); |
| 549 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), false); |
| 550 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(20, 20), false); |
| 551 |
| 552 child->setMasksToBounds(true); |
| 553 child->setOpacity(0.4); |
| 554 grandChild->setOpacity(0.5); |
| 555 greatGrandChild->setOpacity(0.4); |
| 556 |
| 557 // Contaminate the grandChild and greatGrandChild's clipRect to reproduce th
e crash |
| 558 // bug found in http://code.google.com/p/chromium/issues/detail?id=106734. I
n this |
| 559 // bug, the clipRect was not re-computed for layers that create RenderSurfac
es, and |
| 560 // therefore leafNode2 thinks it should draw itself. As a result, an extra |
| 561 // renderSurface remains on the renderSurfaceLayerList, which violates the a
ssumption |
| 562 // that an empty renderSurface will always be the last item on the list, whi
ch |
| 563 // ultimately caused the crash. |
| 564 // |
| 565 // FIXME: it is also useful to test with this commented out. Eventually we s
hould |
| 566 // create several test cases that test clipRect/drawableContentRect computat
ion. |
| 567 child->setClipRect(IntRect(IntPoint::zero(), IntSize(20, 20))); |
| 568 greatGrandChild->setClipRect(IntRect(IntPoint::zero(), IntSize(1234, 1234)))
; |
| 569 |
| 570 Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; |
| 571 Vector<RefPtr<LayerChromium> > dummyLayerList; |
| 572 int dummyMaxTextureSize = 512; |
| 573 |
| 574 // FIXME: when we fix this "root-layer special case" behavior in CCLayerTree
Host, we will have to fix it here, too. |
| 575 parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); |
| 576 renderSurfaceLayerList.append(parent); |
| 577 |
| 578 CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), pa
rent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerLi
st, dummyMaxTextureSize); |
| 579 |
| 580 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
| 581 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 582 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
| 583 } |
| 584 |
512 // FIXME: | 585 // FIXME: |
513 // continue working on https://bugs.webkit.org/show_bug.cgi?id=68942 | 586 // continue working on https://bugs.webkit.org/show_bug.cgi?id=68942 |
514 // - add a test to verify clipping that changes the "center point" | 587 // - add a test to verify clipping that changes the "center point" |
515 // - add a case that checks if a render surface's drawTransform is computed cor
rectly. For the general case, and for special cases when clipping. | 588 // - add a case that checks if a render surface's drawTransform is computed cor
rectly. For the general case, and for special cases when clipping. |
516 // - add a case that checks if a render surface's replicaTransform is computed
correctly. | 589 // - add a case that checks if a render surface's replicaTransform is computed
correctly. |
517 // - test all the conditions under which render surfaces are created | 590 // - test all the conditions under which render surfaces are created |
518 // - if possible, test all conditions under which render surfaces are not creat
ed | 591 // - if possible, test all conditions under which render surfaces are not creat
ed |
519 // - verify that the layer lists of render surfaces are correct, verify that "t
argetRenderSurface" values for each layer are correct. | 592 // - verify that the layer lists of render surfaces are correct, verify that "t
argetRenderSurface" values for each layer are correct. |
520 // - test the computation of clip rects and content rects | 593 // - test the computation of clip rects and content rects |
521 // - test the special cases for mask layers and replica layers | 594 // - test the special cases for mask layers and replica layers |
522 // - test the other functions in CCLayerTreeHostCommon | 595 // - test the other functions in CCLayerTreeHostCommon |
523 // | 596 // |
524 | 597 |
525 } // namespace | 598 } // namespace |
OLD | NEW |