summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 00:36:33 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 00:36:33 +0000
commit41084bf399c66d9a29abc7f8f14f6cef1148e57d (patch)
tree9b9a4699bc4585e93790915d1b4a5f24e60c306e
parent349bce9fe93f3b69fd86f74163a2d9d99ac360ed (diff)
downloadchromium_src-41084bf399c66d9a29abc7f8f14f6cef1148e57d.zip
chromium_src-41084bf399c66d9a29abc7f8f14f6cef1148e57d.tar.gz
chromium_src-41084bf399c66d9a29abc7f8f14f6cef1148e57d.tar.bz2
cc: Fix accelerated video freezing with commit aborts
Although VideoLayer doesn't update any resources, it needs to not let commits abort when it has been invalidated as this is currently the mechanism on desktop to tell the compositor to redraw it with a new frame. R=danakj@chromium.org BUG=266350 Review URL: https://chromiumcodereview.appspot.com/21567003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215169 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/layers/video_layer.cc10
-rw-r--r--cc/layers/video_layer.h2
-rw-r--r--cc/trees/layer_tree_host_unittest.cc52
3 files changed, 64 insertions, 0 deletions
diff --git a/cc/layers/video_layer.cc b/cc/layers/video_layer.cc
index 5066835..6cba239 100644
--- a/cc/layers/video_layer.cc
+++ b/cc/layers/video_layer.cc
@@ -22,4 +22,14 @@ scoped_ptr<LayerImpl> VideoLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
return VideoLayerImpl::Create(tree_impl, id(), provider_).PassAs<LayerImpl>();
}
+bool VideoLayer::Update(ResourceUpdateQueue* queue,
+ const OcclusionTracker* occlusion) {
+ // Video layer doesn't update any resources from the main thread side,
+ // but repaint rects need to be sent to the VideoLayerImpl via commit.
+ //
+ // This is the inefficient legacy redraw path for videos. It's better to
+ // communicate this directly to the VideoLayerImpl.
+ return !update_rect_.IsEmpty();
+}
+
} // namespace cc
diff --git a/cc/layers/video_layer.h b/cc/layers/video_layer.h
index c894c84..4d14f80 100644
--- a/cc/layers/video_layer.h
+++ b/cc/layers/video_layer.h
@@ -24,6 +24,8 @@ class CC_EXPORT VideoLayer : public Layer {
virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
OVERRIDE;
+ virtual bool Update(ResourceUpdateQueue* queue,
+ const OcclusionTracker* occlusion) OVERRIDE;
private:
explicit VideoLayer(VideoFrameProvider* provider);
virtual ~VideoLayer();
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 5e823b6..0a4c236 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -16,6 +16,7 @@
#include "cc/layers/layer_impl.h"
#include "cc/layers/picture_layer.h"
#include "cc/layers/scrollbar_layer.h"
+#include "cc/layers/video_layer.h"
#include "cc/output/begin_frame_args.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
@@ -33,6 +34,7 @@
#include "cc/test/fake_proxy.h"
#include "cc/test/fake_scoped_ui_resource.h"
#include "cc/test/fake_scrollbar_layer.h"
+#include "cc/test/fake_video_frame_provider.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/occlusion_tracker_test_common.h"
@@ -4021,5 +4023,55 @@ TEST_F(LayerTreeHostTestTreeActivationCallback, DelegatingRenderer) {
RunTest(true, true, true);
}
+// VideoLayer must support being invalidated and then passing that along
+// to the compositor thread, even though no resources are updated in
+// response to that invalidation.
+class LayerTreeHostTestVideoLayerInvalidate : public LayerTreeHostTest {
+ public:
+ LayerTreeHostTestVideoLayerInvalidate() : num_commits_(0), num_draws_(0) {}
+
+ virtual void SetupTree() OVERRIDE {
+ LayerTreeHostTest::SetupTree();
+ video_layer_ = VideoLayer::Create(&provider_);
+ video_layer_->SetBounds(gfx::Size(10, 10));
+ video_layer_->SetIsDrawable(true);
+ layer_tree_host()->root_layer()->AddChild(video_layer_);
+ }
+
+ virtual void BeginTest() OVERRIDE {
+ // One initial commit.
+ PostSetNeedsCommitToMainThread();
+ }
+
+ virtual void DidCommitAndDrawFrame() OVERRIDE {
+ // After commit, invalidate the video layer. This should cause a commit.
+ if (layer_tree_host()->source_frame_number() == 1)
+ video_layer_->SetNeedsDisplay();
+ }
+
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ num_draws_++;
+ if (impl->active_tree()->source_frame_number() == 1)
+ EndTest();
+ }
+
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ num_commits_++;
+ }
+
+ virtual void AfterTest() OVERRIDE {
+ EXPECT_GE(2, num_commits_);
+ EXPECT_GE(2, num_draws_);
+ }
+
+ private:
+ FakeVideoFrameProvider provider_;
+ scoped_refptr<VideoLayer> video_layer_;
+ int num_commits_;
+ int num_draws_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate);
+
} // namespace
} // namespace cc