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

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 10 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
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/trees/layer_tree_host_common.h" 5 #include "cc/trees/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/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 layer->contents_opaque(); 1824 layer->contents_opaque();
1825 } 1825 }
1826 1826
1827 // full_hierarchy_matrix is the matrix that transforms objects between screen 1827 // full_hierarchy_matrix is the matrix that transforms objects between screen
1828 // space (except projection matrix) and the most recent RenderSurfaceImpl's 1828 // space (except projection matrix) and the most recent RenderSurfaceImpl's
1829 // space. next_hierarchy_matrix will only change if this layer uses a new 1829 // space. next_hierarchy_matrix will only change if this layer uses a new
1830 // RenderSurfaceImpl, otherwise remains the same. 1830 // RenderSurfaceImpl, otherwise remains the same.
1831 data_for_children.full_hierarchy_matrix = 1831 data_for_children.full_hierarchy_matrix =
1832 data_from_ancestor.full_hierarchy_matrix; 1832 data_from_ancestor.full_hierarchy_matrix;
1833 1833
1834 // If the subtree will scale layer contents by the transform hierarchy, then
1835 // we should scale things into the render surface by the transform hierarchy
1836 // to take advantage of that.
1837 gfx::Vector2dF render_surface_sublayer_scale =
1838 globals.can_adjust_raster_scales
1839 ? combined_transform_scales
1840 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors);
1841
1842 bool render_to_separate_surface = 1834 bool render_to_separate_surface =
1843 IsRootLayer(layer) || 1835 IsRootLayer(layer) ||
1844 (globals.can_render_to_separate_surface && layer->render_surface()); 1836 (globals.can_render_to_separate_surface && layer->render_surface());
1845 1837
1846 if (render_to_separate_surface) { 1838 if (render_to_separate_surface) {
1847 DCHECK(layer->render_surface()); 1839 DCHECK(layer->render_surface());
1848 // Check back-face visibility before continuing with this surface and its 1840 // Check back-face visibility before continuing with this surface and its
1849 // subtree 1841 // subtree
1850 if (!layer->double_sided() && TransformToParentIsKnown(layer) && 1842 if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
1851 IsSurfaceBackFaceVisible(layer, combined_transform)) { 1843 IsSurfaceBackFaceVisible(layer, combined_transform)) {
(...skipping 14 matching lines...) Expand all
1866 data_for_children.parent_matrix = combined_transform; 1858 data_for_children.parent_matrix = combined_transform;
1867 1859
1868 // The root surface does not contribute to any other surface, it has no 1860 // The root surface does not contribute to any other surface, it has no
1869 // target. 1861 // target.
1870 layer->render_surface()->set_contributes_to_drawn_surface(false); 1862 layer->render_surface()->set_contributes_to_drawn_surface(false);
1871 } else { 1863 } else {
1872 // The owning layer's draw transform has a scale from content to layer 1864 // The owning layer's draw transform has a scale from content to layer
1873 // space which we do not want; so here we use the combined_transform 1865 // space which we do not want; so here we use the combined_transform
1874 // instead of the draw_transform. However, we do need to add a different 1866 // instead of the draw_transform. However, we do need to add a different
1875 // scale factor that accounts for the surface's pixel dimensions. 1867 // scale factor that accounts for the surface's pixel dimensions.
1876 combined_transform.Scale(1.0 / render_surface_sublayer_scale.x(), 1868 // Remove the combined_transform scale from the draw transform.
1877 1.0 / render_surface_sublayer_scale.y()); 1869 gfx::Transform draw_transform = combined_transform;
1878 render_surface->SetDrawTransform(combined_transform); 1870 draw_transform.Scale(1.0 / combined_transform_scales.x(),
1871 1.0 / combined_transform_scales.y());
1872 render_surface->SetDrawTransform(draw_transform);
1879 1873
1880 // The owning layer's transform was re-parented by the surface, so the 1874 // The owning layer's transform was re-parented by the surface, so the
1881 // layer's new draw_transform only needs to scale the layer to surface 1875 // layer's new draw_transform only needs to scale the layer to surface
1882 // space. 1876 // space.
1883 layer_draw_properties.target_space_transform.MakeIdentity(); 1877 layer_draw_properties.target_space_transform.MakeIdentity();
1884 layer_draw_properties.target_space_transform. 1878 layer_draw_properties.target_space_transform.Scale(
1885 Scale(render_surface_sublayer_scale.x() / layer->contents_scale_x(), 1879 combined_transform_scales.x() / layer->contents_scale_x(),
1886 render_surface_sublayer_scale.y() / layer->contents_scale_y()); 1880 combined_transform_scales.y() / layer->contents_scale_y());
1887 1881
1888 // Inside the surface's subtree, we scale everything to the owning layer's 1882 // Inside the surface's subtree, we scale everything to the owning layer's
1889 // scale. The sublayer matrix transforms layer rects into target surface 1883 // scale. The sublayer matrix transforms layer rects into target surface
1890 // content space. Conceptually, all layers in the subtree inherit the 1884 // content space. Conceptually, all layers in the subtree inherit the
1891 // scale at the point of the render surface in the transform hierarchy, 1885 // scale at the point of the render surface in the transform hierarchy,
1892 // but we apply it explicitly to the owning layer and the remainder of the 1886 // but we apply it explicitly to the owning layer and the remainder of the
1893 // subtree independently. 1887 // subtree independently.
1894 DCHECK(data_for_children.parent_matrix.IsIdentity()); 1888 DCHECK(data_for_children.parent_matrix.IsIdentity());
1895 data_for_children.parent_matrix.Scale(render_surface_sublayer_scale.x(), 1889 data_for_children.parent_matrix.Scale(combined_transform_scales.x(),
1896 render_surface_sublayer_scale.y()); 1890 combined_transform_scales.y());
1897 1891
1898 // Even if the |layer_is_drawn|, it only contributes to a drawn surface 1892 // Even if the |layer_is_drawn|, it only contributes to a drawn surface
1899 // when the |layer_is_visible|. 1893 // when the |layer_is_visible|.
1900 layer->render_surface()->set_contributes_to_drawn_surface( 1894 layer->render_surface()->set_contributes_to_drawn_surface(
1901 layer_is_visible); 1895 layer_is_visible);
1902 } 1896 }
1903 1897
1904 // The opacity value is moved from the layer to its surface, so that the 1898 // The opacity value is moved from the layer to its surface, so that the
1905 // entire subtree properly inherits opacity. 1899 // entire subtree properly inherits opacity.
1906 render_surface->SetDrawOpacity(accumulated_draw_opacity); 1900 render_surface->SetDrawOpacity(accumulated_draw_opacity);
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 IsRootLayer(layer->parent()->render_target()) || 2298 IsRootLayer(layer->parent()->render_target()) ||
2305 layer->parent()->render_target()->is_root_for_isolated_group()); 2299 layer->parent()->render_target()->is_root_for_isolated_group());
2306 2300
2307 render_surface->SetContentRect(clipped_content_rect); 2301 render_surface->SetContentRect(clipped_content_rect);
2308 2302
2309 // The owning layer's screen_space_transform has a scale from content to 2303 // The owning layer's screen_space_transform has a scale from content to
2310 // layer space which we need to undo and replace with a scale from the 2304 // layer space which we need to undo and replace with a scale from the
2311 // surface's subtree into layer space. 2305 // surface's subtree into layer space.
2312 gfx::Transform screen_space_transform = layer->screen_space_transform(); 2306 gfx::Transform screen_space_transform = layer->screen_space_transform();
2313 screen_space_transform.Scale( 2307 screen_space_transform.Scale(
2314 layer->contents_scale_x() / render_surface_sublayer_scale.x(), 2308 layer->contents_scale_x() / combined_transform_scales.x(),
2315 layer->contents_scale_y() / render_surface_sublayer_scale.y()); 2309 layer->contents_scale_y() / combined_transform_scales.y());
2316 render_surface->SetScreenSpaceTransform(screen_space_transform); 2310 render_surface->SetScreenSpaceTransform(screen_space_transform);
2317 2311
2318 if (layer->replica_layer()) { 2312 if (layer->replica_layer()) {
2319 gfx::Transform surface_origin_to_replica_origin_transform; 2313 gfx::Transform surface_origin_to_replica_origin_transform;
2320 surface_origin_to_replica_origin_transform.Scale( 2314 surface_origin_to_replica_origin_transform.Scale(
2321 render_surface_sublayer_scale.x(), render_surface_sublayer_scale.y()); 2315 combined_transform_scales.x(), combined_transform_scales.y());
2322 surface_origin_to_replica_origin_transform.Translate( 2316 surface_origin_to_replica_origin_transform.Translate(
2323 layer->replica_layer()->position().x() + 2317 layer->replica_layer()->position().x() +
2324 layer->replica_layer()->transform_origin().x(), 2318 layer->replica_layer()->transform_origin().x(),
2325 layer->replica_layer()->position().y() + 2319 layer->replica_layer()->position().y() +
2326 layer->replica_layer()->transform_origin().y()); 2320 layer->replica_layer()->transform_origin().y());
2327 surface_origin_to_replica_origin_transform.PreconcatTransform( 2321 surface_origin_to_replica_origin_transform.PreconcatTransform(
2328 layer->replica_layer()->transform()); 2322 layer->replica_layer()->transform());
2329 surface_origin_to_replica_origin_transform.Translate( 2323 surface_origin_to_replica_origin_transform.Translate(
2330 -layer->replica_layer()->transform_origin().x(), 2324 -layer->replica_layer()->transform_origin().x(),
2331 -layer->replica_layer()->transform_origin().y()); 2325 -layer->replica_layer()->transform_origin().y());
2332 surface_origin_to_replica_origin_transform.Scale( 2326 surface_origin_to_replica_origin_transform.Scale(
2333 1.0 / render_surface_sublayer_scale.x(), 2327 1.0 / combined_transform_scales.x(),
2334 1.0 / render_surface_sublayer_scale.y()); 2328 1.0 / combined_transform_scales.y());
2335 2329
2336 // Compute the replica's "originTransform" that maps from the replica's 2330 // Compute the replica's "originTransform" that maps from the replica's
2337 // origin space to the target surface origin space. 2331 // origin space to the target surface origin space.
2338 gfx::Transform replica_origin_transform = 2332 gfx::Transform replica_origin_transform =
2339 layer->render_surface()->draw_transform() * 2333 layer->render_surface()->draw_transform() *
2340 surface_origin_to_replica_origin_transform; 2334 surface_origin_to_replica_origin_transform;
2341 render_surface->SetReplicaDrawTransform(replica_origin_transform); 2335 render_surface->SetReplicaDrawTransform(replica_origin_transform);
2342 2336
2343 // Compute the replica's "screen_space_transform" that maps from the 2337 // Compute the replica's "screen_space_transform" that maps from the
2344 // replica's origin space to the screen's origin space. 2338 // replica's origin space to the screen's origin space.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 inputs->current_render_surface_layer_list_id); 2564 inputs->current_render_surface_layer_list_id);
2571 2565
2572 // The dummy layer list should not have been used. 2566 // The dummy layer list should not have been used.
2573 DCHECK_EQ(0u, dummy_layer_list.size()); 2567 DCHECK_EQ(0u, dummy_layer_list.size());
2574 // A root layer render_surface should always exist after 2568 // A root layer render_surface should always exist after
2575 // CalculateDrawProperties. 2569 // CalculateDrawProperties.
2576 DCHECK(inputs->root_layer->render_surface()); 2570 DCHECK(inputs->root_layer->render_surface());
2577 } 2571 }
2578 2572
2579 } // namespace cc 2573 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_web_graphics_context_3d_unittest.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698