summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-28 19:41:21 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-28 19:41:21 +0000
commit35d9cac5bfb76c76039cf75c4273c6bb51a7787b (patch)
tree924958dbd266f216e3dbd297d6beb580918e4f61 /cc
parent2ae17dfc026344bd06ab6f82203cb3777f4940a4 (diff)
downloadchromium_src-35d9cac5bfb76c76039cf75c4273c6bb51a7787b.zip
chromium_src-35d9cac5bfb76c76039cf75c4273c6bb51a7787b.tar.gz
chromium_src-35d9cac5bfb76c76039cf75c4273c6bb51a7787b.tar.bz2
cc: Damage the video layer when requesting it be redrawn.
When the video layer requests the screen to be redrawn, it should also damage itself, otherwise the video layer will not be updated in partial swap. Tests: LayerTreeHostVideoTestSetNeedsDisplay.RunSingleThread LayerTreeHostVideoTestSetNeedsDisplay.RunMultiThread R=enne BUG=179729 Review URL: https://chromiumcodereview.appspot.com/12540012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/cc_tests.gyp1
-rw-r--r--cc/layers/layer_impl.h1
-rw-r--r--cc/layers/video_layer_impl.cc1
-rw-r--r--cc/trees/layer_tree_host_unittest_video.cc97
4 files changed, 100 insertions, 0 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index 0098c36..d6c60d1 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -36,6 +36,7 @@
'trees/layer_tree_host_unittest_delegated.cc',
'trees/layer_tree_host_unittest_occlusion.cc',
'trees/layer_tree_host_unittest_scroll.cc',
+ 'trees/layer_tree_host_unittest_video.cc',
'layers/layer_unittest.cc',
'base/math_util_unittest.cc',
'layers/nine_patch_layer_impl_unittest.cc',
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h
index 2bee592..ed291a6 100644
--- a/cc/layers/layer_impl.h
+++ b/cc/layers/layer_impl.h
@@ -332,6 +332,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
bool TransformIsAnimating() const;
bool TransformIsAnimatingOnImplOnly() const;
+ // Note this rect is in layer space (not content space).
void set_update_rect(const gfx::RectF& update_rect) {
update_rect_ = update_rect;
}
diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc
index 8228488..a0bfda1 100644
--- a/cc/layers/video_layer_impl.cc
+++ b/cc/layers/video_layer_impl.cc
@@ -465,6 +465,7 @@ void VideoLayerImpl::DidLoseOutputSurface() {
}
void VideoLayerImpl::SetNeedsRedraw() {
+ set_update_rect(gfx::UnionRects(update_rect(), gfx::RectF(bounds())));
layer_tree_impl()->SetNeedsRedraw();
}
diff --git a/cc/trees/layer_tree_host_unittest_video.cc b/cc/trees/layer_tree_host_unittest_video.cc
new file mode 100644
index 0000000..86d4dc4
--- /dev/null
+++ b/cc/trees/layer_tree_host_unittest_video.cc
@@ -0,0 +1,97 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/trees/layer_tree_host.h"
+
+#include "base/basictypes.h"
+#include "cc/layers/video_layer.h"
+#include "cc/layers/video_layer_impl.h"
+#include "cc/test/fake_video_frame_provider.h"
+#include "cc/test/layer_tree_test.h"
+#include "cc/trees/damage_tracker.h"
+#include "cc/trees/layer_tree_impl.h"
+
+namespace cc {
+namespace {
+
+// These tests deal with compositing video.
+class LayerTreeHostVideoTest : public LayerTreeTest {};
+
+class LayerTreeHostVideoTestSetNeedsDisplay
+ : public LayerTreeHostVideoTest {
+ public:
+ virtual void SetupTree() OVERRIDE {
+ scoped_refptr<Layer> root = Layer::Create();
+ root->SetBounds(gfx::Size(10, 10));
+ root->SetAnchorPoint(gfx::PointF());
+ root->SetIsDrawable(true);
+
+ scoped_refptr<VideoLayer> video = VideoLayer::Create(
+ &video_frame_provider_);
+ video->SetPosition(gfx::PointF(3.f, 3.f));
+ video->SetBounds(gfx::Size(4, 4));
+ video->SetAnchorPoint(gfx::PointF());
+ video->SetIsDrawable(true);
+ root->AddChild(video);
+
+ layer_tree_host()->SetRootLayer(root);
+ layer_tree_host()->SetDeviceScaleFactor(2.f);
+ LayerTreeHostVideoTest::SetupTree();
+ }
+
+ virtual void BeginTest() OVERRIDE {
+ num_draws_ = 0;
+ PostSetNeedsCommitToMainThread();
+ }
+
+ virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
+ LayerTreeHostImpl::FrameData* frame,
+ bool result) OVERRIDE {
+ LayerImpl* root_layer = host_impl->active_tree()->root_layer();
+ RenderSurfaceImpl* root_surface = root_layer->render_surface();
+ gfx::RectF damage_rect =
+ root_surface->damage_tracker()->current_damage_rect();
+
+ switch (num_draws_) {
+ case 0:
+ // First frame the whole viewport is damaged.
+ EXPECT_EQ(gfx::RectF(0.f, 0.f, 20.f, 20.f).ToString(),
+ damage_rect.ToString());
+ break;
+ case 1:
+ // Second frame the video layer is damaged.
+ EXPECT_EQ(gfx::RectF(6.f, 6.f, 8.f, 8.f).ToString(),
+ damage_rect.ToString());
+ EndTest();
+ break;
+ }
+
+ EXPECT_TRUE(result);
+ return result;
+ }
+
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ VideoLayerImpl* video = static_cast<VideoLayerImpl*>(
+ host_impl->active_tree()->root_layer()->children()[0]);
+
+ if (num_draws_ == 0)
+ video->SetNeedsRedraw();
+
+ ++num_draws_;
+ }
+
+ virtual void AfterTest() OVERRIDE {
+ EXPECT_EQ(2, num_draws_);
+ }
+
+ private:
+ int num_draws_;
+
+ FakeVideoFrameProvider video_frame_provider_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostVideoTestSetNeedsDisplay);
+
+} // namespace
+} // namespace cc