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