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/client/gpu_control_client.h" | |
14 #include "gpu/command_buffer/common/command_buffer_id.h" | 13 #include "gpu/command_buffer/common/command_buffer_id.h" |
15 #include "gpu/command_buffer/common/mailbox.h" | 14 #include "gpu/command_buffer/common/mailbox.h" |
16 #include "gpu/command_buffer/common/sync_token.h" | 15 #include "gpu/command_buffer/common/sync_token.h" |
17 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" | 16 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
18 #include "ppapi/shared_impl/resource.h" | 17 #include "ppapi/shared_impl/resource.h" |
19 | 18 |
20 namespace gpu { | 19 namespace gpu { |
21 struct Capabilities; | 20 struct Capabilities; |
22 class CommandBufferProxyImpl; | 21 class CommandBufferProxyImpl; |
23 class GpuChannelHost; | 22 class GpuChannelHost; |
24 } | 23 } |
25 | 24 |
26 namespace content { | 25 namespace content { |
27 | 26 |
28 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared, | 27 class PPB_Graphics3D_Impl : public ppapi::PPB_Graphics3D_Shared { |
29 public gpu::GpuControlClient { | |
30 public: | 28 public: |
31 static PP_Resource CreateRaw(PP_Instance instance, | 29 static PP_Resource CreateRaw(PP_Instance instance, |
32 PP_Resource share_context, | 30 PP_Resource share_context, |
33 const int32_t* attrib_list, | 31 const int32_t* attrib_list, |
34 gpu::Capabilities* capabilities, | 32 gpu::Capabilities* capabilities, |
35 base::SharedMemoryHandle* shared_state_handle, | 33 base::SharedMemoryHandle* shared_state_handle, |
36 gpu::CommandBufferId* command_buffer_id); | 34 gpu::CommandBufferId* command_buffer_id); |
37 | 35 |
38 // PPB_Graphics3D_API trusted implementation. | 36 // PPB_Graphics3D_API trusted implementation. |
39 PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override; | 37 PP_Bool SetGetBuffer(int32_t transfer_buffer_id) override; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 74 |
77 private: | 75 private: |
78 explicit PPB_Graphics3D_Impl(PP_Instance instance); | 76 explicit PPB_Graphics3D_Impl(PP_Instance instance); |
79 | 77 |
80 bool InitRaw(PPB_Graphics3D_API* share_context, | 78 bool InitRaw(PPB_Graphics3D_API* share_context, |
81 const int32_t* attrib_list, | 79 const int32_t* attrib_list, |
82 gpu::Capabilities* capabilities, | 80 gpu::Capabilities* capabilities, |
83 base::SharedMemoryHandle* shared_state_handle, | 81 base::SharedMemoryHandle* shared_state_handle, |
84 gpu::CommandBufferId* command_buffer_id); | 82 gpu::CommandBufferId* command_buffer_id); |
85 | 83 |
86 // GpuControlClient implementation. | 84 // Notifications received from the GPU process. |
87 void OnGpuControlLostContext() final; | |
88 void OnGpuControlErrorMessage(const char* msg, int id) final; | |
89 | |
90 // Other notifications from the GPU process. | |
91 void OnSwapBuffers(); | 85 void OnSwapBuffers(); |
| 86 void OnContextLost(); |
| 87 void OnConsoleMessage(const std::string& msg, int id); |
92 // Notifications sent to plugin. | 88 // Notifications sent to plugin. |
93 void SendContextLost(); | 89 void SendContextLost(); |
94 | 90 |
95 // True if context is bound to instance. | 91 // True if context is bound to instance. |
96 bool bound_to_instance_; | 92 bool bound_to_instance_; |
97 // True when waiting for compositor to commit our backing texture. | 93 // True when waiting for compositor to commit our backing texture. |
98 bool commit_pending_; | 94 bool commit_pending_; |
99 | 95 |
100 #if DCHECK_IS_ON() | |
101 bool lost_context_ = false; | |
102 #endif | |
103 | |
104 gpu::Mailbox mailbox_; | 96 gpu::Mailbox mailbox_; |
105 gpu::SyncToken sync_token_; | 97 gpu::SyncToken sync_token_; |
106 bool has_alpha_; | 98 bool has_alpha_; |
107 scoped_refptr<gpu::GpuChannelHost> channel_; | 99 scoped_refptr<gpu::GpuChannelHost> channel_; |
108 scoped_ptr<gpu::CommandBufferProxyImpl> command_buffer_; | 100 scoped_ptr<gpu::CommandBufferProxyImpl> command_buffer_; |
109 | 101 |
110 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; | 102 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; |
111 | 103 |
112 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); | 104 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); |
113 }; | 105 }; |
114 | 106 |
115 } // namespace content | 107 } // namespace content |
116 | 108 |
117 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ | 109 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ |
OLD | NEW |