diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-04 00:54:45 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-04 00:54:45 +0000 |
commit | 30fe19ff40762f1cc3771fb705bd85a736f20515 (patch) | |
tree | 3995542f4366d5ba92a94779e33fe490ae37092b /cc/layers | |
parent | 7cdf718fc246843a381a48041c697355e314a563 (diff) | |
download | chromium_src-30fe19ff40762f1cc3771fb705bd85a736f20515.zip chromium_src-30fe19ff40762f1cc3771fb705bd85a736f20515.tar.gz chromium_src-30fe19ff40762f1cc3771fb705bd85a736f20515.tar.bz2 |
cc: Allow readbacks from hidden layers.
If a layer or any of its ancestors has hide_layer_and_subtree() set
to true, the layer will not be part of the compositor's output. But
if we want to service a CopyOutputRequest on a layer in the hidden
subtree, we need to draw it.
This CL tracks visibility recursively in CalcDropProperties, so that
when an output request exists in the subtree, we can avoid skipping
the subtree, but make note that the layers in it are not visible (at
least, until we recurse into the copy output requested layer).
If a layer with an output request can not be drawn (it is clipped
away/empty), then we abort the copy request and send an empty result.
This is done for any remaining copy requests in the layer tree after
we have taken requests that will be used and moved them onto
RenderPasses.
Tests:
LayerTreeHostCommonTest.SubtreeHiddenWithCopyRequest
LayerTreeHostCommonTest.ClippedOutCopyRequest
LayerTreeHostTestAsyncReadbackInHiddenSubtree.RunSingleThread_DirectRenderer
LayerTreeHostTestAsyncReadbackInHiddenSubtree.RunMultiThread_DirectRenderer_MainThreadPaint
LayerTreeHostTestAsyncReadbackInHiddenSubtree.RunMultiThread_DirectRenderer_ImplSidePaint
LayerTreeHostTestAsyncReadbackClippedOut.RunSingleThread_DirectRenderer
LayerTreeHostTestAsyncReadbackClippedOut.RunMultiThread_DirectRenderer_MainThreadPaint
LayerTreeHostTestAsyncReadbackClippedOut.RunMultiThread_DirectRenderer_ImplSidePaint
LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest.RunSingleThread_DirectRenderer
LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest.RunMultiThread_DirectRenderer_MainThreadPaint
LayerTreeHostTestHiddenSurfaceNotAllocatedForSubtreeCopyRequest.RunMultiThread_DirectRenderer_ImplSidePaint
R=enne
BUG=242572
Review URL: https://chromiumcodereview.appspot.com/17619004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers')
-rw-r--r-- | cc/layers/draw_properties.h | 7 | ||||
-rw-r--r-- | cc/layers/layer_impl.cc | 10 | ||||
-rw-r--r-- | cc/layers/render_surface.cc | 1 | ||||
-rw-r--r-- | cc/layers/render_surface.h | 12 | ||||
-rw-r--r-- | cc/layers/render_surface_impl.cc | 1 | ||||
-rw-r--r-- | cc/layers/render_surface_impl.h | 12 |
6 files changed, 41 insertions, 2 deletions
diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h index c9bd90c..bb80dce 100644 --- a/cc/layers/draw_properties.h +++ b/cc/layers/draw_properties.h @@ -28,7 +28,8 @@ struct CC_EXPORT DrawProperties { contents_scale_y(1.f), num_descendants_that_draw_content(0), descendants_can_clip_selves(false), - can_draw_directly_to_backbuffer(false) {} + can_draw_directly_to_backbuffer(false), + layer_or_descendant_has_copy_request(false) {} // Transforms objects from content space to target surface space, where // this layer would be drawn. @@ -92,6 +93,10 @@ struct CC_EXPORT DrawProperties { bool descendants_can_clip_selves; bool can_draw_directly_to_backbuffer; + + // If true, the layer or some layer in its sub-tree has a CopyOutputRequest + // present on it. + bool layer_or_descendant_has_copy_request; }; } // namespace cc diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index b40579b..80c7a35 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -108,9 +108,13 @@ void LayerImpl::PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests) { if (requests->empty()) return; + DCHECK(copy_requests_.empty()); + copy_requests_.insert_and_take(copy_requests_.end(), *requests); requests->clear(); + if (layer_tree_impl()->IsActiveTree()) + layer_tree_impl()->AddLayerWithCopyOutputRequest(this); NoteLayerPropertyChangedForSubtree(); } @@ -119,10 +123,11 @@ void LayerImpl::TakeCopyRequestsAndTransformToTarget( if (copy_requests_.empty()) return; + size_t first_inserted_request = requests->size(); requests->insert_and_take(requests->end(), copy_requests_); copy_requests_.clear(); - for (size_t i = 0; i < requests->size(); ++i) { + for (size_t i = first_inserted_request; i < requests->size(); ++i) { CopyOutputRequest* request = requests->at(i); if (!request->has_area()) continue; @@ -134,6 +139,9 @@ void LayerImpl::TakeCopyRequestsAndTransformToTarget( MathUtil::MapClippedRect(draw_properties_.target_space_transform, request_in_content_space)); } + + if (layer_tree_impl()->IsActiveTree()) + layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); } void LayerImpl::CreateRenderSurface() { diff --git a/cc/layers/render_surface.cc b/cc/layers/render_surface.cc index 4eb5d34..60d9cb2 100644 --- a/cc/layers/render_surface.cc +++ b/cc/layers/render_surface.cc @@ -17,6 +17,7 @@ RenderSurface::RenderSurface(Layer* owning_layer) target_surface_transforms_are_animating_(false), screen_space_transforms_are_animating_(false), is_clipped_(false), + contributes_to_drawn_surface_(false), nearest_ancestor_that_moves_pixels_(NULL) {} RenderSurface::~RenderSurface() {} diff --git a/cc/layers/render_surface.h b/cc/layers/render_surface.h index 11d7d4e..369d8c9 100644 --- a/cc/layers/render_surface.h +++ b/cc/layers/render_surface.h @@ -86,6 +86,17 @@ class CC_EXPORT RenderSurface { gfx::Rect clip_rect() const { return clip_rect_; } void SetClipRect(gfx::Rect clip_rect) { clip_rect_ = clip_rect; } + // When false, the RenderSurface does not contribute to another target + // RenderSurface that is being drawn for the current frame. It could still be + // drawn to as a target, but its output will not be a part of any other + // surface. + bool contributes_to_drawn_surface() const { + return contributes_to_drawn_surface_; + } + void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface) { + contributes_to_drawn_surface_ = contributes_to_drawn_surface; + } + LayerList& layer_list() { return layer_list_; } // A no-op since DelegatedRendererLayers on the main thread don't have any // RenderPasses so they can't contribute to a surface. @@ -117,6 +128,7 @@ class CC_EXPORT RenderSurface { bool screen_space_transforms_are_animating_; bool is_clipped_; + bool contributes_to_drawn_surface_; // Uses the space of the surface's target surface. gfx::Rect clip_rect_; diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc index 5aafb8a..3262e28 100644 --- a/cc/layers/render_surface_impl.cc +++ b/cc/layers/render_surface_impl.cc @@ -33,6 +33,7 @@ RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owning_layer) target_surface_transforms_are_animating_(false), screen_space_transforms_are_animating_(false), is_clipped_(false), + contributes_to_drawn_surface_(false), nearest_ancestor_that_moves_pixels_(NULL), target_render_surface_layer_index_history_(0), current_layer_index_history_(0) { diff --git a/cc/layers/render_surface_impl.h b/cc/layers/render_surface_impl.h index 6f3e752..f887a65 100644 --- a/cc/layers/render_surface_impl.h +++ b/cc/layers/render_surface_impl.h @@ -104,6 +104,17 @@ class CC_EXPORT RenderSurfaceImpl { void SetClipRect(gfx::Rect clip_rect); gfx::Rect clip_rect() const { return clip_rect_; } + // When false, the RenderSurface does not contribute to another target + // RenderSurface that is being drawn for the current frame. It could still be + // drawn to as a target, but its output will not be a part of any other + // surface. + bool contributes_to_drawn_surface() const { + return contributes_to_drawn_surface_; + } + void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface) { + contributes_to_drawn_surface_ = contributes_to_drawn_surface; + } + bool ContentsChanged() const; void SetContentRect(gfx::Rect content_rect); @@ -146,6 +157,7 @@ class CC_EXPORT RenderSurfaceImpl { bool screen_space_transforms_are_animating_; bool is_clipped_; + bool contributes_to_drawn_surface_; // Uses the space of the surface's target surface. gfx::Rect clip_rect_; |