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/c/pp_completion_callback.h" | 5 #include "ppapi/c/pp_completion_callback.h" |
6 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
7 #include "ppapi/thunk/common.h" | 7 #include "ppapi/thunk/common.h" |
8 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
9 #include "ppapi/thunk/thunk.h" | 9 #include "ppapi/thunk/thunk.h" |
10 #include "ppapi/thunk/ppb_graphics_3d_api.h" | 10 #include "ppapi/thunk/ppb_graphics_3d_api.h" |
11 #include "ppapi/thunk/resource_creation_api.h" | 11 #include "ppapi/thunk/resource_creation_api.h" |
12 | 12 |
13 namespace ppapi { | 13 namespace ppapi { |
14 namespace thunk { | 14 namespace thunk { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D; | 18 typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D; |
19 | 19 |
| 20 int32_t GetAttribMaxValue(PP_Resource instance, |
| 21 int32_t attribute, |
| 22 int32_t* value) { |
| 23 // TODO(alokp): Implement me. |
| 24 return PP_ERROR_FAILED; |
| 25 } |
| 26 |
20 PP_Resource Create(PP_Instance instance, | 27 PP_Resource Create(PP_Instance instance, |
21 PP_Resource share_context, | 28 PP_Resource share_context, |
22 const int32_t* attrib_list) { | 29 const int32_t* attrib_list) { |
23 EnterFunction<ResourceCreationAPI> enter(instance, true); | 30 EnterFunction<ResourceCreationAPI> enter(instance, true); |
24 if (enter.failed()) | 31 if (enter.failed()) |
25 return 0; | 32 return 0; |
26 return enter.functions()->CreateGraphics3D( | 33 return enter.functions()->CreateGraphics3D( |
27 instance, share_context, attrib_list); | 34 instance, share_context, attrib_list); |
28 } | 35 } |
29 | 36 |
30 PP_Bool IsGraphics3D(PP_Resource resource) { | 37 PP_Bool IsGraphics3D(PP_Resource resource) { |
31 EnterGraphics3D enter(resource, false); | 38 EnterGraphics3D enter(resource, false); |
32 return PP_FromBool(enter.succeeded()); | 39 return PP_FromBool(enter.succeeded()); |
33 } | 40 } |
34 | 41 |
35 int32_t GetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { | 42 int32_t GetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { |
36 EnterGraphics3D enter(graphics_3d, true); | 43 EnterGraphics3D enter(graphics_3d, true); |
37 if (enter.failed()) | 44 if (enter.failed()) |
38 return PP_ERROR_BADRESOURCE; | 45 return PP_ERROR_BADRESOURCE; |
39 return enter.object()->GetAttribs(attrib_list); | 46 return enter.object()->GetAttribs(attrib_list); |
40 } | 47 } |
41 | 48 |
42 int32_t SetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { | 49 int32_t SetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { |
43 EnterGraphics3D enter(graphics_3d, true); | 50 EnterGraphics3D enter(graphics_3d, true); |
44 if (enter.failed()) | 51 if (enter.failed()) |
45 return PP_ERROR_BADRESOURCE; | 52 return PP_ERROR_BADRESOURCE; |
46 return enter.object()->SetAttribs(attrib_list); | 53 return enter.object()->SetAttribs(attrib_list); |
47 } | 54 } |
48 | 55 |
| 56 int32_t GetError(PP_Resource graphics_3d) { |
| 57 EnterGraphics3D enter(graphics_3d, true); |
| 58 if (enter.failed()) |
| 59 return PP_ERROR_BADRESOURCE; |
| 60 |
| 61 return enter.object()->GetError(); |
| 62 } |
| 63 |
49 int32_t ResizeBuffers(PP_Resource graphics_3d, int32_t width, int32_t height) { | 64 int32_t ResizeBuffers(PP_Resource graphics_3d, int32_t width, int32_t height) { |
50 EnterGraphics3D enter(graphics_3d, true); | 65 EnterGraphics3D enter(graphics_3d, true); |
51 if (enter.failed()) | 66 if (enter.failed()) |
52 return PP_ERROR_BADRESOURCE; | 67 return PP_ERROR_BADRESOURCE; |
53 return enter.object()->ResizeBuffers(width, height); | 68 return enter.object()->ResizeBuffers(width, height); |
54 } | 69 } |
55 | 70 |
56 int32_t SwapBuffers(PP_Resource graphics_3d, PP_CompletionCallback callback) { | 71 int32_t SwapBuffers(PP_Resource graphics_3d, PP_CompletionCallback callback) { |
57 EnterGraphics3D enter(graphics_3d, true); | 72 EnterGraphics3D enter(graphics_3d, true); |
58 if (enter.failed()) | 73 if (enter.failed()) |
59 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); | 74 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
60 int32_t result = enter.object()->SwapBuffers(callback); | 75 int32_t result = enter.object()->SwapBuffers(callback); |
61 return MayForceCallback(callback, result); | 76 return MayForceCallback(callback, result); |
62 } | 77 } |
63 | 78 |
64 const PPB_Graphics3D_Dev g_ppb_graphics_3d_thunk = { | 79 const PPB_Graphics3D_Dev g_ppb_graphics_3d_thunk = { |
| 80 &GetAttribMaxValue, |
65 &Create, | 81 &Create, |
66 &IsGraphics3D, | 82 &IsGraphics3D, |
67 &GetAttribs, | 83 &GetAttribs, |
68 &SetAttribs, | 84 &SetAttribs, |
| 85 &GetError, |
69 &ResizeBuffers, | 86 &ResizeBuffers, |
70 &SwapBuffers | 87 &SwapBuffers |
71 }; | 88 }; |
72 | 89 |
73 } // namespace | 90 } // namespace |
74 | 91 |
75 const PPB_Graphics3D_Dev* GetPPB_Graphics3D_Thunk() { | 92 const PPB_Graphics3D_Dev* GetPPB_Graphics3D_Thunk() { |
76 return &g_ppb_graphics_3d_thunk; | 93 return &g_ppb_graphics_3d_thunk; |
77 } | 94 } |
78 | 95 |
79 } // namespace thunk | 96 } // namespace thunk |
80 } // namespace ppapi | 97 } // namespace ppapi |
OLD | NEW |