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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "content/common/gpu/sync_point_manager.h" | 22 #include "content/common/gpu/sync_point_manager.h" |
23 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
25 #include "gpu/command_buffer/common/constants.h" | 25 #include "gpu/command_buffer/common/constants.h" |
26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
27 #include "gpu/command_buffer/common/mailbox.h" | 27 #include "gpu/command_buffer/common/mailbox.h" |
28 #include "gpu/command_buffer/service/gl_context_virtual.h" | 28 #include "gpu/command_buffer/service/gl_context_virtual.h" |
29 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 29 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
30 #include "gpu/command_buffer/service/logger.h" | 30 #include "gpu/command_buffer/service/logger.h" |
31 #include "gpu/command_buffer/service/memory_tracking.h" | 31 #include "gpu/command_buffer/service/memory_tracking.h" |
| 32 #include "gpu/command_buffer/service/query_manager.h" |
32 #include "ui/gl/gl_bindings.h" | 33 #include "ui/gl/gl_bindings.h" |
33 #include "ui/gl/gl_switches.h" | 34 #include "ui/gl/gl_switches.h" |
34 | 35 |
35 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
36 #include "content/public/common/sandbox_init.h" | 37 #include "content/public/common/sandbox_init.h" |
37 #endif | 38 #endif |
38 | 39 |
39 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
40 #include "content/common/gpu/stream_texture_manager_android.h" | 41 #include "content/common/gpu/stream_texture_manager_android.h" |
41 #endif | 42 #endif |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, | 204 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible, |
204 OnSetSurfaceVisible) | 205 OnSetSurfaceVisible) |
205 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer, | 206 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer, |
206 OnDiscardBackbuffer) | 207 OnDiscardBackbuffer) |
207 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer, | 208 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EnsureBackbuffer, |
208 OnEnsureBackbuffer) | 209 OnEnsureBackbuffer) |
209 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint, | 210 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_RetireSyncPoint, |
210 OnRetireSyncPoint) | 211 OnRetireSyncPoint) |
211 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint, | 212 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint, |
212 OnSignalSyncPoint) | 213 OnSignalSyncPoint) |
| 214 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalQuery, |
| 215 OnSignalQuery) |
213 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SendClientManagedMemoryStats, | 216 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SendClientManagedMemoryStats, |
214 OnReceivedClientManagedMemoryStats) | 217 OnReceivedClientManagedMemoryStats) |
215 IPC_MESSAGE_HANDLER( | 218 IPC_MESSAGE_HANDLER( |
216 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, | 219 GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, |
217 OnSetClientHasMemoryAllocationChangedCallback) | 220 OnSetClientHasMemoryAllocationChangedCallback) |
218 IPC_MESSAGE_UNHANDLED(handled = false) | 221 IPC_MESSAGE_UNHANDLED(handled = false) |
219 IPC_END_MESSAGE_MAP() | 222 IPC_END_MESSAGE_MAP() |
220 | 223 |
221 // Ensure that any delayed work that was created will be handled. | 224 // Ensure that any delayed work that was created will be handled. |
222 ScheduleDelayedWork(kHandleMoreWorkPeriodMs); | 225 ScheduleDelayedWork(kHandleMoreWorkPeriodMs); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 sync_point, | 810 sync_point, |
808 base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, | 811 base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, |
809 this->AsWeakPtr(), | 812 this->AsWeakPtr(), |
810 id)); | 813 id)); |
811 } | 814 } |
812 | 815 |
813 void GpuCommandBufferStub::OnSignalSyncPointAck(uint32 id) { | 816 void GpuCommandBufferStub::OnSignalSyncPointAck(uint32 id) { |
814 Send(new GpuCommandBufferMsg_SignalSyncPointAck(route_id_, id)); | 817 Send(new GpuCommandBufferMsg_SignalSyncPointAck(route_id_, id)); |
815 } | 818 } |
816 | 819 |
| 820 void GpuCommandBufferStub::OnSignalQuery(uint32 query_id, uint32 id) { |
| 821 if (decoder_) { |
| 822 gpu::gles2::QueryManager* query_manager = decoder_->GetQueryManager(); |
| 823 if (query_manager) { |
| 824 gpu::gles2::QueryManager::Query* query = |
| 825 query_manager->GetQuery(query_id); |
| 826 if (query) { |
| 827 query->AddCallback( |
| 828 base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, |
| 829 this->AsWeakPtr(), |
| 830 id)); |
| 831 return; |
| 832 } |
| 833 } |
| 834 } |
| 835 // Something went wrong, run callback immediately. |
| 836 OnSignalSyncPointAck(id); |
| 837 } |
| 838 |
| 839 |
817 void GpuCommandBufferStub::OnReceivedClientManagedMemoryStats( | 840 void GpuCommandBufferStub::OnReceivedClientManagedMemoryStats( |
818 const GpuManagedMemoryStats& stats) { | 841 const GpuManagedMemoryStats& stats) { |
819 TRACE_EVENT0( | 842 TRACE_EVENT0( |
820 "gpu", | 843 "gpu", |
821 "GpuCommandBufferStub::OnReceivedClientManagedMemoryStats"); | 844 "GpuCommandBufferStub::OnReceivedClientManagedMemoryStats"); |
822 if (memory_manager_client_state_) | 845 if (memory_manager_client_state_) |
823 memory_manager_client_state_->SetManagedMemoryStats(stats); | 846 memory_manager_client_state_->SetManagedMemoryStats(stats); |
824 } | 847 } |
825 | 848 |
826 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( | 849 void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 if (surface_.get() && MakeCurrent()) | 927 if (surface_.get() && MakeCurrent()) |
905 surface_->SetFrontbufferAllocation( | 928 surface_->SetFrontbufferAllocation( |
906 allocation.browser_allocation.suggest_have_frontbuffer); | 929 allocation.browser_allocation.suggest_have_frontbuffer); |
907 } | 930 } |
908 | 931 |
909 last_memory_allocation_valid_ = true; | 932 last_memory_allocation_valid_ = true; |
910 last_memory_allocation_ = allocation; | 933 last_memory_allocation_ = allocation; |
911 } | 934 } |
912 | 935 |
913 } // namespace content | 936 } // namespace content |
OLD | NEW |