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