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 "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "gpu/command_buffer/common/command_buffer_id.h" |
13 #include "gpu/command_buffer/common/mailbox.h" | 14 #include "gpu/command_buffer/common/mailbox.h" |
14 #include "gpu/command_buffer/common/sync_token.h" | 15 #include "gpu/command_buffer/common/sync_token.h" |
15 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" | 16 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
16 #include "ppapi/shared_impl/resource.h" | 17 #include "ppapi/shared_impl/resource.h" |
17 | 18 |
18 namespace gpu { | 19 namespace gpu { |
19 struct Capabilities; | 20 struct Capabilities; |
20 } | 21 } |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 class CommandBufferProxyImpl; | 24 class CommandBufferProxyImpl; |
24 class GpuChannelHost; | 25 class GpuChannelHost; |
25 | 26 |
26 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared { | 27 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared { |
27 public: | 28 public: |
28 static PP_Resource Create(PP_Instance instance, | 29 static PP_Resource Create(PP_Instance instance, |
29 PP_Resource share_context, | 30 PP_Resource share_context, |
30 const int32_t* attrib_list); | 31 const int32_t* attrib_list); |
31 static PP_Resource CreateRaw( | 32 static PP_Resource CreateRaw(PP_Instance instance, |
32 PP_Instance instance, | 33 PP_Resource share_context, |
33 PP_Resource share_context, | 34 const int32_t* attrib_list, |
34 const int32_t* attrib_list, | 35 gpu::Capabilities* capabilities, |
35 gpu::Capabilities* capabilities, | 36 base::SharedMemoryHandle* shared_state_handle, |
36 base::SharedMemoryHandle* shared_state_handle, | 37 gpu::CommandBufferId* command_buffer_id); |
37 uint64_t* command_buffer_id); | |
38 | 38 |
39 // PPB_Graphics3D_API trusted implementation. | 39 // PPB_Graphics3D_API trusted implementation. |
40 PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override; | 40 PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override; |
41 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, | 41 scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size, |
42 int32_t* id) override; | 42 int32_t* id) override; |
43 PP_Bool DestroyTransferBuffer(int32_t id) override; | 43 PP_Bool DestroyTransferBuffer(int32_t id) override; |
44 PP_Bool Flush(int32_t put_offset) override; | 44 PP_Bool Flush(int32_t put_offset) override; |
45 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, | 45 gpu::CommandBuffer::State WaitForTokenInRange(int32_t start, |
46 int32_t end) override; | 46 int32_t end) override; |
47 gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, | 47 gpu::CommandBuffer::State WaitForGetOffsetInRange(int32_t start, |
(...skipping 28 matching lines...) Expand all Loading... |
76 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token) override; | 76 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token) override; |
77 | 77 |
78 private: | 78 private: |
79 explicit PPB_Graphics3D_Impl(PP_Instance instance); | 79 explicit PPB_Graphics3D_Impl(PP_Instance instance); |
80 | 80 |
81 bool Init(PPB_Graphics3D_API* share_context, const int32_t* attrib_list); | 81 bool Init(PPB_Graphics3D_API* share_context, const int32_t* attrib_list); |
82 bool InitRaw(PPB_Graphics3D_API* share_context, | 82 bool InitRaw(PPB_Graphics3D_API* share_context, |
83 const int32_t* attrib_list, | 83 const int32_t* attrib_list, |
84 gpu::Capabilities* capabilities, | 84 gpu::Capabilities* capabilities, |
85 base::SharedMemoryHandle* shared_state_handle, | 85 base::SharedMemoryHandle* shared_state_handle, |
86 uint64_t* command_buffer_id); | 86 gpu::CommandBufferId* command_buffer_id); |
87 | 87 |
88 // Notifications received from the GPU process. | 88 // Notifications received from the GPU process. |
89 void OnSwapBuffers(); | 89 void OnSwapBuffers(); |
90 void OnContextLost(); | 90 void OnContextLost(); |
91 void OnConsoleMessage(const std::string& msg, int id); | 91 void OnConsoleMessage(const std::string& msg, int id); |
92 // Notifications sent to plugin. | 92 // Notifications sent to plugin. |
93 void SendContextLost(); | 93 void SendContextLost(); |
94 | 94 |
95 // True if context is bound to instance. | 95 // True if context is bound to instance. |
96 bool bound_to_instance_; | 96 bool bound_to_instance_; |
97 // True when waiting for compositor to commit our backing texture. | 97 // True when waiting for compositor to commit our backing texture. |
98 bool commit_pending_; | 98 bool commit_pending_; |
99 | 99 |
100 gpu::Mailbox mailbox_; | 100 gpu::Mailbox mailbox_; |
101 gpu::SyncToken sync_token_; | 101 gpu::SyncToken sync_token_; |
102 bool has_alpha_; | 102 bool has_alpha_; |
103 scoped_refptr<GpuChannelHost> channel_; | 103 scoped_refptr<GpuChannelHost> channel_; |
104 scoped_ptr<CommandBufferProxyImpl> command_buffer_; | 104 scoped_ptr<CommandBufferProxyImpl> command_buffer_; |
105 | 105 |
106 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; | 106 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); | 108 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace content | 111 } // namespace content |
112 | 112 |
113 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ | 113 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ |
OLD | NEW |