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 "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "webkit/plugins/ppapi/common.h" | 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 11 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 12 |
| 13 using ppapi::thunk::PPB_Graphics3D_API; |
11 | 14 |
12 namespace webkit { | 15 namespace webkit { |
13 namespace ppapi { | 16 namespace ppapi { |
14 | 17 |
15 namespace { | |
16 | |
17 int32_t GetConfigs(PP_Config3D_Dev* configs, | |
18 int32_t config_size, | |
19 int32_t* num_config) { | |
20 // TODO(alokp): Implement me. | |
21 return PP_ERROR_FAILED; | |
22 } | |
23 | |
24 int32_t GetConfigAttribs(PP_Config3D_Dev config, int32_t* attrib_list) { | |
25 // TODO(alokp): Implement me. | |
26 return PP_ERROR_FAILED; | |
27 } | |
28 | |
29 PP_Var GetString(int32_t name) { | |
30 // TODO(alokp): Implement me. | |
31 return PP_MakeUndefined(); | |
32 } | |
33 | |
34 PP_Resource Create(PP_Instance instance_id, | |
35 PP_Config3D_Dev config, | |
36 PP_Resource share_context, | |
37 const int32_t* attrib_list) { | |
38 // TODO(alokp): Support shared context. | |
39 DCHECK_EQ(0, share_context); | |
40 if (share_context != 0) | |
41 return 0; | |
42 | |
43 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | |
44 if (!instance) | |
45 return 0; | |
46 | |
47 scoped_refptr<PPB_Graphics3D_Impl> context( | |
48 new PPB_Graphics3D_Impl(instance)); | |
49 if (!context->Init(config, share_context, attrib_list)) | |
50 return 0; | |
51 | |
52 return context->GetReference(); | |
53 } | |
54 | |
55 PP_Bool IsGraphics3D(PP_Resource resource) { | |
56 return BoolToPPBool(!!Resource::GetAs<PPB_Graphics3D_Impl>(resource)); | |
57 } | |
58 | |
59 int32_t GetAttribs(PP_Resource context, int32_t* attrib_list) { | |
60 // TODO(alokp): Implement me. | |
61 return 0; | |
62 } | |
63 | |
64 int32_t SetAttribs(PP_Resource context, int32_t* attrib_list) { | |
65 // TODO(alokp): Implement me. | |
66 return 0; | |
67 } | |
68 | |
69 int32_t SwapBuffers(PP_Resource context, PP_CompletionCallback callback) { | |
70 // TODO(alokp): Implement me. | |
71 return 0; | |
72 } | |
73 | |
74 const PPB_Graphics3D_Dev ppb_graphics3d = { | |
75 &GetConfigs, | |
76 &GetConfigAttribs, | |
77 &GetString, | |
78 &Create, | |
79 &IsGraphics3D, | |
80 &GetAttribs, | |
81 &SetAttribs, | |
82 &SwapBuffers | |
83 }; | |
84 | |
85 } // namespace | |
86 | |
87 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginInstance* instance) | 18 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginInstance* instance) |
88 : Resource(instance) { | 19 : Resource(instance) { |
89 } | 20 } |
90 | 21 |
91 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { | 22 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { |
92 } | 23 } |
93 | 24 |
94 const PPB_Graphics3D_Dev* PPB_Graphics3D_Impl::GetInterface() { | 25 // static |
95 return &ppb_graphics3d; | 26 PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance pp_instance, |
| 27 PP_Config3D_Dev config, |
| 28 PP_Resource share_context, |
| 29 const int32_t* attrib_list) { |
| 30 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); |
| 31 if (!instance) |
| 32 return 0; |
| 33 |
| 34 scoped_refptr<PPB_Graphics3D_Impl> t(new PPB_Graphics3D_Impl(instance)); |
| 35 if (!t->Init(config, share_context, attrib_list)) |
| 36 return 0; |
| 37 return t->GetReference(); |
96 } | 38 } |
97 | 39 |
98 PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::AsPPB_Graphics3D_Impl() { | 40 PPB_Graphics3D_API* PPB_Graphics3D_Impl::AsPPB_Graphics3D_API() { |
99 return this; | 41 return this; |
100 } | 42 } |
101 | 43 |
| 44 int32_t PPB_Graphics3D_Impl::GetAttribs(int32_t* attrib_list) { |
| 45 // TODO(alokp): Implement me. |
| 46 return PP_ERROR_FAILED; |
| 47 } |
| 48 |
| 49 int32_t PPB_Graphics3D_Impl::SetAttribs(int32_t* attrib_list) { |
| 50 // TODO(alokp): Implement me. |
| 51 return PP_ERROR_FAILED; |
| 52 } |
| 53 |
| 54 int32_t PPB_Graphics3D_Impl::SwapBuffers(PP_CompletionCallback callback) { |
| 55 // TODO(alokp): Implement me. |
| 56 return PP_ERROR_FAILED; |
| 57 } |
| 58 |
102 bool PPB_Graphics3D_Impl::Init(PP_Config3D_Dev config, | 59 bool PPB_Graphics3D_Impl::Init(PP_Config3D_Dev config, |
103 PP_Resource share_context, | 60 PP_Resource share_context, |
104 const int32_t* attrib_list) { | 61 const int32_t* attrib_list) { |
105 // TODO(alokp): Implement me. | 62 // TODO(alokp): Implement me. |
106 return false; | 63 return false; |
107 } | 64 } |
108 | 65 |
109 } // namespace ppapi | 66 } // namespace ppapi |
110 } // namespace webkit | 67 } // namespace webkit |
111 | 68 |
OLD | NEW |