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

Side by Side Diff: cc/layers/layer.cc

Issue 1848613002: Extract subpixel offsets from composited layer transforms when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 gfx::Transform inverse(gfx::Transform::kSkipInitialization); 608 gfx::Transform inverse(gfx::Transform::kSkipInitialization);
609 *is_invertible = b.GetInverse(&inverse); 609 *is_invertible = b.GetInverse(&inverse);
610 610
611 inverse *= a; 611 inverse *= a;
612 return inverse.Preserves2dAxisAlignment(); 612 return inverse.Preserves2dAxisAlignment();
613 } 613 }
614 614
615 void Layer::SetTransform(const gfx::Transform& transform) { 615 void Layer::SetTransform(const gfx::Transform& transform) {
616 DCHECK(IsPropertyChangeAllowed()); 616 DCHECK(IsPropertyChangeAllowed());
617 if (transform_ == transform) 617 transform_ = transform;
618
619 if (transform.IsIdentityOr2DTranslation()) {
620 gfx::Vector2dF translate = transform.To2dTranslation();
621 // Am I correct? -vmpstr
622 subpixel_offset_.set_x(translate.x() - std::floor(translate.x()));
623 subpixel_offset_.set_y(translate.y() - std::floor(translate.y()));
624 transform_.Translate(-subpixel_offset_.x(), -subpixel_offset_.y());
625 LOG(ERROR) << "Layer::SetTransform with subpixel: " << this << ": " << subpi xel_offset_.ToString() << ": " << transform_.To2dTranslation().ToString();
626 }
627
628 if (transform_ == transform) {
629 LOG(ERROR) << "early out";
618 return; 630 return;
631 }
619 632
620 SetSubtreePropertyChanged(); 633 SetSubtreePropertyChanged();
621 if (layer_tree_host_) { 634 if (layer_tree_host_) {
635 LOG(ERROR) << "layer_tree_host_ found";
636
622 if (TransformNode* transform_node = 637 if (TransformNode* transform_node =
623 layer_tree_host_->property_trees()->transform_tree.Node( 638 layer_tree_host_->property_trees()->transform_tree.Node(
624 transform_tree_index())) { 639 transform_tree_index())) {
640 LOG(ERROR) << "node found";
625 if (transform_node->owner_id == id()) { 641 if (transform_node->owner_id == id()) {
642 LOG(ERROR) << "id found";
626 // We need to trigger a rebuild if we could have affected 2d axis 643 // We need to trigger a rebuild if we could have affected 2d axis
627 // alignment. We'll check to see if transform and transform_ are axis 644 // alignment. We'll check to see if transform and transform_ are axis
628 // align with respect to one another. 645 // align with respect to one another.
629 bool invertible = false; 646 bool invertible = false;
630 bool preserves_2d_axis_alignment = 647 bool preserves_2d_axis_alignment =
631 Are2dAxisAligned(transform_, transform, &invertible); 648 Are2dAxisAligned(transform_, transform, &invertible);
632 transform_node->data.local = transform; 649 transform_node->data.local = transform;
650
633 transform_node->data.needs_local_transform_update = true; 651 transform_node->data.needs_local_transform_update = true;
634 transform_node->data.transform_changed = true; 652 transform_node->data.transform_changed = true;
635 layer_tree_host_->property_trees()->transform_tree.set_needs_update( 653 layer_tree_host_->property_trees()->transform_tree.set_needs_update(
636 true); 654 true);
637 if (preserves_2d_axis_alignment) 655 if (preserves_2d_axis_alignment)
638 SetNeedsCommitNoRebuild(); 656 SetNeedsCommitNoRebuild();
639 else 657 else
640 SetNeedsCommit(); 658 SetNeedsCommit();
641 transform_ = transform; 659 transform_ = transform;
642 transform_is_invertible_ = invertible; 660 transform_is_invertible_ = invertible;
643 return; 661 return;
644 } 662 }
645 } 663 }
664 } else {
665 LOG(ERROR) << "no layer tree host???";
646 } 666 }
647 667
648 transform_ = transform;
649 transform_is_invertible_ = transform.IsInvertible(); 668 transform_is_invertible_ = transform.IsInvertible();
650 669
651 SetNeedsCommit(); 670 SetNeedsCommit();
652 } 671 }
653 672
654 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { 673 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) {
655 DCHECK(IsPropertyChangeAllowed()); 674 DCHECK(IsPropertyChangeAllowed());
656 if (transform_origin_ == transform_origin) 675 if (transform_origin_ == transform_origin)
657 return; 676 return;
658 transform_origin_ = transform_origin; 677 transform_origin_ = transform_origin;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_); 1147 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_);
1129 layer->SetBounds(use_paint_properties ? paint_properties_.bounds 1148 layer->SetBounds(use_paint_properties ? paint_properties_.bounds
1130 : bounds_); 1149 : bounds_);
1131 1150
1132 #if defined(NDEBUG) 1151 #if defined(NDEBUG)
1133 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) 1152 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots())
1134 layer->SetDebugInfo(TakeDebugInfo()); 1153 layer->SetDebugInfo(TakeDebugInfo());
1135 #else 1154 #else
1136 layer->SetDebugInfo(TakeDebugInfo()); 1155 layer->SetDebugInfo(TakeDebugInfo());
1137 #endif 1156 #endif
1138 1157 layer->SetSubpixelOffset(subpixel_offset_);
1139 layer->SetTransformTreeIndex(transform_tree_index()); 1158 layer->SetTransformTreeIndex(transform_tree_index());
1140 layer->SetEffectTreeIndex(effect_tree_index()); 1159 layer->SetEffectTreeIndex(effect_tree_index());
1141 layer->SetClipTreeIndex(clip_tree_index()); 1160 layer->SetClipTreeIndex(clip_tree_index());
1142 layer->SetScrollTreeIndex(scroll_tree_index()); 1161 layer->SetScrollTreeIndex(scroll_tree_index());
1143 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 1162 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
1144 layer->SetDoubleSided(double_sided_); 1163 layer->SetDoubleSided(double_sided_);
1145 layer->SetDrawsContent(DrawsContent()); 1164 layer->SetDrawsContent(DrawsContent());
1146 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 1165 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
1147 layer->SetHasRenderSurface(has_render_surface_); 1166 layer->SetHasRenderSurface(has_render_surface_);
1148 // subtree_property_changed_ is propagated to all descendants while building 1167 // subtree_property_changed_ is propagated to all descendants while building
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 this, layer_tree_host_->property_trees()->transform_tree); 1864 this, layer_tree_host_->property_trees()->transform_tree);
1846 } 1865 }
1847 1866
1848 gfx::Transform Layer::screen_space_transform() const { 1867 gfx::Transform Layer::screen_space_transform() const {
1849 DCHECK_NE(transform_tree_index_, -1); 1868 DCHECK_NE(transform_tree_index_, -1);
1850 return draw_property_utils::ScreenSpaceTransform( 1869 return draw_property_utils::ScreenSpaceTransform(
1851 this, layer_tree_host_->property_trees()->transform_tree); 1870 this, layer_tree_host_->property_trees()->transform_tree);
1852 } 1871 }
1853 1872
1854 } // namespace cc 1873 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698