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_context_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_Context3D_API> EnterContext3D; | |
16 | |
17 PP_Context3DTrustedState GetErrorState() { | |
18 PP_Context3DTrustedState error_state = { 0 }; | |
19 error_state.error = kGenericError; | |
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()->CreateContext3DRaw(instance, config, share_context, | |
31 attrib_list); | |
32 } | |
33 | |
34 PP_Bool Initialize(PP_Resource context, int32_t size) { | |
35 EnterContext3D enter(context, true); | |
36 if (enter.failed()) | |
37 return PP_FALSE; | |
38 return enter.object()->InitializeTrusted(size); | |
39 } | |
40 | |
41 PP_Bool GetRingBuffer(PP_Resource context, | |
42 int* shm_handle, | |
43 uint32_t* shm_size) { | |
44 EnterContext3D enter(context, true); | |
45 if (enter.failed()) | |
46 return PP_FALSE; | |
47 return enter.object()->GetRingBuffer(shm_handle, shm_size); | |
48 } | |
49 | |
50 PP_Context3DTrustedState GetState(PP_Resource context) { | |
51 EnterContext3D enter(context, true); | |
52 if (enter.failed()) | |
53 return GetErrorState(); | |
54 return enter.object()->GetState(); | |
55 } | |
56 | |
57 PP_Bool Flush(PP_Resource context, int32_t put_offset) { | |
58 EnterContext3D enter(context, true); | |
59 if (enter.failed()) | |
60 return PP_FALSE; | |
61 return enter.object()->Flush(put_offset); | |
62 } | |
63 | |
64 PP_Context3DTrustedState FlushSync(PP_Resource context, int32_t put_offset) { | |
65 EnterContext3D enter(context, true); | |
66 if (enter.failed()) | |
67 return GetErrorState(); | |
68 return enter.object()->FlushSync(put_offset); | |
69 } | |
70 | |
71 int32_t CreateTransferBuffer(PP_Resource context, uint32_t size) { | |
72 EnterContext3D enter(context, true); | |
73 if (enter.failed()) | |
74 return PP_FALSE; | |
75 return enter.object()->CreateTransferBuffer(size); | |
76 } | |
77 | |
78 PP_Bool DestroyTransferBuffer(PP_Resource context, int32_t id) { | |
79 EnterContext3D enter(context, true); | |
80 if (enter.failed()) | |
81 return PP_FALSE; | |
82 return enter.object()->DestroyTransferBuffer(id); | |
83 } | |
84 | |
85 PP_Bool GetTransferBuffer(PP_Resource context, | |
86 int32_t id, | |
87 int* shm_handle, | |
88 uint32_t* shm_size) { | |
89 EnterContext3D enter(context, true); | |
90 if (enter.failed()) | |
91 return PP_FALSE; | |
92 return enter.object()->GetTransferBuffer(id, shm_handle, shm_size); | |
93 } | |
94 | |
95 PP_Context3DTrustedState FlushSyncFast(PP_Resource context, | |
96 int32_t put_offset, | |
97 int32_t last_known_get) { | |
98 EnterContext3D 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_Context3DTrusted_Dev g_ppb_context_3d_trusted_thunk = { | |
105 &CreateRaw, | |
106 &Initialize, | |
107 &GetRingBuffer, | |
108 &GetState, | |
109 &Flush, | |
110 &FlushSync, | |
111 &CreateTransferBuffer, | |
112 &DestroyTransferBuffer, | |
113 &GetTransferBuffer, | |
114 &FlushSyncFast, | |
115 }; | |
116 | |
117 } // namespace | |
118 | |
119 const PPB_Context3DTrusted_Dev* GetPPB_Context3DTrusted_Thunk() { | |
120 return &g_ppb_context_3d_trusted_thunk; | |
121 } | |
122 | |
123 } // namespace thunk | |
124 } // namespace ppapi | |
OLD | NEW |