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 CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ |
6 #define CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PPB_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 "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "gpu/command_buffer/client/gpu_control_client.h" | 15 #include "gpu/command_buffer/client/gpu_control_client.h" |
16 #include "gpu/command_buffer/common/command_buffer_id.h" | 16 #include "gpu/command_buffer/common/command_buffer_id.h" |
17 #include "gpu/command_buffer/common/mailbox.h" | 17 #include "gpu/command_buffer/common/mailbox.h" |
18 #include "gpu/command_buffer/common/sync_token.h" | 18 #include "gpu/command_buffer/common/sync_token.h" |
19 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" | 19 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
20 #include "ppapi/shared_impl/resource.h" | 20 #include "ppapi/shared_impl/resource.h" |
21 | 21 |
22 namespace gpu { | 22 namespace gpu { |
23 namespace gles2 { | |
24 struct ContextCreationAttribHelper; | |
25 } | |
26 struct Capabilities; | 23 struct Capabilities; |
27 class CommandBufferProxyImpl; | 24 class CommandBufferProxyImpl; |
28 } | 25 } |
29 | 26 |
30 namespace content { | 27 namespace content { |
31 | 28 |
32 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared, | 29 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared, |
33 public gpu::GpuControlClient { | 30 public gpu::GpuControlClient { |
34 public: | 31 public: |
35 static PP_Resource CreateRaw( | 32 static PP_Resource CreateRaw(PP_Instance instance, |
36 PP_Instance instance, | 33 PP_Resource share_context, |
37 PP_Resource share_context, | 34 const int32_t* attrib_list, |
38 const gpu::gles2::ContextCreationAttribHelper& attrib_helper, | 35 gpu::Capabilities* capabilities, |
39 gpu::Capabilities* capabilities, | 36 base::SharedMemoryHandle* shared_state_handle, |
40 base::SharedMemoryHandle* shared_state_handle, | 37 gpu::CommandBufferId* command_buffer_id); |
41 gpu::CommandBufferId* command_buffer_id); | |
42 | 38 |
43 // PPB_Graphics3D_API trusted implementation. | 39 // PPB_Graphics3D_API trusted implementation. |
44 PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override; | 40 PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override; |
45 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, | 41 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, |
46 int32_t* id) override; | 42 int32_t* id) override; |
47 PP_Bool DestroyTransferBuffer(int32_t id) override; | 43 PP_Bool DestroyTransferBuffer(int32_t id) override; |
48 PP_Bool Flush(int32_t put_offset) override; | 44 PP_Bool Flush(int32_t put_offset) override; |
49 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, | 45 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, |
50 int32_t end) override; | 46 int32_t end) override; |
51 gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, | 47 gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, |
(...skipping 21 matching lines...) Expand all Loading... |
73 ~PPB_Graphics3D_Impl() override; | 69 ~PPB_Graphics3D_Impl() override; |
74 // ppapi::PPB_Graphics3D_Shared overrides. | 70 // ppapi::PPB_Graphics3D_Shared overrides. |
75 gpu::CommandBuffer* GetCommandBuffer() override; | 71 gpu::CommandBuffer* GetCommandBuffer() override; |
76 gpu::GpuControl* GetGpuControl() override; | 72 gpu::GpuControl* GetGpuControl() override; |
77 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token) override; | 73 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token) override; |
78 | 74 |
79 private: | 75 private: |
80 explicit PPB_Graphics3D_Impl(PP_Instance instance); | 76 explicit PPB_Graphics3D_Impl(PP_Instance instance); |
81 | 77 |
82 bool InitRaw(PPB_Graphics3D_API* share_context, | 78 bool InitRaw(PPB_Graphics3D_API* share_context, |
83 const gpu::gles2::ContextCreationAttribHelper& attrib_helper, | 79 const int32_t* attrib_list, |
84 gpu::Capabilities* capabilities, | 80 gpu::Capabilities* capabilities, |
85 base::SharedMemoryHandle* shared_state_handle, | 81 base::SharedMemoryHandle* shared_state_handle, |
86 gpu::CommandBufferId* command_buffer_id); | 82 gpu::CommandBufferId* command_buffer_id); |
87 | 83 |
88 // GpuControlClient implementation. | 84 // GpuControlClient implementation. |
89 void OnGpuControlLostContext() final; | 85 void OnGpuControlLostContext() final; |
90 void OnGpuControlLostContextMaybeReentrant() final; | 86 void OnGpuControlLostContextMaybeReentrant() final; |
91 void OnGpuControlErrorMessage(const char* msg, int id) final; | 87 void OnGpuControlErrorMessage(const char* msg, int id) final; |
92 | 88 |
93 // Other notifications from the GPU process. | 89 // Other notifications from the GPU process. |
(...skipping 24 matching lines...) Expand all Loading... |
118 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_; | 114 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_; |
119 | 115 |
120 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; | 116 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; |
121 | 117 |
122 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); | 118 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); |
123 }; | 119 }; |
124 | 120 |
125 } // namespace content | 121 } // namespace content |
126 | 122 |
127 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ | 123 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ |
OLD | NEW |