Pepper_47_C++_interfaces
graphics_3d.cc
Go to the documentation of this file.
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 
6 
7 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/module_impl.h"
11 #include "ppapi/cpp/var.h"
12 
13 namespace pp {
14 
15 namespace {
16 
17 template <> const char* interface_name<PPB_Graphics3D_1_0>() {
18  return PPB_GRAPHICS_3D_INTERFACE_1_0;
19 }
20 
21 } // namespace
22 
24 }
25 
27  const int32_t attrib_list[]) {
28  if (has_interface<PPB_Graphics3D_1_0>()) {
29  PassRefFromConstructor(get_interface<PPB_Graphics3D_1_0>()->Create(
30  instance.pp_instance(), 0, attrib_list));
31  }
32 }
33 
35  const Graphics3D& share_context,
36  const int32_t attrib_list[]) {
37  if (has_interface<PPB_Graphics3D_1_0>()) {
38  PassRefFromConstructor(get_interface<PPB_Graphics3D_1_0>()->Create(
39  instance.pp_instance(),
40  share_context.pp_resource(),
41  attrib_list));
42  }
43 }
44 
46 }
47 
48 int32_t Graphics3D::GetAttribs(int32_t attrib_list[]) const {
49  if (!has_interface<PPB_Graphics3D_1_0>())
50  return PP_ERROR_NOINTERFACE;
51 
52  return get_interface<PPB_Graphics3D_1_0>()->GetAttribs(
53  pp_resource(),
54  attrib_list);
55 }
56 
57 int32_t Graphics3D::SetAttribs(const int32_t attrib_list[]) {
58  if (!has_interface<PPB_Graphics3D_1_0>())
59  return PP_ERROR_NOINTERFACE;
60 
61  return get_interface<PPB_Graphics3D_1_0>()->SetAttribs(
62  pp_resource(),
63  attrib_list);
64 }
65 
67  if (!has_interface<PPB_Graphics3D_1_0>())
68  return PP_ERROR_NOINTERFACE;
69 
70  return get_interface<PPB_Graphics3D_1_0>()->ResizeBuffers(
71  pp_resource(), width, height);
72 }
73 
75  if (!has_interface<PPB_Graphics3D_1_0>())
76  return PP_ERROR_NOINTERFACE;
77 
78  return get_interface<PPB_Graphics3D_1_0>()->SwapBuffers(
79  pp_resource(),
81 }
82 
83 } // namespace pp
void PassRefFromConstructor(PP_Resource resource)
Definition: resource.cc:50
int32_t ResizeBuffers(int32_t width, int32_t height)
Definition: graphics_3d.cc:66
const PP_CompletionCallback & pp_completion_callback() const
This class represents a 3D rendering context in the browser.
Definition: graphics_3d.h:19
Graphics3D()
Default constructor for creating an is_null() Graphics3D object.
Definition: graphics_3d.cc:23
int32_t SwapBuffers(const CompletionCallback &cc)
Definition: graphics_3d.cc:74
int32_t GetAttribs(int32_t attrib_list[]) const
Definition: graphics_3d.cc:48
PP_Resource pp_resource() const
Definition: resource.h:47
int32_t SetAttribs(const int32_t attrib_list[])
Definition: graphics_3d.cc:57
PP_Instance pp_instance() const
~Graphics3D()
Destructor.
Definition: graphics_3d.cc:45