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