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

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc

Issue 23130004: Enforce a memory limit on MappedMemoryManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix another namespace error Created 7 years, 4 months 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
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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/GLES2/gl2.h"
8 #ifndef GL_GLEXT_PROTOTYPES 8 #ifndef GL_GLEXT_PROTOTYPES
9 #define GL_GLEXT_PROTOTYPES 1 9 #define GL_GLEXT_PROTOTYPES 1
10 #endif 10 #endif
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 cached_height_(0), 227 cached_height_(0),
228 weak_ptr_factory_(this), 228 weak_ptr_factory_(this),
229 initialized_(false), 229 initialized_(false),
230 gl_(NULL), 230 gl_(NULL),
231 frame_number_(0), 231 frame_number_(0),
232 bind_generates_resources_(false), 232 bind_generates_resources_(false),
233 use_echo_for_swap_ack_(true), 233 use_echo_for_swap_ack_(true),
234 command_buffer_size_(0), 234 command_buffer_size_(0),
235 start_transfer_buffer_size_(0), 235 start_transfer_buffer_size_(0),
236 min_transfer_buffer_size_(0), 236 min_transfer_buffer_size_(0),
237 max_transfer_buffer_size_(0) { 237 max_transfer_buffer_size_(0),
238 mapped_memory_limit_(gpu::gles2::GLES2Implementation::kNoLimit) {
238 #if (defined(OS_MACOSX) || defined(OS_WIN)) && !defined(USE_AURA) 239 #if (defined(OS_MACOSX) || defined(OS_WIN)) && !defined(USE_AURA)
239 // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path. 240 // Get ViewMsg_SwapBuffers_ACK from browser for single-threaded path.
240 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 241 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
241 use_echo_for_swap_ack_ = 242 use_echo_for_swap_ack_ =
242 command_line.HasSwitch(switches::kEnableThreadedCompositing); 243 command_line.HasSwitch(switches::kEnableThreadedCompositing);
243 #endif 244 #endif
244 } 245 }
245 246
246 WebGraphicsContext3DCommandBufferImpl:: 247 WebGraphicsContext3DCommandBufferImpl::
247 ~WebGraphicsContext3DCommandBufferImpl() { 248 ~WebGraphicsContext3DCommandBufferImpl() {
(...skipping 11 matching lines...) Expand all
259 bool WebGraphicsContext3DCommandBufferImpl::InitializeWithDefaultBufferSizes( 260 bool WebGraphicsContext3DCommandBufferImpl::InitializeWithDefaultBufferSizes(
260 const WebGraphicsContext3D::Attributes& attributes, 261 const WebGraphicsContext3D::Attributes& attributes,
261 bool bind_generates_resources, 262 bool bind_generates_resources,
262 CauseForGpuLaunch cause) { 263 CauseForGpuLaunch cause) {
263 return Initialize(attributes, 264 return Initialize(attributes,
264 bind_generates_resources, 265 bind_generates_resources,
265 cause, 266 cause,
266 kDefaultCommandBufferSize, 267 kDefaultCommandBufferSize,
267 kDefaultStartTransferBufferSize, 268 kDefaultStartTransferBufferSize,
268 kDefaultMinTransferBufferSize, 269 kDefaultMinTransferBufferSize,
269 kDefaultMaxTransferBufferSize); 270 kDefaultMaxTransferBufferSize,
271 gpu::gles2::GLES2Implementation::kNoLimit);
270 } 272 }
271 273
272 bool WebGraphicsContext3DCommandBufferImpl::Initialize( 274 bool WebGraphicsContext3DCommandBufferImpl::Initialize(
273 const WebGraphicsContext3D::Attributes& attributes, 275 const WebGraphicsContext3D::Attributes& attributes,
274 bool bind_generates_resources, 276 bool bind_generates_resources,
275 CauseForGpuLaunch cause, 277 CauseForGpuLaunch cause,
276 size_t command_buffer_size, 278 size_t command_buffer_size,
277 size_t start_transfer_buffer_size, 279 size_t start_transfer_buffer_size,
278 size_t min_transfer_buffer_size, 280 size_t min_transfer_buffer_size,
279 size_t max_transfer_buffer_size) { 281 size_t max_transfer_buffer_size,
282 size_t mapped_memory_limit) {
280 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize"); 283 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize");
281 284
282 attributes_ = attributes; 285 attributes_ = attributes;
283 bind_generates_resources_ = bind_generates_resources; 286 bind_generates_resources_ = bind_generates_resources;
284 DCHECK(!command_buffer_); 287 DCHECK(!command_buffer_);
285 288
286 if (!factory_) 289 if (!factory_)
287 return false; 290 return false;
288 291
289 if (attributes.preferDiscreteGPU) 292 if (attributes.preferDiscreteGPU)
290 gpu_preference_ = gfx::PreferDiscreteGpu; 293 gpu_preference_ = gfx::PreferDiscreteGpu;
291 294
292 host_ = factory_->EstablishGpuChannelSync(cause); 295 host_ = factory_->EstablishGpuChannelSync(cause);
293 if (!host_.get()) 296 if (!host_.get())
294 return false; 297 return false;
295 298
296 command_buffer_size_ = command_buffer_size; 299 command_buffer_size_ = command_buffer_size;
297 start_transfer_buffer_size_ = start_transfer_buffer_size; 300 start_transfer_buffer_size_ = start_transfer_buffer_size;
298 min_transfer_buffer_size_ = min_transfer_buffer_size; 301 min_transfer_buffer_size_ = min_transfer_buffer_size;
299 max_transfer_buffer_size_ = max_transfer_buffer_size; 302 max_transfer_buffer_size_ = max_transfer_buffer_size;
303 mapped_memory_limit_ = mapped_memory_limit;
300 304
301 return true; 305 return true;
302 } 306 }
303 307
304 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL( 308 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL(
305 const char* allowed_extensions) { 309 const char* allowed_extensions) {
306 if (initialized_) 310 if (initialized_)
307 return true; 311 return true;
308 312
309 if (initialize_failed_) 313 if (initialize_failed_)
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 477
474 if (attributes_.shareResources) { 478 if (attributes_.shareResources) {
475 // Don't add ourselves to the list before others can get to our ShareGroup. 479 // Don't add ourselves to the list before others can get to our ShareGroup.
476 g_all_shared_contexts.Pointer()->insert(this); 480 g_all_shared_contexts.Pointer()->insert(this);
477 lock.reset(); 481 lock.reset();
478 } 482 }
479 483
480 if (!real_gl_->Initialize( 484 if (!real_gl_->Initialize(
481 start_transfer_buffer_size_, 485 start_transfer_buffer_size_,
482 min_transfer_buffer_size_, 486 min_transfer_buffer_size_,
483 max_transfer_buffer_size_)) { 487 max_transfer_buffer_size_,
488 mapped_memory_limit_)) {
484 return false; 489 return false;
485 } 490 }
486 491
487 if (CommandLine::ForCurrentProcess()->HasSwitch( 492 if (CommandLine::ForCurrentProcess()->HasSwitch(
488 switches::kEnableGpuClientTracing)) { 493 switches::kEnableGpuClientTracing)) {
489 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(gl_)); 494 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(gl_));
490 gl_ = trace_gl_.get(); 495 gl_ = trace_gl_.get();
491 } 496 }
492 497
493 return true; 498 return true;
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 1591
1587 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( 1592 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage(
1588 const std::string& message, int id) { 1593 const std::string& message, int id) {
1589 if (error_message_callback_) { 1594 if (error_message_callback_) {
1590 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); 1595 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str());
1591 error_message_callback_->onErrorMessage(str, id); 1596 error_message_callback_->onErrorMessage(str, id);
1592 } 1597 }
1593 } 1598 }
1594 1599
1595 } // namespace content 1600 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698