| 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" |
| 11 #include "mojo/public/cpp/environment/environment.h" |
| 11 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
| 12 | 13 |
| 13 namespace mojo { | 14 namespace mojo { |
| 14 namespace examples { | 15 namespace examples { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 gpu::CommandBuffer::State GetErrorState() { | 19 gpu::CommandBuffer::State GetErrorState() { |
| 19 gpu::CommandBuffer::State error_state; | 20 gpu::CommandBuffer::State error_state; |
| 20 error_state.error = gpu::error::kGenericError; | 21 error_state.error = gpu::error::kGenericError; |
| 21 return error_state; | 22 return error_state; |
| 22 } | 23 } |
| 23 | 24 |
| 24 } // namespace | 25 } // namespace |
| 25 | 26 |
| 26 Graphics3DResource::Graphics3DResource(PP_Instance instance) | 27 Graphics3DResource::Graphics3DResource(PP_Instance instance) |
| 27 : Resource(ppapi::OBJECT_IS_IMPL, instance) { | 28 : Resource(ppapi::OBJECT_IS_IMPL, instance) { |
| 28 ScopedMessagePipeHandle pipe = MojoPpapiGlobals::Get()->CreateGLES2Context(); | 29 ScopedMessagePipeHandle pipe = MojoPpapiGlobals::Get()->CreateGLES2Context(); |
| 29 context_ = MojoGLES2CreateContext(pipe.release().value(), | 30 context_ = MojoGLES2CreateContext(pipe.release().value(), |
| 30 &ContextLostThunk, | 31 &ContextLostThunk, |
| 31 this); | 32 this, |
| 33 Environment::GetDefaultAsyncWaiter()); |
| 32 } | 34 } |
| 33 | 35 |
| 34 bool Graphics3DResource::IsBoundGraphics() const { | 36 bool Graphics3DResource::IsBoundGraphics() const { |
| 35 PluginInstance* plugin_instance = | 37 PluginInstance* plugin_instance = |
| 36 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); | 38 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); |
| 37 return plugin_instance && plugin_instance->IsBoundGraphics(pp_resource()); | 39 return plugin_instance && plugin_instance->IsBoundGraphics(pp_resource()); |
| 38 } | 40 } |
| 39 | 41 |
| 40 void Graphics3DResource::BindGraphics() { | 42 void Graphics3DResource::BindGraphics() { |
| 41 MojoGLES2MakeCurrent(context_); | 43 MojoGLES2MakeCurrent(context_); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 157 |
| 156 void Graphics3DResource::ContextLost() { | 158 void Graphics3DResource::ContextLost() { |
| 157 PluginInstance* plugin_instance = | 159 PluginInstance* plugin_instance = |
| 158 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); | 160 MojoPpapiGlobals::Get()->GetInstance(pp_instance()); |
| 159 if (plugin_instance) | 161 if (plugin_instance) |
| 160 plugin_instance->Graphics3DContextLost(); | 162 plugin_instance->Graphics3DContextLost(); |
| 161 } | 163 } |
| 162 | 164 |
| 163 } // namespace examples | 165 } // namespace examples |
| 164 } // namespace mojo | 166 } // namespace mojo |
| OLD | NEW |