| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "cc/output/context_provider.h" | 6 #include "cc/output/context_provider.h" |
| 7 #include "content/browser/compositor/image_transport_factory.h" | 7 #include "content/browser/compositor/image_transport_factory.h" |
| 8 #include "content/browser/compositor/owned_mailbox.h" |
| 8 #include "content/public/browser/gpu_data_manager.h" | 9 #include "content/public/browser/gpu_data_manager.h" |
| 9 #include "content/public/test/content_browser_test.h" | 10 #include "content/public/test/content_browser_test.h" |
| 10 #include "gpu/GLES2/gl2extchromium.h" | 11 #include "gpu/GLES2/gl2extchromium.h" |
| 11 #include "gpu/command_buffer/client/gles2_interface.h" | 12 #include "gpu/command_buffer/client/gles2_interface.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "ui/compositor/compositor.h" | 14 #include "ui/compositor/compositor.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 31 #endif | 32 #endif |
| 32 // Checks that upon context loss, the observer is called and the created | 33 // Checks that upon context loss, the observer is called and the created |
| 33 // resources are reset. | 34 // resources are reset. |
| 34 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, | 35 IN_PROC_BROWSER_TEST_F(ImageTransportFactoryBrowserTest, |
| 35 MAYBE_TestLostContext) { | 36 MAYBE_TestLostContext) { |
| 36 // This test doesn't make sense in software compositing mode. | 37 // This test doesn't make sense in software compositing mode. |
| 37 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) | 38 if (!GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) |
| 38 return; | 39 return; |
| 39 | 40 |
| 40 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 41 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 41 ui::ContextFactory* context_factory = ui::ContextFactory::GetInstance(); | |
| 42 gpu::gles2::GLES2Interface* gl = | |
| 43 context_factory->SharedMainThreadContextProvider()->ContextGL(); | |
| 44 GLuint texture_id = 0; | |
| 45 gl->GenTextures(1, &texture_id); | |
| 46 | 42 |
| 47 scoped_refptr<ui::Texture> texture = | 43 scoped_refptr<OwnedMailbox> mailbox = |
| 48 factory->CreateOwnedTexture(gfx::Size(1, 1), 1.f, texture_id); | 44 new OwnedMailbox(factory->GetGLHelper()); |
| 49 ASSERT_TRUE(texture.get()); | 45 EXPECT_FALSE(mailbox->mailbox().IsZero()); |
| 50 | 46 |
| 51 MockImageTransportFactoryObserver observer; | 47 MockImageTransportFactoryObserver observer; |
| 52 factory->AddObserver(&observer); | 48 factory->AddObserver(&observer); |
| 53 | 49 |
| 54 base::RunLoop run_loop; | 50 base::RunLoop run_loop; |
| 55 EXPECT_CALL(observer, OnLostResources()) | 51 EXPECT_CALL(observer, OnLostResources()) |
| 56 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 52 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 57 | 53 |
| 54 ui::ContextFactory* context_factory = ui::ContextFactory::GetInstance(); |
| 55 gpu::gles2::GLES2Interface* gl = |
| 56 context_factory->SharedMainThreadContextProvider()->ContextGL(); |
| 58 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | 57 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, |
| 59 GL_INNOCENT_CONTEXT_RESET_ARB); | 58 GL_INNOCENT_CONTEXT_RESET_ARB); |
| 60 | 59 |
| 61 // We have to flush to make sure that the client side gets a chance to notice | 60 // We have to flush to make sure that the client side gets a chance to notice |
| 62 // the context is gone. | 61 // the context is gone. |
| 63 gl->Flush(); | 62 gl->Flush(); |
| 64 | 63 |
| 65 run_loop.Run(); | 64 run_loop.Run(); |
| 66 EXPECT_EQ(0u, texture->PrepareTexture()); | 65 EXPECT_TRUE(mailbox->mailbox().IsZero()); |
| 67 | 66 |
| 68 factory->RemoveObserver(&observer); | 67 factory->RemoveObserver(&observer); |
| 69 } | 68 } |
| 70 | 69 |
| 71 } // anonymous namespace | 70 } // anonymous namespace |
| 72 } // namespace content | 71 } // namespace content |
| OLD | NEW |