Update user pod message to use Smart Lock.
[chromium-blink-merge.git] / ppapi / thunk / ppb_graphics_3d_thunk.cc
blob92f988665bbce5780209969e9d4a54f6e71e5542
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 // From ppb_graphics_3d.idl modified Fri Nov 1 16:12:12 2013.
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"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
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);
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, share_context,
38 attrib_list);
41 PP_Bool IsGraphics3D(PP_Resource resource) {
42 VLOG(4) << "PPB_Graphics3D::IsGraphics3D()";
43 EnterResource<PPB_Graphics3D_API> enter(resource, false);
44 return PP_FromBool(enter.succeeded());
47 int32_t GetAttribs(PP_Resource context, int32_t attrib_list[]) {
48 VLOG(4) << "PPB_Graphics3D::GetAttribs()";
49 EnterResource<PPB_Graphics3D_API> enter(context, true);
50 if (enter.failed())
51 return enter.retval();
52 return enter.object()->GetAttribs(attrib_list);
55 int32_t SetAttribs(PP_Resource context, const int32_t attrib_list[]) {
56 VLOG(4) << "PPB_Graphics3D::SetAttribs()";
57 EnterResource<PPB_Graphics3D_API> enter(context, true);
58 if (enter.failed())
59 return enter.retval();
60 return enter.object()->SetAttribs(attrib_list);
63 int32_t GetError(PP_Resource context) {
64 VLOG(4) << "PPB_Graphics3D::GetError()";
65 EnterResource<PPB_Graphics3D_API> enter(context, true);
66 if (enter.failed())
67 return enter.retval();
68 return enter.object()->GetError();
71 int32_t ResizeBuffers(PP_Resource context, int32_t width, int32_t height) {
72 VLOG(4) << "PPB_Graphics3D::ResizeBuffers()";
73 EnterResource<PPB_Graphics3D_API> enter(context, true);
74 if (enter.failed())
75 return enter.retval();
76 return enter.object()->ResizeBuffers(width, height);
79 int32_t SwapBuffers(PP_Resource context,
80 struct PP_CompletionCallback callback) {
81 VLOG(4) << "PPB_Graphics3D::SwapBuffers()";
82 EnterResource<PPB_Graphics3D_API> enter(context, callback, true);
83 if (enter.failed())
84 return enter.retval();
85 return enter.SetResult(enter.object()->SwapBuffers(enter.callback()));
88 const PPB_Graphics3D_1_0 g_ppb_graphics3d_thunk_1_0 = {&GetAttribMaxValue,
89 &Create,
90 &IsGraphics3D,
91 &GetAttribs,
92 &SetAttribs,
93 &GetError,
94 &ResizeBuffers,
95 &SwapBuffers};
97 } // namespace
99 PPAPI_THUNK_EXPORT const PPB_Graphics3D_1_0* GetPPB_Graphics3D_1_0_Thunk() {
100 return &g_ppb_graphics3d_thunk_1_0;
103 } // namespace thunk
104 } // namespace ppapi