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/common.h" | |
7 #include "ppapi/thunk/enter.h" | |
8 #include "ppapi/thunk/thunk.h" | |
9 #include "ppapi/thunk/ppb_surface_3d_api.h" | |
10 #include "ppapi/thunk/resource_creation_api.h" | |
11 | |
12 namespace ppapi { | |
13 namespace thunk { | |
14 | |
15 namespace { | |
16 | |
17 PP_Resource Create(PP_Instance instance, | |
18 PP_Config3D_Dev config, | |
19 const int32_t* attrib_list) { | |
20 EnterFunction<ResourceCreationAPI> enter(instance, true); | |
21 if (enter.failed()) | |
22 return 0; | |
23 return enter.functions()->CreateSurface3D(instance, config, attrib_list); | |
24 } | |
25 | |
26 PP_Bool IsSurface3D(PP_Resource resource) { | |
27 EnterResource<PPB_Surface3D_API> enter(resource, true); | |
28 return PP_FromBool(enter.succeeded()); | |
29 } | |
30 | |
31 int32_t SetAttrib(PP_Resource surface, int32_t attribute, int32_t value) { | |
32 EnterResource<PPB_Surface3D_API> enter(surface, true); | |
33 if (enter.failed()) | |
34 return PP_ERROR_BADRESOURCE; | |
35 return enter.object()->SetAttrib(attribute, value); | |
36 } | |
37 | |
38 int32_t GetAttrib(PP_Resource surface, | |
39 int32_t attribute, | |
40 int32_t* value) { | |
41 EnterResource<PPB_Surface3D_API> enter(surface, true); | |
42 if (enter.failed()) | |
43 return PP_ERROR_BADRESOURCE; | |
44 return enter.object()->GetAttrib(attribute, value); | |
45 } | |
46 | |
47 int32_t SwapBuffers(PP_Resource surface, | |
48 PP_CompletionCallback callback) { | |
49 EnterResource<PPB_Surface3D_API> enter(surface, true); | |
50 if (enter.failed()) | |
51 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); | |
52 int32_t result = enter.object()->SwapBuffers(callback); | |
53 return MayForceCallback(callback, result); | |
54 } | |
55 | |
56 const PPB_Surface3D_Dev g_ppb_surface_3d_thunk = { | |
57 &Create, | |
58 &IsSurface3D, | |
59 &SetAttrib, | |
60 &GetAttrib, | |
61 &SwapBuffers | |
62 }; | |
63 | |
64 } // namespace | |
65 | |
66 const PPB_Surface3D_Dev* GetPPB_Surface3D_Dev_Thunk() { | |
67 return &g_ppb_surface_3d_thunk; | |
68 } | |
69 | |
70 } // namespace thunk | |
71 } // namespace ppapi | |
OLD | NEW |