OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/gles2/gles2_support_impl.h" | 5 #include "mojo/gles2/gles2_support_impl.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "gpu/command_buffer/client/gles2_interface.h" | 8 #include "gpu/command_buffer/client/gles2_interface.h" |
9 #include "mojo/gles2/gles2_context.h" | 9 #include "mojo/gles2/gles2_context.h" |
10 #include "mojo/public/gles2/gles2_interface.h" | 10 #include "mojo/public/gles2/gles2_interface.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 void GLES2SupportImpl::Terminate() { | 56 void GLES2SupportImpl::Terminate() { |
57 DCHECK(async_waiter_); | 57 DCHECK(async_waiter_); |
58 async_waiter_ = NULL; | 58 async_waiter_ = NULL; |
59 } | 59 } |
60 | 60 |
61 MojoGLES2Context GLES2SupportImpl::CreateContext( | 61 MojoGLES2Context GLES2SupportImpl::CreateContext( |
62 MessagePipeHandle handle, | 62 MessagePipeHandle handle, |
63 MojoGLES2ContextLost lost_callback, | 63 MojoGLES2ContextLost lost_callback, |
64 MojoGLES2DrawAnimationFrame animation_callback, | |
65 void* closure) { | 64 void* closure) { |
66 ScopedMessagePipeHandle scoped_handle(handle); | 65 ScopedMessagePipeHandle scoped_handle(handle); |
67 scoped_ptr<GLES2Context> client(new GLES2Context(async_waiter_, | 66 scoped_ptr<GLES2Context> client(new GLES2Context(async_waiter_, |
68 scoped_handle.Pass(), | 67 scoped_handle.Pass(), |
69 lost_callback, | 68 lost_callback, |
70 animation_callback, | |
71 closure)); | 69 closure)); |
72 if (!client->Initialize()) | 70 if (!client->Initialize()) |
73 client.reset(); | 71 client.reset(); |
74 return client.release(); | 72 return client.release(); |
75 } | 73 } |
76 | 74 |
77 void GLES2SupportImpl::DestroyContext(MojoGLES2Context context) { | 75 void GLES2SupportImpl::DestroyContext(MojoGLES2Context context) { |
78 delete static_cast<GLES2Context*>(context); | 76 delete static_cast<GLES2Context*>(context); |
79 } | 77 } |
80 | 78 |
81 void GLES2SupportImpl::MakeCurrent(MojoGLES2Context context) { | 79 void GLES2SupportImpl::MakeCurrent(MojoGLES2Context context) { |
82 gpu::gles2::GLES2Interface* interface = NULL; | 80 gpu::gles2::GLES2Interface* interface = NULL; |
83 if (context) { | 81 if (context) { |
84 GLES2Context* client = static_cast<GLES2Context*>(context); | 82 GLES2Context* client = static_cast<GLES2Context*>(context); |
85 interface = client->interface(); | 83 interface = client->interface(); |
86 DCHECK(interface); | 84 DCHECK(interface); |
87 } | 85 } |
88 g_gles2_interface.Get().set_gpu_interface(interface); | 86 g_gles2_interface.Get().set_gpu_interface(interface); |
89 } | 87 } |
90 | 88 |
91 void GLES2SupportImpl::SwapBuffers() { | 89 void GLES2SupportImpl::SwapBuffers() { |
92 g_gles2_interface.Get().gpu_interface()->SwapBuffers(); | 90 g_gles2_interface.Get().gpu_interface()->SwapBuffers(); |
93 } | 91 } |
94 | 92 |
95 void GLES2SupportImpl::RequestAnimationFrames(MojoGLES2Context context) { | |
96 static_cast<GLES2Context*>(context)->RequestAnimationFrames(); | |
97 } | |
98 | |
99 void GLES2SupportImpl::CancelAnimationFrames(MojoGLES2Context context) { | |
100 static_cast<GLES2Context*>(context)->CancelAnimationFrames(); | |
101 } | |
102 | |
103 void* GLES2SupportImpl::GetGLES2Interface(MojoGLES2Context context) { | 93 void* GLES2SupportImpl::GetGLES2Interface(MojoGLES2Context context) { |
104 return static_cast<GLES2Context*>(context)->interface(); | 94 return static_cast<GLES2Context*>(context)->interface(); |
105 } | 95 } |
106 | 96 |
107 void* GLES2SupportImpl::GetContextSupport(MojoGLES2Context context) { | 97 void* GLES2SupportImpl::GetContextSupport(MojoGLES2Context context) { |
108 return static_cast<GLES2Context*>(context)->context_support(); | 98 return static_cast<GLES2Context*>(context)->context_support(); |
109 } | 99 } |
110 | 100 |
111 GLES2Interface* GLES2SupportImpl::GetGLES2InterfaceForCurrentContext() { | 101 GLES2Interface* GLES2SupportImpl::GetGLES2InterfaceForCurrentContext() { |
112 return &g_gles2_interface.Get(); | 102 return &g_gles2_interface.Get(); |
113 } | 103 } |
114 | 104 |
115 } // namespace gles2 | 105 } // namespace gles2 |
116 } // namespace mojo | 106 } // namespace mojo |
OLD | NEW |