1 // Copyright 2013 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.
5 #include "mojo/services/gles2/gles2_impl.h"
9 #include "gpu/command_buffer/client/gl_in_process_context.h"
10 #include "gpu/command_buffer/client/gles2_implementation.h"
15 GLES2Impl::GLES2Impl(ScopedMessagePipeHandle client)
16 : client_(client.Pass(), this) {
19 GLES2Impl::~GLES2Impl() {
22 void GLES2Impl::RequestAnimationFrames() {
23 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(16),
24 this, &GLES2Impl::DrawAnimationFrame);
27 void GLES2Impl::CancelAnimationFrames() {
31 void GLES2Impl::Destroy() {
35 void GLES2Impl::CreateContext(gfx::AcceleratedWidget widget,
36 const gfx::Size& size) {
37 gpu::GLInProcessContextAttribs attribs;
38 gl_context_.reset(gpu::GLInProcessContext::CreateContext(
39 false, widget, size, false, attribs, gfx::PreferDiscreteGpu));
40 gl_context_->SetContextLostCallback(base::Bind(
41 &GLES2Impl::OnGLContextLost, base::Unretained(this)));
43 gpu::gles2::GLES2Interface* gl = gl_context_->GetImplementation();
44 uint64_t encoded_gl = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(gl));
46 client_->DidCreateContext(encoded_gl, size.width(), size.height());
49 void GLES2Impl::OnGLContextLost() {
50 client_->ContextLost();
53 void GLES2Impl::DrawAnimationFrame() {
54 client_->DrawAnimationFrame();
57 } // namespace services