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

Side by Side Diff: cc/CCLayerTreeHostCommon.cpp

Issue 10916279: Chromium compositor change implementing page-scale driven pinch-zoom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Change m_unpinchedViewportSize and remove unnecessary >1 page scale clamping. Created 8 years, 2 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include "config.h" 6 #include "config.h"
7 7
8 #include "CCLayerTreeHostCommon.h" 8 #include "CCLayerTreeHostCommon.h"
9 9
10 #include "CCLayerImpl.h" 10 #include "CCLayerImpl.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // -- this is just a translation by scrollDelta. 264 // -- this is just a translation by scrollDelta.
265 // Step 3. transform back to target surface space. 265 // Step 3. transform back to target surface space.
266 // -- this transform is the "partialLayerOriginTransform" = (paren tMatrix * scale(layer->pageScaleDelta())); 266 // -- this transform is the "partialLayerOriginTransform" = (paren tMatrix * scale(layer->pageScaleDelta()));
267 // 267 //
268 // These steps create a matrix that both start and end in targetSurfaceSpace . So this matrix can 268 // These steps create a matrix that both start and end in targetSurfaceSpace . So this matrix can
269 // pre-multiply any fixed-position layer's drawTransform to undo the scrollD eltas -- as long as 269 // pre-multiply any fixed-position layer's drawTransform to undo the scrollD eltas -- as long as
270 // that fixed position layer is fixed onto the same renderTarget as this scr ollingLayer. 270 // that fixed position layer is fixed onto the same renderTarget as this scr ollingLayer.
271 // 271 //
272 272
273 WebTransformationMatrix partialLayerOriginTransform = parentMatrix; 273 WebTransformationMatrix partialLayerOriginTransform = parentMatrix;
274 partialLayerOriginTransform.scale(scrollingLayer->pageScaleDelta()); 274 partialLayerOriginTransform.multiply(scrollingLayer->implTransform());
275 275
276 WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginT ransform; // Step 3 276 WebTransformationMatrix scrollCompensationForThisLayer = partialLayerOriginT ransform; // Step 3
277 scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().width (), scrollingLayer->scrollDelta().height()); // Step 2 277 scrollCompensationForThisLayer.translate(scrollingLayer->scrollDelta().width (), scrollingLayer->scrollDelta().height()); // Step 2
278 scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse( )); // Step 1 278 scrollCompensationForThisLayer.multiply(partialLayerOriginTransform.inverse( )); // Step 1
279 return scrollCompensationForThisLayer; 279 return scrollCompensationForThisLayer;
280 } 280 }
281 281
282 WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerChromium * currentLayer, const WebTransformationMatrix& currentParentMatrix, const WebTra nsformationMatrix& currentScrollCompensation) 282 WebTransformationMatrix computeScrollCompensationMatrixForChildren(LayerChromium * currentLayer, const WebTransformationMatrix& currentParentMatrix, const WebTra nsformationMatrix& currentScrollCompensation)
283 { 283 {
284 // The main thread (i.e. LayerChromium) does not need to worry about scroll compensation. 284 // The main thread (i.e. LayerChromium) does not need to worry about scroll compensation.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 461
462 IntSize bounds = layer->bounds(); 462 IntSize bounds = layer->bounds();
463 FloatPoint anchorPoint = layer->anchorPoint(); 463 FloatPoint anchorPoint = layer->anchorPoint();
464 FloatPoint position = layer->position() - layer->scrollDelta(); 464 FloatPoint position = layer->position() - layer->scrollDelta();
465 465
466 // Offset between anchor point and the center of the quad. 466 // Offset between anchor point and the center of the quad.
467 float centerOffsetX = (0.5 - anchorPoint.x()) * bounds.width(); 467 float centerOffsetX = (0.5 - anchorPoint.x()) * bounds.width();
468 float centerOffsetY = (0.5 - anchorPoint.y()) * bounds.height(); 468 float centerOffsetY = (0.5 - anchorPoint.y()) * bounds.height();
469 469
470 WebTransformationMatrix layerLocalTransform; 470 WebTransformationMatrix layerLocalTransform;
471 // LT = S[pageScaleDelta] 471 // LT = M[impl transformation]
472 layerLocalTransform.scale(layer->pageScaleDelta()); 472 layerLocalTransform.multiply(layer->implTransform());
473 // LT = S[pageScaleDelta] * Tr[origin] * Tr[origin2anchor] 473 // LT = M[impl transformation] * Tr[origin] * Tr[origin2anchor]
474 layerLocalTransform.translate3d(position.x() + anchorPoint.x() * bounds.widt h(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ()); 474 layerLocalTransform.translate3d(position.x() + anchorPoint.x() * bounds.widt h(), position.y() + anchorPoint.y() * bounds.height(), layer->anchorPointZ());
475 // LT = S[pageScaleDelta] * Tr[origin] * Tr[origin2anchor] * M[layer] 475 // LT = M[impl transformation] * Tr[origin] * Tr[origin2anchor] * M[layer]
476 layerLocalTransform.multiply(layer->transform()); 476 layerLocalTransform.multiply(layer->transform());
477 // LT = S[pageScaleDelta] * Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[a nchor2center] 477 // LT = M[impl transformation] * Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2center]
478 layerLocalTransform.translate3d(centerOffsetX, centerOffsetY, -layer->anchor PointZ()); 478 layerLocalTransform.translate3d(centerOffsetX, centerOffsetY, -layer->anchor PointZ());
479 479
480 WebTransformationMatrix combinedTransform = parentMatrix; 480 WebTransformationMatrix combinedTransform = parentMatrix;
481 combinedTransform.multiply(layerLocalTransform); 481 combinedTransform.multiply(layerLocalTransform);
482 482
483 if (layer->fixedToContainerLayer()) { 483 if (layer->fixedToContainerLayer()) {
484 // Special case: this layer is a composited fixed-position layer; we nee d to 484 // Special case: this layer is a composited fixed-position layer; we nee d to
485 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep this layer 485 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep this layer
486 // fixed correctly. 486 // fixed correctly.
487 combinedTransform = currentScrollCompensationMatrix * combinedTransform; 487 combinedTransform = currentScrollCompensationMatrix * combinedTransform;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 885
886 foundLayer = currentLayer; 886 foundLayer = currentLayer;
887 break; 887 break;
888 } 888 }
889 889
890 // This can potentially return 0, which means the viewportPoint did not succ essfully hit test any layers, not even the root layer. 890 // This can potentially return 0, which means the viewportPoint did not succ essfully hit test any layers, not even the root layer.
891 return foundLayer; 891 return foundLayer;
892 } 892 }
893 893
894 } // namespace cc 894 } // namespace cc
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHost.cpp ('k') | cc/CCLayerTreeHostImpl.h » ('j') | cc/CCLayerTreeHostImplTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698