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" |
18 | 19 |
19 namespace gpu { | 20 namespace gpu { |
20 class CommandBuffer; | 21 class CommandBuffer; |
21 class GpuControl; | 22 class GpuControl; |
22 class TransferBuffer; | 23 class TransferBuffer; |
23 namespace gles2 { | 24 namespace gles2 { |
24 class GLES2CmdHelper; | 25 class GLES2CmdHelper; |
25 class GLES2Implementation; | 26 class GLES2Implementation; |
26 class GLES2Interface; | 27 class GLES2Interface; |
27 } // namespace gles2 | 28 } // namespace gles2 |
28 } // namespace gpu. | 29 } // namespace gpu. |
29 | 30 |
30 namespace ppapi { | 31 namespace ppapi { |
31 | 32 |
32 class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared | 33 class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared |
33 : public Resource, | 34 : public Resource, |
34 public thunk::PPB_Graphics3D_API { | 35 public thunk::PPB_Graphics3D_API { |
35 public: | 36 public: |
36 // Resource overrides. | 37 // Resource overrides. |
37 thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() override; | 38 thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() override; |
38 | 39 |
39 // PPB_Graphics3D_API implementation. | 40 // PPB_Graphics3D_API implementation. |
40 int32_t GetAttribs(int32_t attrib_list[]) override; | 41 int32_t GetAttribs(int32_t attrib_list[]) override; |
41 int32_t SetAttribs(const int32_t attrib_list[]) override; | 42 int32_t SetAttribs(const int32_t attrib_list[]) override; |
42 int32_t GetError() override; | 43 int32_t GetError() override; |
43 int32_t ResizeBuffers(int32_t width, int32_t height) override; | 44 int32_t ResizeBuffers(int32_t width, int32_t height) override; |
44 int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override; | 45 int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override; |
45 int32_t SwapBuffersWithSyncToken(scoped_refptr<TrackedCallback> callback, | 46 int32_t SwapBuffersWithSyncToken(scoped_refptr<TrackedCallback> callback, |
46 const gpu::SyncToken& sync_token, | 47 const gpu::SyncToken& sync_token, |
47 int32_t width, | 48 const gfx::Size& size) override; |
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); |
71 ~PPB_Graphics3D_Shared() override; | 72 ~PPB_Graphics3D_Shared() override; |
72 | 73 |
73 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; | 74 virtual gpu::CommandBuffer* GetCommandBuffer() = 0; |
74 virtual gpu::GpuControl* GetGpuControl() = 0; | 75 virtual gpu::GpuControl* GetGpuControl() = 0; |
75 virtual int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, | 76 virtual int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, |
76 int32_t width, | 77 const gfx::Size& size) = 0; |
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. | 90 // A local cache of the size of the viewport. This is only valid in plugin |
91 int32_t width_ = -1; | 91 // resources. |
92 int32_t height_ = -1; | 92 gfx::Size size_; |
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 |