| Index: cc/layers/texture_layer_unittest.cc
|
| diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
|
| index 1ee8dfba34d4379ab38a84b1f58b66d68a189c8b..4071dab7228ca09af6a60b700f2496de830f3733 100644
|
| --- a/cc/layers/texture_layer_unittest.cc
|
| +++ b/cc/layers/texture_layer_unittest.cc
|
| @@ -51,8 +51,8 @@ class MockLayerTreeHost : public LayerTreeHost {
|
| MOCK_METHOD0(AcquireLayerTextures, void());
|
| MOCK_METHOD0(SetNeedsCommit, void());
|
| MOCK_METHOD0(SetNeedsUpdateLayers, void());
|
| - MOCK_METHOD1(StartRateLimiter, void(WebKit::WebGraphicsContext3D* context));
|
| - MOCK_METHOD1(StopRateLimiter, void(WebKit::WebGraphicsContext3D* context));
|
| + MOCK_METHOD1(StartRateLimiter, void(TextureLayerClient* client));
|
| + MOCK_METHOD1(StopRateLimiter, void(TextureLayerClient* client));
|
| };
|
|
|
| class TextureLayerTest : public testing::Test {
|
| @@ -245,16 +245,18 @@ TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) {
|
|
|
| class FakeTextureLayerClient : public TextureLayerClient {
|
| public:
|
| - FakeTextureLayerClient() : context_(TestWebGraphicsContext3D::Create()) {}
|
| + FakeTextureLayerClient() {}
|
|
|
| virtual unsigned PrepareTexture() OVERRIDE {
|
| return 0;
|
| }
|
|
|
| - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
|
| - return context_.get();
|
| + virtual bool IsContextLost() OVERRIDE {
|
| + return false;
|
| }
|
|
|
| + virtual void RateLimitContext() OVERRIDE {}
|
| +
|
| virtual bool PrepareTextureMailbox(
|
| TextureMailbox* mailbox,
|
| scoped_ptr<SingleReleaseCallback>* release_callback,
|
| @@ -265,7 +267,6 @@ class FakeTextureLayerClient : public TextureLayerClient {
|
| }
|
|
|
| private:
|
| - scoped_ptr<TestWebGraphicsContext3D> context_;
|
| DISALLOW_COPY_AND_ASSIGN(FakeTextureLayerClient);
|
| };
|
|
|
| @@ -283,18 +284,18 @@ TEST_F(TextureLayerTest, RateLimiter) {
|
| Mock::VerifyAndClearExpectations(layer_tree_host_.get());
|
|
|
| // Do rate limit after we invalidate.
|
| - EXPECT_CALL(*layer_tree_host_, StartRateLimiter(client.Context3d()));
|
| + EXPECT_CALL(*layer_tree_host_, StartRateLimiter(&client));
|
| test_layer->SetNeedsDisplay();
|
| Mock::VerifyAndClearExpectations(layer_tree_host_.get());
|
|
|
| // Stop rate limiter when we don't want it any more.
|
| - EXPECT_CALL(*layer_tree_host_, StopRateLimiter(client.Context3d()));
|
| + EXPECT_CALL(*layer_tree_host_, StopRateLimiter(&client));
|
| test_layer->SetRateLimitContext(false);
|
| Mock::VerifyAndClearExpectations(layer_tree_host_.get());
|
|
|
| // Or we clear the client.
|
| test_layer->SetRateLimitContext(true);
|
| - EXPECT_CALL(*layer_tree_host_, StopRateLimiter(client.Context3d()));
|
| + EXPECT_CALL(*layer_tree_host_, StopRateLimiter(&client));
|
| EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber());
|
| test_layer->ClearClient();
|
| Mock::VerifyAndClearExpectations(layer_tree_host_.get());
|
| @@ -308,12 +309,12 @@ TEST_F(TextureLayerTest, RateLimiter) {
|
| layer_tree_host_->SetRootLayer(test_layer);
|
| EXPECT_CALL(*layer_tree_host_, StartRateLimiter(_)).Times(0);
|
| Mock::VerifyAndClearExpectations(layer_tree_host_.get());
|
| - EXPECT_CALL(*layer_tree_host_, StartRateLimiter(client.Context3d()));
|
| + EXPECT_CALL(*layer_tree_host_, StartRateLimiter(&client));
|
| test_layer->SetNeedsDisplay();
|
| Mock::VerifyAndClearExpectations(layer_tree_host_.get());
|
|
|
| // Stop rate limiter when we're removed from the tree.
|
| - EXPECT_CALL(*layer_tree_host_, StopRateLimiter(client.Context3d()));
|
| + EXPECT_CALL(*layer_tree_host_, StopRateLimiter(&client));
|
| layer_tree_host_->SetRootLayer(NULL);
|
| Mock::VerifyAndClearExpectations(layer_tree_host_.get());
|
| }
|
| @@ -893,7 +894,7 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest,
|
| TextureLayerNoMailboxIsActivatedDuringCommit()
|
| : wait_thread_("WAIT"),
|
| wait_event_(false, false),
|
| - context_(TestWebGraphicsContext3D::Create()) {
|
| + texture_(0u) {
|
| wait_thread_.Start();
|
| }
|
|
|
| @@ -917,14 +918,19 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest,
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| + virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
|
| + OVERRIDE {
|
| + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
|
| + texture_ = provider->UnboundTestContext3d()->createExternalTexture();
|
| + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>();
|
| + }
|
| +
|
| // TextureLayerClient implementation.
|
| virtual unsigned PrepareTexture() OVERRIDE {
|
| - context_->makeContextCurrent();
|
| - return context_->createTexture();
|
| - }
|
| - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
|
| - return context_.get();
|
| + return texture_;
|
| }
|
| + virtual bool IsContextLost() OVERRIDE { return false; }
|
| + virtual void RateLimitContext() OVERRIDE {}
|
| virtual bool PrepareTextureMailbox(
|
| TextureMailbox* mailbox,
|
| scoped_ptr<SingleReleaseCallback>* release_callback,
|
| @@ -1002,11 +1008,10 @@ class TextureLayerNoMailboxIsActivatedDuringCommit : public LayerTreeTest,
|
| base::Thread wait_thread_;
|
| base::WaitableEvent wait_event_;
|
| base::Lock activate_lock_;
|
| + unsigned texture_;
|
| int activate_count_;
|
| - int activate_commit_;
|
| scoped_refptr<Layer> root_;
|
| scoped_refptr<TextureLayer> layer_;
|
| - scoped_ptr<TestWebGraphicsContext3D> context_;
|
| };
|
|
|
| SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
|
| @@ -1406,28 +1411,21 @@ class TextureLayerClientTest
|
| public TextureLayerClient {
|
| public:
|
| TextureLayerClientTest()
|
| - : context_(NULL),
|
| - texture_(0),
|
| + : texture_(0),
|
| commit_count_(0),
|
| expected_used_textures_on_draw_(0),
|
| expected_used_textures_on_commit_(0) {}
|
|
|
| virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
|
| OVERRIDE {
|
| - scoped_ptr<TestWebGraphicsContext3D> context(
|
| - TestWebGraphicsContext3D::Create());
|
| - context_ = context.get();
|
| - texture_ = context->createTexture();
|
| - return FakeOutputSurface::Create3d(context.Pass()).PassAs<OutputSurface>();
|
| - }
|
| -
|
| - virtual unsigned PrepareTexture() OVERRIDE {
|
| - return texture_;
|
| + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
|
| + texture_ = provider->UnboundTestContext3d()->createExternalTexture();
|
| + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>();
|
| }
|
|
|
| - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
|
| - return context_;
|
| - }
|
| + virtual unsigned PrepareTexture() OVERRIDE { return texture_; }
|
| + virtual bool IsContextLost() OVERRIDE { return false; }
|
| + virtual void RateLimitContext() OVERRIDE { }
|
|
|
| virtual bool PrepareTextureMailbox(
|
| TextureMailbox* mailbox,
|
| @@ -1470,7 +1468,6 @@ class TextureLayerClientTest
|
| base::AutoLock lock(lock_);
|
| expected_used_textures_on_commit_ = 0;
|
| }
|
| - texture_ = 0;
|
| break;
|
| case 2:
|
| EndTest();
|
| @@ -1489,21 +1486,26 @@ class TextureLayerClientTest
|
| virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
|
| LayerTreeHostImpl::FrameData* frame_data,
|
| bool result) OVERRIDE {
|
| - context_->ResetUsedTextures();
|
| + ContextForImplThread(host_impl)->ResetUsedTextures();
|
| return true;
|
| }
|
|
|
| virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
|
| bool result) OVERRIDE {
|
| ASSERT_TRUE(result);
|
| - EXPECT_EQ(expected_used_textures_on_draw_, context_->NumUsedTextures());
|
| + EXPECT_EQ(expected_used_textures_on_draw_,
|
| + ContextForImplThread(host_impl)->NumUsedTextures());
|
| }
|
|
|
| virtual void AfterTest() OVERRIDE {}
|
|
|
| private:
|
| + TestWebGraphicsContext3D* ContextForImplThread(LayerTreeHostImpl* host_impl) {
|
| + return static_cast<TestWebGraphicsContext3D*>(
|
| + host_impl->output_surface()->context_provider()->Context3d());
|
| + }
|
| +
|
| scoped_refptr<TextureLayer> texture_layer_;
|
| - TestWebGraphicsContext3D* context_;
|
| unsigned texture_;
|
| int commit_count_;
|
|
|
| @@ -1528,25 +1530,25 @@ class TextureLayerChangeInvisibleTest
|
| public TextureLayerClient {
|
| public:
|
| TextureLayerChangeInvisibleTest()
|
| - : client_context_(TestWebGraphicsContext3D::Create()),
|
| - texture_(client_context_->createTexture()),
|
| - texture_to_delete_on_next_commit_(0),
|
| + : texture_(0u),
|
| prepare_called_(0),
|
| commit_count_(0),
|
| expected_texture_on_draw_(0) {}
|
|
|
| + virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
|
| + OVERRIDE {
|
| + scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
|
| + texture_ = provider->UnboundTestContext3d()->createExternalTexture();
|
| + return FakeOutputSurface::Create3d(provider).PassAs<OutputSurface>();
|
| + }
|
| +
|
| // TextureLayerClient implementation.
|
| virtual unsigned PrepareTexture() OVERRIDE {
|
| ++prepare_called_;
|
| return texture_;
|
| }
|
| -
|
| - // TextureLayerClient implementation.
|
| - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
|
| - return client_context_.get();
|
| - }
|
| -
|
| - // TextureLayerClient implementation.
|
| + virtual bool IsContextLost() OVERRIDE { return false; }
|
| + virtual void RateLimitContext() OVERRIDE {}
|
| virtual bool PrepareTextureMailbox(
|
| cc::TextureMailbox* mailbox,
|
| scoped_ptr<SingleReleaseCallback>* release_callback,
|
| @@ -1597,9 +1599,6 @@ class TextureLayerChangeInvisibleTest
|
| case 2: {
|
| // Layer shouldn't have been updated.
|
| EXPECT_EQ(1, prepare_called_);
|
| - // Change the texture.
|
| - texture_to_delete_on_next_commit_ = texture_;
|
| - texture_ = client_context_->createTexture();
|
| texture_layer_->SetNeedsDisplay();
|
| // Force a change to make sure we draw a frame.
|
| solid_layer_->SetBackgroundColor(SK_ColorGRAY);
|
| @@ -1607,8 +1606,6 @@ class TextureLayerChangeInvisibleTest
|
| }
|
| case 3:
|
| EXPECT_EQ(1, prepare_called_);
|
| - client_context_->deleteTexture(texture_to_delete_on_next_commit_);
|
| - texture_to_delete_on_next_commit_ = 0;
|
| // Make layer visible again.
|
| parent_layer_->SetOpacity(1.f);
|
| break;
|
| @@ -1616,7 +1613,6 @@ class TextureLayerChangeInvisibleTest
|
| // Layer should have been updated.
|
| EXPECT_EQ(2, prepare_called_);
|
| texture_layer_->ClearClient();
|
| - client_context_->deleteTexture(texture_);
|
| texture_ = 0;
|
| break;
|
| }
|
| @@ -1676,14 +1672,12 @@ class TextureLayerChangeInvisibleTest
|
| scoped_refptr<SolidColorLayer> solid_layer_;
|
| scoped_refptr<Layer> parent_layer_;
|
| scoped_refptr<TextureLayer> texture_layer_;
|
| - scoped_ptr<TestWebGraphicsContext3D> client_context_;
|
|
|
| // Used on the main thread, and on the impl thread while the main thread is
|
| // blocked.
|
| unsigned texture_;
|
|
|
| // Used on the main thread.
|
| - unsigned texture_to_delete_on_next_commit_;
|
| int prepare_called_;
|
| int commit_count_;
|
|
|
| @@ -1709,12 +1703,8 @@ class TextureLayerNoExtraCommitForMailboxTest
|
| NOTREACHED();
|
| return 0;
|
| }
|
| -
|
| - // TextureLayerClient implementation.
|
| - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
|
| - NOTREACHED();
|
| - return NULL;
|
| - }
|
| + virtual bool IsContextLost() OVERRIDE { return false; }
|
| + virtual void RateLimitContext() OVERRIDE {}
|
|
|
| virtual bool PrepareTextureMailbox(
|
| cc::TextureMailbox* mailbox,
|
| @@ -1818,14 +1808,9 @@ class TextureLayerChangeInvisibleMailboxTest
|
| NOTREACHED();
|
| return 0;
|
| }
|
| + virtual bool IsContextLost() OVERRIDE { return false; }
|
| + virtual void RateLimitContext() OVERRIDE {}
|
|
|
| - // TextureLayerClient implementation.
|
| - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
|
| - NOTREACHED();
|
| - return NULL;
|
| - }
|
| -
|
| - // TextureLayerClient implementation.
|
| virtual bool PrepareTextureMailbox(
|
| cc::TextureMailbox* mailbox,
|
| scoped_ptr<SingleReleaseCallback>* release_callback,
|
| @@ -1965,27 +1950,26 @@ class TextureLayerLostContextTest
|
| public TextureLayerClient {
|
| public:
|
| TextureLayerLostContextTest()
|
| - : texture_(0),
|
| + : context_lost_(false),
|
| draw_count_(0) {}
|
|
|
| virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback)
|
| OVERRIDE {
|
| - texture_context_ = TestWebGraphicsContext3D::Create();
|
| - texture_ = texture_context_->createTexture();
|
| return CreateFakeOutputSurface();
|
| }
|
|
|
| virtual unsigned PrepareTexture() OVERRIDE {
|
| if (draw_count_ == 0) {
|
| - texture_context_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
|
| - GL_INNOCENT_CONTEXT_RESET_ARB);
|
| + context_lost_ = true;
|
| + return 0u;
|
| }
|
| - return texture_;
|
| + return 1u;
|
| }
|
|
|
| - virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
|
| - return texture_context_.get();
|
| + virtual bool IsContextLost() OVERRIDE {
|
| + return context_lost_;
|
| }
|
| + virtual void RateLimitContext() OVERRIDE {}
|
|
|
| virtual bool PrepareTextureMailbox(
|
| TextureMailbox* mailbox,
|
| @@ -2021,7 +2005,7 @@ class TextureLayerLostContextTest
|
| if (++draw_count_ == 1)
|
| EXPECT_EQ(0u, texture_layer->texture_id());
|
| else
|
| - EXPECT_EQ(texture_, texture_layer->texture_id());
|
| + EXPECT_EQ(1u, texture_layer->texture_id());
|
| return true;
|
| }
|
|
|
| @@ -2033,8 +2017,7 @@ class TextureLayerLostContextTest
|
|
|
| private:
|
| scoped_refptr<TextureLayer> texture_layer_;
|
| - scoped_ptr<TestWebGraphicsContext3D> texture_context_;
|
| - unsigned texture_;
|
| + bool context_lost_;
|
| int draw_count_;
|
| };
|
|
|
|
|