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

Side by Side Diff: cc/layer_tree_host_common.cc

Issue 11503005: cc: Refactor content scale/bounds into draw properties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix shadowing Created 8 years 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 #include "cc/layer_tree_host_common.h" 5 #include "cc/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/layer.h" 10 #include "cc/layer.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // The adjustment allows us to continue using the scrollCompensation on the next surface. 366 // The adjustment allows us to continue using the scrollCompensation on the next surface.
367 // Step 1 (right-most in the math): transform from the new surface to the o riginal ancestor surface 367 // Step 1 (right-most in the math): transform from the new surface to the o riginal ancestor surface
368 // Step 2: apply the scroll compensation 368 // Step 2: apply the scroll compensation
369 // Step 3: transform back to the new surface. 369 // Step 3: transform back to the new surface.
370 if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) 370 if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity())
371 nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()- >drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawT ransform(); 371 nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()- >drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawT ransform();
372 372
373 return nextScrollCompensationMatrix; 373 return nextScrollCompensationMatrix;
374 } 374 }
375 375
376 // There is no contentsScale on impl thread. 376 static inline void updateLayerContentsScale(LayerImpl* layer, const gfx::Transfo rm& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool anim atingTransformToScreen)
danakj 2012/12/14 20:37:23 Prefer this as a separate change where it'll be us
enne (OOO) 2012/12/14 22:06:05 Done.
377 static inline void updateLayerContentsScale(LayerImpl*, const gfx::Transform&, f loat, float, bool) { } 377 {
378 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleComponents( combinedTransform);
379 float contentsScale = std::max(transformScale.x(), transformScale.y());
380 layer->updateContentsScale(contentsScale);
381
382 LayerImpl* maskLayer = layer->maskLayer();
383 if (maskLayer)
384 maskLayer->updateContentsScale(contentsScale);
385
386 LayerImpl* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()- >maskLayer() : 0;
387 if (replicaMaskLayer)
388 replicaMaskLayer->updateContentsScale(contentsScale);
389 }
378 390
379 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin gTransformToScreen) 391 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin gTransformToScreen)
380 { 392 {
381 float rasterScale = layer->rasterScale(); 393 float rasterScale = layer->rasterScale();
382 if (!rasterScale) { 394 if (!rasterScale) {
383 rasterScale = 1; 395 rasterScale = 1;
384 396
385 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal e()) { 397 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal e()) {
386 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom ponents(combinedTransform); 398 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom ponents(combinedTransform);
387 float combinedScale = std::max(transformScale.x(), transformScale.y( )); 399 float combinedScale = std::max(transformScale.x(), transformScale.y( ));
388 rasterScale = combinedScale / deviceScaleFactor; 400 rasterScale = combinedScale / deviceScaleFactor;
389 if (!layer->boundsContainPageScale()) 401 if (!layer->boundsContainPageScale())
390 rasterScale /= pageScaleFactor; 402 rasterScale /= pageScaleFactor;
391 // Prevent scale factors below 1 from being used or saved. 403 // Prevent scale factors below 1 from being used or saved.
392 if (rasterScale < 1) 404 if (rasterScale < 1)
393 rasterScale = 1; 405 rasterScale = 1;
394 else 406 else
395 layer->setRasterScale(rasterScale); 407 layer->setRasterScale(rasterScale);
396 } 408 }
397 } 409 }
398 410
399 float contentsScale = rasterScale * deviceScaleFactor; 411 float contentsScale = rasterScale * deviceScaleFactor;
400 if (!layer->boundsContainPageScale()) 412 if (!layer->boundsContainPageScale())
401 contentsScale *= pageScaleFactor; 413 contentsScale *= pageScaleFactor;
402 layer->setContentsScale(contentsScale); 414 layer->updateContentsScale(contentsScale);
403 415
404 Layer* maskLayer = layer->maskLayer(); 416 Layer* maskLayer = layer->maskLayer();
405 if (maskLayer) 417 if (maskLayer)
406 maskLayer->setContentsScale(contentsScale); 418 maskLayer->updateContentsScale(contentsScale);
407 419
408 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas kLayer() : 0; 420 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas kLayer() : 0;
409 if (replicaMaskLayer) 421 if (replicaMaskLayer)
410 replicaMaskLayer->setContentsScale(contentsScale); 422 replicaMaskLayer->updateContentsScale(contentsScale);
411 } 423 }
412 424
413 template<typename LayerType, typename LayerList> 425 template<typename LayerType, typename LayerList>
414 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList & renderSurfaceLayerList) 426 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList & renderSurfaceLayerList)
415 { 427 {
416 DCHECK(layerToRemove->renderSurface()); 428 DCHECK(layerToRemove->renderSurface());
417 // Technically, we know that the layer we want to remove should be 429 // Technically, we know that the layer we want to remove should be
418 // at the back of the renderSurfaceLayerList. However, we have had 430 // at the back of the renderSurfaceLayerList. However, we have had
419 // bugs before that added unnecessary layers here 431 // bugs before that added unnecessary layers here
420 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes 432 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1107
1096 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up 1108 // At this point, we think the point does hit the touch event handler region o n the layer, but we need to walk up
1097 // the parents to ensure that the layer was not clipped in such a way that the 1109 // the parents to ensure that the layer was not clipped in such a way that the
1098 // hit point actually should not hit the layer. 1110 // hit point actually should not hit the layer.
1099 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1111 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1100 return false; 1112 return false;
1101 1113
1102 return true; 1114 return true;
1103 } 1115 }
1104 } // namespace cc 1116 } // namespace cc
OLDNEW
« cc/layer_impl.cc ('K') | « cc/layer_impl.cc ('k') | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698