Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1459)

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 14772021: cc::OutputSurfaceClient::InitializeForGL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test, revert scheduler change, DCHECK(!inside_draw_) Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index ab97c8636d71e6b3f1242340001974ba2d750782..37a291046f16ab452d2462c55119070e28c2ea85 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -64,6 +64,7 @@ class LayerTreeHostImplTest : public testing::Test,
: proxy_(scoped_ptr<Thread>(NULL)),
always_impl_thread_(&proxy_),
always_main_thread_blocked_(&proxy_),
+ did_try_initialize_renderer_(false),
on_can_draw_state_changed_called_(false),
has_pending_tree_(false),
did_request_commit_(false),
@@ -90,6 +91,11 @@ class LayerTreeHostImplTest : public testing::Test,
virtual void TearDown() OVERRIDE {}
+ virtual void DidTryInitializeRendererOnImplThread(
+ bool success,
+ scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE {
+ did_try_initialize_renderer_ = true;
+ }
virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {}
virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {}
virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
@@ -275,6 +281,7 @@ class LayerTreeHostImplTest : public testing::Test,
scoped_ptr<LayerTreeHostImpl> host_impl_;
FakeRenderingStatsInstrumentation stats_instrumentation_;
+ bool did_try_initialize_renderer_;
bool on_can_draw_state_changed_called_;
bool has_pending_tree_;
bool did_request_commit_;
@@ -5786,6 +5793,7 @@ TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) {
host_impl_->SetViewportSize(gfx::Size(50, 50));
CountingSoftwareDevice* software_device = new CountingSoftwareDevice();
FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL(
+ scoped_ptr<WebKit::WebGraphicsContext3D>(),
scoped_ptr<SoftwareOutputDevice>(software_device)).release();
host_impl_->InitializeRenderer(scoped_ptr<OutputSurface>(output_surface));
@@ -5808,6 +5816,7 @@ TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) {
TEST_F(LayerTreeHostImplTest,
ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) {
FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL(
+ scoped_ptr<WebKit::WebGraphicsContext3D>(),
scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice())).release();
host_impl_->InitializeRenderer(
scoped_ptr<OutputSurface>(output_surface));
@@ -5838,5 +5847,37 @@ TEST_F(LayerTreeHostImplTest,
EXPECT_EQ(host_impl_->active_tree()->root_layer(), frame.will_draw_layers[0]);
}
+TEST_F(LayerTreeHostImplTest, DeferredInitializeSmoke) {
+ host_impl_->InitializeRenderer(
+ scoped_ptr<OutputSurface>(FakeOutputSurface::CreateDeferredGL(
+ scoped_ptr<WebKit::WebGraphicsContext3D>(
+ TestWebGraphicsContext3D::Create(
+ WebKit::WebGraphicsContext3D::Attributes())),
+ scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()))));
+
+ // Add two layers.
+ scoped_ptr<SolidColorLayerImpl> root_layer =
+ SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
+ FakeVideoFrameProvider provider;
+ scoped_ptr<VideoLayerImpl> video_layer =
+ VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
+ video_layer->SetBounds(gfx::Size(10, 10));
+ video_layer->SetContentBounds(gfx::Size(10, 10));
+ video_layer->SetDrawsContent(true);
+ root_layer->AddChild(video_layer.PassAs<LayerImpl>());
+ SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
+
+ // Software draw.
+ DrawFrame();
+
+ // DeferredInitialize and hardware draw.
+ EXPECT_FALSE(did_try_initialize_renderer_);
+ host_impl_->DeferredInitialize(scoped_refptr<ContextProvider>());
+ EXPECT_TRUE(did_try_initialize_renderer_);
+
+ // Defer intialized GL draw.
+ DrawFrame();
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698