summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 16:54:36 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 16:54:36 +0000
commit4145d17a54bbf9c5b7b29efb9f55eaa6f954602b (patch)
tree4400d937ae8e2ccd1eb2aa162456c2535254951e /cc
parent7a956a61566c1021d310c7a0097c5df45c340269 (diff)
downloadchromium_src-4145d17a54bbf9c5b7b29efb9f55eaa6f954602b.zip
chromium_src-4145d17a54bbf9c5b7b29efb9f55eaa6f954602b.tar.gz
chromium_src-4145d17a54bbf9c5b7b29efb9f55eaa6f954602b.tar.bz2
cc: Run all LayerTreeHost tests with a delegating renderer.
Unless they choose to opt out. The VideoResourceUpdater was deleting resources when the ResourceProvider shut down, which was not ideal. Instead, it deletes them when it shuts down itself (before the ResourceProvider). This works out fine, since anyone else using it will be using it through a mailbox. DelegatingRenderer needs to use and export the resources in the quads it is given inside of DrawFrame() as they may be deleted afterward, instead of waiting until SwapBuffers(). Depends on: https://codereview.chromium.org/14960006/ TEST=cc_unittests R=jamesr, piman BUG=123444 Review URL: https://chromiumcodereview.appspot.com/14925009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/heads_up_display_layer_impl.cc12
-rw-r--r--cc/layers/heads_up_display_layer_impl.h1
-rw-r--r--cc/layers/scrollbar_layer_unittest.cc13
-rw-r--r--cc/layers/texture_layer_unittest.cc7
-rw-r--r--cc/output/delegating_renderer_unittest.cc12
-rw-r--r--cc/resources/video_resource_updater.cc34
-rw-r--r--cc/resources/video_resource_updater.h4
-rw-r--r--cc/test/layer_tree_pixel_test.cc4
-rw-r--r--cc/test/layer_tree_test.cc48
-rw-r--r--cc/test/layer_tree_test.h78
-rw-r--r--cc/trees/layer_tree_host_perftest.cc8
-rw-r--r--cc/trees/layer_tree_host_unittest.cc59
-rw-r--r--cc/trees/layer_tree_host_unittest_context.cc224
-rw-r--r--cc/trees/layer_tree_host_unittest_damage.cc18
-rw-r--r--cc/trees/layer_tree_host_unittest_delegated.cc19
-rw-r--r--cc/trees/layer_tree_host_unittest_scroll.cc69
16 files changed, 418 insertions, 192 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc
index f8ab6ae..46e6701 100644
--- a/cc/layers/heads_up_display_layer_impl.cc
+++ b/cc/layers/heads_up_display_layer_impl.cc
@@ -165,18 +165,6 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
gfx::Vector2d());
}
-void HeadsUpDisplayLayerImpl::DidDraw(ResourceProvider* resource_provider) {
- LayerImpl::DidDraw(resource_provider);
-
- if (!hud_resource_->id())
- return;
-
- // FIXME: the following assert will not be true when sending resources to a
- // parent compositor. We will probably need to hold on to hud_resource_ for
- // longer, and have several HUD textures in the pipeline.
- DCHECK(!resource_provider->InUseByConsumer(hud_resource_->id()));
-}
-
void HeadsUpDisplayLayerImpl::DidLoseOutputSurface() { hud_resource_.reset(); }
bool HeadsUpDisplayLayerImpl::LayerIsAlwaysDamaged() const { return true; }
diff --git a/cc/layers/heads_up_display_layer_impl.h b/cc/layers/heads_up_display_layer_impl.h
index 7e7f2df..373f89d 100644
--- a/cc/layers/heads_up_display_layer_impl.h
+++ b/cc/layers/heads_up_display_layer_impl.h
@@ -40,7 +40,6 @@ class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl {
virtual void AppendQuads(QuadSink* quad_sink,
AppendQuadsData* append_quads_data) OVERRIDE;
void UpdateHudTexture(ResourceProvider* resource_provider);
- virtual void DidDraw(ResourceProvider* resource_provider) OVERRIDE;
virtual void DidLoseOutputSurface() OVERRIDE;
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index 7786d41..9cc0165 100644
--- a/cc/layers/scrollbar_layer_unittest.cc
+++ b/cc/layers/scrollbar_layer_unittest.cc
@@ -328,13 +328,22 @@ class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest {
gfx::Size bounds_;
};
-TEST_F(ScrollbarLayerTestMaxTextureSize, RunTest) {
+TEST_F(ScrollbarLayerTestMaxTextureSize, DirectRenderer) {
scoped_ptr<TestWebGraphicsContext3D> context =
TestWebGraphicsContext3D::Create();
int max_size = 0;
context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size);
SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100));
- RunTest(true);
+ RunTest(true, false);
+}
+
+TEST_F(ScrollbarLayerTestMaxTextureSize, DelegatingRenderer) {
+ scoped_ptr<TestWebGraphicsContext3D> context =
+ TestWebGraphicsContext3D::Create();
+ int max_size = 0;
+ context->getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size);
+ SetScrollbarBounds(gfx::Size(max_size + 100, max_size + 100));
+ RunTest(true, true);
}
class MockLayerTreeHost : public LayerTreeHost {
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index 55b4c73..ff204d6 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -402,7 +402,8 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
scoped_refptr<TextureLayer> layer_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerImplWithMailboxThreadedCallback);
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+ TextureLayerImplWithMailboxThreadedCallback);
class TextureLayerImplWithMailboxTest : public TextureLayerTest {
protected:
@@ -623,7 +624,9 @@ class TextureLayerClientTest
unsigned expected_used_textures_on_commit_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(TextureLayerClientTest);
+// The TextureLayerClient does not use mailboxes, so can't use a delegating
+// renderer.
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TextureLayerClientTest);
} // namespace
} // namespace cc
diff --git a/cc/output/delegating_renderer_unittest.cc b/cc/output/delegating_renderer_unittest.cc
index bad075c..94cae6a 100644
--- a/cc/output/delegating_renderer_unittest.cc
+++ b/cc/output/delegating_renderer_unittest.cc
@@ -18,13 +18,8 @@ class DelegatingRendererTest : public LayerTreeTest {
virtual ~DelegatingRendererTest() {}
virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
- scoped_ptr<TestWebGraphicsContext3D> context3d =
- TestWebGraphicsContext3D::Create(
- WebKit::WebGraphicsContext3D::Attributes());
- context3d_ = context3d.get();
scoped_ptr<FakeOutputSurface> output_surface =
- FakeOutputSurface::CreateDelegating3d(
- context3d.PassAs<WebKit::WebGraphicsContext3D>());
+ FakeOutputSurface::CreateDelegating3d();
output_surface_ = output_surface.get();
return output_surface.PassAs<OutputSurface>();
}
@@ -84,7 +79,7 @@ class DelegatingRendererTestDraw : public DelegatingRendererTest {
}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(DelegatingRendererTestDraw);
+SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(DelegatingRendererTestDraw);
class DelegatingRendererTestResources : public DelegatingRendererTest {
public:
@@ -143,6 +138,7 @@ class DelegatingRendererTestResources : public DelegatingRendererTest {
}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(DelegatingRendererTestResources);
+SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(
+ DelegatingRendererTestResources);
} // namespace cc
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
index 9aa3644..a171cb7 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -29,9 +29,9 @@ VideoResourceUpdater::VideoResourceUpdater(ResourceProvider* resource_provider)
}
VideoResourceUpdater::~VideoResourceUpdater() {
- while (!recycled_resources_.empty()) {
- resource_provider_->DeleteResource(recycled_resources_.back().resource_id);
- recycled_resources_.pop_back();
+ while (!all_resources_.empty()) {
+ resource_provider_->DeleteResource(all_resources_.back());
+ all_resources_.pop_back();
}
}
@@ -176,6 +176,8 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
resource_provider_->CreateResource(output_plane_resource_size,
output_resource_format,
ResourceProvider::TextureUsageAny);
+ if (resource_id)
+ all_resources_.push_back(resource_id);
}
if (resource_id == 0) {
@@ -330,9 +332,12 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
resource_provider_->CreateResourceFromExternalTexture(
video_frame->texture_target(),
video_frame->texture_id());
+ if (external_resources.hardware_resource)
+ all_resources_.push_back(external_resources.hardware_resource);
TextureMailbox::ReleaseCallback callback_to_return_resource =
base::Bind(&ReturnTexture,
+ AsWeakPtr(),
base::Unretained(resource_provider_),
external_resources.hardware_resource);
external_resources.hardware_release_callback = callback_to_return_resource;
@@ -341,11 +346,21 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
// static
void VideoResourceUpdater::ReturnTexture(
+ base::WeakPtr<VideoResourceUpdater> updater,
ResourceProvider* resource_provider,
unsigned resource_id,
unsigned sync_point,
bool lost_resource) {
+ if (!updater) {
+ // Resource was already deleted.
+ return;
+ }
+
resource_provider->DeleteResource(resource_id);
+ std::vector<unsigned>& all_resources = updater->all_resources_;
+ all_resources.erase(std::remove(all_resources.begin(),
+ all_resources.end(),
+ resource_id));
}
// static
@@ -355,10 +370,15 @@ void VideoResourceUpdater::RecycleResource(
RecycleResourceData data,
unsigned sync_point,
bool lost_resource) {
+ if (!updater) {
+ // Resource was already deleted.
+ return;
+ }
+
WebKit::WebGraphicsContext3D* context =
resource_provider->GraphicsContext3D();
if (context && sync_point)
- GLC(context, context->waitSyncPoint(sync_point));
+ GLC(context, context->waitSyncPoint(sync_point));
if (context && !lost_resource) {
ResourceProvider::ScopedWriteLockGL lock(resource_provider,
data.resource_id);
@@ -368,8 +388,12 @@ void VideoResourceUpdater::RecycleResource(
GLC(context, context->bindTexture(GL_TEXTURE_2D, 0));
}
- if (!updater || lost_resource) {
+ if (lost_resource) {
resource_provider->DeleteResource(data.resource_id);
+ std::vector<unsigned>& all_resources = updater->all_resources_;
+ all_resources.erase(std::remove(all_resources.begin(),
+ all_resources.end(),
+ data.resource_id));
return;
}
diff --git a/cc/resources/video_resource_updater.h b/cc/resources/video_resource_updater.h
index 5dad985..2785ff4 100644
--- a/cc/resources/video_resource_updater.h
+++ b/cc/resources/video_resource_updater.h
@@ -103,7 +103,8 @@ class VideoResourceUpdater
RecycleResourceData data,
unsigned sync_point,
bool lost_resource);
- static void ReturnTexture(ResourceProvider* resource_provider,
+ static void ReturnTexture(base::WeakPtr<VideoResourceUpdater> updater,
+ ResourceProvider* resource_provider,
unsigned resource_id,
unsigned sync_point,
bool lost_resource);
@@ -111,6 +112,7 @@ class VideoResourceUpdater
ResourceProvider* resource_provider_;
scoped_ptr<media::SkCanvasVideoRenderer> video_renderer_;
+ std::vector<unsigned> all_resources_;
std::vector<PlaneResource> recycled_resources_;
DISALLOW_COPY_AND_ASSIGN(VideoResourceUpdater);
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc
index 1c9855f..27dd3e7 100644
--- a/cc/test/layer_tree_pixel_test.cc
+++ b/cc/test/layer_tree_pixel_test.cc
@@ -118,7 +118,7 @@ void LayerTreePixelTest::RunPixelTest(
content_root_ = content_root;
readback_target_ = NULL;
ref_file_ = file_name;
- RunTest(true);
+ RunTest(true, false);
}
void LayerTreePixelTest::RunPixelTestWithReadbackTarget(
@@ -128,7 +128,7 @@ void LayerTreePixelTest::RunPixelTestWithReadbackTarget(
content_root_ = content_root;
readback_target_ = target;
ref_file_ = file_name;
- RunTest(true);
+ RunTest(true, false);
}
void LayerTreePixelTest::SetupTree() {
diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc
index 43ae511..22de2d8 100644
--- a/cc/test/layer_tree_test.cc
+++ b/cc/test/layer_tree_test.cc
@@ -16,6 +16,7 @@
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
#include "cc/test/animation_test_common.h"
+#include "cc/test/fake_context_provider.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/occlusion_tracker_test_common.h"
@@ -27,9 +28,7 @@
namespace cc {
-TestHooks::TestHooks()
- : fake_client_(
- new FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D)) {}
+TestHooks::TestHooks() {}
TestHooks::~TestHooks() {}
@@ -43,20 +42,6 @@ bool TestHooks::CanActivatePendingTree() {
return true;
}
-scoped_ptr<OutputSurface> TestHooks::CreateOutputSurface() {
- return CreateFakeOutputSurface();
-}
-
-scoped_refptr<cc::ContextProvider> TestHooks::
- OffscreenContextProviderForMainThread() {
- return fake_client_->OffscreenContextProviderForMainThread();
-}
-
-scoped_refptr<cc::ContextProvider> TestHooks::
- OffscreenContextProviderForCompositorThread() {
- return fake_client_->OffscreenContextProviderForCompositorThread();
-}
-
// Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
public:
@@ -550,7 +535,7 @@ void LayerTreeTest::DispatchComposite() {
layer_tree_host_->Composite(now);
}
-void LayerTreeTest::RunTest(bool threaded) {
+void LayerTreeTest::RunTest(bool threaded, bool delegating_renderer) {
if (threaded) {
impl_thread_.reset(new base::Thread("Compositor"));
ASSERT_TRUE(impl_thread_->Start());
@@ -558,6 +543,8 @@ void LayerTreeTest::RunTest(bool threaded) {
main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread();
+ delegating_renderer_ = delegating_renderer;
+
// Spend less time waiting for vsync because the output is mocked out.
settings_.refresh_rate = 200.0;
InitializeSettings(&settings_);
@@ -588,4 +575,29 @@ void LayerTreeTest::RunTest(bool threaded) {
AfterTest();
}
+scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface() {
+ if (delegating_renderer_)
+ return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
+ return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
+}
+
+scoped_refptr<cc::ContextProvider> LayerTreeTest::
+ OffscreenContextProviderForMainThread() {
+ if (!main_thread_contexts_ ||
+ main_thread_contexts_->DestroyedOnMainThread()) {
+ main_thread_contexts_ = FakeContextProvider::Create();
+ if (!main_thread_contexts_->BindToCurrentThread())
+ main_thread_contexts_ = NULL;
+ }
+ return main_thread_contexts_;
+}
+
+scoped_refptr<cc::ContextProvider> LayerTreeTest::
+ OffscreenContextProviderForCompositorThread() {
+ if (!compositor_thread_contexts_ ||
+ compositor_thread_contexts_->DestroyedOnMainThread())
+ compositor_thread_contexts_ = FakeContextProvider::Create();
+ return compositor_thread_contexts_;
+}
+
} // namespace cc
diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h
index 81cb174..4d5758a 100644
--- a/cc/test/layer_tree_test.h
+++ b/cc/test/layer_tree_test.h
@@ -18,6 +18,7 @@ class WebGraphicsContext3D;
}
namespace cc {
+class FakeContextProvider;
class FakeLayerTreeHostClient;
class LayerImpl;
class LayerTreeHost;
@@ -69,15 +70,11 @@ class TestHooks : public WebKit::WebAnimationDelegate {
virtual void notifyAnimationStarted(double time) OVERRIDE {}
virtual void notifyAnimationFinished(double time) OVERRIDE {}
- virtual scoped_ptr<OutputSurface> CreateOutputSurface();
-
+ virtual scoped_ptr<OutputSurface> CreateOutputSurface() = 0;
virtual scoped_refptr<cc::ContextProvider>
- OffscreenContextProviderForMainThread();
+ OffscreenContextProviderForMainThread() = 0;
virtual scoped_refptr<cc::ContextProvider>
- OffscreenContextProviderForCompositorThread();
-
- private:
- scoped_ptr<FakeLayerTreeHostClient> fake_client_;
+ OffscreenContextProviderForCompositorThread() = 0;
};
class BeginTask;
@@ -138,7 +135,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
void DispatchComposite();
void DispatchDidAddAnimation();
- virtual void RunTest(bool threaded);
+ virtual void RunTest(bool threaded, bool delegating_renderer);
Thread* ImplThread() { return proxy() ? proxy()->ImplThread() : NULL; }
Proxy* proxy() const {
@@ -148,6 +145,13 @@ class LayerTreeTest : public testing::Test, public TestHooks {
bool TestEnded() const { return ended_; }
LayerTreeHost* layer_tree_host() { return layer_tree_host_.get(); }
+ bool delegating_renderer() const { return delegating_renderer_; }
+
+ virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE;
+ virtual scoped_refptr<cc::ContextProvider>
+ OffscreenContextProviderForMainThread() OVERRIDE;
+ virtual scoped_refptr<cc::ContextProvider>
+ OffscreenContextProviderForCompositorThread() OVERRIDE;
private:
LayerTreeSettings settings_;
@@ -161,6 +165,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
bool schedule_when_set_visible_true_;
bool started_;
bool ended_;
+ bool delegating_renderer_;
int timeout_seconds_;
@@ -169,25 +174,54 @@ class LayerTreeTest : public testing::Test, public TestHooks {
base::CancelableClosure timeout_;
base::WeakPtr<LayerTreeTest> main_thread_weak_ptr_;
base::WeakPtrFactory<LayerTreeTest> weak_factory_;
+ scoped_refptr<FakeContextProvider> main_thread_contexts_;
+ scoped_refptr<FakeContextProvider> compositor_thread_contexts_;
};
} // namespace cc
-#define SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \
- TEST_F(TEST_FIXTURE_NAME, RunSingleThread) { \
- RunTest(false); \
- } \
- class SingleThreadNeedsSemicolon##TEST_FIXTURE_NAME {}
-
-
-#define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \
- TEST_F(TEST_FIXTURE_NAME, RunMultiThread) { \
- RunTest(true); \
- } \
- class MultiThreadNeedsSemicolon##TEST_FIXTURE_NAME {}
+#define SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \
+ TEST_F(TEST_FIXTURE_NAME, RunSingleThread_DirectRenderer) { \
+ RunTest(false, false); \
+ } \
+ class SingleThreadDirectNeedsSemicolon##TEST_FIXTURE_NAME {}
+
+#define SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \
+ TEST_F(TEST_FIXTURE_NAME, RunSingleThread_DelegatingRenderer) { \
+ RunTest(false, true); \
+ } \
+ class SingleThreadDelegatingNeedsSemicolon##TEST_FIXTURE_NAME {}
+
+#define SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME) \
+ SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \
+ SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME)
+
+#define MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \
+ TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DirectRenderer) { \
+ RunTest(true, false); \
+ } \
+ class MultiThreadDirectNeedsSemicolon##TEST_FIXTURE_NAME {}
+
+#define MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \
+ TEST_F(TEST_FIXTURE_NAME, RunMultiThread_DelegatingRenderer) { \
+ RunTest(true, true); \
+ } \
+ class MultiThreadDelegatingNeedsSemicolon##TEST_FIXTURE_NAME {}
+
+#define MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \
+ MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \
+ MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME)
+
+#define SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME) \
+ SINGLE_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \
+ MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME)
+
+#define SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) \
+ SINGLE_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME); \
+ MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME)
#define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \
- SINGLE_THREAD_TEST_F(TEST_FIXTURE_NAME); \
- MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME)
+ SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \
+ SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME)
#endif // CC_TEST_LAYER_TREE_TEST_H_
diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc
index 7e5df86..040b32b 100644
--- a/cc/trees/layer_tree_host_perftest.cc
+++ b/cc/trees/layer_tree_host_perftest.cc
@@ -131,7 +131,7 @@ class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest {
// Simulates a tab switcher scene with two stacks of 10 tabs each.
TEST_F(LayerTreeHostPerfTestJsonReader, TenTenSingleThread) {
ReadTestFile("10_10_layer_tree");
- RunTest(false);
+ RunTest(false, false);
}
// Simulates a tab switcher scene with two stacks of 10 tabs each.
@@ -139,7 +139,7 @@ TEST_F(LayerTreeHostPerfTestJsonReader,
TenTenSingleThread_FullDamageEachFrame) {
full_damage_each_frame_ = true;
ReadTestFile("10_10_layer_tree");
- RunTest(false);
+ RunTest(false, false);
}
// Simulates main-thread scrolling on each frame.
@@ -166,7 +166,7 @@ class ScrollingLayerTreePerfTest : public LayerTreeHostPerfTestJsonReader {
TEST_F(ScrollingLayerTreePerfTest, LongScrollablePage) {
ReadTestFile("long_scrollable_page");
- RunTest(false);
+ RunTest(false, false);
}
// Simulates impl-side painting.
@@ -185,7 +185,7 @@ TEST_F(ImplSidePaintingPerfTest, HeavyPage) {
animation_driven_drawing_ = true;
measure_commit_cost_ = true;
ReadTestFile("heavy_layer_tree");
- RunTest(true);
+ RunTest(true, false);
}
} // namespace
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index c10e70a..8be478e 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -978,7 +978,7 @@ class LayerTreeHostTestAtomicCommit : public LayerTreeHostTest {
TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>(
impl->output_surface()->context3d());
- // Number of textures used for draw should always be one for each layer.
+ // We draw/ship one texture each frame for each layer.
EXPECT_EQ(2u, context->NumUsedTextures());
context->ResetUsedTextures();
}
@@ -1205,7 +1205,9 @@ class LayerTreeHostTestAtomicCommitWithPartialUpdate
int num_commits_;
};
-MULTI_THREAD_TEST_F(LayerTreeHostTestAtomicCommitWithPartialUpdate);
+// Partial updates are not possible with a delegating renderer.
+MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+ LayerTreeHostTestAtomicCommitWithPartialUpdate);
class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
public:
@@ -1358,7 +1360,8 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
scoped_refptr<FakeContentLayer> replica_layer2_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(
+ // Surfaces don't exist with a delegated renderer.
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit);
class EvictionTestLayer : public Layer {
@@ -1908,19 +1911,13 @@ class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest {
public:
LayerTreeHostTestMaxPendingFrames() : LayerTreeHostTest() {}
- virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
- if (delegating_renderer_)
- return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
- return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
- }
-
virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
DCHECK(host_impl->proxy()->HasImplThread());
const ThreadProxy* proxy = static_cast<ThreadProxy*>(host_impl->proxy());
- if (delegating_renderer_) {
+ if (delegating_renderer()) {
EXPECT_EQ(1, proxy->MaxFramesPendingForTesting());
} else {
EXPECT_EQ(FrameRateController::DEFAULT_MAX_FRAMES_PENDING,
@@ -1930,19 +1927,14 @@ class LayerTreeHostTestMaxPendingFrames : public LayerTreeHostTest {
}
virtual void AfterTest() OVERRIDE {}
-
- protected:
- bool delegating_renderer_;
};
TEST_F(LayerTreeHostTestMaxPendingFrames, DelegatingRenderer) {
- delegating_renderer_ = true;
- RunTest(true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostTestMaxPendingFrames, GLRenderer) {
- delegating_renderer_ = false;
- RunTest(true);
+ RunTest(true, false);
}
class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted
@@ -2583,7 +2575,9 @@ class LayerTreeHostTestIOSurfaceDrawing : public LayerTreeHostTest {
gfx::Size io_surface_size_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestIOSurfaceDrawing);
+// TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+ LayerTreeHostTestIOSurfaceDrawing);
class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
protected:
@@ -2683,24 +2677,25 @@ class LayerTreeHostTestAsyncReadback : public LayerTreeHostTest {
scoped_refptr<FakeContentLayer> child;
};
+// Readback can't be done with a delegating renderer.
TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunSingleThread) {
use_gl_renderer_ = true;
- RunTest(false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostTestAsyncReadback, GLRenderer_RunMultiThread) {
use_gl_renderer_ = true;
- RunTest(true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunSingleThread) {
use_gl_renderer_ = false;
- RunTest(false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostTestAsyncReadback, SoftwareRenderer_RunMultiThread) {
use_gl_renderer_ = false;
- RunTest(true);
+ RunTest(true, false);
}
class LayerTreeHostTestAsyncReadbackLayerDestroyed : public LayerTreeHostTest {
@@ -2794,18 +2789,11 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestAsyncReadbackLayerDestroyed);
class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
public:
- LayerTreeHostTestNumFramesPending()
- : delegating_renderer_(false),
- frame_(0) {}
-
- virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
- if (delegating_renderer_)
- return FakeOutputSurface::CreateDelegating3d().PassAs<OutputSurface>();
- return FakeOutputSurface::Create3d().PassAs<OutputSurface>();
+ virtual void BeginTest() OVERRIDE {
+ frame_ = 0;
+ PostSetNeedsCommitToMainThread();
}
- virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
-
// Round 1: commit + draw
// Round 2: commit only (no draw/swap)
// Round 3: draw only (no commit)
@@ -2864,18 +2852,15 @@ class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
virtual void AfterTest() OVERRIDE {}
protected:
- bool delegating_renderer_;
int frame_;
};
TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
- delegating_renderer_ = true;
- RunTest(true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
- delegating_renderer_ = false;
- RunTest(true);
+ RunTest(true, false);
}
} // namespace
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 6ca7001..198907d 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -13,6 +13,7 @@
#include "cc/layers/picture_layer.h"
#include "cc/layers/scrollbar_layer.h"
#include "cc/layers/texture_layer.h"
+#include "cc/layers/texture_layer_impl.h"
#include "cc/layers/video_layer.h"
#include "cc/layers/video_layer_impl.h"
#include "cc/test/fake_content_layer.h"
@@ -106,6 +107,10 @@ class LayerTreeHostContextTest : public LayerTreeTest {
ExpectCreateToFail();
}
+ if (delegating_renderer()) {
+ return FakeOutputSurface::CreateDelegating3d(
+ context3d.PassAs<WebGraphicsContext3D>()).PassAs<OutputSurface>();
+ }
return FakeOutputSurface::Create3d(
context3d.PassAs<WebGraphicsContext3D>()).PassAs<OutputSurface>();
}
@@ -479,27 +484,40 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
};
TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
- NoSurface_SingleThread) {
+ NoSurface_SingleThread_DirectRenderer) {
+ use_surface_ = false;
+ RunTest(false, false);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
+ NoSurface_SingleThread_DelegatingRenderer) {
+ use_surface_ = false;
+ RunTest(false, true);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
+ NoSurface_MultiThread_DirectRenderer) {
use_surface_ = false;
- RunTest(false);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
- NoSurface_MultiThread) {
+ NoSurface_MultiThread_DelegatingRenderer) {
use_surface_ = false;
- RunTest(true);
+ RunTest(true, true);
}
+// Surfaces don't exist with a delegating renderer.
TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
- WithSurface_SingleThread) {
+ WithSurface_SingleThread_DirectRenderer) {
use_surface_ = true;
- RunTest(false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
- WithSurface_MultiThread) {
+ WithSurface_MultiThread_DirectRenderer) {
use_surface_ = true;
- RunTest(true);
+ RunTest(true, false);
}
class LayerTreeHostContextTestOffscreenContextFails
@@ -602,51 +620,99 @@ class LayerTreeHostContextTestLostContextFails
};
TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_SingleThread) {
+ FailReinitialize100_SingleThread_DirectRenderer) {
+ times_to_fail_reinitialize_ = 100;
+ times_to_fail_recreate_ = 0;
+ times_to_lose_on_recreate_ = 0;
+ RunTest(false, false);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextFails,
+ FailReinitialize100_SingleThread_DelegatingRenderer) {
+ times_to_fail_reinitialize_ = 100;
+ times_to_fail_recreate_ = 0;
+ times_to_lose_on_recreate_ = 0;
+ RunTest(false, true);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextFails,
+ FailReinitialize100_MultiThread_DirectRenderer) {
times_to_fail_reinitialize_ = 100;
times_to_fail_recreate_ = 0;
times_to_lose_on_recreate_ = 0;
- RunTest(false);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostContextTestLostContextFails,
- FailReinitialize100_MultiThread) {
+ FailReinitialize100_MultiThread_DelegatingRenderer) {
times_to_fail_reinitialize_ = 100;
times_to_fail_recreate_ = 0;
times_to_lose_on_recreate_ = 0;
- RunTest(true);
+ RunTest(true, true);
}
TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_SingleThread) {
+ FailRecreate100_SingleThread_DirectRenderer) {
times_to_fail_reinitialize_ = 0;
times_to_fail_recreate_ = 100;
times_to_lose_on_recreate_ = 0;
- RunTest(false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostContextTestLostContextFails,
- FailRecreate100_MultiThread) {
+ FailRecreate100_SingleThread_DelegatingRenderer) {
times_to_fail_reinitialize_ = 0;
times_to_fail_recreate_ = 100;
times_to_lose_on_recreate_ = 0;
- RunTest(true);
+ RunTest(false, true);
}
TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_SingleThread) {
+ FailRecreate100_MultiThread_DirectRenderer) {
+ times_to_fail_reinitialize_ = 0;
+ times_to_fail_recreate_ = 100;
+ times_to_lose_on_recreate_ = 0;
+ RunTest(true, false);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextFails,
+ FailRecreate100_MultiThread_DelegatingRenderer) {
+ times_to_fail_reinitialize_ = 0;
+ times_to_fail_recreate_ = 100;
+ times_to_lose_on_recreate_ = 0;
+ RunTest(true, true);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextFails,
+ LoseOnRecreate100_SingleThread_DirectRenderer) {
times_to_fail_reinitialize_ = 0;
times_to_fail_recreate_ = 0;
times_to_lose_on_recreate_ = 100;
- RunTest(false);
+ RunTest(false, false);
}
TEST_F(LayerTreeHostContextTestLostContextFails,
- LoseOnRecreate100_MultiThread) {
+ LoseOnRecreate100_SingleThread_DelegatingRenderer) {
times_to_fail_reinitialize_ = 0;
times_to_fail_recreate_ = 0;
times_to_lose_on_recreate_ = 100;
- RunTest(true);
+ RunTest(false, true);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextFails,
+ LoseOnRecreate100_MultiThread_DirectRenderer) {
+ times_to_fail_reinitialize_ = 0;
+ times_to_fail_recreate_ = 0;
+ times_to_lose_on_recreate_ = 100;
+ RunTest(true, false);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextFails,
+ LoseOnRecreate100_MultiThread_DelegatingRenderer) {
+ times_to_fail_reinitialize_ = 0;
+ times_to_fail_recreate_ = 0;
+ times_to_lose_on_recreate_ = 100;
+ RunTest(true, true);
}
class LayerTreeHostContextTestFinishAllRenderingAfterLoss
@@ -750,27 +816,51 @@ class LayerTreeHostContextTestLostContextAndEvictTextures
};
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseAfterEvict_SingleThread) {
+ LoseAfterEvict_SingleThread_DirectRenderer) {
+ lose_after_evict_ = true;
+ RunTest(false, false);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
+ LoseAfterEvict_SingleThread_DelegatingRenderer) {
lose_after_evict_ = true;
- RunTest(false);
+ RunTest(false, true);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseAfterEvict_MultiThread) {
+ LoseAfterEvict_MultiThread_DirectRenderer) {
lose_after_evict_ = true;
- RunTest(true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseBeforeEvict_SingleThread) {
+ LoseAfterEvict_MultiThread_DelegatingRenderer) {
+ lose_after_evict_ = true;
+ RunTest(true, true);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
+ LoseBeforeEvict_SingleThread_DirectRenderer) {
+ lose_after_evict_ = false;
+ RunTest(false, false);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
+ LoseBeforeEvict_SingleThread_DelegatingRenderer) {
+ lose_after_evict_ = false;
+ RunTest(false, true);
+}
+
+TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
+ LoseBeforeEvict_MultiThread_DirectRenderer) {
lose_after_evict_ = false;
- RunTest(false);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
- LoseBeforeEvict_MultiThread) {
+ LoseBeforeEvict_MultiThread_DelegatingRenderer) {
lose_after_evict_ = false;
- RunTest(true);
+ RunTest(true, true);
}
class LayerTreeHostContextTestLostContextWhileUpdatingResources
@@ -941,7 +1031,6 @@ class LayerTreeHostContextTestDontUseLostResources
scoped_refptr<TextureLayer> texture_ = TextureLayer::Create(NULL);
texture_->SetBounds(gfx::Size(10, 10));
texture_->SetAnchorPoint(gfx::PointF());
- texture_->SetTextureId(TestWebGraphicsContext3D::kExternalTextureId);
texture_->SetIsDrawable(true);
root_->AddChild(texture_);
@@ -964,26 +1053,33 @@ class LayerTreeHostContextTestDontUseLostResources
video_color_->SetIsDrawable(true);
root_->AddChild(video_color_);
- scoped_refptr<VideoLayer> video_hw_ = VideoLayer::Create(
- &hw_frame_provider_);
- video_hw_->SetBounds(gfx::Size(10, 10));
- video_hw_->SetAnchorPoint(gfx::PointF());
- video_hw_->SetIsDrawable(true);
- root_->AddChild(video_hw_);
-
- scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::Create(
- &scaled_hw_frame_provider_);
- video_scaled_hw_->SetBounds(gfx::Size(10, 10));
- video_scaled_hw_->SetAnchorPoint(gfx::PointF());
- video_scaled_hw_->SetIsDrawable(true);
- root_->AddChild(video_scaled_hw_);
-
- scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::Create();
- io_surface_->SetBounds(gfx::Size(10, 10));
- io_surface_->SetAnchorPoint(gfx::PointF());
- io_surface_->SetIsDrawable(true);
- io_surface_->SetIOSurfaceProperties(1, gfx::Size(10, 10));
- root_->AddChild(io_surface_);
+ if (!delegating_renderer()) {
+ // TODO(danakj): Hardware video decode can not be transported.
+ // crbug.com/179729
+ scoped_refptr<VideoLayer> video_hw_ = VideoLayer::Create(
+ &hw_frame_provider_);
+ video_hw_->SetBounds(gfx::Size(10, 10));
+ video_hw_->SetAnchorPoint(gfx::PointF());
+ video_hw_->SetIsDrawable(true);
+ root_->AddChild(video_hw_);
+
+ scoped_refptr<VideoLayer> video_scaled_hw_ = VideoLayer::Create(
+ &scaled_hw_frame_provider_);
+ video_scaled_hw_->SetBounds(gfx::Size(10, 10));
+ video_scaled_hw_->SetAnchorPoint(gfx::PointF());
+ video_scaled_hw_->SetIsDrawable(true);
+ root_->AddChild(video_scaled_hw_);
+ }
+
+ if (!delegating_renderer()) {
+ // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
+ scoped_refptr<IOSurfaceLayer> io_surface_ = IOSurfaceLayer::Create();
+ io_surface_->SetBounds(gfx::Size(10, 10));
+ io_surface_->SetAnchorPoint(gfx::PointF());
+ io_surface_->SetIsDrawable(true);
+ io_surface_->SetIOSurfaceProperties(1, gfx::Size(10, 10));
+ root_->AddChild(io_surface_);
+ }
// Enable the hud.
LayerTreeDebugState debug_state;
@@ -1048,17 +1144,31 @@ class LayerTreeHostContextTestDontUseLostResources
delegated_impl->SetFrameDataForRenderPasses(&pass_list);
EXPECT_TRUE(pass_list.empty());
+ // Third child is the texture layer.
+ TextureLayerImpl* texture_impl =
+ static_cast<TextureLayerImpl*>(
+ host_impl->active_tree()->root_layer()->children()[2]);
+ texture_impl->set_texture_id(
+ resource_provider->GraphicsContext3D()->createTexture());
+
+ DCHECK(resource_provider->GraphicsContext3D());
+ ResourceProvider::ResourceId texture = resource_provider->CreateResource(
+ gfx::Size(4, 4),
+ resource_provider->default_resource_type(),
+ ResourceProvider::TextureUsageAny);
+ ResourceProvider::ScopedWriteLockGL lock(resource_provider, texture);
+
color_video_frame_ = VideoFrame::CreateColorFrame(
gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
hw_video_frame_ = VideoFrame::WrapNativeTexture(
- resource_provider->GraphicsContext3D()->createTexture(),
+ lock.texture_id(),
GL_TEXTURE_2D,
gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4),
base::TimeDelta(),
VideoFrame::ReadPixelsCB(),
base::Closure());
scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture(
- resource_provider->GraphicsContext3D()->createTexture(),
+ lock.texture_id(),
GL_TEXTURE_2D,
gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4),
base::TimeDelta(),
@@ -1207,8 +1317,9 @@ class LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit
times_output_surface_created_ = 0;
char pixels[4];
- EXPECT_TRUE(layer_tree_host()->CompositeAndReadback(
- &pixels, gfx::Rect(1, 1)));
+ bool result = layer_tree_host()->CompositeAndReadback(
+ &pixels, gfx::Rect(1, 1));
+ EXPECT_EQ(!delegating_renderer(), result);
EXPECT_EQ(1, times_output_surface_created_);
PostSetNeedsCommitToMainThread();
@@ -1363,7 +1474,8 @@ class LayerTreeHostContextTestFailsToCreateSurface
int failure_count_;
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestFailsToCreateSurface);
+SINGLE_AND_MULTI_THREAD_TEST_F(
+ LayerTreeHostContextTestFailsToCreateSurface);
// Not reusing LayerTreeTest because it expects creating LTH to always succeed.
class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface
@@ -1373,12 +1485,12 @@ class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface
LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface()
: FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) {}
- // FakeLayerTreeHostClient
+ // FakeLayerTreeHostClient implementation.
virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
return scoped_ptr<OutputSurface>();
}
- void RunTest(bool threaded) {
+ void RunTest(bool threaded, bool delegating_renderer) {
scoped_ptr<base::Thread> impl_thread;
scoped_ptr<cc::Thread> impl_ccthread(NULL);
if (threaded) {
diff --git a/cc/trees/layer_tree_host_unittest_damage.cc b/cc/trees/layer_tree_host_unittest_damage.cc
index beed63c..1d5402c 100644
--- a/cc/trees/layer_tree_host_unittest_damage.cc
+++ b/cc/trees/layer_tree_host_unittest_damage.cc
@@ -31,7 +31,7 @@ class LayerTreeHostDamageTestNoDamageDoesNotSwap
// Most of the layer isn't visible.
content_ = FakeContentLayer::Create(&client_);
- content_->SetBounds(gfx::Size(100, 100));
+ content_->SetBounds(gfx::Size(2000, 100));
root->AddChild(content_);
layer_tree_host()->SetRootLayer(root);
@@ -86,7 +86,7 @@ class LayerTreeHostDamageTestNoDamageDoesNotSwap
break;
case 3:
// Cause non-visible damage.
- content_->SetNeedsDisplayRect(gfx::Rect(90, 90, 10, 10));
+ content_->SetNeedsDisplayRect(gfx::Rect(1990, 1990, 10, 10));
break;
}
}
@@ -229,9 +229,17 @@ class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest {
child_damage_rect_ = gfx::RectF(10, 11, 12, 13);
break;
case 3:
- // The update rect in the child should be damaged.
- EXPECT_EQ(gfx::RectF(100+10, 100+11, 12, 13).ToString(),
- root_damage.ToString());
+ if (!delegating_renderer()) {
+ // The update rect in the child should be damaged.
+ EXPECT_EQ(gfx::RectF(100+10, 100+11, 12, 13).ToString(),
+ root_damage.ToString());
+ } else {
+ // When using a delegating renderer, the entire child is considered
+ // damaged as we need to replace its resources with newly created
+ // ones.
+ EXPECT_EQ(gfx::RectF(child_->position(), child_->bounds()).ToString(),
+ root_damage.ToString());
+ }
EXPECT_FALSE(frame_data->has_no_damage);
// If we damage part of the frame, but also damage the full
diff --git a/cc/trees/layer_tree_host_unittest_delegated.cc b/cc/trees/layer_tree_host_unittest_delegated.cc
index 2b13cf5..6823bc8 100644
--- a/cc/trees/layer_tree_host_unittest_delegated.cc
+++ b/cc/trees/layer_tree_host_unittest_delegated.cc
@@ -539,7 +539,9 @@ class LayerTreeHostDelegatedTestReturnUnusedResources
virtual void AfterTest() OVERRIDE {}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestReturnUnusedResources);
+// Enable this for delegating renderer. crbug.com/239290
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+ LayerTreeHostDelegatedTestReturnUnusedResources);
class LayerTreeHostDelegatedTestReusedResources
: public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
@@ -598,7 +600,9 @@ class LayerTreeHostDelegatedTestReusedResources
virtual void AfterTest() OVERRIDE {}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestReusedResources);
+// Enable this for delegating renderer. crbug.com/239290
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+ LayerTreeHostDelegatedTestReusedResources);
class LayerTreeHostDelegatedTestFrameBeforeAck
: public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
@@ -695,7 +699,9 @@ class LayerTreeHostDelegatedTestFrameBeforeAck
virtual void AfterTest() OVERRIDE {}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestFrameBeforeAck);
+// Enable this for delegating renderer. crbug.com/239290
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+ LayerTreeHostDelegatedTestFrameBeforeAck);
class LayerTreeHostDelegatedTestFrameBeforeTakeResources
: public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
@@ -799,7 +805,8 @@ class LayerTreeHostDelegatedTestFrameBeforeTakeResources
virtual void AfterTest() OVERRIDE {}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(
+// Enable this for delegating renderer. crbug.com/239290
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
LayerTreeHostDelegatedTestFrameBeforeTakeResources);
class LayerTreeHostDelegatedTestBadFrame
@@ -942,7 +949,9 @@ class LayerTreeHostDelegatedTestBadFrame
virtual void AfterTest() OVERRIDE {}
};
-SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDelegatedTestBadFrame);
+// Enable this for delegating renderer. crbug.com/239290
+SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
+ LayerTreeHostDelegatedTestBadFrame);
class LayerTreeHostDelegatedTestUnnamedResource
: public LayerTreeHostDelegatedTestCaseSingleDelegatedLayer {
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index d433c42..6be91ea 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -450,43 +450,88 @@ class LayerTreeHostScrollTestCaseWithChild
scoped_refptr<Layer> expected_no_scroll_layer_;
};
-TEST_F(LayerTreeHostScrollTestCaseWithChild, DeviceScaleFactor1_ScrollChild) {
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor1_ScrollChild_DirectRenderer) {
device_scale_factor_ = 1.f;
scroll_child_layer_ = true;
- RunTest(true);
+ RunTest(true, false);
}
-TEST_F(LayerTreeHostScrollTestCaseWithChild, DeviceScaleFactor15_ScrollChild) {
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor1_ScrollChild_DelegatingRenderer) {
+ device_scale_factor_ = 1.f;
+ scroll_child_layer_ = true;
+ RunTest(true, true);
+}
+
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor15_ScrollChild_DirectRenderer) {
device_scale_factor_ = 1.5f;
scroll_child_layer_ = true;
- RunTest(true);
+ RunTest(true, false);
}
-TEST_F(LayerTreeHostScrollTestCaseWithChild, DeviceScaleFactor2_ScrollChild) {
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor15_ScrollChild_DelegatingRenderer) {
+ device_scale_factor_ = 1.5f;
+ scroll_child_layer_ = true;
+ RunTest(true, true);
+}
+
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor2_ScrollChild_DirectRenderer) {
device_scale_factor_ = 2.f;
scroll_child_layer_ = true;
- RunTest(true);
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor1_ScrollRootScrollLayer) {
+ DeviceScaleFactor2_ScrollChild_DelegatingRenderer) {
+ device_scale_factor_ = 2.f;
+ scroll_child_layer_ = true;
+ RunTest(true, true);
+}
+
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor1_ScrollRootScrollLayer_DirectRenderer) {
+ device_scale_factor_ = 1.f;
+ scroll_child_layer_ = false;
+ RunTest(true, false);
+}
+
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor1_ScrollRootScrollLayer_DelegatingRenderer) {
device_scale_factor_ = 1.f;
scroll_child_layer_ = false;
- RunTest(true);
+ RunTest(true, true);
+}
+
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor15_ScrollRootScrollLayer_DirectRenderer) {
+ device_scale_factor_ = 1.5f;
+ scroll_child_layer_ = false;
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor15_ScrollRootScrollLayer) {
+ DeviceScaleFactor15_ScrollRootScrollLayer_DelegatingRenderer) {
device_scale_factor_ = 1.5f;
scroll_child_layer_ = false;
- RunTest(true);
+ RunTest(true, true);
+}
+
+TEST_F(LayerTreeHostScrollTestCaseWithChild,
+ DeviceScaleFactor2_ScrollRootScrollLayer_DirectRenderer) {
+ device_scale_factor_ = 2.f;
+ scroll_child_layer_ = false;
+ RunTest(true, false);
}
TEST_F(LayerTreeHostScrollTestCaseWithChild,
- DeviceScaleFactor2_ScrollRootScrollLayer) {
+ DeviceScaleFactor2_ScrollRootScrollLayer_DelegatingRenderer) {
device_scale_factor_ = 2.f;
scroll_child_layer_ = false;
- RunTest(true);
+ RunTest(true, true);
}
class ImplSidePaintingScrollTest : public LayerTreeHostScrollTest {