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/examples/pepper_container_app/graphics_3d_resource.h" | 5 #include "mojo/examples/pepper_container_app/graphics_3d_resource.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h" | 8 #include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h" |
9 #include "mojo/examples/pepper_container_app/plugin_instance.h" | 9 #include "mojo/examples/pepper_container_app/plugin_instance.h" |
10 #include "mojo/public/c/gles2/gles2.h" | 10 #include "mojo/public/c/gles2/gles2.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 return error_state; | 21 return error_state; |
22 } | 22 } |
23 | 23 |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 Graphics3DResource::Graphics3DResource(PP_Instance instance) | 26 Graphics3DResource::Graphics3DResource(PP_Instance instance) |
27 : Resource(ppapi::OBJECT_IS_IMPL, instance) { | 27 : Resource(ppapi::OBJECT_IS_IMPL, instance) { |
28 ScopedMessagePipeHandle pipe = MojoPpapiGlobals::Get()->CreateGLES2Context(); | 28 ScopedMessagePipeHandle pipe = MojoPpapiGlobals::Get()->CreateGLES2Context(); |
29 context_ = MojoGLES2CreateContext(pipe.release().value(), | 29 context_ = MojoGLES2CreateContext(pipe.release().value(), |
30 &ContextLostThunk, | 30 &ContextLostThunk, |
31 &DrawAnimationFrameThunk, | |
32 this); | 31 this); |
33 } | 32 } |
34 | 33 |
35 bool Graphics3DResource::IsBoundGraphics() const { | 34 bool Graphics3DResource::IsBoundGraphics() const { |
36 PluginInstance* plugin_instance = | 35 PluginInstance* plugin_instance = |
37 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); | 36 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); |
38 return plugin_instance && plugin_instance->IsBoundGraphics(pp_resource()); | 37 return plugin_instance && plugin_instance->IsBoundGraphics(pp_resource()); |
39 } | 38 } |
40 | 39 |
41 void Graphics3DResource::BindGraphics() { | 40 void Graphics3DResource::BindGraphics() { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 146 } |
148 | 147 |
149 Graphics3DResource::~Graphics3DResource() { | 148 Graphics3DResource::~Graphics3DResource() { |
150 MojoGLES2DestroyContext(context_); | 149 MojoGLES2DestroyContext(context_); |
151 } | 150 } |
152 | 151 |
153 void Graphics3DResource::ContextLostThunk(void* closure) { | 152 void Graphics3DResource::ContextLostThunk(void* closure) { |
154 static_cast<Graphics3DResource*>(closure)->ContextLost(); | 153 static_cast<Graphics3DResource*>(closure)->ContextLost(); |
155 } | 154 } |
156 | 155 |
157 void Graphics3DResource::DrawAnimationFrameThunk(void* closure) { | |
158 // TODO(yzshen): Use this notification to drive the SwapBuffers() callback. | |
159 } | |
160 | |
161 void Graphics3DResource::ContextLost() { | 156 void Graphics3DResource::ContextLost() { |
162 PluginInstance* plugin_instance = | 157 PluginInstance* plugin_instance = |
163 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); | 158 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); |
164 if (plugin_instance) | 159 if (plugin_instance) |
165 plugin_instance->Graphics3DContextLost(); | 160 plugin_instance->Graphics3DContextLost(); |
166 } | 161 } |
167 | 162 |
168 } // namespace examples | 163 } // namespace examples |
169 } // namespace mojo | 164 } // namespace mojo |
OLD | NEW |