OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 "ppapi/cpp/dev/context_3d_dev.h" |
| 6 |
| 7 #include "ppapi/c/pp_completion_callback.h" |
| 8 #include "ppapi/c/dev/ppb_opengles_dev.h" |
| 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/cpp/instance.h" |
| 11 #include "ppapi/cpp/module_impl.h" |
| 12 |
| 13 namespace pp { |
| 14 |
| 15 namespace { |
| 16 |
| 17 template <> const char* interface_name<PPB_Context3D_Dev>() { |
| 18 return PPB_CONTEXT_3D_DEV_INTERFACE; |
| 19 } |
| 20 |
| 21 template <> const char* interface_name<PPB_OpenGLES2_Dev>() { |
| 22 return PPB_OPENGLES2_DEV_INTERFACE; |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 27 Context3D_Dev Context3D_Dev::FromResource(PP_Resource resource_id) { |
| 28 if (has_interface<PPB_Context3D_Dev>() && |
| 29 get_interface<PPB_Context3D_Dev>()->IsContext3D(resource_id)) |
| 30 return Context3D_Dev(resource_id); |
| 31 |
| 32 return Context3D_Dev(); |
| 33 } |
| 34 |
| 35 Context3D_Dev::Context3D_Dev(const Instance& instance, |
| 36 PP_Config3D_Dev config, |
| 37 const Context3D_Dev& share_context, |
| 38 const int32_t* attrib_list) { |
| 39 if (has_interface<PPB_Context3D_Dev>() && |
| 40 has_interface<PPB_OpenGLES2_Dev>()) { |
| 41 PassRefFromConstructor(get_interface<PPB_Context3D_Dev>()->Create( |
| 42 instance.pp_instance(), |
| 43 config, |
| 44 share_context.pp_resource(), |
| 45 attrib_list)); |
| 46 } |
| 47 } |
| 48 |
| 49 int32_t Context3D_Dev::SwapBuffers() const { |
| 50 if (!has_interface<PPB_Context3D_Dev>()) |
| 51 return PP_ERROR_NOINTERFACE; |
| 52 |
| 53 return get_interface<PPB_Context3D_Dev>()->SwapBuffers( |
| 54 pp_resource(), |
| 55 PP_BlockUntilComplete()); |
| 56 } |
| 57 |
| 58 } // namespace pp |
OLD | NEW |