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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 551073: Call xglMakeCurrent for each command buffer to allow for multiple GL contexts... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <vector> 9 #include <vector>
10 #include <string> 10 #include <string>
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // Overridden from AsyncAPIInterface. 479 // Overridden from AsyncAPIInterface.
480 virtual ParseError DoCommand(unsigned int command, 480 virtual ParseError DoCommand(unsigned int command,
481 unsigned int arg_count, 481 unsigned int arg_count,
482 const void* args); 482 const void* args);
483 483
484 // Overridden from AsyncAPIInterface. 484 // Overridden from AsyncAPIInterface.
485 virtual const char* GetCommandName(unsigned int command_id) const; 485 virtual const char* GetCommandName(unsigned int command_id) const;
486 486
487 // Overridden from GLES2Decoder. 487 // Overridden from GLES2Decoder.
488 virtual bool Initialize(); 488 virtual bool Initialize();
489
490 // Overridden from GLES2Decoder.
491 virtual void Destroy(); 489 virtual void Destroy();
492 490 virtual bool MakeCurrent();
493 // Overridden from GLES2Decoder.
494 virtual uint32 GetServiceIdForTesting(uint32 client_id); 491 virtual uint32 GetServiceIdForTesting(uint32 client_id);
495 492
496 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used 493 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used
497 // on glDeleteBuffers so we can make sure the user does not try to render 494 // on glDeleteBuffers so we can make sure the user does not try to render
498 // with deleted buffers. 495 // with deleted buffers.
499 void RemoveBufferInfo(GLuint buffer_id); 496 void RemoveBufferInfo(GLuint buffer_id);
500 497
501 private: 498 private:
502 bool InitPlatformSpecific(); 499 bool InitPlatformSpecific();
503 bool InitGlew(); 500 bool InitGlew();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 current_program_(0), 683 current_program_(0),
687 #if defined(UNIT_TEST) 684 #if defined(UNIT_TEST)
688 #elif defined(OS_WIN) 685 #elif defined(OS_WIN)
689 device_context_(NULL), 686 device_context_(NULL),
690 gl_context_(NULL), 687 gl_context_(NULL),
691 #endif 688 #endif
692 anti_aliased_(false) { 689 anti_aliased_(false) {
693 } 690 }
694 691
695 bool GLES2DecoderImpl::Initialize() { 692 bool GLES2DecoderImpl::Initialize() {
693 bool success = false;
694
696 id_manager_.reset(new IdManager()); 695 id_manager_.reset(new IdManager());
697 buffer_manager_.reset(new BufferManager()); 696 buffer_manager_.reset(new BufferManager());
698 program_manager_.reset(new ProgramManager()); 697 program_manager_.reset(new ProgramManager());
699 698
700 if (!InitPlatformSpecific()) 699 if (InitPlatformSpecific()) {
701 return false; 700 if (MakeCurrent()) {
702 if (!InitGlew()) 701 if (InitGlew()) {
703 return false; 702 CHECK_GL_ERROR();
704 CHECK_GL_ERROR();
705 703
706 // Lookup GL things we need to know. 704 // Lookup GL things we need to know.
707 GLint value; 705 GLint value;
708 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value); 706 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
709 max_vertex_attribs_ = value; 707 max_vertex_attribs_ = value;
710 708
711 DCHECK_GE(max_vertex_attribs_, 8u); 709 DCHECK_GE(max_vertex_attribs_, 8u);
712 710
713 vertex_attrib_infos_.reset(new VertexAttribInfo[max_vertex_attribs_]); 711 vertex_attrib_infos_.reset(new VertexAttribInfo[max_vertex_attribs_]);
714 memset(vertex_attrib_infos_.get(), 0, 712 memset(vertex_attrib_infos_.get(), 0,
715 sizeof(vertex_attrib_infos_[0]) * max_vertex_attribs_); 713 sizeof(vertex_attrib_infos_[0]) * max_vertex_attribs_);
716 714
717 // glBindFramebuffer(0, 0); 715 // glBindFramebuffer(0, 0);
718 return true; 716 success = true;
717 }
718 }
719 }
720
721 return success;
719 } 722 }
720 723
721 namespace { 724 namespace {
722 725
723 #if defined(UNIT_TEST) 726 #if defined(UNIT_TEST)
724 #elif defined(OS_WIN) 727 #elif defined(OS_WIN)
725 728
726 const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = { 729 const PIXELFORMATDESCRIPTOR kPixelFormatDescriptor = {
727 sizeof(kPixelFormatDescriptor), // Size of structure. 730 sizeof(kPixelFormatDescriptor), // Size of structure.
728 1, // Default version. 731 1, // Default version.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 glDeleteRenderbuffersEXT(n, ids); 933 glDeleteRenderbuffersEXT(n, ids);
931 } 934 }
932 935
933 void GLDeleteTexturesHelper( 936 void GLDeleteTexturesHelper(
934 GLES2DecoderImpl*, GLsizei n, GLuint* ids) { 937 GLES2DecoderImpl*, GLsizei n, GLuint* ids) {
935 glDeleteTextures(n, ids); 938 glDeleteTextures(n, ids);
936 } 939 }
937 940
938 } // anonymous namespace 941 } // anonymous namespace
939 942
943 bool GLES2DecoderImpl::MakeCurrent() {
944 #if defined(UNIT_TEST)
945 return true;
946 #elif defined(OS_WIN)
947 if (::wglGetCurrentDC() == device_context_ &&
948 ::wglGetCurrentContext() == gl_context_) {
949 return true;
950 }
951 if (!::wglMakeCurrent(device_context_, gl_context_)) {
952 DLOG(ERROR) << "Unable to make gl context current.";
953 return false;
954 }
955 return true;
956 #elif defined(OS_LINUX)
957 return window()->MakeCurrent();
958 #else
959 NOTREACHED();
960 return false;
961 #endif
962 }
963
940 uint32 GLES2DecoderImpl::GetServiceIdForTesting(uint32 client_id) { 964 uint32 GLES2DecoderImpl::GetServiceIdForTesting(uint32 client_id) {
941 #if defined(UNIT_TEST) 965 #if defined(UNIT_TEST)
942 GLuint service_id; 966 GLuint service_id;
943 bool result = id_manager_->GetServiceId(client_id, &service_id); 967 bool result = id_manager_->GetServiceId(client_id, &service_id);
944 return result ? service_id : 0u; 968 return result ? service_id : 0u;
945 #else 969 #else
946 DCHECK(false); 970 DCHECK(false);
947 return 0u; 971 return 0u;
948 #endif 972 #endif
949 } 973 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 &kPixelFormatDescriptor)) { 1023 &kPixelFormatDescriptor)) {
1000 DLOG(ERROR) << "Unable to set the pixel format for GL context."; 1024 DLOG(ERROR) << "Unable to set the pixel format for GL context.";
1001 return false; 1025 return false;
1002 } 1026 }
1003 1027
1004 gl_context_ = ::wglCreateContext(device_context_); 1028 gl_context_ = ::wglCreateContext(device_context_);
1005 if (!gl_context_) { 1029 if (!gl_context_) {
1006 DLOG(ERROR) << "Failed to create GL context."; 1030 DLOG(ERROR) << "Failed to create GL context.";
1007 return false; 1031 return false;
1008 } 1032 }
1009
1010 if (!::wglMakeCurrent(device_context_, gl_context_)) {
1011 DLOG(ERROR) << "Unable to make gl context current.";
1012 return false;
1013 }
1014 #elif defined(OS_LINUX) 1033 #elif defined(OS_LINUX)
1015 DCHECK(window()); 1034 DCHECK(window());
1016 if (!window()->Initialize()) 1035 if (!window()->Initialize())
1017 return false; 1036 return false;
1018 if (!window()->MakeCurrent())
1019 return false;
1020 #endif 1037 #endif
1021 1038
1022 return true; 1039 return true;
1023 } 1040 }
1024 1041
1025 bool GLES2DecoderImpl::InitGlew() { 1042 bool GLES2DecoderImpl::InitGlew() {
1026 #if !defined(UNIT_TEST) 1043 #if !defined(UNIT_TEST)
1027 DLOG(INFO) << "Initializing GL and GLEW for GLES2Decoder."; 1044 DLOG(INFO) << "Initializing GL and GLEW for GLES2Decoder.";
1028 1045
1029 GLenum glew_error = glewInit(); 1046 GLenum glew_error = glewInit();
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 return parse_error::kParseNoError; 1877 return parse_error::kParseNoError;
1861 } 1878 }
1862 1879
1863 // Include the auto-generated part of this file. We split this because it means 1880 // Include the auto-generated part of this file. We split this because it means
1864 // we can easily edit the non-auto generated parts right here in this file 1881 // we can easily edit the non-auto generated parts right here in this file
1865 // instead of having to edit some template or the code generator. 1882 // instead of having to edit some template or the code generator.
1866 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 1883 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
1867 1884
1868 } // namespace gles2 1885 } // namespace gles2
1869 } // namespace gpu 1886 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698