Chromium Code Reviews| Index: mojo/services/native_viewport/native_viewport.cc |
| diff --git a/mojo/services/native_viewport/native_viewport.cc b/mojo/services/native_viewport/native_viewport.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..91e93d16a13f362408d6436ee90ddc13afc079a8 |
| --- /dev/null |
| +++ b/mojo/services/native_viewport/native_viewport.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "mojo/services/native_viewport/native_viewport.h" |
| + |
| +#include "base/bind.h" |
| +#include "gpu/command_buffer/client/gl_in_process_context.h" |
| +#include "gpu/command_buffer/client/gles2_implementation.h" |
| + |
| +namespace mojo { |
| +namespace services { |
| + |
| +NativeViewport::NativeViewport(NativeViewportDelegate* delegate) |
| + : delegate_(delegate), |
| + widget_(gfx::kNullAcceleratedWidget) { |
| +} |
| + |
| +NativeViewport::~NativeViewport() { |
| +} |
| + |
| +void NativeViewport::OnAcceleratedWidgetAvailable() { |
| + gpu::GLInProcessContextAttribs attribs; |
| + gl_context_.reset(gpu::GLInProcessContext::CreateContext( |
| + false, widget_, bounds_.size(), false, |
|
Ben Goodger (Google)
2013/11/06 07:17:17
nit: 4-space indent here
abarth-chromium
2013/11/06 15:40:55
Done.
|
| + attribs, gfx::PreferDiscreteGpu)); |
| + gl_context_->SetContextLostCallback(base::Bind( |
| + &NativeViewport::OnGLContextLost, base::Unretained(this))); |
|
Ben Goodger (Google)
2013/11/06 07:17:17
and here
abarth-chromium
2013/11/06 15:40:55
Done.
|
| + |
| + delegate_->OnGLContextAvailable(gl_context_->GetImplementation()); |
| +} |
| + |
| +void NativeViewport::OnGLContextLost() { |
| + gl_context_.reset(); |
| + delegate_->OnGLContextLost(); |
| +} |
| + |
| +} // namespace services |
| +} // namespace mojo |