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 <memory> | 10 #include <memory> |
(...skipping 29 matching lines...) Expand all Loading... |
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, |
48 int32_t end) override; | 48 int32_t end) override; |
49 void EnsureWorkVisible() override; | 49 void EnsureWorkVisible() override; |
50 void TakeFrontBuffer() override; | |
51 void ReturnFrontBuffer(const gpu::Mailbox& mailbox, | |
52 const gpu::SyncToken& sync_token, | |
53 bool is_lost); | |
54 | 50 |
55 // Binds/unbinds the graphics of this context with the associated instance. | 51 // Binds/unbinds the graphics of this context with the associated instance. |
56 // Returns true if binding/unbinding is successful. | 52 // Returns true if binding/unbinding is successful. |
57 bool BindToInstance(bool bind); | 53 bool BindToInstance(bool bind); |
58 | 54 |
59 // Returns true if the backing texture is always opaque. | 55 // Returns true if the backing texture is always opaque. |
60 bool IsOpaque(); | 56 bool IsOpaque(); |
61 | 57 |
62 // Notifications about the view's progress painting. See PluginInstance. | 58 // Notifications about the view's progress painting. See PluginInstance. |
63 // These messages are used to send Flush callbacks to the plugin. | 59 // These messages are used to send Flush callbacks to the plugin. |
64 void ViewInitiatedPaint(); | 60 void ViewInitiatedPaint(); |
65 | 61 |
| 62 void GetBackingMailbox(gpu::Mailbox* mailbox, gpu::SyncToken* sync_token) { |
| 63 *mailbox = mailbox_; |
| 64 *sync_token = sync_token_; |
| 65 } |
| 66 |
66 gpu::CommandBufferProxyImpl* GetCommandBufferProxy(); | 67 gpu::CommandBufferProxyImpl* GetCommandBufferProxy(); |
67 | 68 |
68 protected: | 69 protected: |
69 ~PPB_Graphics3D_Impl() override; | 70 ~PPB_Graphics3D_Impl() override; |
70 // ppapi::PPB_Graphics3D_Shared overrides. | 71 // ppapi::PPB_Graphics3D_Shared overrides. |
71 gpu::CommandBuffer* GetCommandBuffer() override; | 72 gpu::CommandBuffer* GetCommandBuffer() override; |
72 gpu::GpuControl* GetGpuControl() override; | 73 gpu::GpuControl* GetGpuControl() override; |
73 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token) override; | 74 int32_t DoSwapBuffers(const gpu::SyncToken& sync_token) override; |
74 | 75 |
75 private: | 76 private: |
76 explicit PPB_Graphics3D_Impl(PP_Instance instance); | 77 explicit PPB_Graphics3D_Impl(PP_Instance instance); |
77 | 78 |
78 bool InitRaw(PPB_Graphics3D_API* share_context, | 79 bool InitRaw(PPB_Graphics3D_API* share_context, |
79 const int32_t* attrib_list, | 80 const int32_t* attrib_list, |
80 gpu::Capabilities* capabilities, | 81 gpu::Capabilities* capabilities, |
81 base::SharedMemoryHandle* shared_state_handle, | 82 base::SharedMemoryHandle* shared_state_handle, |
82 gpu::CommandBufferId* command_buffer_id); | 83 gpu::CommandBufferId* command_buffer_id); |
83 | 84 |
84 // GpuControlClient implementation. | 85 // GpuControlClient implementation. |
85 void OnGpuControlLostContext() final; | 86 void OnGpuControlLostContext() final; |
86 void OnGpuControlLostContextMaybeReentrant() final; | 87 void OnGpuControlLostContextMaybeReentrant() final; |
87 void OnGpuControlErrorMessage(const char* msg, int id) final; | 88 void OnGpuControlErrorMessage(const char* msg, int id) final; |
88 | 89 |
89 // Other notifications from the GPU process. | 90 // Other notifications from the GPU process. |
90 void OnSwapBuffers(); | 91 void OnSwapBuffers(); |
91 // Notifications sent to plugin. | 92 // Notifications sent to plugin. |
92 void SendContextLost(); | 93 void SendContextLost(); |
93 | 94 |
94 // Reuses a mailbox if one is available, otherwise makes a new one. | |
95 gpu::Mailbox GenerateMailbox(); | |
96 | |
97 // A front buffer that was recently taken from the command buffer. This should | |
98 // be immediately consumed by DoSwapBuffers(). | |
99 gpu::Mailbox taken_front_buffer_; | |
100 | |
101 // Mailboxes that are no longer in use. | |
102 std::vector<gpu::Mailbox> mailboxes_to_reuse_; | |
103 | |
104 // True if context is bound to instance. | 95 // True if context is bound to instance. |
105 bool bound_to_instance_; | 96 bool bound_to_instance_; |
106 // True when waiting for compositor to commit our backing texture. | 97 // True when waiting for compositor to commit our backing texture. |
107 bool commit_pending_; | 98 bool commit_pending_; |
108 | 99 |
109 #if DCHECK_IS_ON() | 100 #if DCHECK_IS_ON() |
110 bool lost_context_ = false; | 101 bool lost_context_ = false; |
111 #endif | 102 #endif |
112 | 103 |
| 104 gpu::Mailbox mailbox_; |
| 105 gpu::SyncToken sync_token_; |
113 bool has_alpha_; | 106 bool has_alpha_; |
114 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_; | 107 std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_; |
115 | 108 |
116 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; | 109 base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_; |
117 | 110 |
118 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); | 111 DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); |
119 }; | 112 }; |
120 | 113 |
121 } // namespace content | 114 } // namespace content |
122 | 115 |
123 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ | 116 #endif // CONTENT_RENDERER_PEPPER_PPB_GRAPHICS_3D_IMPL_H_ |
OLD | NEW |