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