Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / ppapi / thunk / ppb_graphics_3d_thunk.cc
blobeb079bbba80cf5e1c5ae09c53b09348472e3202c
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/c/pp_completion_callback.h"
6 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/shared_impl/tracked_callback.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/thunk.h"
10 #include "ppapi/thunk/ppb_graphics_3d_api.h"
11 #include "ppapi/thunk/resource_creation_api.h"
13 namespace ppapi {
14 namespace thunk {
16 namespace {
18 typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D;
20 int32_t GetAttribMaxValue(PP_Instance instance,
21 int32_t attribute,
22 int32_t* value) {
23 // TODO(alokp): Implement me.
24 return PP_ERROR_FAILED;
27 PP_Resource Create(PP_Instance instance,
28 PP_Resource share_context,
29 const int32_t attrib_list[]) {
30 EnterResourceCreation enter(instance);
31 if (enter.failed())
32 return 0;
33 return enter.functions()->CreateGraphics3D(
34 instance, share_context, attrib_list);
37 PP_Bool IsGraphics3D(PP_Resource resource) {
38 EnterGraphics3D enter(resource, false);
39 return PP_FromBool(enter.succeeded());
42 int32_t GetAttribs(PP_Resource graphics_3d, int32_t attrib_list[]) {
43 EnterGraphics3D enter(graphics_3d, true);
44 if (enter.failed())
45 return enter.retval();
46 return enter.object()->GetAttribs(attrib_list);
49 int32_t SetAttribs(PP_Resource graphics_3d, const int32_t attrib_list[]) {
50 EnterGraphics3D enter(graphics_3d, true);
51 if (enter.failed())
52 return enter.retval();
53 return enter.object()->SetAttribs(attrib_list);
56 int32_t GetError(PP_Resource graphics_3d) {
57 EnterGraphics3D enter(graphics_3d, true);
58 if (enter.failed())
59 return enter.retval();
60 return enter.object()->GetError();
63 int32_t ResizeBuffers(PP_Resource graphics_3d, int32_t width, int32_t height) {
64 EnterGraphics3D enter(graphics_3d, true);
65 if (enter.failed())
66 return enter.retval();
67 return enter.object()->ResizeBuffers(width, height);
70 int32_t SwapBuffers(PP_Resource graphics_3d, PP_CompletionCallback callback) {
71 EnterGraphics3D enter(graphics_3d, callback, true);
72 if (enter.failed())
73 return enter.retval();
74 return enter.SetResult(enter.object()->SwapBuffers(enter.callback()));
77 const PPB_Graphics3D g_ppb_graphics_3d_thunk = {
78 &GetAttribMaxValue,
79 &Create,
80 &IsGraphics3D,
81 &GetAttribs,
82 &SetAttribs,
83 &GetError,
84 &ResizeBuffers,
85 &SwapBuffers
88 } // namespace
90 const PPB_Graphics3D_1_0* GetPPB_Graphics3D_1_0_Thunk() {
91 return &g_ppb_graphics_3d_thunk;
94 } // namespace thunk
95 } // namespace ppapi