| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/single_thread_task_runner.h" | |
| 14 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 15 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
| 16 #include "cc/output/compositor_frame_metadata.h" | 15 #include "cc/output/compositor_frame_metadata.h" |
| 17 #include "cc/output/copy_output_request.h" | 16 #include "cc/output/copy_output_request.h" |
| 18 #include "cc/output/copy_output_result.h" | 17 #include "cc/output/copy_output_result.h" |
| 19 #include "cc/output/overlay_strategy_single_on_top.h" | 18 #include "cc/output/overlay_strategy_single_on_top.h" |
| 20 #include "cc/output/overlay_strategy_underlay.h" | 19 #include "cc/output/overlay_strategy_underlay.h" |
| 21 #include "cc/output/texture_mailbox_deleter.h" | 20 #include "cc/output/texture_mailbox_deleter.h" |
| 22 #include "cc/quads/texture_draw_quad.h" | 21 #include "cc/quads/texture_draw_quad.h" |
| 23 #include "cc/resources/resource_provider.h" | 22 #include "cc/resources/resource_provider.h" |
| (...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1872 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
| 1874 renderer_->SwapBuffers(CompositorFrameMetadata()); | 1873 renderer_->SwapBuffers(CompositorFrameMetadata()); |
| 1875 | 1874 |
| 1876 device_viewport_rect = gfx::Rect(1, 1); | 1875 device_viewport_rect = gfx::Rect(1, 1); |
| 1877 | 1876 |
| 1878 DrawFrame(1.f, device_viewport_rect, true); | 1877 DrawFrame(1.f, device_viewport_rect, true); |
| 1879 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); | 1878 EXPECT_CALL(output_surface_, SwapBuffers(_)).Times(1); |
| 1880 renderer_->SwapBuffers(CompositorFrameMetadata()); | 1879 renderer_->SwapBuffers(CompositorFrameMetadata()); |
| 1881 } | 1880 } |
| 1882 | 1881 |
| 1883 class GLRendererTestSyncPoint : public GLRendererPixelTest { | |
| 1884 protected: | |
| 1885 static void SyncTokenCallback(int* callback_count) { | |
| 1886 ++(*callback_count); | |
| 1887 base::MessageLoop::current()->QuitWhenIdle(); | |
| 1888 } | |
| 1889 | |
| 1890 static void OtherCallback(int* callback_count) { | |
| 1891 ++(*callback_count); | |
| 1892 base::MessageLoop::current()->QuitWhenIdle(); | |
| 1893 } | |
| 1894 }; | |
| 1895 | |
| 1896 #if !defined(OS_ANDROID) | |
| 1897 TEST_F(GLRendererTestSyncPoint, SignalSyncPointOnLostContext) { | |
| 1898 int sync_token_callback_count = 0; | |
| 1899 int other_callback_count = 0; | |
| 1900 gpu::gles2::GLES2Interface* gl = | |
| 1901 output_surface_->context_provider()->ContextGL(); | |
| 1902 gpu::ContextSupport* context_support = | |
| 1903 output_surface_->context_provider()->ContextSupport(); | |
| 1904 | |
| 1905 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | |
| 1906 gl->ShallowFlushCHROMIUM(); | |
| 1907 | |
| 1908 gpu::SyncToken sync_token; | |
| 1909 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | |
| 1910 | |
| 1911 gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB, | |
| 1912 GL_INNOCENT_CONTEXT_RESET_ARB); | |
| 1913 | |
| 1914 context_support->SignalSyncToken( | |
| 1915 sync_token, base::Bind(&SyncTokenCallback, &sync_token_callback_count)); | |
| 1916 EXPECT_EQ(0, sync_token_callback_count); | |
| 1917 EXPECT_EQ(0, other_callback_count); | |
| 1918 | |
| 1919 // Make the sync point happen. | |
| 1920 gl->Finish(); | |
| 1921 // Post a task after the sync point. | |
| 1922 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 1923 FROM_HERE, base::Bind(&OtherCallback, &other_callback_count)); | |
| 1924 | |
| 1925 base::MessageLoop::current()->Run(); | |
| 1926 | |
| 1927 // The sync point shouldn't have happened since the context was lost. | |
| 1928 EXPECT_EQ(0, sync_token_callback_count); | |
| 1929 EXPECT_EQ(1, other_callback_count); | |
| 1930 } | |
| 1931 | |
| 1932 TEST_F(GLRendererTestSyncPoint, SignalSyncPoint) { | |
| 1933 int sync_token_callback_count = 0; | |
| 1934 int other_callback_count = 0; | |
| 1935 | |
| 1936 gpu::gles2::GLES2Interface* gl = | |
| 1937 output_surface_->context_provider()->ContextGL(); | |
| 1938 gpu::ContextSupport* context_support = | |
| 1939 output_surface_->context_provider()->ContextSupport(); | |
| 1940 | |
| 1941 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | |
| 1942 gl->ShallowFlushCHROMIUM(); | |
| 1943 | |
| 1944 gpu::SyncToken sync_token; | |
| 1945 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | |
| 1946 | |
| 1947 context_support->SignalSyncToken( | |
| 1948 sync_token, base::Bind(&SyncTokenCallback, &sync_token_callback_count)); | |
| 1949 EXPECT_EQ(0, sync_token_callback_count); | |
| 1950 EXPECT_EQ(0, other_callback_count); | |
| 1951 | |
| 1952 // Make the sync point happen. | |
| 1953 gl->Finish(); | |
| 1954 // Post a task after the sync point. | |
| 1955 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 1956 FROM_HERE, base::Bind(&OtherCallback, &other_callback_count)); | |
| 1957 | |
| 1958 base::MessageLoop::current()->Run(); | |
| 1959 | |
| 1960 // The sync point should have happened. | |
| 1961 EXPECT_EQ(1, sync_token_callback_count); | |
| 1962 EXPECT_EQ(1, other_callback_count); | |
| 1963 } | |
| 1964 #endif // OS_ANDROID | |
| 1965 | |
| 1966 class TestOverlayProcessor : public OverlayProcessor { | 1882 class TestOverlayProcessor : public OverlayProcessor { |
| 1967 public: | 1883 public: |
| 1968 class Strategy : public OverlayProcessor::Strategy { | 1884 class Strategy : public OverlayProcessor::Strategy { |
| 1969 public: | 1885 public: |
| 1970 Strategy() {} | 1886 Strategy() {} |
| 1971 ~Strategy() override {} | 1887 ~Strategy() override {} |
| 1972 MOCK_METHOD3(Attempt, | 1888 MOCK_METHOD3(Attempt, |
| 1973 bool(ResourceProvider* resource_provider, | 1889 bool(ResourceProvider* resource_provider, |
| 1974 RenderPass* render_pass, | 1890 RenderPass* render_pass, |
| 1975 OverlayCandidateList* candidates)); | 1891 OverlayCandidateList* candidates)); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2233 EXPECT_CALL(overlay_scheduler, | 2149 EXPECT_CALL(overlay_scheduler, |
| 2234 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, | 2150 Schedule(1, gfx::OVERLAY_TRANSFORM_NONE, _, viewport_rect, |
| 2235 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); | 2151 BoundingRect(uv_top_left, uv_bottom_right))).Times(1); |
| 2236 | 2152 |
| 2237 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, | 2153 renderer.DrawFrame(&render_passes_in_draw_order_, 1.f, viewport_rect, |
| 2238 viewport_rect, false); | 2154 viewport_rect, false); |
| 2239 } | 2155 } |
| 2240 | 2156 |
| 2241 } // namespace | 2157 } // namespace |
| 2242 } // namespace cc | 2158 } // namespace cc |
| OLD | NEW |