• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 // From ppb_graphics_3d.idl modified Thu Oct 31 12:30:06 2013.
6 
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_graphics_3d.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppapi_thunk_export.h"
13 #include "ppapi/thunk/ppb_graphics_3d_api.h"
14 
15 namespace ppapi {
16 namespace thunk {
17 
18 namespace {
19 
GetAttribMaxValue(PP_Resource instance,int32_t attribute,int32_t * value)20 int32_t GetAttribMaxValue(PP_Resource instance,
21                           int32_t attribute,
22                           int32_t* value) {
23   VLOG(4) << "PPB_Graphics3D::GetAttribMaxValue()";
24   EnterResource<PPB_Graphics3D_API> enter(instance, true);
25   if (enter.failed())
26     return enter.retval();
27   return enter.object()->GetAttribMaxValue(attribute, value);
28 }
29 
Create(PP_Instance instance,PP_Resource share_context,const int32_t attrib_list[])30 PP_Resource Create(PP_Instance instance,
31                    PP_Resource share_context,
32                    const int32_t attrib_list[]) {
33   VLOG(4) << "PPB_Graphics3D::Create()";
34   EnterResourceCreation enter(instance);
35   if (enter.failed())
36     return 0;
37   return enter.functions()->CreateGraphics3D(instance,
38                                              share_context,
39                                              attrib_list);
40 }
41 
IsGraphics3D(PP_Resource resource)42 PP_Bool IsGraphics3D(PP_Resource resource) {
43   VLOG(4) << "PPB_Graphics3D::IsGraphics3D()";
44   EnterResource<PPB_Graphics3D_API> enter(resource, false);
45   return PP_FromBool(enter.succeeded());
46 }
47 
GetAttribs(PP_Resource context,int32_t attrib_list[])48 int32_t GetAttribs(PP_Resource context, int32_t attrib_list[]) {
49   VLOG(4) << "PPB_Graphics3D::GetAttribs()";
50   EnterResource<PPB_Graphics3D_API> enter(context, true);
51   if (enter.failed())
52     return enter.retval();
53   return enter.object()->GetAttribs(attrib_list);
54 }
55 
SetAttribs(PP_Resource context,const int32_t attrib_list[])56 int32_t SetAttribs(PP_Resource context, const int32_t attrib_list[]) {
57   VLOG(4) << "PPB_Graphics3D::SetAttribs()";
58   EnterResource<PPB_Graphics3D_API> enter(context, true);
59   if (enter.failed())
60     return enter.retval();
61   return enter.object()->SetAttribs(attrib_list);
62 }
63 
GetError(PP_Resource context)64 int32_t GetError(PP_Resource context) {
65   VLOG(4) << "PPB_Graphics3D::GetError()";
66   EnterResource<PPB_Graphics3D_API> enter(context, true);
67   if (enter.failed())
68     return enter.retval();
69   return enter.object()->GetError();
70 }
71 
ResizeBuffers(PP_Resource context,int32_t width,int32_t height)72 int32_t ResizeBuffers(PP_Resource context, int32_t width, int32_t height) {
73   VLOG(4) << "PPB_Graphics3D::ResizeBuffers()";
74   EnterResource<PPB_Graphics3D_API> enter(context, true);
75   if (enter.failed())
76     return enter.retval();
77   return enter.object()->ResizeBuffers(width, height);
78 }
79 
SwapBuffers(PP_Resource context,struct PP_CompletionCallback callback)80 int32_t SwapBuffers(PP_Resource context,
81                     struct PP_CompletionCallback callback) {
82   VLOG(4) << "PPB_Graphics3D::SwapBuffers()";
83   EnterResource<PPB_Graphics3D_API> enter(context, callback, true);
84   if (enter.failed())
85     return enter.retval();
86   return enter.SetResult(enter.object()->SwapBuffers(enter.callback()));
87 }
88 
89 const PPB_Graphics3D_1_0 g_ppb_graphics3d_thunk_1_0 = {
90   &GetAttribMaxValue,
91   &Create,
92   &IsGraphics3D,
93   &GetAttribs,
94   &SetAttribs,
95   &GetError,
96   &ResizeBuffers,
97   &SwapBuffers
98 };
99 
100 }  // namespace
101 
GetPPB_Graphics3D_1_0_Thunk()102 PPAPI_THUNK_EXPORT const PPB_Graphics3D_1_0* GetPPB_Graphics3D_1_0_Thunk() {
103   return &g_ppb_graphics3d_thunk_1_0;
104 }
105 
106 }  // namespace thunk
107 }  // namespace ppapi
108