Home | History | Annotate | Download | only in gles2
      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.
      4 
      5 #include "mojo/gles2/gles2_impl.h"
      6 
      7 #include "gpu/command_buffer/client/gles2_lib.h"
      8 #include "mojo/public/gles2/gles2_private.h"
      9 
     10 namespace mojo {
     11 namespace gles2 {
     12 
     13 GLES2Impl::GLES2Impl() {
     14 }
     15 
     16 GLES2Impl::~GLES2Impl() {
     17 }
     18 
     19 void GLES2Impl::Init() {
     20   GLES2Private::Init(new GLES2Impl());
     21 }
     22 
     23 void GLES2Impl::Initialize() {
     24   ::gles2::Initialize();
     25 }
     26 
     27 void GLES2Impl::Terminate() {
     28   ::gles2::Terminate();
     29 }
     30 
     31 void GLES2Impl::MakeCurrent(uint64_t encoded) {
     32   // Ack, Hans! It's the giant hack.
     33   // TODO(abarth): Replace this hack with something more disciplined. Most
     34   // likley, we should receive a MojoHandle that we use to wire up the
     35   // client side of an out-of-process command buffer. Given that we're
     36   // still in-process, we just reinterpret_cast the value into a GL interface.
     37   gpu::gles2::GLES2Interface* gl_interface =
     38       reinterpret_cast<gpu::gles2::GLES2Interface*>(
     39           static_cast<uintptr_t>(encoded));
     40   ::gles2::SetGLContext(gl_interface);
     41 }
     42 
     43 void GLES2Impl::SwapBuffers() {
     44   ::gles2::GetGLContext()->SwapBuffers();
     45 }
     46 
     47 }  // namespace gles2
     48 }  // namespace mojo
     49