Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 1420533009: Cleanup GpuMemoryManager and helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_memory_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/hash.h" 8 #include "base/hash.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 ~DevToolsChannelData() override {} 142 ~DevToolsChannelData() override {}
143 scoped_ptr<base::Value> value_; 143 scoped_ptr<base::Value> value_;
144 DISALLOW_COPY_AND_ASSIGN(DevToolsChannelData); 144 DISALLOW_COPY_AND_ASSIGN(DevToolsChannelData);
145 }; 145 };
146 146
147 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 147 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
148 DevToolsChannelData::CreateForChannel(GpuChannel* channel) { 148 DevToolsChannelData::CreateForChannel(GpuChannel* channel) {
149 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); 149 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue);
150 res->SetInteger("renderer_pid", channel->GetClientPID()); 150 res->SetInteger("renderer_pid", channel->GetClientPID());
151 res->SetDouble("used_bytes", channel->GetMemoryUsage()); 151 res->SetDouble("used_bytes", channel->GetMemoryUsage());
152 res->SetDouble("limit_bytes",
153 channel->gpu_channel_manager()
154 ->gpu_memory_manager()
155 ->GetMaximumClientAllocation());
156 return new DevToolsChannelData(res.release()); 152 return new DevToolsChannelData(res.release());
157 } 153 }
158 154
159 void RunOnThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner, 155 void RunOnThread(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
160 const base::Closure& callback) { 156 const base::Closure& callback) {
161 if (task_runner->BelongsToCurrentThread()) { 157 if (task_runner->BelongsToCurrentThread()) {
162 callback.Run(); 158 callback.Run();
163 } else { 159 } else {
164 task_runner->PostTask(FROM_HERE, callback); 160 task_runner->PostTask(FROM_HERE, callback);
165 } 161 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 use_virtualized_gl_context_(false), 198 use_virtualized_gl_context_(false),
203 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)), 199 command_buffer_id_(GetCommandBufferID(channel->client_id(), route_id)),
204 stream_id_(stream_id), 200 stream_id_(stream_id),
205 route_id_(route_id), 201 route_id_(route_id),
206 offscreen_(offscreen), 202 offscreen_(offscreen),
207 last_flush_count_(0), 203 last_flush_count_(0),
208 watchdog_(watchdog), 204 watchdog_(watchdog),
209 waiting_for_sync_point_(false), 205 waiting_for_sync_point_(false),
210 previous_processed_num_(0), 206 previous_processed_num_(0),
211 preemption_flag_(preempt_by_flag), 207 preemption_flag_(preempt_by_flag),
212 active_url_(active_url), 208 active_url_(active_url) {
213 total_gpu_memory_(0) {
214 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec()); 209 active_url_hash_ = base::Hash(active_url.possibly_invalid_spec());
215 FastSetActiveURL(active_url_, active_url_hash_); 210 FastSetActiveURL(active_url_, active_url_hash_);
216 211
217 gpu::gles2::ContextCreationAttribHelper attrib_parser; 212 gpu::gles2::ContextCreationAttribHelper attrib_parser;
218 attrib_parser.Parse(requested_attribs_); 213 attrib_parser.Parse(requested_attribs_);
219 214
220 if (share_group) { 215 if (share_group) {
221 context_group_ = share_group->context_group_; 216 context_group_ = share_group->context_group_;
222 DCHECK(context_group_->bind_generates_resource() == 217 DCHECK(context_group_->bind_generates_resource() ==
223 attrib_parser.bind_generates_resource); 218 attrib_parser.bind_generates_resource);
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 LOG(ERROR) << "Failed to make context current."; 599 LOG(ERROR) << "Failed to make context current.";
605 OnInitializeFailed(reply_message); 600 OnInitializeFailed(reply_message);
606 return; 601 return;
607 } 602 }
608 603
609 if (!context->GetGLStateRestorer()) { 604 if (!context->GetGLStateRestorer()) {
610 context->SetGLStateRestorer( 605 context->SetGLStateRestorer(
611 new gpu::GLStateRestorerImpl(decoder_->AsWeakPtr())); 606 new gpu::GLStateRestorerImpl(decoder_->AsWeakPtr()));
612 } 607 }
613 608
614 if (!context->GetTotalGpuMemory(&total_gpu_memory_))
615 total_gpu_memory_ = 0;
616
617 if (!context_group_->has_program_cache() && 609 if (!context_group_->has_program_cache() &&
618 !context_group_->feature_info()->workarounds().disable_program_cache) { 610 !context_group_->feature_info()->workarounds().disable_program_cache) {
619 context_group_->set_program_cache( 611 context_group_->set_program_cache(
620 channel_->gpu_channel_manager()->program_cache()); 612 channel_->gpu_channel_manager()->program_cache());
621 } 613 }
622 614
623 // Initialize the decoder with either the view or pbuffer GLContext. 615 // Initialize the decoder with either the view or pbuffer GLContext.
624 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_, 616 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_,
625 disallowed_features_, requested_attribs_)) { 617 disallowed_features_, requested_attribs_)) {
626 DLOG(ERROR) << "Failed to initialize decoder."; 618 DLOG(ERROR) << "Failed to initialize decoder.";
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 void GpuCommandBufferStub::AddDestructionObserver( 1184 void GpuCommandBufferStub::AddDestructionObserver(
1193 DestructionObserver* observer) { 1185 DestructionObserver* observer) {
1194 destruction_observers_.AddObserver(observer); 1186 destruction_observers_.AddObserver(observer);
1195 } 1187 }
1196 1188
1197 void GpuCommandBufferStub::RemoveDestructionObserver( 1189 void GpuCommandBufferStub::RemoveDestructionObserver(
1198 DestructionObserver* observer) { 1190 DestructionObserver* observer) {
1199 destruction_observers_.RemoveObserver(observer); 1191 destruction_observers_.RemoveObserver(observer);
1200 } 1192 }
1201 1193
1202 bool GpuCommandBufferStub::GetTotalGpuMemory(uint64* bytes) {
1203 *bytes = total_gpu_memory_;
1204 return !!total_gpu_memory_;
1205 }
1206
1207 gfx::Size GpuCommandBufferStub::GetSurfaceSize() const {
1208 if (!surface_.get())
1209 return gfx::Size();
1210 return surface_->GetSize();
1211 }
1212
1213 const gpu::gles2::FeatureInfo* GpuCommandBufferStub::GetFeatureInfo() const { 1194 const gpu::gles2::FeatureInfo* GpuCommandBufferStub::GetFeatureInfo() const {
1214 return context_group_->feature_info(); 1195 return context_group_->feature_info();
1215 } 1196 }
1216 1197
1217 gpu::gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const { 1198 gpu::gles2::MemoryTracker* GpuCommandBufferStub::GetMemoryTracker() const {
1218 return context_group_->memory_tracker(); 1199 return context_group_->memory_tracker();
1219 } 1200 }
1220 1201
1221 void GpuCommandBufferStub::SuggestHaveFrontBuffer(
1222 bool suggest_have_frontbuffer) {
1223 // This can be called outside of OnMessageReceived, so the context needs
1224 // to be made current before calling methods on the surface.
1225 if (surface_.get() && MakeCurrent())
1226 surface_->SetFrontbufferAllocation(suggest_have_frontbuffer);
1227 }
1228
1229 bool GpuCommandBufferStub::CheckContextLost() { 1202 bool GpuCommandBufferStub::CheckContextLost() {
1230 DCHECK(command_buffer_); 1203 DCHECK(command_buffer_);
1231 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 1204 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
1232 bool was_lost = state.error == gpu::error::kLostContext; 1205 bool was_lost = state.error == gpu::error::kLostContext;
1233 1206
1234 if (was_lost) { 1207 if (was_lost) {
1235 bool was_lost_by_robustness = 1208 bool was_lost_by_robustness =
1236 decoder_ && decoder_->WasContextLostByRobustnessExtension(); 1209 decoder_ && decoder_->WasContextLostByRobustnessExtension();
1237 1210
1238 // Work around issues with recovery by allowing a new GPU process to launch. 1211 // Work around issues with recovery by allowing a new GPU process to launch.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 result)); 1254 result));
1282 } 1255 }
1283 1256
1284 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1257 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1285 base::TimeDelta interval) { 1258 base::TimeDelta interval) {
1286 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1259 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1287 interval)); 1260 interval));
1288 } 1261 }
1289 1262
1290 } // namespace content 1263 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_memory_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698