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

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: rebase 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
« no previous file with comments | « cc/layer_impl.cc ('k') | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
377 static inline void updateLayerContentsScale(LayerImpl*, const gfx::Transform&, f loat, float, bool) { } 377 {
378 }
378 379
379 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin gTransformToScreen) 380 static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animatin gTransformToScreen)
380 { 381 {
381 float rasterScale = layer->rasterScale(); 382 float rasterScale = layer->rasterScale();
382 if (!rasterScale) { 383 if (!rasterScale) {
383 rasterScale = 1; 384 rasterScale = 1;
384 385
385 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal e()) { 386 if (!animatingTransformToScreen && layer->automaticallyComputeRasterScal e()) {
386 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom ponents(combinedTransform); 387 gfx::Vector2dF transformScale = MathUtil::computeTransform2dScaleCom ponents(combinedTransform);
387 float combinedScale = std::max(transformScale.x(), transformScale.y( )); 388 float combinedScale = std::max(transformScale.x(), transformScale.y( ));
388 rasterScale = combinedScale / deviceScaleFactor; 389 rasterScale = combinedScale / deviceScaleFactor;
389 if (!layer->boundsContainPageScale()) 390 if (!layer->boundsContainPageScale())
390 rasterScale /= pageScaleFactor; 391 rasterScale /= pageScaleFactor;
391 // Prevent scale factors below 1 from being used or saved. 392 // Prevent scale factors below 1 from being used or saved.
392 if (rasterScale < 1) 393 if (rasterScale < 1)
393 rasterScale = 1; 394 rasterScale = 1;
394 else 395 else
395 layer->setRasterScale(rasterScale); 396 layer->setRasterScale(rasterScale);
396 } 397 }
397 } 398 }
398 399
399 float contentsScale = rasterScale * deviceScaleFactor; 400 float contentsScale = rasterScale * deviceScaleFactor;
400 if (!layer->boundsContainPageScale()) 401 if (!layer->boundsContainPageScale())
401 contentsScale *= pageScaleFactor; 402 contentsScale *= pageScaleFactor;
402 layer->setContentsScale(contentsScale); 403 layer->calculateContentsScale(
404 contentsScale,
405 &layer->drawProperties().contents_scale_x,
406 &layer->drawProperties().contents_scale_y,
407 &layer->drawProperties().content_bounds);
403 408
404 Layer* maskLayer = layer->maskLayer(); 409 Layer* maskLayer = layer->maskLayer();
405 if (maskLayer) 410 if (maskLayer)
406 maskLayer->setContentsScale(contentsScale); 411 {
412 maskLayer->calculateContentsScale(
413 contentsScale,
414 &maskLayer->drawProperties().contents_scale_x,
415 &maskLayer->drawProperties().contents_scale_y,
416 &maskLayer->drawProperties().content_bounds);
417 }
407 418
408 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas kLayer() : 0; 419 Layer* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->mas kLayer() : 0;
409 if (replicaMaskLayer) 420 if (replicaMaskLayer)
410 replicaMaskLayer->setContentsScale(contentsScale); 421 {
422 replicaMaskLayer->calculateContentsScale(
423 contentsScale,
424 &replicaMaskLayer->drawProperties().contents_scale_x,
425 &replicaMaskLayer->drawProperties().contents_scale_y,
426 &replicaMaskLayer->drawProperties().content_bounds);
427 }
411 } 428 }
412 429
413 template<typename LayerType, typename LayerList> 430 template<typename LayerType, typename LayerList>
414 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList & renderSurfaceLayerList) 431 static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList & renderSurfaceLayerList)
415 { 432 {
416 DCHECK(layerToRemove->renderSurface()); 433 DCHECK(layerToRemove->renderSurface());
417 // Technically, we know that the layer we want to remove should be 434 // Technically, we know that the layer we want to remove should be
418 // at the back of the renderSurfaceLayerList. However, we have had 435 // at the back of the renderSurfaceLayerList. However, we have had
419 // bugs before that added unnecessary layers here 436 // bugs before that added unnecessary layers here
420 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes 437 // (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 1112
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 1113 // 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 1114 // 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. 1115 // hit point actually should not hit the layer.
1099 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) 1116 if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl))
1100 return false; 1117 return false;
1101 1118
1102 return true; 1119 return true;
1103 } 1120 }
1104 } // namespace cc 1121 } // namespace cc
OLDNEW
« no previous file with comments | « 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