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

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 465853004: Moving RenderSurface creation outside of CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unit tests Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 840a32b2ef4a59037f22e33e251c9edee72bc649..0d94d15ed8695529768f2cfd81315665d5cca1cd 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -14,7 +14,9 @@
#include "cc/layers/layer_iterator.h"
#include "cc/layers/render_surface.h"
#include "cc/layers/render_surface_impl.h"
+#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/trees/layer_sorter.h"
+#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/transform.h"
@@ -548,9 +550,8 @@ static inline void SavePaintPropertiesLayer(Layer* layer) {
layer->replica_layer()->mask_layer()->SavePaintProperties();
}
-template <typename LayerType>
static bool SubtreeShouldRenderToSeparateSurface(
- LayerType* layer,
+ Layer* layer,
bool axis_aligned_with_respect_to_parent) {
//
// A layer and its descendants should render onto a new RenderSurfaceImpl if
@@ -1815,23 +1816,25 @@ static void CalculateDrawPropertiesInternal(
bool render_to_separate_surface;
if (globals.can_render_to_separate_surface) {
- render_to_separate_surface = SubtreeShouldRenderToSeparateSurface(
- layer, combined_transform.Preserves2dAxisAlignment());
+ render_to_separate_surface = layer->ShouldHaveRenderSurface();
} else {
- render_to_separate_surface = IsRootLayer(layer);
+ render_to_separate_surface =
+ layer->ShouldHaveRenderSurface() && IsRootLayer(layer);
danakj 2014/08/26 18:06:13 the root has to have a surface, and nothing else i
awoloszyn 2014/08/28 19:31:43 We may still have a render-surface if !globals.can
}
+ layer->SetRenderSurfaceActive(render_to_separate_surface);
danakj 2014/08/26 18:06:13 The RS computation decides if the render surface s
awoloszyn 2014/08/28 19:31:43 Done.
+
if (render_to_separate_surface) {
// Check back-face visibility before continuing with this surface and its
// subtree
if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
IsSurfaceBackFaceVisible(layer, combined_transform)) {
- layer->ClearRenderSurfaceLayerList();
+ layer->SetRenderSurfaceActive(false);
danakj 2014/08/26 18:06:13 And since the RS exists or not correctly, we shoul
awoloszyn 2014/08/28 19:31:43 Done.
return;
}
typename LayerType::RenderSurfaceType* render_surface =
- CreateOrReuseRenderSurface(layer);
-
+ layer->render_surface();
+ render_surface->ClearLayerLists();
if (IsRootLayer(layer)) {
// The root layer's render surface size is predetermined and so the root
// layer can't directly support non-identity transforms. It should just
@@ -2006,8 +2009,6 @@ static void CalculateDrawPropertiesInternal(
animating_opacity_to_screen;
data_for_children.parent_matrix = combined_transform;
- layer->ClearRenderSurface();
-
// Layers without render_surfaces directly inherit the ancestor's clip
// status.
layer_or_ancestor_clips_descendants = ancestor_clips_subtree;
@@ -2383,8 +2384,38 @@ static void ProcessCalcDrawPropsInputs(
data_for_recursion->subtree_is_visible_from_ancestor = true;
}
+void CreateOrDestroyRenderSurface(Layer* layer, gfx::Transform* transform) {
+ if (SubtreeShouldRenderToSeparateSurface(
+ layer,
+ transform->IsIdentity() || transform->Preserves2dAxisAlignment())) {
+ transform->MakeIdentity();
+ layer->SetShouldHaveRenderSurface(true);
+ if (!layer->render_surface()) {
+ layer->CreateRenderSurface();
+ }
+ return;
+ }
+ if (layer->render_surface())
+ layer->ClearRenderSurface();
+ layer->SetShouldHaveRenderSurface(false);
+}
+
+static void CreateRenderSurfaces(Layer* layer,
+ const gfx::Transform& parent_transform) {
+ if (!layer)
+ return;
+ gfx::Transform transformForChildren = layer->transform();
+ transformForChildren *= parent_transform;
+ CreateOrDestroyRenderSurface(layer, &transformForChildren);
+
+ for (size_t i = 0; i < layer->children().size(); ++i) {
+ CreateRenderSurfaces(layer->children()[i], transformForChildren);
+ }
+}
+
void LayerTreeHostCommon::CalculateDrawProperties(
CalcDrawPropsMainInputs* inputs) {
+ CreateRenderSurfaces(inputs->root_layer, gfx::Transform());
LayerList dummy_layer_list;
SubtreeGlobals<Layer> globals;
DataForRecursion<Layer> data_for_recursion;

Powered by Google App Engine
This is Rietveld 408576698