| 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/thunk/thunk.h" | |
| 6 #include "ppapi/thunk/enter.h" | |
| 7 #include "ppapi/thunk/ppb_graphics_3d_api.h" | |
| 8 #include "ppapi/thunk/resource_creation_api.h" | |
| 9 | |
| 10 namespace ppapi { | |
| 11 namespace thunk { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D; | |
| 16 | |
| 17 PP_Graphics3DTrustedState GetErrorState() { | |
| 18 PP_Graphics3DTrustedState error_state = { 0 }; | |
| 19 error_state.error = PPB_GRAPHICS3D_TRUSTED_ERROR_GENERICERROR; | |
| 20 return error_state; | |
| 21 } | |
| 22 | |
| 23 PP_Resource CreateRaw(PP_Instance instance, | |
| 24 PP_Config3D_Dev config, | |
| 25 PP_Resource share_context, | |
| 26 const int32_t* attrib_list) { | |
| 27 EnterFunction<ResourceCreationAPI> enter(instance, true); | |
| 28 if (enter.failed()) | |
| 29 return 0; | |
| 30 return enter.functions()->CreateGraphics3DRaw( | |
| 31 instance, config, share_context, attrib_list); | |
| 32 } | |
| 33 | |
| 34 PP_Bool InitCommandBuffer(PP_Resource context, int32_t size) { | |
| 35 EnterGraphics3D enter(context, true); | |
| 36 if (enter.failed()) | |
| 37 return PP_FALSE; | |
| 38 return enter.object()->InitCommandBuffer(size); | |
| 39 } | |
| 40 | |
| 41 PP_Bool GetRingBuffer(PP_Resource context, | |
| 42 int* shm_handle, | |
| 43 uint32_t* shm_size) { | |
| 44 EnterGraphics3D enter(context, true); | |
| 45 if (enter.failed()) | |
| 46 return PP_FALSE; | |
| 47 return enter.object()->GetRingBuffer(shm_handle, shm_size); | |
| 48 } | |
| 49 | |
| 50 PP_Graphics3DTrustedState GetState(PP_Resource context) { | |
| 51 EnterGraphics3D enter(context, true); | |
| 52 if (enter.failed()) | |
| 53 return GetErrorState(); | |
| 54 return enter.object()->GetState(); | |
| 55 } | |
| 56 | |
| 57 int32_t CreateTransferBuffer(PP_Resource context, uint32_t size) { | |
| 58 EnterGraphics3D enter(context, true); | |
| 59 if (enter.failed()) | |
| 60 return PP_FALSE; | |
| 61 return enter.object()->CreateTransferBuffer(size); | |
| 62 } | |
| 63 | |
| 64 PP_Bool DestroyTransferBuffer(PP_Resource context, int32_t id) { | |
| 65 EnterGraphics3D enter(context, true); | |
| 66 if (enter.failed()) | |
| 67 return PP_FALSE; | |
| 68 return enter.object()->DestroyTransferBuffer(id); | |
| 69 } | |
| 70 | |
| 71 PP_Bool GetTransferBuffer(PP_Resource context, | |
| 72 int32_t id, | |
| 73 int* shm_handle, | |
| 74 uint32_t* shm_size) { | |
| 75 EnterGraphics3D enter(context, true); | |
| 76 if (enter.failed()) | |
| 77 return PP_FALSE; | |
| 78 return enter.object()->GetTransferBuffer(id, shm_handle, shm_size); | |
| 79 } | |
| 80 | |
| 81 PP_Bool Flush(PP_Resource context, int32_t put_offset) { | |
| 82 EnterGraphics3D enter(context, true); | |
| 83 if (enter.failed()) | |
| 84 return PP_FALSE; | |
| 85 return enter.object()->Flush(put_offset); | |
| 86 } | |
| 87 | |
| 88 PP_Graphics3DTrustedState FlushSync(PP_Resource context, int32_t put_offset) { | |
| 89 EnterGraphics3D enter(context, true); | |
| 90 if (enter.failed()) | |
| 91 return GetErrorState(); | |
| 92 return enter.object()->FlushSync(put_offset); | |
| 93 } | |
| 94 | |
| 95 PP_Graphics3DTrustedState FlushSyncFast(PP_Resource context, | |
| 96 int32_t put_offset, | |
| 97 int32_t last_known_get) { | |
| 98 EnterGraphics3D enter(context, true); | |
| 99 if (enter.failed()) | |
| 100 return GetErrorState(); | |
| 101 return enter.object()->FlushSyncFast(put_offset, last_known_get); | |
| 102 } | |
| 103 | |
| 104 const PPB_Graphics3DTrusted_Dev g_ppb_graphics_3d_trusted_thunk = { | |
| 105 &CreateRaw, | |
| 106 &InitCommandBuffer, | |
| 107 &GetRingBuffer, | |
| 108 &GetState, | |
| 109 &CreateTransferBuffer, | |
| 110 &DestroyTransferBuffer, | |
| 111 &GetTransferBuffer, | |
| 112 &Flush, | |
| 113 &FlushSync, | |
| 114 &FlushSyncFast, | |
| 115 }; | |
| 116 | |
| 117 } // namespace | |
| 118 | |
| 119 const PPB_Graphics3DTrusted_Dev* GetPPB_Graphics3DTrusted_Thunk() { | |
| 120 return &g_ppb_graphics_3d_trusted_thunk; | |
| 121 } | |
| 122 | |
| 123 } // namespace thunk | |
| 124 } // namespace ppapi | |
| 125 | |
| OLD | NEW |