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