summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authoraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 02:46:48 +0000
committeraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 02:46:48 +0000
commit4594871632427d17950b1766c54a19e82ed26818 (patch)
tree09a54760bfd1d9c31c47389201a5804341dbf9b9 /cc
parent29628381a0764af95abadd36621738f31d4affdc (diff)
downloadchromium_src-4594871632427d17950b1766c54a19e82ed26818.zip
chromium_src-4594871632427d17950b1766c54a19e82ed26818.tar.gz
chromium_src-4594871632427d17950b1766c54a19e82ed26818.tar.bz2
Move tile-free-software render surface disabling to UpdateDrawProperties.
Currently when DrawProperties decides a subtree needs a render surface, Android WebView software mode just drops it at CalculateRenderPasses time and draws nothing. If we instead suppress the render surface decision at an earlier stage, we're more likely to get a halfway reasonable result. The motivating example was a page setting preserve-3d where the render surface didn't affect the output result anyway. New test LayerTreeHostCommonTest.CanRenderToSeparateSurface. NOTRY=true BUG=297299 Review URL: https://codereview.chromium.org/24280009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225637 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/trees/layer_tree_host.cc2
-rw-r--r--cc/trees/layer_tree_host_common.cc15
-rw-r--r--cc/trees/layer_tree_host_common.h5
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc78
-rw-r--r--cc/trees/layer_tree_host_impl.cc8
-rw-r--r--cc/trees/layer_tree_impl.cc3
6 files changed, 107 insertions, 4 deletions
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index f8f0d61..e3a1b32 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -797,6 +797,7 @@ bool LayerTreeHost::UpdateLayers(Layer* root_layer,
}
TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps");
+ bool can_render_to_separate_surface = true;
LayerTreeHostCommon::CalcDrawPropsMainInputs inputs(
root_layer,
device_viewport_size(),
@@ -806,6 +807,7 @@ bool LayerTreeHost::UpdateLayers(Layer* root_layer,
page_scale_layer,
GetRendererCapabilities().max_texture_size,
settings_.can_use_lcd_text,
+ can_render_to_separate_surface,
settings_.layer_transforms_should_scale_layer_contents,
&update_list);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 27090da..c2b77bd 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -1088,6 +1088,7 @@ struct SubtreeGlobals {
float page_scale_factor;
LayerType* page_scale_application_layer;
bool can_adjust_raster_scales;
+ bool can_render_to_separate_surface;
};
template<typename LayerType, typename RenderSurfaceType>
@@ -1448,8 +1449,14 @@ static void CalculateDrawPropertiesInternal(
? combined_transform_scales
: gfx::Vector2dF(layer_scale_factors, layer_scale_factors);
- if (SubtreeShouldRenderToSeparateSurface(
- layer, combined_transform.Preserves2dAxisAlignment())) {
+ bool render_to_separate_surface;
+ if (globals.can_render_to_separate_surface) {
+ render_to_separate_surface = SubtreeShouldRenderToSeparateSurface(
+ layer, combined_transform.Preserves2dAxisAlignment());
+ } else {
+ render_to_separate_surface = IsRootLayer(layer);
+ }
+ if (render_to_separate_surface) {
// Check back-face visibility before continuing with this surface and its
// subtree
if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
@@ -1939,6 +1946,8 @@ void LayerTreeHostCommon::CalculateDrawProperties(
globals.device_scale_factor = inputs->device_scale_factor;
globals.page_scale_factor = inputs->page_scale_factor;
globals.page_scale_application_layer = inputs->page_scale_application_layer;
+ globals.can_render_to_separate_surface =
+ inputs->can_render_to_separate_surface;
globals.can_adjust_raster_scales = inputs->can_adjust_raster_scales;
DataForRecursion<Layer, RenderSurface> data_for_recursion;
@@ -1996,6 +2005,8 @@ void LayerTreeHostCommon::CalculateDrawProperties(
globals.device_scale_factor = inputs->device_scale_factor;
globals.page_scale_factor = inputs->page_scale_factor;
globals.page_scale_application_layer = inputs->page_scale_application_layer;
+ globals.can_render_to_separate_surface =
+ inputs->can_render_to_separate_surface;
globals.can_adjust_raster_scales = inputs->can_adjust_raster_scales;
DataForRecursion<LayerImpl, RenderSurfaceImpl> data_for_recursion;
diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h
index 05affee..adabd13 100644
--- a/cc/trees/layer_tree_host_common.h
+++ b/cc/trees/layer_tree_host_common.h
@@ -39,6 +39,7 @@ class CC_EXPORT LayerTreeHostCommon {
LayerType* page_scale_application_layer,
int max_texture_size,
bool can_use_lcd_text,
+ bool can_render_to_separate_surface,
bool can_adjust_raster_scales,
RenderSurfaceLayerListType* render_surface_layer_list)
: root_layer(root_layer),
@@ -49,6 +50,7 @@ class CC_EXPORT LayerTreeHostCommon {
page_scale_application_layer(page_scale_application_layer),
max_texture_size(max_texture_size),
can_use_lcd_text(can_use_lcd_text),
+ can_render_to_separate_surface(can_render_to_separate_surface),
can_adjust_raster_scales(can_adjust_raster_scales),
render_surface_layer_list(render_surface_layer_list) {}
@@ -60,6 +62,7 @@ class CC_EXPORT LayerTreeHostCommon {
LayerType* page_scale_application_layer;
int max_texture_size;
bool can_use_lcd_text;
+ bool can_render_to_separate_surface;
bool can_adjust_raster_scales;
RenderSurfaceLayerListType* render_surface_layer_list;
};
@@ -220,6 +223,7 @@ LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType,
NULL,
std::numeric_limits<int>::max() / 2,
false,
+ true,
false,
render_surface_layer_list) {
DCHECK(root_layer);
@@ -242,6 +246,7 @@ LayerTreeHostCommon::CalcDrawPropsInputsForTesting<LayerType,
NULL,
std::numeric_limits<int>::max() / 2,
false,
+ true,
false,
render_surface_layer_list) {
DCHECK(root_layer);
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 6847f9c..04ffc32 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -8883,6 +8883,84 @@ TEST_F(LayerTreeHostCommonTest,
EXPECT_EQ(0, render_surface2->num_unclipped_descendants());
}
+TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
+ FakeImplProxy proxy;
+ FakeLayerTreeHostImpl host_impl(&proxy);
+ scoped_ptr<LayerImpl> root =
+ LayerImpl::Create(host_impl.active_tree(), 12345);
+ scoped_ptr<LayerImpl> child1 =
+ LayerImpl::Create(host_impl.active_tree(), 123456);
+ scoped_ptr<LayerImpl> child2 =
+ LayerImpl::Create(host_impl.active_tree(), 1234567);
+ scoped_ptr<LayerImpl> child3 =
+ LayerImpl::Create(host_impl.active_tree(), 12345678);
+
+ gfx::Transform identity_matrix;
+ gfx::PointF anchor;
+ gfx::PointF position;
+ gfx::Size bounds(100, 100);
+ SetLayerPropertiesForTesting(root.get(),
+ identity_matrix,
+ identity_matrix,
+ anchor,
+ position,
+ bounds,
+ false);
+ root->SetDrawsContent(true);
+
+ // This layer structure normally forces render surface due to preserves3d
+ // behavior.
+ bool preserves3d = true;
+ SetLayerPropertiesForTesting(child1.get(),
+ identity_matrix,
+ identity_matrix,
+ anchor,
+ position,
+ bounds,
+ preserves3d);
+ child1->SetDrawsContent(true);
+ SetLayerPropertiesForTesting(child2.get(),
+ identity_matrix,
+ identity_matrix,
+ anchor,
+ position,
+ bounds,
+ false);
+ child2->SetDrawsContent(true);
+ SetLayerPropertiesForTesting(child3.get(),
+ identity_matrix,
+ identity_matrix,
+ anchor,
+ position,
+ bounds,
+ false);
+ child3->SetDrawsContent(true);
+
+ child2->AddChild(child3.Pass());
+ child1->AddChild(child2.Pass());
+ root->AddChild(child1.Pass());
+
+ {
+ LayerImplList render_surface_layer_list;
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
+ root.get(), root->bounds(), &render_surface_layer_list);
+ inputs.can_render_to_separate_surface = true;
+ LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+
+ EXPECT_EQ(2u, render_surface_layer_list.size());
+ }
+
+ {
+ LayerImplList render_surface_layer_list;
+ LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
+ root.get(), root->bounds(), &render_surface_layer_list);
+ inputs.can_render_to_separate_surface = false;
+ LayerTreeHostCommon::CalculateDrawProperties(&inputs);
+
+ EXPECT_EQ(1u, render_surface_layer_list.size());
+ }
+}
+
TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) {
scoped_refptr<Layer> root = Layer::Create();
scoped_refptr<Layer> render_surface = Layer::Create();
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 4524e10..60272111 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -859,8 +859,7 @@ bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) {
DCHECK(!have_copy_request);
RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame);
- if (!output_surface_->ForcedDrawToSoftwareDevice())
- renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes);
+ renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes);
RemoveRenderPasses(CullRenderPassesWithCachedTextures(renderer_.get()),
frame);
@@ -876,6 +875,11 @@ bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) {
// If we're making a frame to draw, it better have at least one render pass.
DCHECK(!frame->render_passes.empty());
+
+ // Should only have one render pass in resourceless software mode.
+ if (output_surface_->ForcedDrawToSoftwareDevice())
+ DCHECK_EQ(1u, frame->render_passes.size());
+
return draw_frame;
}
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index c388e33..1b527cc 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -355,6 +355,8 @@ void LayerTreeImpl::UpdateDrawProperties() {
source_frame_number_);
LayerImpl* page_scale_layer =
page_scale_layer_ ? page_scale_layer_ : RootContainerLayer();
+ bool can_render_to_separate_surface =
+ !output_surface()->ForcedDrawToSoftwareDevice();
LayerTreeHostCommon::CalcDrawPropsImplInputs inputs(
root_layer(),
DrawViewportSize(),
@@ -364,6 +366,7 @@ void LayerTreeImpl::UpdateDrawProperties() {
page_scale_layer,
MaxTextureSize(),
settings().can_use_lcd_text,
+ can_render_to_separate_surface,
settings().layer_transforms_should_scale_layer_contents,
&render_surface_layer_list_);
LayerTreeHostCommon::CalculateDrawProperties(&inputs);