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

Side by Side Diff: Source/core/rendering/compositing/CompositedLayerMapping.cpp

Issue 343543005: Round in the range [-0.5, 0.5) when computing offsetFromRenderer and subpixelAccumulation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added test. Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/compositing/squashing/subpixel-rounding-expected.html ('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) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 549
550 squashedBounds.move(offsetFromSquashingLayer); 550 squashedBounds.move(offsetFromSquashingLayer);
551 totalSquashBounds.unite(squashedBounds); 551 totalSquashBounds.unite(squashedBounds);
552 } 552 }
553 553
554 *offsetFromTransformedAncestor = referenceOffsetFromTransformedAncestor; 554 *offsetFromTransformedAncestor = referenceOffsetFromTransformedAncestor;
555 offsetFromTransformedAncestor->moveBy(totalSquashBounds.location()); 555 offsetFromTransformedAncestor->moveBy(totalSquashBounds.location());
556 556
557 // The totalSquashBounds is positioned with respect to referenceLayer of thi s CompositedLayerMapping. 557 // The totalSquashBounds is positioned with respect to referenceLayer of thi s CompositedLayerMapping.
558 // But the squashingLayer needs to be positioned with respect to the ancesto r CompositedLayerMapping. 558 // But the squashingLayer needs to be positioned with respect to the ancesto r CompositedLayerMapping.
559 // The conversion between referenceLayer and the ancestor CLM is already com puted in the caller as 559 // The conversion between referenceLayer and the ancestor CLM is already com puted as
560 // offsetFromReferenceLayerToCompositedAncestor. 560 // offsetFromReferenceLayerToParentGraphicsLayer.
561 totalSquashBounds.moveBy(offsetFromReferenceLayerToParentGraphicsLayer); 561 totalSquashBounds.moveBy(offsetFromReferenceLayerToParentGraphicsLayer);
562 IntRect squashLayerBounds = enclosingIntRect(totalSquashBounds); 562 IntRect squashLayerBounds = enclosingIntRect(totalSquashBounds);
563 IntPoint squashLayerOrigin = squashLayerBounds.location(); 563 IntPoint squashLayerOrigin = squashLayerBounds.location();
564 LayoutSize squashLayerOriginInOwningLayerSpace = squashLayerOrigin - offsetF romReferenceLayerToParentGraphicsLayer; 564 LayoutSize squashLayerOriginInOwningLayerSpace = squashLayerOrigin - offsetF romReferenceLayerToParentGraphicsLayer;
565 565
566 squashingLayer->setPosition(squashLayerBounds.location()); 566 squashingLayer->setPosition(squashLayerBounds.location());
567 squashingLayer->setSize(squashLayerBounds.size()); 567 squashingLayer->setSize(squashLayerBounds.size());
568 568
569 // Now that the squashing bounds are known, we can convert the RenderLayer p ainting offsets 569 // Now that the squashing bounds are known, we can convert the RenderLayer p ainting offsets
570 // from CLM owning layer space to the squashing layer space. 570 // from CLM owning layer space to the squashing layer space.
571 // 571 //
572 // The painting offset we want to compute for each squashed RenderLayer is e ssentially the position of 572 // The painting offset we want to compute for each squashed RenderLayer is e ssentially the position of
573 // the squashed RenderLayer described w.r.t. referenceLayer's origin. For th is purpose we already cached 573 // the squashed RenderLayer described w.r.t. referenceLayer's origin. For th is purpose we already cached
574 // offsetFromSquashingCLM before, which describes where the squashed RenderL ayer is located w.r.t. 574 // offsetFromSquashingCLM before, which describes where the squashed RenderL ayer is located w.r.t.
575 // referenceLayer. So we just need to convert that point from referenceLayer space to referenceLayer 575 // referenceLayer. So we just need to convert that point from referenceLayer space to referenceLayer
576 // space. This is simply done by subtracing squashLayerOriginInOwningLayerSp ace, but then the offset 576 // space. This is simply done by subtracing squashLayerOriginInOwningLayerSp ace, but then the offset
577 // overall needs to be negated because that's the direction that the paintin g code expects the 577 // overall needs to be negated because that's the direction that the paintin g code expects the
578 // offset to be. 578 // offset to be.
579 for (size_t i = 0; i < layers.size(); ++i) { 579 for (size_t i = 0; i < layers.size(); ++i) {
580 LayoutPoint offsetFromTransformedAncestorForSquashedLayer = layers[i].re nderLayer->computeOffsetFromTransformedAncestor(); 580 LayoutPoint offsetFromTransformedAncestorForSquashedLayer = layers[i].re nderLayer->computeOffsetFromTransformedAncestor();
581 LayoutSize offsetFromSquashLayerOrigin = (offsetFromTransformedAncestorF orSquashedLayer - referenceOffsetFromTransformedAncestor) - squashLayerOriginInO wningLayerSpace; 581 LayoutSize offsetFromSquashLayerOrigin = (offsetFromTransformedAncestorF orSquashedLayer - referenceOffsetFromTransformedAncestor) - squashLayerOriginInO wningLayerSpace;
582 582
583 // It is ok to repaint here, because all of the geometry needed to corre ctly repaint is computed by this point. 583 // It is ok to repaint here, because all of the geometry needed to corre ctly repaint is computed by this point.
584 IntSize newOffsetFromRenderer = -flooredIntSize(offsetFromSquashLayerOri gin); 584 IntSize newOffsetFromRenderer = -IntSize(offsetFromSquashLayerOrigin.wid th().round(), offsetFromSquashLayerOrigin.height().round());
585 LayoutSize subpixelAccumulation = offsetFromSquashLayerOrigin + newOffse tFromRenderer;
585 if (layers[i].offsetFromRendererSet && layers[i].offsetFromRenderer != n ewOffsetFromRenderer) 586 if (layers[i].offsetFromRendererSet && layers[i].offsetFromRenderer != n ewOffsetFromRenderer)
586 layers[i].renderLayer->repainter().repaintIncludingNonCompositingDes cendants(); 587 layers[i].renderLayer->repainter().repaintIncludingNonCompositingDes cendants();
587 layers[i].offsetFromRenderer = newOffsetFromRenderer; 588 layers[i].offsetFromRenderer = newOffsetFromRenderer;
588 layers[i].offsetFromRendererSet = true; 589 layers[i].offsetFromRendererSet = true;
589 590
590 layers[i].renderLayer->setSubpixelAccumulation(offsetFromSquashLayerOrig in.fraction()); 591 layers[i].renderLayer->setSubpixelAccumulation(subpixelAccumulation);
591 ASSERT(layers[i].renderLayer->subpixelAccumulation() ==
592 toLayoutSize(computeOffsetFromCompositedAncestor(layers[i].renderLay er, layers[i].renderLayer->ancestorCompositingLayer())).fraction());
leviw_travelin_and_unemployed 2014/06/18 17:33:35 I'm sad to see the assert leave, but I'll just cro
593 592
594 // FIXME: find a better design to avoid this redundant value - most like ly it will make 593 // FIXME: find a better design to avoid this redundant value - most like ly it will make
595 // sense to move the paint task info into RenderLayer's m_compositingPro perties. 594 // sense to move the paint task info into RenderLayer's m_compositingPro perties.
596 layers[i].renderLayer->setOffsetFromSquashingLayerOrigin(layers[i].offse tFromRenderer); 595 layers[i].renderLayer->setOffsetFromSquashingLayerOrigin(layers[i].offse tFromRenderer);
597 } 596 }
598 597
599 for (size_t i = 0; i < layers.size(); ++i) 598 for (size_t i = 0; i < layers.size(); ++i)
600 layers[i].localClipRectForSquashedLayer = localClipRectForSquashedLayer( referenceLayer, layers[i], layers); 599 layers[i].localClipRectForSquashedLayer = localClipRectForSquashedLayer( referenceLayer, layers[i], layers);
601 } 600 }
602 601
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2265 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2267 name = "Scrolling Block Selection Layer"; 2266 name = "Scrolling Block Selection Layer";
2268 } else { 2267 } else {
2269 ASSERT_NOT_REACHED(); 2268 ASSERT_NOT_REACHED();
2270 } 2269 }
2271 2270
2272 return name; 2271 return name;
2273 } 2272 }
2274 2273
2275 } // namespace WebCore 2274 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/compositing/squashing/subpixel-rounding-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698