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