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