Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / cc / trees / layer_tree_host_unittest_context.cc
index 57c780b..baf2b2d 100644 (file)
@@ -76,8 +76,8 @@ class LayerTreeHostContextTest : public LayerTreeTest {
     return TestWebGraphicsContext3D::Create();
   }
 
-  virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurfaceForTest(
-      bool fallback) OVERRIDE {
+  virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
+      OVERRIDE {
     if (times_to_fail_create_) {
       --times_to_fail_create_;
       ExpectCreateToFail();
@@ -127,12 +127,13 @@ class LayerTreeHostContextTest : public LayerTreeTest {
     return offscreen_contexts_;
   }
 
-  virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
-                                     LayerTreeHostImpl::FrameData* frame,
-                                     bool result) OVERRIDE {
-    EXPECT_TRUE(result);
+  virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
+      LayerTreeHostImpl* host_impl,
+      LayerTreeHostImpl::FrameData* frame,
+      DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
+    EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, draw_result);
     if (!times_to_lose_during_draw_)
-      return result;
+      return draw_result;
 
     --times_to_lose_during_draw_;
     LoseContext();
@@ -142,7 +143,7 @@ class LayerTreeHostContextTest : public LayerTreeTest {
     times_to_fail_create_offscreen_ = times_to_fail_recreate_offscreen_;
     times_to_fail_recreate_offscreen_ = 0;
 
-    return result;
+    return draw_result;
   }
 
   virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
@@ -503,10 +504,10 @@ class LayerTreeHostContextTestCreateOutputSurfaceFails
     PostSetNeedsCommitToMainThread();
   }
 
-  virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
+  virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
       OVERRIDE {
-    scoped_ptr<OutputSurface> surface =
-        LayerTreeHostContextTest::CreateOutputSurface(fallback);
+    scoped_ptr<FakeOutputSurface> surface =
+        LayerTreeHostContextTest::CreateFakeOutputSurface(fallback);
 
     if (surface)
       EXPECT_EQ(times_to_fail_, times_create_failed_);
@@ -1003,7 +1004,7 @@ class LayerTreeHostContextTestDontUseLostResources
     texture->SetAnchorPoint(gfx::PointF());
     texture->SetIsDrawable(true);
     texture->SetTextureMailbox(
-        TextureMailbox(mailbox, sync_point),
+        TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point),
         SingleReleaseCallback::Create(
             base::Bind(&LayerTreeHostContextTestDontUseLostResources::
                             EmptyReleaseCallback)));
@@ -1044,30 +1045,24 @@ class LayerTreeHostContextTestDontUseLostResources
 
     color_video_frame_ = VideoFrame::CreateColorFrame(
         gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
-    hw_video_frame_ = VideoFrame::WrapNativeTexture(
-        make_scoped_ptr(new VideoFrame::MailboxHolder(
-            mailbox,
-            sync_point,
-            VideoFrame::MailboxHolder::TextureNoLongerNeededCallback())),
-        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(
-        make_scoped_ptr(new VideoFrame::MailboxHolder(
-            mailbox,
-            sync_point,
-            VideoFrame::MailboxHolder::TextureNoLongerNeededCallback())),
-        GL_TEXTURE_2D,
-        gfx::Size(4, 4),
-        gfx::Rect(0, 0, 3, 2),
-        gfx::Size(4, 4),
-        base::TimeDelta(),
-        VideoFrame::ReadPixelsCB(),
-        base::Closure());
+    hw_video_frame_ =
+        VideoFrame::WrapNativeTexture(make_scoped_ptr(new gpu::MailboxHolder(
+                                          mailbox, GL_TEXTURE_2D, sync_point)),
+                                      media::VideoFrame::ReleaseMailboxCB(),
+                                      gfx::Size(4, 4),
+                                      gfx::Rect(0, 0, 4, 4),
+                                      gfx::Size(4, 4),
+                                      base::TimeDelta(),
+                                      VideoFrame::ReadPixelsCB());
+    scaled_hw_video_frame_ =
+        VideoFrame::WrapNativeTexture(make_scoped_ptr(new gpu::MailboxHolder(
+                                          mailbox, GL_TEXTURE_2D, sync_point)),
+                                      media::VideoFrame::ReleaseMailboxCB(),
+                                      gfx::Size(4, 4),
+                                      gfx::Rect(0, 0, 3, 2),
+                                      gfx::Size(4, 4),
+                                      base::TimeDelta(),
+                                      VideoFrame::ReadPixelsCB());
 
     color_frame_provider_.set_frame(color_video_frame_);
     hw_frame_provider_.set_frame(hw_video_frame_);
@@ -1114,18 +1109,19 @@ class LayerTreeHostContextTestDontUseLostResources
     }
   }
 
-  virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
-                                     LayerTreeHostImpl::FrameData* frame,
-                                     bool result) OVERRIDE {
+  virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
+      LayerTreeHostImpl* host_impl,
+      LayerTreeHostImpl::FrameData* frame,
+      DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
     if (host_impl->active_tree()->source_frame_number() == 2) {
       // Lose the context during draw on the second commit. This will cause
       // a third commit to recover.
       context3d_->set_times_bind_texture_succeeds(0);
     }
-    return true;
+    return draw_result;
   }
 
-  virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
+  virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(bool fallback)
       OVERRIDE {
     // This will get called twice:
     // First when we create the initial output surface...
@@ -1135,7 +1131,7 @@ class LayerTreeHostContextTestDontUseLostResources
       lost_context_ = true;
       EXPECT_EQ(layer_tree_host()->source_frame_number(), 3);
     }
-    return LayerTreeHostContextTest::CreateOutputSurface(fallback);
+    return LayerTreeHostContextTest::CreateFakeOutputSurface(fallback);
   }
 
   virtual void DidCommitAndDrawFrame() OVERRIDE {
@@ -1209,12 +1205,13 @@ class LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit
     EXPECT_EQ(1, times_output_surface_created_);
   }
 
-  virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
-                                     LayerTreeHostImpl::FrameData* frame_data,
-                                     bool result) OVERRIDE {
+  virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
+      LayerTreeHostImpl* host_impl,
+      LayerTreeHostImpl::FrameData* frame_data,
+      DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
     EXPECT_GE(host_impl->active_tree()->source_frame_number(), 0);
     EXPECT_LE(host_impl->active_tree()->source_frame_number(), 1);
-    return true;
+    return draw_result;
   }
 
   virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
@@ -1260,9 +1257,10 @@ class LayerTreeHostContextTestLoseOutputSurfaceDuringReadbackAndForcedDraw
 
   virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
 
-  virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
-                                     LayerTreeHostImpl::FrameData* frame_data,
-                                     bool result) OVERRIDE {
+  virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
+      LayerTreeHostImpl* host_impl,
+      LayerTreeHostImpl::FrameData* frame_data,
+      DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
     int sfn = host_impl->active_tree()->source_frame_number();
     EXPECT_TRUE(sfn == kFirstOutputSurfaceInitSourceFrameNumber ||
                 sfn == kSecondOutputSurfaceInitSourceFrameNumber ||
@@ -1279,7 +1277,7 @@ class LayerTreeHostContextTestLoseOutputSurfaceDuringReadbackAndForcedDraw
       LoseContext();
     }
 
-    return false;
+    return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
   }
 
   virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl,
@@ -1338,9 +1336,10 @@ class LayerTreeHostContextTestReadbackWithForcedDrawAndOutputSurfaceInit
 
   virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
 
-  virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
-                                     LayerTreeHostImpl::FrameData* frame_data,
-                                     bool result) OVERRIDE {
+  virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
+      LayerTreeHostImpl* host_impl,
+      LayerTreeHostImpl::FrameData* frame_data,
+      DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
     int sfn = host_impl->active_tree()->source_frame_number();
     EXPECT_TRUE(sfn == kFirstOutputSurfaceInitSourceFrameNumber ||
                 sfn == kSecondOutputSurfaceInitSourceFrameNumber ||
@@ -1356,7 +1355,7 @@ class LayerTreeHostContextTestReadbackWithForcedDrawAndOutputSurfaceInit
     }
 
     // Returning false will result in a forced draw.
-    return false;
+    return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
   }
 
   virtual void DidInitializeOutputSurface(bool succeeded) OVERRIDE {