| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/cpp/graphics_3d.h" | 5 #include "ppapi/cpp/graphics_3d.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/cpp/completion_callback.h" | 8 #include "ppapi/cpp/completion_callback.h" |
| 9 #include "ppapi/cpp/instance.h" | 9 #include "ppapi/cpp/instance.h" |
| 10 #include "ppapi/cpp/module_impl.h" | 10 #include "ppapi/cpp/module_impl.h" |
| 11 #include "ppapi/cpp/var.h" | 11 #include "ppapi/cpp/var.h" |
| 12 | 12 |
| 13 namespace pp { | 13 namespace pp { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 template <> const char* interface_name<PPB_Graphics3D>() { | 17 template <> const char* interface_name<PPB_Graphics3D>() { |
| 18 return PPB_GRAPHICS_3D_INTERFACE; | 18 return PPB_GRAPHICS_3D_INTERFACE; |
| 19 } | 19 } |
| 20 | 20 |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 Graphics3D::Graphics3D() { | 23 Graphics3D::Graphics3D() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 Graphics3D::Graphics3D(const Instance* instance, | 26 Graphics3D::Graphics3D(const Instance* instance, |
| 27 const int32_t* attrib_list) { | 27 const int32_t attrib_list[]) { |
| 28 if (has_interface<PPB_Graphics3D>()) { | 28 if (has_interface<PPB_Graphics3D>()) { |
| 29 PassRefFromConstructor(get_interface<PPB_Graphics3D>()->Create( | 29 PassRefFromConstructor(get_interface<PPB_Graphics3D>()->Create( |
| 30 instance->pp_instance(), 0, attrib_list)); | 30 instance->pp_instance(), 0, attrib_list)); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 Graphics3D::Graphics3D(const Instance* instance, | 34 Graphics3D::Graphics3D(const Instance* instance, |
| 35 const Graphics3D& share_context, | 35 const Graphics3D& share_context, |
| 36 const int32_t* attrib_list) { | 36 const int32_t attrib_list[]) { |
| 37 if (has_interface<PPB_Graphics3D>()) { | 37 if (has_interface<PPB_Graphics3D>()) { |
| 38 PassRefFromConstructor(get_interface<PPB_Graphics3D>()->Create( | 38 PassRefFromConstructor(get_interface<PPB_Graphics3D>()->Create( |
| 39 instance->pp_instance(), | 39 instance->pp_instance(), |
| 40 share_context.pp_resource(), | 40 share_context.pp_resource(), |
| 41 attrib_list)); | 41 attrib_list)); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 Graphics3D::~Graphics3D() { | 45 Graphics3D::~Graphics3D() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 int32_t Graphics3D::GetAttribs(int32_t* attrib_list) const { | 48 int32_t Graphics3D::GetAttribs(int32_t attrib_list[]) const { |
| 49 if (!has_interface<PPB_Graphics3D>()) | 49 if (!has_interface<PPB_Graphics3D>()) |
| 50 return PP_ERROR_NOINTERFACE; | 50 return PP_ERROR_NOINTERFACE; |
| 51 | 51 |
| 52 return get_interface<PPB_Graphics3D>()->GetAttribs( | 52 return get_interface<PPB_Graphics3D>()->GetAttribs( |
| 53 pp_resource(), | 53 pp_resource(), |
| 54 attrib_list); | 54 attrib_list); |
| 55 } | 55 } |
| 56 | 56 |
| 57 int32_t Graphics3D::SetAttribs(int32_t* attrib_list) { | 57 int32_t Graphics3D::SetAttribs(const int32_t attrib_list[]) { |
| 58 if (!has_interface<PPB_Graphics3D>()) | 58 if (!has_interface<PPB_Graphics3D>()) |
| 59 return PP_ERROR_NOINTERFACE; | 59 return PP_ERROR_NOINTERFACE; |
| 60 | 60 |
| 61 return get_interface<PPB_Graphics3D>()->SetAttribs( | 61 return get_interface<PPB_Graphics3D>()->SetAttribs( |
| 62 pp_resource(), | 62 pp_resource(), |
| 63 attrib_list); | 63 attrib_list); |
| 64 } | 64 } |
| 65 | 65 |
| 66 int32_t Graphics3D::ResizeBuffers(int32_t width, int32_t height) { | 66 int32_t Graphics3D::ResizeBuffers(int32_t width, int32_t height) { |
| 67 if (!has_interface<PPB_Graphics3D>()) | 67 if (!has_interface<PPB_Graphics3D>()) |
| 68 return PP_ERROR_NOINTERFACE; | 68 return PP_ERROR_NOINTERFACE; |
| 69 | 69 |
| 70 return get_interface<PPB_Graphics3D>()->ResizeBuffers( | 70 return get_interface<PPB_Graphics3D>()->ResizeBuffers( |
| 71 pp_resource(), width, height); | 71 pp_resource(), width, height); |
| 72 } | 72 } |
| 73 | 73 |
| 74 int32_t Graphics3D::SwapBuffers(const CompletionCallback& cc) { | 74 int32_t Graphics3D::SwapBuffers(const CompletionCallback& cc) { |
| 75 if (!has_interface<PPB_Graphics3D>()) | 75 if (!has_interface<PPB_Graphics3D>()) |
| 76 return PP_ERROR_NOINTERFACE; | 76 return PP_ERROR_NOINTERFACE; |
| 77 | 77 |
| 78 return get_interface<PPB_Graphics3D>()->SwapBuffers( | 78 return get_interface<PPB_Graphics3D>()->SwapBuffers( |
| 79 pp_resource(), | 79 pp_resource(), |
| 80 cc.pp_completion_callback()); | 80 cc.pp_completion_callback()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace pp | 83 } // namespace pp |
| 84 | 84 |
| OLD | NEW |