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 "base/memory/shared_memory.h" |
8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
9 #include "gpu/command_buffer/common/mailbox.h" | 10 #include "gpu/command_buffer/common/mailbox.h" |
10 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" | 11 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
11 #include "ppapi/shared_impl/resource.h" | 12 #include "ppapi/shared_impl/resource.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 class CommandBufferProxyImpl; | 15 class CommandBufferProxyImpl; |
15 class GpuChannelHost; | 16 class GpuChannelHost; |
16 | 17 |
17 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared { | 18 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared { |
18 public: | 19 public: |
19 static PP_Resource Create(PP_Instance instance, | 20 static PP_Resource Create(PP_Instance instance, |
20 PP_Resource share_context, | 21 PP_Resource share_context, |
21 const int32_t* attrib_list); | 22 const int32_t* attrib_list); |
22 static PP_Resource CreateRaw(PP_Instance instance, | 23 static PP_Resource CreateRaw( |
23 PP_Resource share_context, | 24 PP_Instance instance, |
24 const int32_t* attrib_list); | 25 PP_Resource share_context, |
| 26 const int32_t* attrib_list, |
| 27 base::SharedMemoryHandle* shared_state_handle); |
25 | 28 |
26 // PPB_Graphics3D_API trusted implementation. | 29 // PPB_Graphics3D_API trusted implementation. |
27 virtual PP_Bool SetGetBuffer(int32_t transfer_buffer_id) OVERRIDE; | 30 virtual PP_Bool SetGetBuffer(int32_t transfer_buffer_id) OVERRIDE; |
28 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, | 31 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, |
29 int32* id) OVERRIDE; | 32 int32* id) OVERRIDE; |
30 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; | 33 virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; |
31 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; | 34 virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; |
32 virtual gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, | 35 virtual gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, |
33 int32_t end) OVERRIDE; | 36 int32_t end) OVERRIDE; |
34 virtual gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, | 37 virtual gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, |
(...skipping 28 matching lines...) Expand all Loading... |
63 virtual ~PPB_Graphics3D_Impl(); | 66 virtual ~PPB_Graphics3D_Impl(); |
64 // ppapi::PPB_Graphics3D_Shared overrides. | 67 // ppapi::PPB_Graphics3D_Shared overrides. |
65 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE; | 68 virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE; |
66 virtual gpu::GpuControl* GetGpuControl() OVERRIDE; | 69 virtual gpu::GpuControl* GetGpuControl() OVERRIDE; |
67 virtual int32 DoSwapBuffers() OVERRIDE; | 70 virtual int32 DoSwapBuffers() OVERRIDE; |
68 | 71 |
69 private: | 72 private: |
70 explicit PPB_Graphics3D_Impl(PP_Instance instance); | 73 explicit PPB_Graphics3D_Impl(PP_Instance instance); |
71 | 74 |
72 bool Init(PPB_Graphics3D_API* share_context, const int32_t* attrib_list); | 75 bool Init(PPB_Graphics3D_API* share_context, const int32_t* attrib_list); |
73 bool InitRaw(PPB_Graphics3D_API* share_context, const int32_t* attrib_list); | 76 bool InitRaw(PPB_Graphics3D_API* share_context, |
| 77 const int32_t* attrib_list, |
| 78 base::SharedMemoryHandle* shared_state_handle); |
74 | 79 |
75 // Notifications received from the GPU process. | 80 // Notifications received from the GPU process. |
76 void OnSwapBuffers(); | 81 void OnSwapBuffers(); |
77 void OnContextLost(); | 82 void OnContextLost(); |
78 void OnConsoleMessage(const std::string& msg, int id); | 83 void OnConsoleMessage(const std::string& msg, int id); |
79 // Notifications sent to plugin. | 84 // Notifications sent to plugin. |
80 void SendContextLost(); | 85 void SendContextLost(); |
81 | 86 |
82 // True if context is bound to instance. | 87 // True if context is bound to instance. |
83 bool bound_to_instance_; | 88 bool bound_to_instance_; |
84 // True when waiting for compositor to commit our backing texture. | 89 // True when waiting for compositor to commit our backing texture. |
85 bool commit_pending_; | 90 bool commit_pending_; |
86 | 91 |
87 gpu::Mailbox mailbox_; | 92 gpu::Mailbox mailbox_; |
88 uint32 sync_point_; | 93 uint32 sync_point_; |
89 bool has_alpha_; | 94 bool has_alpha_; |
90 scoped_refptr<GpuChannelHost> channel_; | 95 scoped_refptr<GpuChannelHost> channel_; |
91 CommandBufferProxyImpl* command_buffer_; | 96 CommandBufferProxyImpl* command_buffer_; |
92 | 97 |
93 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; | 98 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; |
94 | 99 |
95 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); | 100 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); |
96 }; | 101 }; |
97 | 102 |
98 } // namespace content | 103 } // namespace content |
99 | 104 |
100 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ | 105 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ |
OLD | NEW |