| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/surfaces/direct_output_surface_ozone.h" | 5 #include "services/ui/surfaces/direct_output_surface_ozone.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "cc/output/compositor_frame.h" | |
| 12 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
| 13 #include "cc/output/output_surface_client.h" | 12 #include "cc/output/output_surface_client.h" |
| 13 #include "cc/output/output_surface_frame.h" |
| 14 #include "cc/scheduler/begin_frame_source.h" | 14 #include "cc/scheduler/begin_frame_source.h" |
| 15 #include "components/display_compositor/buffer_queue.h" | 15 #include "components/display_compositor/buffer_queue.h" |
| 16 #include "gpu/command_buffer/client/context_support.h" | 16 #include "gpu/command_buffer/client/context_support.h" |
| 17 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" |
| 18 #include "services/ui/surfaces/surfaces_context_provider.h" | 18 #include "services/ui/surfaces/surfaces_context_provider.h" |
| 19 #include "ui/display/types/display_snapshot.h" | 19 #include "ui/display/types/display_snapshot.h" |
| 20 | 20 |
| 21 using display_compositor::BufferQueue; | 21 using display_compositor::BufferQueue; |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 void DirectOutputSurfaceOzone::DiscardBackbuffer() { | 77 void DirectOutputSurfaceOzone::DiscardBackbuffer() { |
| 78 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); | 78 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void DirectOutputSurfaceOzone::BindFramebuffer() { | 81 void DirectOutputSurfaceOzone::BindFramebuffer() { |
| 82 DCHECK(buffer_queue_); | 82 DCHECK(buffer_queue_); |
| 83 buffer_queue_->BindFramebuffer(); | 83 buffer_queue_->BindFramebuffer(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void DirectOutputSurfaceOzone::SwapBuffers(cc::CompositorFrame frame) { | 86 void DirectOutputSurfaceOzone::SwapBuffers(cc::OutputSurfaceFrame frame) { |
| 87 DCHECK(buffer_queue_); | 87 DCHECK(buffer_queue_); |
| 88 DCHECK(frame.gl_frame_data); | |
| 89 | 88 |
| 90 // TODO(rjkroege): What if swap happens again before OnGpuSwapBuffersCompleted | 89 // TODO(rjkroege): What if swap happens again before OnGpuSwapBuffersCompleted |
| 91 // then it would see the wrong size? | 90 // then it would see the wrong size? |
| 92 DCHECK(reshape_size_ == frame.gl_frame_data->size); | 91 DCHECK(reshape_size_ == frame.size); |
| 93 swap_size_ = reshape_size_; | 92 swap_size_ = reshape_size_; |
| 94 | 93 |
| 95 buffer_queue_->SwapBuffers(frame.gl_frame_data->sub_buffer_rect); | 94 buffer_queue_->SwapBuffers(frame.sub_buffer_rect); |
| 96 | 95 |
| 97 // Code combining GpuBrowserCompositorOutputSurface + DirectOutputSurface | 96 // Code combining GpuBrowserCompositorOutputSurface + DirectOutputSurface |
| 98 if (frame.gl_frame_data->sub_buffer_rect == | 97 if (frame.sub_buffer_rect == gfx::Rect(frame.size)) { |
| 99 gfx::Rect(frame.gl_frame_data->size)) { | |
| 100 context_provider_->ContextSupport()->Swap(); | 98 context_provider_->ContextSupport()->Swap(); |
| 101 } else { | 99 } else { |
| 102 context_provider_->ContextSupport()->PartialSwapBuffers( | 100 context_provider_->ContextSupport()->PartialSwapBuffers( |
| 103 frame.gl_frame_data->sub_buffer_rect); | 101 frame.sub_buffer_rect); |
| 104 } | 102 } |
| 105 | 103 |
| 106 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 104 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 107 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 105 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 108 gl->ShallowFlushCHROMIUM(); | 106 gl->ShallowFlushCHROMIUM(); |
| 109 | 107 |
| 110 gpu::SyncToken sync_token; | 108 gpu::SyncToken sync_token; |
| 111 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 109 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 112 } | 110 } |
| 113 | 111 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 170 } |
| 173 | 171 |
| 174 buffer_queue_->PageFlipComplete(); | 172 buffer_queue_->PageFlipComplete(); |
| 175 client_->DidSwapBuffersComplete(); | 173 client_->DidSwapBuffersComplete(); |
| 176 | 174 |
| 177 if (force_swap) | 175 if (force_swap) |
| 178 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); | 176 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); |
| 179 } | 177 } |
| 180 | 178 |
| 181 } // namespace ui | 179 } // namespace ui |
| OLD | NEW |