| 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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // The GpuCommandBufferMemoryTracker class provides a bridge between the | 61 // The GpuCommandBufferMemoryTracker class provides a bridge between the |
| 62 // ContextGroup's memory type managers and the GpuMemoryManager class. | 62 // ContextGroup's memory type managers and the GpuMemoryManager class. |
| 63 class GpuCommandBufferMemoryTracker : public gpu::gles2::MemoryTracker { | 63 class GpuCommandBufferMemoryTracker : public gpu::gles2::MemoryTracker { |
| 64 public: | 64 public: |
| 65 explicit GpuCommandBufferMemoryTracker(GpuChannel* channel) : | 65 explicit GpuCommandBufferMemoryTracker(GpuChannel* channel) : |
| 66 tracking_group_(channel->gpu_channel_manager()->gpu_memory_manager()-> | 66 tracking_group_(channel->gpu_channel_manager()->gpu_memory_manager()-> |
| 67 CreateTrackingGroup(channel->renderer_pid(), this)) { | 67 CreateTrackingGroup(channel->renderer_pid(), this)) { |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual void TrackMemoryAllocatedChange( | 70 void TrackMemoryAllocatedChange( |
| 71 size_t old_size, | 71 size_t old_size, |
| 72 size_t new_size, | 72 size_t new_size, |
| 73 gpu::gles2::MemoryTracker::Pool pool) override { | 73 gpu::gles2::MemoryTracker::Pool pool) override { |
| 74 tracking_group_->TrackMemoryAllocatedChange( | 74 tracking_group_->TrackMemoryAllocatedChange( |
| 75 old_size, new_size, pool); | 75 old_size, new_size, pool); |
| 76 } | 76 } |
| 77 | 77 |
| 78 virtual bool EnsureGPUMemoryAvailable(size_t size_needed) override { | 78 bool EnsureGPUMemoryAvailable(size_t size_needed) override { |
| 79 return tracking_group_->EnsureGPUMemoryAvailable(size_needed); | 79 return tracking_group_->EnsureGPUMemoryAvailable(size_needed); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 virtual ~GpuCommandBufferMemoryTracker() { | 83 ~GpuCommandBufferMemoryTracker() override {} |
| 84 } | |
| 85 scoped_ptr<GpuMemoryTrackingGroup> tracking_group_; | 84 scoped_ptr<GpuMemoryTrackingGroup> tracking_group_; |
| 86 | 85 |
| 87 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); | 86 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the | 89 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the |
| 91 // url_hash matches. | 90 // url_hash matches. |
| 92 void FastSetActiveURL(const GURL& url, size_t url_hash) { | 91 void FastSetActiveURL(const GURL& url, size_t url_hash) { |
| 93 // Leave the previously set URL in the empty case -- empty URLs are given by | 92 // Leave the previously set URL in the empty case -- empty URLs are given by |
| 94 // BlinkPlatformImpl::createOffscreenGraphicsContext3D. Hopefully the | 93 // BlinkPlatformImpl::createOffscreenGraphicsContext3D. Hopefully the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 const int64 kHandleMoreWorkPeriodBusyMs = 1; | 109 const int64 kHandleMoreWorkPeriodBusyMs = 1; |
| 111 | 110 |
| 112 // Prevents idle work from being starved. | 111 // Prevents idle work from being starved. |
| 113 const int64 kMaxTimeSinceIdleMs = 10; | 112 const int64 kMaxTimeSinceIdleMs = 10; |
| 114 | 113 |
| 115 class DevToolsChannelData : public base::debug::ConvertableToTraceFormat { | 114 class DevToolsChannelData : public base::debug::ConvertableToTraceFormat { |
| 116 public: | 115 public: |
| 117 static scoped_refptr<base::debug::ConvertableToTraceFormat> CreateForChannel( | 116 static scoped_refptr<base::debug::ConvertableToTraceFormat> CreateForChannel( |
| 118 GpuChannel* channel); | 117 GpuChannel* channel); |
| 119 | 118 |
| 120 virtual void AppendAsTraceFormat(std::string* out) const override { | 119 void AppendAsTraceFormat(std::string* out) const override { |
| 121 std::string tmp; | 120 std::string tmp; |
| 122 base::JSONWriter::Write(value_.get(), &tmp); | 121 base::JSONWriter::Write(value_.get(), &tmp); |
| 123 *out += tmp; | 122 *out += tmp; |
| 124 } | 123 } |
| 125 | 124 |
| 126 private: | 125 private: |
| 127 explicit DevToolsChannelData(base::Value* value) : value_(value) {} | 126 explicit DevToolsChannelData(base::Value* value) : value_(value) {} |
| 128 virtual ~DevToolsChannelData() {} | 127 ~DevToolsChannelData() override {} |
| 129 scoped_ptr<base::Value> value_; | 128 scoped_ptr<base::Value> value_; |
| 130 DISALLOW_COPY_AND_ASSIGN(DevToolsChannelData); | 129 DISALLOW_COPY_AND_ASSIGN(DevToolsChannelData); |
| 131 }; | 130 }; |
| 132 | 131 |
| 133 scoped_refptr<base::debug::ConvertableToTraceFormat> | 132 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 134 DevToolsChannelData::CreateForChannel(GpuChannel* channel) { | 133 DevToolsChannelData::CreateForChannel(GpuChannel* channel) { |
| 135 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); | 134 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); |
| 136 res->SetInteger("renderer_pid", channel->renderer_pid()); | 135 res->SetInteger("renderer_pid", channel->renderer_pid()); |
| 137 res->SetDouble("used_bytes", channel->GetMemoryUsage()); | 136 res->SetDouble("used_bytes", channel->GetMemoryUsage()); |
| 138 res->SetDouble("limit_bytes", | 137 res->SetDouble("limit_bytes", |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 uint64 GpuCommandBufferStub::GetMemoryUsage() const { | 1080 uint64 GpuCommandBufferStub::GetMemoryUsage() const { |
| 1082 return GetMemoryManager()->GetClientMemoryUsage(this); | 1081 return GetMemoryManager()->GetClientMemoryUsage(this); |
| 1083 } | 1082 } |
| 1084 | 1083 |
| 1085 void GpuCommandBufferStub::SwapBuffersCompleted( | 1084 void GpuCommandBufferStub::SwapBuffersCompleted( |
| 1086 const std::vector<ui::LatencyInfo>& latency_info) { | 1085 const std::vector<ui::LatencyInfo>& latency_info) { |
| 1087 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); | 1086 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); |
| 1088 } | 1087 } |
| 1089 | 1088 |
| 1090 } // namespace content | 1089 } // namespace content |
| OLD | NEW |