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

Side by Side Diff: ui/gl/gl_gl_api_implementation.cc

Issue 1129693004: Disabled extensions in bug list now automatically removes the extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 "ui/gl/gl_gl_api_implementation.h" 5 #include "ui/gl/gl_gl_api_implementation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 void RealGLApi::Initialize(DriverGL* driver) { 407 void RealGLApi::Initialize(DriverGL* driver) {
408 InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess()); 408 InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess());
409 } 409 }
410 410
411 void RealGLApi::InitializeWithCommandLine(DriverGL* driver, 411 void RealGLApi::InitializeWithCommandLine(DriverGL* driver,
412 base::CommandLine* command_line) { 412 base::CommandLine* command_line) {
413 DCHECK(command_line); 413 DCHECK(command_line);
414 InitializeBase(driver); 414 InitializeBase(driver);
415 415
416 DCHECK(filtered_exts_.empty() && filtered_exts_str_.empty());
417
418 const std::string disabled_extensions = command_line->GetSwitchValueASCII( 416 const std::string disabled_extensions = command_line->GetSwitchValueASCII(
419 switches::kDisableGLExtensions); 417 switches::kDisableGLExtensions);
420 if (!disabled_extensions.empty()) { 418 if (!disabled_extensions.empty()) {
421 std::vector<std::string> disabled_extensions_vec; 419 Tokenize(disabled_extensions, ", ;", &disabled_exts_);
422 Tokenize(disabled_extensions, ", ;", &disabled_extensions_vec);
423
424 // Fill in filtered_exts_ vector first.
425 if (gfx::GetGLImplementation() !=
426 gfx::kGLImplementationDesktopGLCoreProfile) {
427 const char* gl_extensions = reinterpret_cast<const char*>(
428 GLApiBase::glGetStringFn(GL_EXTENSIONS));
429 if (gl_extensions)
430 base::SplitString(gl_extensions, ' ', &filtered_exts_);
431 } else {
432 GLint num_extensions = 0;
433 GLApiBase::glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions);
434 for (GLint i = 0; i < num_extensions; ++i) {
435 const char* gl_extension = reinterpret_cast<const char*>(
436 GLApiBase::glGetStringiFn(GL_EXTENSIONS, i));
437 DCHECK(gl_extension != NULL);
438 filtered_exts_.push_back(gl_extension);
439 }
440 }
441
442 // Filter out extensions from the command line.
443 for (const std::string& disabled_ext : disabled_extensions_vec) {
444 filtered_exts_.erase(std::remove(filtered_exts_.begin(),
445 filtered_exts_.end(),
446 disabled_ext),
447 filtered_exts_.end());
448 }
449
450 // Construct filtered extensions string for GL_EXTENSIONS string lookups.
451 filtered_exts_str_ = JoinString(filtered_exts_, " ");
452 } 420 }
453 } 421 }
454 422
455 void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { 423 void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) {
424 InitializeFilteredExtensions();
no sievers 2015/05/15 18:31:51 Why this change and make this initialization lazy
no sievers 2015/05/15 23:58:56 Still wondering about this change.
David Yen 2015/05/16 00:01:31 Sorry, I wrote about it in my first message. I had
no sievers 2015/05/16 00:17:19 Can you do it from InitializeCustomDynamicBindings
David Yen 2015/05/18 17:08:48 InitializeCustomDynamicBindings() is a DriverGL fu
no sievers 2015/05/18 18:19:32 Can you call g_real_gl->InitializeWithContext() or
David Yen 2015/05/18 18:23:37 I'll try the g_real_gl method. Virtual contexts w
456 if (!filtered_exts_.empty() && pname == GL_NUM_EXTENSIONS) { 425 if (!filtered_exts_.empty() && pname == GL_NUM_EXTENSIONS) {
457 *params = static_cast<GLint>(filtered_exts_.size()); 426 *params = static_cast<GLint>(filtered_exts_.size());
458 } else { 427 } else {
459 GLApiBase::glGetIntegervFn(pname, params); 428 GLApiBase::glGetIntegervFn(pname, params);
460 } 429 }
461 } 430 }
462 431
463 const GLubyte* RealGLApi::glGetStringFn(GLenum name) { 432 const GLubyte* RealGLApi::glGetStringFn(GLenum name) {
433 InitializeFilteredExtensions();
464 if (!filtered_exts_.empty() && name == GL_EXTENSIONS) { 434 if (!filtered_exts_.empty() && name == GL_EXTENSIONS) {
465 return reinterpret_cast<const GLubyte*>(filtered_exts_str_.c_str()); 435 return reinterpret_cast<const GLubyte*>(filtered_exts_str_.c_str());
466 } 436 }
467 return GLApiBase::glGetStringFn(name); 437 return GLApiBase::glGetStringFn(name);
468 } 438 }
469 439
470 const GLubyte* RealGLApi::glGetStringiFn(GLenum name, GLuint index) { 440 const GLubyte* RealGLApi::glGetStringiFn(GLenum name, GLuint index) {
441 InitializeFilteredExtensions();
471 if (!filtered_exts_str_.empty() && name == GL_EXTENSIONS) { 442 if (!filtered_exts_str_.empty() && name == GL_EXTENSIONS) {
472 if (index >= filtered_exts_.size()) { 443 if (index >= filtered_exts_.size()) {
473 return NULL; 444 return NULL;
474 } 445 }
475 return reinterpret_cast<const GLubyte*>(filtered_exts_[index].c_str()); 446 return reinterpret_cast<const GLubyte*>(filtered_exts_[index].c_str());
476 } 447 }
477 return GLApiBase::glGetStringiFn(name, index); 448 return GLApiBase::glGetStringiFn(name, index);
478 } 449 }
479 450
480 void RealGLApi::glFlushFn() { 451 void RealGLApi::glFlushFn() {
481 GLApiBase::glFlushFn(); 452 GLApiBase::glFlushFn();
482 } 453 }
483 454
484 void RealGLApi::glFinishFn() { 455 void RealGLApi::glFinishFn() {
485 GLApiBase::glFinishFn(); 456 GLApiBase::glFinishFn();
486 } 457 }
487 458
459 void RealGLApi::InitializeFilteredExtensions() {
460 if (!disabled_exts_.empty() && filtered_exts_.empty()) {
461 DCHECK(filtered_exts_.empty() && filtered_exts_str_.empty());
462 // Fill in filtered_exts_ vector first.
463 if (gfx::GetGLImplementation() !=
464 gfx::kGLImplementationDesktopGLCoreProfile) {
465 const char* gl_extensions = reinterpret_cast<const char*>(
466 GLApiBase::glGetStringFn(GL_EXTENSIONS));
467 if (gl_extensions)
468 base::SplitString(gl_extensions, ' ', &filtered_exts_);
469 } else {
470 GLint num_extensions = 0;
471 GLApiBase::glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions);
472 for (GLint i = 0; i < num_extensions; ++i) {
473 const char* gl_extension = reinterpret_cast<const char*>(
474 GLApiBase::glGetStringiFn(GL_EXTENSIONS, i));
475 DCHECK(gl_extension != NULL);
476 filtered_exts_.push_back(gl_extension);
477 }
478 }
479
480 // Filter out extensions from the command line.
481 for (const std::string& disabled_ext : disabled_exts_) {
482 filtered_exts_.erase(std::remove(filtered_exts_.begin(),
483 filtered_exts_.end(),
484 disabled_ext),
485 filtered_exts_.end());
486 }
487
488 // Construct filtered extensions string for GL_EXTENSIONS string lookups.
489 filtered_exts_str_ = JoinString(filtered_exts_, " ");
490 }
491 }
492
488 TraceGLApi::~TraceGLApi() { 493 TraceGLApi::~TraceGLApi() {
489 } 494 }
490 495
491 NoContextGLApi::NoContextGLApi() { 496 NoContextGLApi::NoContextGLApi() {
492 } 497 }
493 498
494 NoContextGLApi::~NoContextGLApi() { 499 NoContextGLApi::~NoContextGLApi() {
495 } 500 }
496 501
497 VirtualGLApi::VirtualGLApi() 502 VirtualGLApi::VirtualGLApi()
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi() 607 ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi()
603 : old_gl_api_(GetCurrentGLApi()) { 608 : old_gl_api_(GetCurrentGLApi()) {
604 SetGLToRealGLApi(); 609 SetGLToRealGLApi();
605 } 610 }
606 611
607 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() { 612 ScopedSetGLToRealGLApi::~ScopedSetGLToRealGLApi() {
608 SetGLApi(old_gl_api_); 613 SetGLApi(old_gl_api_);
609 } 614 }
610 615
611 } // namespace gfx 616 } // namespace gfx
OLDNEW
« gpu/config/gpu_driver_bug_list_json.cc ('K') | « ui/gl/gl_gl_api_implementation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698