OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 5 #ifndef PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
6 #define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 6 #define PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "ppapi/c/pp_completion_callback.h" | 13 #include "ppapi/c/pp_completion_callback.h" |
14 #include "ppapi/shared_impl/ppapi_shared_export.h" | 14 #include "ppapi/shared_impl/ppapi_shared_export.h" |
15 #include "ppapi/shared_impl/resource.h" | 15 #include "ppapi/shared_impl/resource.h" |
16 #include "ppapi/shared_impl/tracked_callback.h" | 16 #include "ppapi/shared_impl/tracked_callback.h" |
17 #include "ppapi/thunk/ppb_graphics_3d_api.h" | 17 #include "ppapi/thunk/ppb_graphics_3d_api.h" |
18 #include "ui/gfx/geometry/size.h" | |
19 | 18 |
20 namespace gpu { | 19 namespace gpu { |
21 class CommandBuffer; | 20 class CommandBuffer; |
22 class GpuControl; | 21 class GpuControl; |
23 class TransferBuffer; | 22 class TransferBuffer; |
24 namespace gles2 { | 23 namespace gles2 { |
25 class GLES2CmdHelper; | 24 class GLES2CmdHelper; |
26 class GLES2Implementation; | 25 class GLES2Implementation; |
27 class GLES2Interface; | 26 class GLES2Interface; |
28 } // namespace gles2 | 27 } // namespace gles2 |
29 } // namespace gpu. | 28 } // namespace gpu. |
30 | 29 |
31 namespace ppapi { | 30 namespace ppapi { |
32 | 31 |
33 class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared | 32 class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared |
34 : public Resource, | 33 : public Resource, |
35 public thunk::PPB_Graphics3D_API { | 34 public thunk::PPB_Graphics3D_API { |
36 public: | 35 public: |
37 // Resource overrides. | 36 // Resource overrides. |
38 thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() override; | 37 thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() override; |
39 | 38 |
40 // PPB_Graphics3D_API implementation. | 39 // PPB_Graphics3D_API implementation. |
41 int32_t GetAttribs(int32_t attrib_list[]) override; | 40 int32_t GetAttribs(int32_t attrib_list[]) override; |
42 int32_t SetAttribs(const int32_t attrib_list[]) override; | 41 int32_t SetAttribs(const int32_t attrib_list[]) override; |
43 int32_t GetError() override; | 42 int32_t GetError() override; |
44 int32_t ResizeBuffers(int32_t width, int32_t height) override; | 43 int32_t ResizeBuffers(int32_t width, int32_t height) override; |
45 int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override; | 44 int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override; |
46 int32_t SwapBuffersWithSyncToken(scoped_refptr<TrackedCallback> callback, | 45 int32_t SwapBuffersWithSyncToken(scoped_refptr<TrackedCallback> callback, |
47 const gpu::SyncToken& sync_token, | 46 const gpu::SyncToken& sync_token, |
48 const gfx::Size& size) override; | 47 int32_t width, |
| 48 int32_t height) override; |
49 int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) override; | 49 int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) override; |
50 | 50 |
51 void* MapTexSubImage2DCHROMIUM(GLenum target, | 51 void* MapTexSubImage2DCHROMIUM(GLenum target, |
52 GLint level, | 52 GLint level, |
53 GLint xoffset, | 53 GLint xoffset, |
54 GLint yoffset, | 54 GLint yoffset, |
55 GLsizei width, | 55 GLsizei width, |
56 GLsizei height, | 56 GLsizei height, |
57 GLenum format, | 57 GLenum format, |
58 GLenum type, | 58 GLenum type, |
59 GLenum access) override; | 59 GLenum access) override; |
60 void UnmapTexSubImage2DCHROMIUM(const void* mem) override; | 60 void UnmapTexSubImage2DCHROMIUM(const void* mem) override; |
61 | 61 |
62 gpu::gles2::GLES2Implementation* gles2_impl() { return gles2_impl_.get(); } | 62 gpu::gles2::GLES2Implementation* gles2_impl() { return gles2_impl_.get(); } |
63 gpu::gles2::GLES2Interface* gles2_interface(); | 63 gpu::gles2::GLES2Interface* gles2_interface(); |
64 | 64 |
65 // Sends swap-buffers notification to the plugin. | 65 // Sends swap-buffers notification to the plugin. |
66 void SwapBuffersACK(int32_t pp_error); | 66 void SwapBuffersACK(int32_t pp_error); |
67 | 67 |
68 protected: | 68 protected: |
69 PPB_Graphics3D_Shared(PP_Instance instance); | 69 PPB_Graphics3D_Shared(PP_Instance instance); |
70 PPB_Graphics3D_Shared(const HostResource& host_resource, | 70 PPB_Graphics3D_Shared(const HostResource& host_resource); |
71 const gfx::Size& size); | |
72 ~PPB_Graphics3D_Shared() override; | 71 ~PPB_Graphics3D_Shared() override; |
73 | 72 |
74 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; | 73 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; |
75 virtual gpu::GpuControl* GetGpuControl() = 0; | 74 virtual gpu::GpuControl* GetGpuControl() = 0; |
76 virtual int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, | 75 virtual int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, |
77 const gfx::Size& size) = 0; | 76 int32_t width, |
| 77 int32_t height) = 0; |
78 | 78 |
79 bool HasPendingSwap() const; | 79 bool HasPendingSwap() const; |
80 bool CreateGLES2Impl(int32_t command_buffer_size, | 80 bool CreateGLES2Impl(int32_t command_buffer_size, |
81 int32_t transfer_buffer_size, | 81 int32_t transfer_buffer_size, |
82 gpu::gles2::GLES2Implementation* share_gles2); | 82 gpu::gles2::GLES2Implementation* share_gles2); |
83 void DestroyGLES2Impl(); | 83 void DestroyGLES2Impl(); |
84 | 84 |
85 private: | 85 private: |
86 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; | 86 std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; |
87 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; | 87 std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; |
88 std::unique_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; | 88 std::unique_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; |
89 | 89 |
90 // A local cache of the size of the viewport. This is only valid in plugin | 90 // A local cache of the size of the viewport. |
91 // resources. | 91 int32_t width_ = -1; |
92 gfx::Size size_; | 92 int32_t height_ = -1; |
93 | 93 |
94 // Callback that needs to be executed when swap-buffers is completed. | 94 // Callback that needs to be executed when swap-buffers is completed. |
95 scoped_refptr<TrackedCallback> swap_callback_; | 95 scoped_refptr<TrackedCallback> swap_callback_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); | 97 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Shared); |
98 }; | 98 }; |
99 | 99 |
100 } // namespace ppapi | 100 } // namespace ppapi |
101 | 101 |
102 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ | 102 #endif // PPAPI_SHARED_IMPL_GRAPHICS_3D_IMPL_H_ |
OLD | NEW |