OLD | NEW |
| (Empty) |
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/public/bindings/gles2_client/gles2_client_impl.h" | |
6 | |
7 #include <assert.h> | |
8 | |
9 #include "gpu/command_buffer/client/gles2_lib.h" | |
10 | |
11 namespace mojo { | |
12 namespace { | |
13 | |
14 bool g_gles2_initialized = false; | |
15 | |
16 } // namespace | |
17 | |
18 GLES2Delegate::~GLES2Delegate() { | |
19 } | |
20 | |
21 void GLES2Delegate::DidCreateContext( | |
22 GLES2ClientImpl* gl, uint32_t width, uint32_t height) { | |
23 } | |
24 | |
25 void GLES2Delegate::ContextLost(GLES2ClientImpl* gl) { | |
26 } | |
27 | |
28 GLES2ClientImpl::GLES2ClientImpl(GLES2Delegate* delegate, | |
29 ScopedMessagePipeHandle gl) | |
30 : delegate_(delegate), | |
31 gl_(gl.Pass()) { | |
32 assert(g_gles2_initialized); | |
33 gl_.SetPeer(this); | |
34 } | |
35 | |
36 GLES2ClientImpl::~GLES2ClientImpl() { | |
37 gl_->Destroy(); | |
38 } | |
39 | |
40 void GLES2ClientImpl::Initialize() { | |
41 assert(!g_gles2_initialized); | |
42 gles2::Initialize(); | |
43 g_gles2_initialized = true; | |
44 } | |
45 | |
46 void GLES2ClientImpl::Terminate() { | |
47 assert(g_gles2_initialized); | |
48 gles2::Terminate(); | |
49 g_gles2_initialized = false; | |
50 } | |
51 | |
52 void GLES2ClientImpl::SwapBuffers() { | |
53 gles2::GetGLContext()->SwapBuffers(); | |
54 } | |
55 | |
56 void GLES2ClientImpl::DidCreateContext( | |
57 uint64_t encoded, uint32_t width, uint32_t height) { | |
58 // Ack, Hans! It's the giant hack. | |
59 // TODO(abarth): Replace this hack with something more disciplined. Most | |
60 // likley, we should receive a MojoHandle that we use to wire up the | |
61 // client side of an out-of-process command buffer. Given that we're | |
62 // still in-process, we just reinterpret_cast the value into a GL interface. | |
63 gpu::gles2::GLES2Interface* gl_interface = | |
64 reinterpret_cast<gpu::gles2::GLES2Interface*>( | |
65 static_cast<uintptr_t>(encoded)); | |
66 gles2::SetGLContext(gl_interface); | |
67 | |
68 delegate_->DidCreateContext(this, width, height); | |
69 } | |
70 | |
71 void GLES2ClientImpl::ContextLost() { | |
72 delegate_->ContextLost(this); | |
73 } | |
74 | |
75 } // mojo | |
OLD | NEW |