| 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 "components/mus/surfaces/surfaces_output_surface.h" | 5 #include "components/mus/surfaces/surfaces_output_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/context_provider.h" | 9 #include "cc/output/context_provider.h" |
| 10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
| 11 #include "gpu/command_buffer/client/context_support.h" | 11 #include "gpu/command_buffer/client/context_support.h" |
| 12 #include "gpu/command_buffer/client/gles2_interface.h" | 12 #include "gpu/command_buffer/client/gles2_interface.h" |
| 13 | 13 |
| 14 namespace mus { | 14 namespace surfaces { |
| 15 | 15 |
| 16 DirectOutputSurface::DirectOutputSurface( | 16 DirectOutputSurface::DirectOutputSurface( |
| 17 const scoped_refptr<cc::ContextProvider>& context_provider) | 17 const scoped_refptr<cc::ContextProvider>& context_provider) |
| 18 : cc::OutputSurface(context_provider), weak_ptr_factory_(this) {} | 18 : cc::OutputSurface(context_provider), weak_ptr_factory_(this) {} |
| 19 | 19 |
| 20 DirectOutputSurface::~DirectOutputSurface() {} | 20 DirectOutputSurface::~DirectOutputSurface() {} |
| 21 | 21 |
| 22 void DirectOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | 22 void DirectOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
| 23 DCHECK(context_provider_.get()); | 23 DCHECK(context_provider_.get()); |
| 24 DCHECK(frame->gl_frame_data); | 24 DCHECK(frame->gl_frame_data); |
| 25 if (frame->gl_frame_data->sub_buffer_rect == | 25 if (frame->gl_frame_data->sub_buffer_rect == |
| 26 gfx::Rect(frame->gl_frame_data->size)) { | 26 gfx::Rect(frame->gl_frame_data->size)) { |
| 27 context_provider_->ContextSupport()->Swap(); | 27 context_provider_->ContextSupport()->Swap(); |
| 28 } else { | 28 } else { |
| 29 context_provider_->ContextSupport()->PartialSwapBuffers( | 29 context_provider_->ContextSupport()->PartialSwapBuffers( |
| 30 frame->gl_frame_data->sub_buffer_rect); | 30 frame->gl_frame_data->sub_buffer_rect); |
| 31 } | 31 } |
| 32 uint32_t sync_point = | 32 uint32_t sync_point = |
| 33 context_provider_->ContextGL()->InsertSyncPointCHROMIUM(); | 33 context_provider_->ContextGL()->InsertSyncPointCHROMIUM(); |
| 34 context_provider_->ContextSupport()->SignalSyncPoint( | 34 context_provider_->ContextSupport()->SignalSyncPoint( |
| 35 sync_point, base::Bind(&OutputSurface::OnSwapBuffersComplete, | 35 sync_point, base::Bind(&OutputSurface::OnSwapBuffersComplete, |
| 36 weak_ptr_factory_.GetWeakPtr())); | 36 weak_ptr_factory_.GetWeakPtr())); |
| 37 client_->DidSwapBuffers(); | 37 client_->DidSwapBuffers(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace mus | 40 } // namespace surfaces |
| OLD | NEW |