| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/dev/graphics_3d_dev.h" | 5 #include "ppapi/cpp/dev/graphics_3d_dev.h" |
| 6 | 6 |
| 7 #include "ppapi/cpp/common.h" |
| 7 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
| 8 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
| 9 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| 10 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
| 11 | 12 |
| 12 extern "C" { | 13 extern "C" { |
| 13 const PPB_OpenGLES_Dev* pepper_opengl_interface = NULL; | 14 const PPB_OpenGLES_Dev* pepper_opengl_interface = NULL; |
| 14 } | 15 } |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 DeviceFuncs<PPB_Graphics3D_Dev> graphics_3d_f(PPB_GRAPHICS_3D_DEV_INTERFACE); | 19 DeviceFuncs<PPB_Graphics3D_Dev> graphics_3d_f(PPB_GRAPHICS_3D_DEV_INTERFACE); |
| 19 DeviceFuncs<PPB_OpenGLES_Dev> opengles_f(PPB_OPENGLES_DEV_INTERFACE); | 20 DeviceFuncs<PPB_OpenGLES_Dev> opengles_f(PPB_OPENGLES_DEV_INTERFACE); |
| 20 | 21 |
| 21 inline void InitializeOpenGLCInterface() { | 22 inline void InitializeOpenGLCInterface() { |
| 22 if (!pepper_opengl_interface) | 23 if (!pepper_opengl_interface) |
| 23 pepper_opengl_interface = &(*opengles_f); | 24 pepper_opengl_interface = &(*opengles_f); |
| 24 } | 25 } |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 28 namespace pp { | 29 namespace pp { |
| 29 | 30 |
| 30 // static | 31 // static |
| 31 bool Graphics3D_Dev::GetConfigs(int32_t *configs, int32_t config_size, | 32 bool Graphics3D_Dev::GetConfigs(int32_t *configs, int32_t config_size, |
| 32 int32_t *num_config) { | 33 int32_t *num_config) { |
| 33 if (graphics_3d_f) | 34 if (graphics_3d_f) { |
| 34 return graphics_3d_f->GetConfigs(configs, config_size, num_config); | 35 return PPBoolToBool(graphics_3d_f->GetConfigs(configs, |
| 36 config_size, |
| 37 num_config)); |
| 38 } |
| 35 return false; | 39 return false; |
| 36 } | 40 } |
| 37 | 41 |
| 38 // static | 42 // static |
| 39 bool Graphics3D_Dev::ChooseConfig(const int32_t *attrib_list, int32_t *configs, | 43 bool Graphics3D_Dev::ChooseConfig(const int32_t *attrib_list, int32_t *configs, |
| 40 int32_t config_size, int32_t *num_config) { | 44 int32_t config_size, int32_t *num_config) { |
| 41 if (graphics_3d_f) | 45 if (graphics_3d_f) { |
| 42 return graphics_3d_f->ChooseConfig(attrib_list, configs, config_size, | 46 return PPBoolToBool(graphics_3d_f->ChooseConfig(attrib_list, |
| 43 num_config); | 47 configs, |
| 48 config_size, |
| 49 num_config)); |
| 50 } |
| 44 return false; | 51 return false; |
| 45 } | 52 } |
| 46 | 53 |
| 47 // static | 54 // static |
| 48 bool Graphics3D_Dev::GetConfigAttrib(int32_t config, int32_t attribute, | 55 bool Graphics3D_Dev::GetConfigAttrib(int32_t config, int32_t attribute, |
| 49 int32_t *value) { | 56 int32_t *value) { |
| 50 if (graphics_3d_f) | 57 if (graphics_3d_f) { |
| 51 return graphics_3d_f->GetConfigAttrib(config, attribute, value); | 58 return PPBoolToBool(graphics_3d_f->GetConfigAttrib(config, |
| 59 attribute, |
| 60 value)); |
| 61 } |
| 52 return false; | 62 return false; |
| 53 } | 63 } |
| 54 | 64 |
| 55 // static | 65 // static |
| 56 const char* Graphics3D_Dev::QueryString(int32_t name) { | 66 const char* Graphics3D_Dev::QueryString(int32_t name) { |
| 57 if (graphics_3d_f) | 67 if (graphics_3d_f) |
| 58 return graphics_3d_f->QueryString(name); | 68 return graphics_3d_f->QueryString(name); |
| 59 return NULL; | 69 return NULL; |
| 60 } | 70 } |
| 61 | 71 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 bool Graphics3D_Dev::MakeCurrent() const { | 117 bool Graphics3D_Dev::MakeCurrent() const { |
| 108 InitializeOpenGLCInterface(); | 118 InitializeOpenGLCInterface(); |
| 109 return graphics_3d_f && graphics_3d_f->MakeCurent(pp_resource()); | 119 return graphics_3d_f && graphics_3d_f->MakeCurent(pp_resource()); |
| 110 } | 120 } |
| 111 | 121 |
| 112 bool Graphics3D_Dev::SwapBuffers() const { | 122 bool Graphics3D_Dev::SwapBuffers() const { |
| 113 return graphics_3d_f && graphics_3d_f->SwapBuffers(pp_resource()); | 123 return graphics_3d_f && graphics_3d_f->SwapBuffers(pp_resource()); |
| 114 } | 124 } |
| 115 | 125 |
| 116 } // namespace pp | 126 } // namespace pp |
| 117 | |
| OLD | NEW |