OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/thunk/thunk.h" |
| 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_context_3d_api.h" |
| 9 #include "ppapi/thunk/resource_creation_api.h" |
| 10 |
| 11 namespace ppapi { |
| 12 namespace thunk { |
| 13 |
| 14 namespace { |
| 15 |
| 16 typedef EnterResource<PPB_Context3D_API> EnterContext3D; |
| 17 |
| 18 PP_Resource Create(PP_Instance instance, |
| 19 PP_Config3D_Dev config, |
| 20 PP_Resource share_context, |
| 21 const int32_t* attrib_list) { |
| 22 EnterFunction<ResourceCreationAPI> enter(instance, true); |
| 23 if (enter.failed()) |
| 24 return 0; |
| 25 return enter.functions()->CreateContext3D(instance, config, share_context, |
| 26 attrib_list); |
| 27 } |
| 28 |
| 29 PP_Bool IsContext3D(PP_Resource resource) { |
| 30 EnterContext3D enter(resource, false); |
| 31 return PP_FromBool(enter.succeeded()); |
| 32 } |
| 33 |
| 34 int32_t GetAttrib(PP_Resource context, int32_t attribute, int32_t* value) { |
| 35 EnterContext3D enter(context, true); |
| 36 if (enter.failed()) |
| 37 return PP_ERROR_BADRESOURCE; |
| 38 return enter.object()->GetAttrib(attribute, value); |
| 39 } |
| 40 |
| 41 int32_t BindSurfaces(PP_Resource context, PP_Resource draw, PP_Resource read) { |
| 42 EnterContext3D enter(context, true); |
| 43 if (enter.failed()) |
| 44 return PP_ERROR_BADRESOURCE; |
| 45 return enter.object()->BindSurfaces(draw, read); |
| 46 } |
| 47 |
| 48 int32_t GetBoundSurfaces(PP_Resource context, |
| 49 PP_Resource* draw, |
| 50 PP_Resource* read) { |
| 51 EnterContext3D enter(context, true); |
| 52 if (enter.failed()) |
| 53 return PP_ERROR_BADRESOURCE; |
| 54 return enter.object()->GetBoundSurfaces(draw, read); |
| 55 } |
| 56 |
| 57 const PPB_Context3D_Dev g_ppb_context_3d_thunk = { |
| 58 &Create, |
| 59 &IsContext3D, |
| 60 &GetAttrib, |
| 61 &BindSurfaces, |
| 62 &GetBoundSurfaces |
| 63 }; |
| 64 |
| 65 } // namespace |
| 66 |
| 67 const PPB_Context3D_Dev* GetPPB_Context3D_Thunk() { |
| 68 return &g_ppb_context_3d_thunk; |
| 69 } |
| 70 |
| 71 } // namespace thunk |
| 72 } // namespace ppapi |
OLD | NEW |