| 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
| 15 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "content/common/gpu/gpu_channel_manager.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/gpu/gpu_memory_manager.h" | 17 #include "content/common/gpu/gpu_memory_manager.h" |
| 18 #include "content/common/gpu/gpu_memory_tracking.h" |
| 18 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
| 19 #include "content/common/gpu/gpu_watchdog.h" | 20 #include "content/common/gpu/gpu_watchdog.h" |
| 20 #include "content/common/gpu/image_transport_surface.h" | 21 #include "content/common/gpu/image_transport_surface.h" |
| 21 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 22 #include "content/common/gpu/sync_point_manager.h" | 23 #include "content/common/gpu/sync_point_manager.h" |
| 23 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
| 24 #include "gpu/command_buffer/common/constants.h" | 25 #include "gpu/command_buffer/common/constants.h" |
| 25 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 26 #include "gpu/command_buffer/service/memory_tracking.h" | 27 #include "gpu/command_buffer/service/memory_tracking.h" |
| 27 #include "net/disk_cache/hash.h" | 28 #include "net/disk_cache/hash.h" |
| 28 #include "ui/gl/gl_bindings.h" | 29 #include "ui/gl/gl_bindings.h" |
| 29 #include "ui/gl/gl_switches.h" | 30 #include "ui/gl/gl_switches.h" |
| 30 | 31 |
| 31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 32 #include "content/public/common/sandbox_init.h" | 33 #include "content/public/common/sandbox_init.h" |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 // The GpuCommandBufferMemoryTracker class provides a bridge between the | 38 // The GpuCommandBufferMemoryTracker class provides a bridge between the |
| 38 // ContextGroup's memory type managers and the GpuMemoryManager class. | 39 // ContextGroup's memory type managers and the GpuMemoryManager class. |
| 39 class GpuCommandBufferMemoryTracker : public gpu::gles2::MemoryTracker { | 40 class GpuCommandBufferMemoryTracker : public gpu::gles2::MemoryTracker { |
| 40 public: | 41 public: |
| 41 GpuCommandBufferMemoryTracker(GpuMemoryManager* gpu_memory_manager) | 42 GpuCommandBufferMemoryTracker(GpuChannel* channel) { |
| 42 : gpu_memory_manager_(gpu_memory_manager) {} | 43 gpu_memory_manager_tracking_group_ = new GpuMemoryTrackingGroup( |
| 44 channel->renderer_pid(), |
| 45 channel->gpu_channel_manager()->gpu_memory_manager()); |
| 46 } |
| 47 |
| 43 void TrackMemoryAllocatedChange(size_t old_size, size_t new_size) { | 48 void TrackMemoryAllocatedChange(size_t old_size, size_t new_size) { |
| 44 gpu_memory_manager_->TrackMemoryAllocatedChange(old_size, new_size); | 49 gpu_memory_manager_tracking_group_->TrackMemoryAllocatedChange( |
| 50 old_size, new_size); |
| 45 } | 51 } |
| 46 | 52 |
| 47 private: | 53 private: |
| 48 ~GpuCommandBufferMemoryTracker() {} | 54 ~GpuCommandBufferMemoryTracker() { |
| 49 GpuMemoryManager* gpu_memory_manager_; | 55 delete gpu_memory_manager_tracking_group_; |
| 56 } |
| 57 GpuMemoryTrackingGroup* gpu_memory_manager_tracking_group_; |
| 50 | 58 |
| 51 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); | 59 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); |
| 52 }; | 60 }; |
| 53 | 61 |
| 54 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the | 62 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the |
| 55 // url_hash matches. | 63 // url_hash matches. |
| 56 void FastSetActiveURL(const GURL& url, size_t url_hash) { | 64 void FastSetActiveURL(const GURL& url, size_t url_hash) { |
| 57 // Leave the previously set URL in the empty case -- empty URLs are given by | 65 // Leave the previously set URL in the empty case -- empty URLs are given by |
| 58 // WebKitPlatformSupportImpl::createOffscreenGraphicsContext3D. Hopefully the | 66 // WebKitPlatformSupportImpl::createOffscreenGraphicsContext3D. Hopefully the |
| 59 // onscreen context URL was set previously and will show up even when a crash | 67 // onscreen context URL was set previously and will show up even when a crash |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 sync_point_wait_count_(0), | 123 sync_point_wait_count_(0), |
| 116 delayed_work_scheduled_(false), | 124 delayed_work_scheduled_(false), |
| 117 active_url_(active_url) { | 125 active_url_(active_url) { |
| 118 active_url_hash_ = | 126 active_url_hash_ = |
| 119 disk_cache::Hash(active_url.possibly_invalid_spec()); | 127 disk_cache::Hash(active_url.possibly_invalid_spec()); |
| 120 FastSetActiveURL(active_url_, active_url_hash_); | 128 FastSetActiveURL(active_url_, active_url_hash_); |
| 121 if (share_group) { | 129 if (share_group) { |
| 122 context_group_ = share_group->context_group_; | 130 context_group_ = share_group->context_group_; |
| 123 } else { | 131 } else { |
| 124 context_group_ = new gpu::gles2::ContextGroup( | 132 context_group_ = new gpu::gles2::ContextGroup( |
| 125 mailbox_manager, | 133 mailbox_manager, |
| 126 new GpuCommandBufferMemoryTracker( | 134 new GpuCommandBufferMemoryTracker(channel), |
| 127 channel->gpu_channel_manager()->gpu_memory_manager()), | 135 true); |
| 128 true); | |
| 129 } | 136 } |
| 130 if (surface_id != 0) | 137 if (surface_id != 0) |
| 131 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( | 138 surface_state_.reset(new GpuCommandBufferStubBase::SurfaceState( |
| 132 surface_id, true, base::TimeTicks::Now())); | 139 surface_id, true, base::TimeTicks::Now())); |
| 133 if (handle_.sync_point) | 140 if (handle_.sync_point) |
| 134 OnWaitSyncPoint(handle_.sync_point); | 141 OnWaitSyncPoint(handle_.sync_point); |
| 135 } | 142 } |
| 136 | 143 |
| 137 GpuCommandBufferStub::~GpuCommandBufferStub() { | 144 GpuCommandBufferStub::~GpuCommandBufferStub() { |
| 138 Destroy(); | 145 Destroy(); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 const GpuMemoryAllocation& allocation) { | 832 const GpuMemoryAllocation& allocation) { |
| 826 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); | 833 Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); |
| 827 // This can be called outside of OnMessageReceived, so the context needs to be | 834 // This can be called outside of OnMessageReceived, so the context needs to be |
| 828 // made current before calling methods on the surface. | 835 // made current before calling methods on the surface. |
| 829 if (!surface_ || !MakeCurrent()) | 836 if (!surface_ || !MakeCurrent()) |
| 830 return; | 837 return; |
| 831 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); | 838 surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); |
| 832 } | 839 } |
| 833 | 840 |
| 834 #endif // defined(ENABLE_GPU) | 841 #endif // defined(ENABLE_GPU) |
| OLD | NEW |