| 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 "content/common/gpu/gpu_command_buffer_stub.h" | 5 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // stubs to process some work, or else the timing of the fences could | 127 // stubs to process some work, or else the timing of the fences could |
| 128 // allow a pattern of alternating fast and slow frames to occur. | 128 // allow a pattern of alternating fast and slow frames to occur. |
| 129 const int64_t kHandleMoreWorkPeriodMs = 2; | 129 const int64_t kHandleMoreWorkPeriodMs = 2; |
| 130 const int64_t kHandleMoreWorkPeriodBusyMs = 1; | 130 const int64_t kHandleMoreWorkPeriodBusyMs = 1; |
| 131 | 131 |
| 132 // Prevents idle work from being starved. | 132 // Prevents idle work from being starved. |
| 133 const int64_t kMaxTimeSinceIdleMs = 10; | 133 const int64_t kMaxTimeSinceIdleMs = 10; |
| 134 | 134 |
| 135 class DevToolsChannelData : public base::trace_event::ConvertableToTraceFormat { | 135 class DevToolsChannelData : public base::trace_event::ConvertableToTraceFormat { |
| 136 public: | 136 public: |
| 137 static scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 137 static scoped_ptr<base::trace_event::ConvertableToTraceFormat> |
| 138 CreateForChannel(GpuChannel* channel); | 138 CreateForChannel(GpuChannel* channel); |
| 139 ~DevToolsChannelData() override {} |
| 139 | 140 |
| 140 void AppendAsTraceFormat(std::string* out) const override { | 141 void AppendAsTraceFormat(std::string* out) const override { |
| 141 std::string tmp; | 142 std::string tmp; |
| 142 base::JSONWriter::Write(*value_, &tmp); | 143 base::JSONWriter::Write(*value_, &tmp); |
| 143 *out += tmp; | 144 *out += tmp; |
| 144 } | 145 } |
| 145 | 146 |
| 146 private: | 147 private: |
| 147 explicit DevToolsChannelData(base::Value* value) : value_(value) {} | 148 explicit DevToolsChannelData(base::Value* value) : value_(value) {} |
| 148 ~DevToolsChannelData() override {} | |
| 149 scoped_ptr<base::Value> value_; | 149 scoped_ptr<base::Value> value_; |
| 150 DISALLOW_COPY_AND_ASSIGN(DevToolsChannelData); | 150 DISALLOW_COPY_AND_ASSIGN(DevToolsChannelData); |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 153 scoped_ptr<base::trace_event::ConvertableToTraceFormat> |
| 154 DevToolsChannelData::CreateForChannel(GpuChannel* channel) { | 154 DevToolsChannelData::CreateForChannel(GpuChannel* channel) { |
| 155 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); | 155 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); |
| 156 res->SetInteger("renderer_pid", channel->GetClientPID()); | 156 res->SetInteger("renderer_pid", channel->GetClientPID()); |
| 157 res->SetDouble("used_bytes", channel->GetMemoryUsage()); | 157 res->SetDouble("used_bytes", channel->GetMemoryUsage()); |
| 158 return new DevToolsChannelData(res.release()); | 158 return make_scoped_ptr(new DevToolsChannelData(res.release())); |
| 159 } | 159 } |
| 160 | 160 |
| 161 gpu::CommandBufferId GetCommandBufferID(int channel_id, int32_t route_id) { | 161 gpu::CommandBufferId GetCommandBufferID(int channel_id, int32_t route_id) { |
| 162 return gpu::CommandBufferId::FromUnsafeValue( | 162 return gpu::CommandBufferId::FromUnsafeValue( |
| 163 (static_cast<uint64_t>(channel_id) << 32) | route_id); | 163 (static_cast<uint64_t>(channel_id) << 32) | route_id); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace | 166 } // namespace |
| 167 | 167 |
| 168 GpuCommandBufferStub::GpuCommandBufferStub( | 168 GpuCommandBufferStub::GpuCommandBufferStub( |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 result)); | 1172 result)); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1175 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1176 base::TimeDelta interval) { | 1176 base::TimeDelta interval) { |
| 1177 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1177 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1178 interval)); | 1178 interval)); |
| 1179 } | 1179 } |
| 1180 | 1180 |
| 1181 } // namespace content | 1181 } // namespace content |
| OLD | NEW |