ash: Update app list layout:
[chromium-blink-merge.git] / ppapi / thunk / ppb_graphics_3d_trusted_thunk.cc
blob8933d12e2c10705640b1534e08ea3ac40fe2b481
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"
10 namespace ppapi {
11 namespace thunk {
13 namespace {
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;
20 return error_state;
23 PP_Resource CreateRaw(PP_Instance instance,
24 PP_Resource share_context,
25 const int32_t* attrib_list) {
26 EnterFunction<ResourceCreationAPI> enter(instance, true);
27 if (enter.failed())
28 return 0;
29 return enter.functions()->CreateGraphics3DRaw(
30 instance, share_context, attrib_list);
33 PP_Bool InitCommandBuffer(PP_Resource context) {
34 EnterGraphics3D enter(context, true);
35 if (enter.failed())
36 return PP_FALSE;
37 return enter.object()->InitCommandBuffer();
40 PP_Bool SetGetBuffer(PP_Resource context, int32_t transfer_buffer_id) {
41 EnterGraphics3D enter(context, true);
42 if (enter.failed())
43 return PP_FALSE;
44 return enter.object()->SetGetBuffer(transfer_buffer_id);
47 PP_Graphics3DTrustedState GetState(PP_Resource context) {
48 EnterGraphics3D enter(context, true);
49 if (enter.failed())
50 return GetErrorState();
51 return enter.object()->GetState();
54 int32_t CreateTransferBuffer(PP_Resource context, uint32_t size) {
55 EnterGraphics3D enter(context, true);
56 if (enter.failed())
57 return PP_FALSE;
58 return enter.object()->CreateTransferBuffer(size);
61 PP_Bool DestroyTransferBuffer(PP_Resource context, int32_t id) {
62 EnterGraphics3D enter(context, true);
63 if (enter.failed())
64 return PP_FALSE;
65 return enter.object()->DestroyTransferBuffer(id);
68 PP_Bool GetTransferBuffer(PP_Resource context,
69 int32_t id,
70 int* shm_handle,
71 uint32_t* shm_size) {
72 EnterGraphics3D enter(context, true);
73 if (enter.failed())
74 return PP_FALSE;
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);
80 if (enter.failed())
81 return PP_FALSE;
82 return enter.object()->Flush(put_offset);
85 PP_Graphics3DTrustedState FlushSync(PP_Resource context, int32_t put_offset) {
86 EnterGraphics3D enter(context, true);
87 if (enter.failed())
88 return GetErrorState();
89 return enter.object()->FlushSync(put_offset);
92 PP_Graphics3DTrustedState FlushSyncFast(PP_Resource context,
93 int32_t put_offset,
94 int32_t last_known_get) {
95 EnterGraphics3D enter(context, true);
96 if (enter.failed())
97 return GetErrorState();
98 return enter.object()->FlushSyncFast(put_offset, last_known_get);
101 const PPB_Graphics3DTrusted g_ppb_graphics_3d_trusted_thunk = {
102 &CreateRaw,
103 &InitCommandBuffer,
104 &SetGetBuffer,
105 &GetState,
106 &CreateTransferBuffer,
107 &DestroyTransferBuffer,
108 &GetTransferBuffer,
109 &Flush,
110 &FlushSync,
111 &FlushSyncFast,
114 } // namespace
116 const PPB_Graphics3DTrusted_1_0* GetPPB_Graphics3DTrusted_1_0_Thunk() {
117 return &g_ppb_graphics_3d_trusted_thunk;
120 } // namespace thunk
121 } // namespace ppapi