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
3 // found in the LICENSE file.
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"
15 typedef EnterResource
<PPB_Graphics3D_API
> EnterGraphics3D
;
17 PP_Graphics3DTrustedState
GetErrorState() {
18 PP_Graphics3DTrustedState error_state
= { 0 };
19 error_state
.error
= PPB_GRAPHICS3D_TRUSTED_ERROR_GENERICERROR
;
23 PP_Resource
CreateRaw(PP_Instance instance
,
24 PP_Resource share_context
,
25 const int32_t* attrib_list
) {
26 EnterResourceCreation
enter(instance
);
29 return enter
.functions()->CreateGraphics3DRaw(
30 instance
, share_context
, attrib_list
);
33 PP_Bool
InitCommandBuffer(PP_Resource context
) {
34 EnterGraphics3D
enter(context
, true);
37 return enter
.object()->InitCommandBuffer();
40 PP_Bool
SetGetBuffer(PP_Resource context
, int32_t transfer_buffer_id
) {
41 EnterGraphics3D
enter(context
, true);
44 return enter
.object()->SetGetBuffer(transfer_buffer_id
);
47 PP_Graphics3DTrustedState
GetState(PP_Resource context
) {
48 EnterGraphics3D
enter(context
, true);
50 return GetErrorState();
51 return enter
.object()->GetState();
54 int32_t CreateTransferBuffer(PP_Resource context
, uint32_t size
) {
55 EnterGraphics3D
enter(context
, true);
58 return enter
.object()->CreateTransferBuffer(size
);
61 PP_Bool
DestroyTransferBuffer(PP_Resource context
, int32_t id
) {
62 EnterGraphics3D
enter(context
, true);
65 return enter
.object()->DestroyTransferBuffer(id
);
68 PP_Bool
GetTransferBuffer(PP_Resource context
,
72 EnterGraphics3D
enter(context
, true);
75 return enter
.object()->GetTransferBuffer(id
, shm_handle
, shm_size
);
78 PP_Bool
Flush(PP_Resource context
, int32_t put_offset
) {
79 EnterGraphics3D
enter(context
, true);
82 return enter
.object()->Flush(put_offset
);
85 PP_Graphics3DTrustedState
FlushSync(PP_Resource context
, int32_t put_offset
) {
86 EnterGraphics3D
enter(context
, true);
88 return GetErrorState();
89 return enter
.object()->FlushSync(put_offset
);
92 PP_Graphics3DTrustedState
FlushSyncFast(PP_Resource context
,
94 int32_t last_known_get
) {
95 EnterGraphics3D
enter(context
, true);
97 return GetErrorState();
98 return enter
.object()->FlushSyncFast(put_offset
, last_known_get
);
101 const PPB_Graphics3DTrusted g_ppb_graphics_3d_trusted_thunk
= {
106 &CreateTransferBuffer
,
107 &DestroyTransferBuffer
,
116 const PPB_Graphics3DTrusted_1_0
* GetPPB_Graphics3DTrusted_1_0_Thunk() {
117 return &g_ppb_graphics_3d_trusted_thunk
;