ppb_graphics_3d_thunk.cc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. // From ppb_graphics_3d.idl modified Wed Jan 27 17:10:16 2016.
  5. #include <stdint.h>
  6. #include "base/logging.h"
  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. namespace ppapi {
  15. namespace thunk {
  16. namespace {
  17. int32_t GetAttribMaxValue(PP_Resource instance,
  18. int32_t attribute,
  19. int32_t* value) {
  20. VLOG(4) << "PPB_Graphics3D::GetAttribMaxValue()";
  21. EnterResource<PPB_Graphics3D_API> enter(instance, true);
  22. if (enter.failed())
  23. return enter.retval();
  24. return enter.object()->GetAttribMaxValue(attribute, value);
  25. }
  26. PP_Resource Create(PP_Instance instance,
  27. PP_Resource share_context,
  28. const int32_t attrib_list[]) {
  29. VLOG(4) << "PPB_Graphics3D::Create()";
  30. EnterResourceCreation enter(instance);
  31. if (enter.failed())
  32. return 0;
  33. return enter.functions()->CreateGraphics3D(instance, share_context,
  34. attrib_list);
  35. }
  36. PP_Bool IsGraphics3D(PP_Resource resource) {
  37. VLOG(4) << "PPB_Graphics3D::IsGraphics3D()";
  38. EnterResource<PPB_Graphics3D_API> enter(resource, false);
  39. return PP_FromBool(enter.succeeded());
  40. }
  41. int32_t GetAttribs(PP_Resource context, int32_t attrib_list[]) {
  42. VLOG(4) << "PPB_Graphics3D::GetAttribs()";
  43. EnterResource<PPB_Graphics3D_API> enter(context, true);
  44. if (enter.failed())
  45. return enter.retval();
  46. return enter.object()->GetAttribs(attrib_list);
  47. }
  48. int32_t SetAttribs(PP_Resource context, const int32_t attrib_list[]) {
  49. VLOG(4) << "PPB_Graphics3D::SetAttribs()";
  50. EnterResource<PPB_Graphics3D_API> enter(context, true);
  51. if (enter.failed())
  52. return enter.retval();
  53. return enter.object()->SetAttribs(attrib_list);
  54. }
  55. int32_t GetError(PP_Resource context) {
  56. VLOG(4) << "PPB_Graphics3D::GetError()";
  57. EnterResource<PPB_Graphics3D_API> enter(context, true);
  58. if (enter.failed())
  59. return enter.retval();
  60. return enter.object()->GetError();
  61. }
  62. int32_t ResizeBuffers(PP_Resource context, int32_t width, int32_t height) {
  63. VLOG(4) << "PPB_Graphics3D::ResizeBuffers()";
  64. EnterResource<PPB_Graphics3D_API> enter(context, true);
  65. if (enter.failed())
  66. return enter.retval();
  67. return enter.object()->ResizeBuffers(width, height);
  68. }
  69. int32_t SwapBuffers(PP_Resource context,
  70. struct PP_CompletionCallback callback) {
  71. VLOG(4) << "PPB_Graphics3D::SwapBuffers()";
  72. EnterResource<PPB_Graphics3D_API> enter(context, callback, true);
  73. if (enter.failed())
  74. return enter.retval();
  75. return enter.SetResult(enter.object()->SwapBuffers(enter.callback()));
  76. }
  77. const PPB_Graphics3D_1_0 g_ppb_graphics3d_thunk_1_0 = {
  78. &GetAttribMaxValue, &Create, &IsGraphics3D, &GetAttribs,
  79. &SetAttribs, &GetError, &ResizeBuffers, &SwapBuffers};
  80. } // namespace
  81. PPAPI_THUNK_EXPORT const PPB_Graphics3D_1_0* GetPPB_Graphics3D_1_0_Thunk() {
  82. return &g_ppb_graphics3d_thunk_1_0;
  83. }
  84. } // namespace thunk
  85. } // namespace ppapi