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 "ui/compositor/test/in_process_context_factory.h" | 5 #include "ui/compositor/test/in_process_context_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "cc/output/compositor_frame.h" | |
15 #include "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
16 #include "cc/output/output_surface_client.h" | 15 #include "cc/output/output_surface_client.h" |
| 16 #include "cc/output/output_surface_frame.h" |
17 #include "cc/output/texture_mailbox_deleter.h" | 17 #include "cc/output/texture_mailbox_deleter.h" |
18 #include "cc/scheduler/begin_frame_source.h" | 18 #include "cc/scheduler/begin_frame_source.h" |
19 #include "cc/scheduler/delay_based_time_source.h" | 19 #include "cc/scheduler/delay_based_time_source.h" |
20 #include "cc/surfaces/direct_compositor_frame_sink.h" | 20 #include "cc/surfaces/direct_compositor_frame_sink.h" |
21 #include "cc/surfaces/display.h" | 21 #include "cc/surfaces/display.h" |
22 #include "cc/surfaces/display_scheduler.h" | 22 #include "cc/surfaces/display_scheduler.h" |
23 #include "cc/surfaces/surface_id_allocator.h" | 23 #include "cc/surfaces/surface_id_allocator.h" |
24 #include "cc/test/pixel_test_output_surface.h" | 24 #include "cc/test/pixel_test_output_surface.h" |
25 #include "cc/test/test_shared_bitmap_manager.h" | 25 #include "cc/test/test_shared_bitmap_manager.h" |
26 #include "gpu/command_buffer/client/context_support.h" | 26 #include "gpu/command_buffer/client/context_support.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 void EnsureBackbuffer() override {} | 59 void EnsureBackbuffer() override {} |
60 void DiscardBackbuffer() override {} | 60 void DiscardBackbuffer() override {} |
61 void BindFramebuffer() override { | 61 void BindFramebuffer() override { |
62 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 62 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
63 } | 63 } |
64 bool BindToClient(cc::OutputSurfaceClient* client) override { | 64 bool BindToClient(cc::OutputSurfaceClient* client) override { |
65 if (!OutputSurface::BindToClient(client)) | 65 if (!OutputSurface::BindToClient(client)) |
66 return false; | 66 return false; |
67 return true; | 67 return true; |
68 } | 68 } |
69 void SwapBuffers(cc::CompositorFrame frame) override { | 69 void SwapBuffers(cc::OutputSurfaceFrame frame) override { |
70 DCHECK(context_provider_.get()); | 70 DCHECK(context_provider_.get()); |
71 DCHECK(frame.gl_frame_data); | 71 if (frame.sub_buffer_rect == gfx::Rect(frame.size)) { |
72 if (frame.gl_frame_data->sub_buffer_rect == | |
73 gfx::Rect(frame.gl_frame_data->size)) { | |
74 context_provider_->ContextSupport()->Swap(); | 72 context_provider_->ContextSupport()->Swap(); |
75 } else { | 73 } else { |
76 context_provider_->ContextSupport()->PartialSwapBuffers( | 74 context_provider_->ContextSupport()->PartialSwapBuffers( |
77 frame.gl_frame_data->sub_buffer_rect); | 75 frame.sub_buffer_rect); |
78 } | 76 } |
79 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 77 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
80 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 78 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
81 gl->ShallowFlushCHROMIUM(); | 79 gl->ShallowFlushCHROMIUM(); |
82 | 80 |
83 gpu::SyncToken sync_token; | 81 gpu::SyncToken sync_token; |
84 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 82 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
85 | 83 |
86 context_provider_->ContextSupport()->SignalSyncToken( | 84 context_provider_->ContextSupport()->SignalSyncToken( |
87 sync_token, base::Bind(&DirectOutputSurface::OnSwapBuffersComplete, | 85 sync_token, base::Bind(&DirectOutputSurface::OnSwapBuffersComplete, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 275 |
278 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { | 276 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { |
279 observer_list_.AddObserver(observer); | 277 observer_list_.AddObserver(observer); |
280 } | 278 } |
281 | 279 |
282 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { | 280 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { |
283 observer_list_.RemoveObserver(observer); | 281 observer_list_.RemoveObserver(observer); |
284 } | 282 } |
285 | 283 |
286 } // namespace ui | 284 } // namespace ui |
OLD | NEW |