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

Side by Side Diff: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 12908004: Lazy initialize WGC3DInProcessCommandBufferImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: return NULL instead of 0 Created 7 years, 9 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) 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 "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 5 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 // Create a GLInProcessContext that renders to an offscreen frame buffer. If 92 // Create a GLInProcessContext that renders to an offscreen frame buffer. If
93 // parent is not NULL, that GLInProcessContext can access a copy of the 93 // parent is not NULL, that GLInProcessContext can access a copy of the
94 // created GLInProcessContext's frame buffer that is updated every time 94 // created GLInProcessContext's frame buffer that is updated every time
95 // SwapBuffers is called. It is not as general as shared GLInProcessContexts 95 // SwapBuffers is called. It is not as general as shared GLInProcessContexts
96 // in other implementations of OpenGL. If parent is not NULL, it must be used 96 // in other implementations of OpenGL. If parent is not NULL, it must be used
97 // on the same thread as the parent. A child GLInProcessContext may not 97 // on the same thread as the parent. A child GLInProcessContext may not
98 // outlive its parent. attrib_list must be NULL or a NONE-terminated list of 98 // outlive its parent. attrib_list must be NULL or a NONE-terminated list of
99 // attribute/value pairs. 99 // attribute/value pairs.
100 static GLInProcessContext* CreateOffscreenContext( 100 static GLInProcessContext* CreateOffscreenContext(
101 GLInProcessContext* parent,
102 const gfx::Size& size, 101 const gfx::Size& size,
103 GLInProcessContext* context_group, 102 GLInProcessContext* context_group,
104 const char* allowed_extensions, 103 const char* allowed_extensions,
105 const int32* attrib_list, 104 const int32* attrib_list,
106 gfx::GpuPreference gpu_preference); 105 gfx::GpuPreference gpu_preference);
107 106
108 // For an offscreen frame buffer GLInProcessContext, return the texture ID 107 // For an offscreen frame buffer GLInProcessContext, return the texture ID
109 // with respect to the parent GLInProcessContext. Returns zero if 108 // with respect to the parent GLInProcessContext. Returns zero if
110 // GLInProcessContext does not have a parent. 109 // GLInProcessContext does not have a parent.
111 uint32 GetParentTextureId(); 110 uint32 GetParentTextureId();
(...skipping 26 matching lines...) Expand all
138 // Return the current error. 137 // Return the current error.
139 Error GetError(); 138 Error GetError();
140 139
141 // Return true if GPU process reported GLInProcessContext lost or there was a 140 // Return true if GPU process reported GLInProcessContext lost or there was a
142 // problem communicating with the GPU process. 141 // problem communicating with the GPU process.
143 bool IsCommandBufferContextLost(); 142 bool IsCommandBufferContextLost();
144 143
145 CommandBufferService* GetCommandBufferService(); 144 CommandBufferService* GetCommandBufferService();
146 145
147 private: 146 private:
148 explicit GLInProcessContext(GLInProcessContext* parent); 147 GLInProcessContext();
149 148
150 bool Initialize(const gfx::Size& size, 149 bool Initialize(const gfx::Size& size,
151 GLInProcessContext* context_group, 150 GLInProcessContext* context_group,
152 const char* allowed_extensions, 151 const char* allowed_extensions,
153 const int32* attrib_list, 152 const int32* attrib_list,
154 gfx::GpuPreference gpu_preference); 153 gfx::GpuPreference gpu_preference);
155 void Destroy(); 154 void Destroy();
156 155
157 void OnContextLost(); 156 void OnContextLost();
158 157
159 base::WeakPtr<GLInProcessContext> parent_;
160 base::Closure context_lost_callback_; 158 base::Closure context_lost_callback_;
161 uint32 parent_texture_id_;
162 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; 159 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
163 scoped_ptr<CommandBufferService> command_buffer_; 160 scoped_ptr<CommandBufferService> command_buffer_;
164 scoped_ptr< ::gpu::GpuScheduler> gpu_scheduler_; 161 scoped_ptr< ::gpu::GpuScheduler> gpu_scheduler_;
165 scoped_ptr< ::gpu::gles2::GLES2Decoder> decoder_; 162 scoped_ptr< ::gpu::gles2::GLES2Decoder> decoder_;
166 scoped_refptr<gfx::GLContext> context_; 163 scoped_refptr<gfx::GLContext> context_;
167 scoped_refptr<gfx::GLSurface> surface_; 164 scoped_refptr<gfx::GLSurface> surface_;
168 scoped_ptr<GLES2CmdHelper> gles2_helper_; 165 scoped_ptr<GLES2CmdHelper> gles2_helper_;
169 scoped_ptr<TransferBuffer> transfer_buffer_; 166 scoped_ptr<TransferBuffer> transfer_buffer_;
170 scoped_ptr<GLES2Implementation> gles2_implementation_; 167 scoped_ptr<GLES2Implementation> gles2_implementation_;
171 Error last_error_; 168 Error last_error_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 static base::LazyInstance<GLES2Initializer> g_gles2_initializer = 206 static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
210 LAZY_INSTANCE_INITIALIZER; 207 LAZY_INSTANCE_INITIALIZER;
211 208
212 } // namespace anonymous 209 } // namespace anonymous
213 210
214 GLInProcessContext::~GLInProcessContext() { 211 GLInProcessContext::~GLInProcessContext() {
215 Destroy(); 212 Destroy();
216 } 213 }
217 214
218 GLInProcessContext* GLInProcessContext::CreateOffscreenContext( 215 GLInProcessContext* GLInProcessContext::CreateOffscreenContext(
219 GLInProcessContext* parent,
220 const gfx::Size& size, 216 const gfx::Size& size,
221 GLInProcessContext* context_group, 217 GLInProcessContext* context_group,
222 const char* allowed_extensions, 218 const char* allowed_extensions,
223 const int32* attrib_list, 219 const int32* attrib_list,
224 gfx::GpuPreference gpu_preference) { 220 gfx::GpuPreference gpu_preference) {
225 scoped_ptr<GLInProcessContext> context(new GLInProcessContext(parent)); 221 scoped_ptr<GLInProcessContext> context(new GLInProcessContext);
226 if (!context->Initialize( 222 if (!context->Initialize(
227 size, 223 size,
228 context_group, 224 context_group,
229 allowed_extensions, 225 allowed_extensions,
230 attrib_list, 226 attrib_list,
231 gpu_preference)) 227 gpu_preference))
232 return NULL; 228 return NULL;
233 229
234 return context.release(); 230 return context.release();
235 } 231 }
(...skipping 16 matching lines...) Expand all
252 context_lost_ = true; 248 context_lost_ = true;
253 } 249 }
254 } 250 }
255 } 251 }
256 252
257 bool GLInProcessContext::GetBufferChanged(int32 transfer_buffer_id) { 253 bool GLInProcessContext::GetBufferChanged(int32 transfer_buffer_id) {
258 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); 254 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id);
259 } 255 }
260 256
261 uint32 GLInProcessContext::GetParentTextureId() { 257 uint32 GLInProcessContext::GetParentTextureId() {
262 return parent_texture_id_; 258 return NULL;
263 } 259 }
264 260
265 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { 261 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) {
266 uint32 texture = 0; 262 uint32 texture = 0;
267 gles2_implementation_->GenTextures(1, &texture); 263 gles2_implementation_->GenTextures(1, &texture);
268 gles2_implementation_->Flush(); 264 gles2_implementation_->Flush();
269 return texture; 265 return texture;
270 } 266 }
271 267
272 void GLInProcessContext::DeleteParentTexture(uint32 texture) { 268 void GLInProcessContext::DeleteParentTexture(uint32 texture) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 330
335 // TODO(gman): Remove This 331 // TODO(gman): Remove This
336 void GLInProcessContext::DisableShaderTranslation() { 332 void GLInProcessContext::DisableShaderTranslation() {
337 NOTREACHED(); 333 NOTREACHED();
338 } 334 }
339 335
340 GLES2Implementation* GLInProcessContext::GetImplementation() { 336 GLES2Implementation* GLInProcessContext::GetImplementation() {
341 return gles2_implementation_.get(); 337 return gles2_implementation_.get();
342 } 338 }
343 339
344 GLInProcessContext::GLInProcessContext(GLInProcessContext* parent) 340 GLInProcessContext::GLInProcessContext()
345 : parent_(parent ? 341 : last_error_(SUCCESS),
346 parent->AsWeakPtr() : base::WeakPtr<GLInProcessContext>()),
347 parent_texture_id_(0),
348 last_error_(SUCCESS),
349 context_lost_(false) { 342 context_lost_(false) {
350 } 343 }
351 344
352 bool GLInProcessContext::Initialize(const gfx::Size& size, 345 bool GLInProcessContext::Initialize(const gfx::Size& size,
353 GLInProcessContext* context_group, 346 GLInProcessContext* context_group,
354 const char* allowed_extensions, 347 const char* allowed_extensions,
355 const int32* attrib_list, 348 const int32* attrib_list,
356 gfx::GpuPreference gpu_preference) { 349 gfx::GpuPreference gpu_preference) {
357 // Use one share group for all contexts. 350 // Use one share group for all contexts.
358 CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group, 351 CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group,
359 (new gfx::GLShareGroup)); 352 (new gfx::GLShareGroup));
360 353
361 DCHECK(size.width() >= 0 && size.height() >= 0); 354 DCHECK(size.width() >= 0 && size.height() >= 0);
362 355
363 // Ensure the gles2 library is initialized first in a thread safe way. 356 // Ensure the gles2 library is initialized first in a thread safe way.
364 g_gles2_initializer.Get(); 357 g_gles2_initializer.Get();
365 358
366 // Allocate a frame buffer ID with respect to the parent.
367 if (parent_.get()) {
368 // Flush any remaining commands in the parent context to make sure the
369 // texture id accounting stays consistent.
370 int32 token = parent_->gles2_helper_->InsertToken();
371 parent_->gles2_helper_->WaitForToken(token);
372 parent_texture_id_ = parent_->gles2_implementation_->MakeTextureId();
373 }
374
375 std::vector<int32> attribs; 359 std::vector<int32> attribs;
376 while (attrib_list) { 360 while (attrib_list) {
377 int32 attrib = *attrib_list++; 361 int32 attrib = *attrib_list++;
378 switch (attrib) { 362 switch (attrib) {
379 // Known attributes 363 // Known attributes
380 case ALPHA_SIZE: 364 case ALPHA_SIZE:
381 case BLUE_SIZE: 365 case BLUE_SIZE:
382 case GREEN_SIZE: 366 case GREEN_SIZE:
383 case RED_SIZE: 367 case RED_SIZE:
384 case DEPTH_SIZE: 368 case DEPTH_SIZE:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 true, 442 true,
459 size, 443 size,
460 disallowed_features, 444 disallowed_features,
461 allowed_extensions, 445 allowed_extensions,
462 attribs)) { 446 attribs)) {
463 LOG(ERROR) << "Could not initialize decoder."; 447 LOG(ERROR) << "Could not initialize decoder.";
464 Destroy(); 448 Destroy();
465 return false; 449 return false;
466 } 450 }
467 451
468 if (!decoder_->SetParent(
469 parent_.get() ? parent_->decoder_.get() : NULL,
470 parent_texture_id_)) {
471 LOG(ERROR) << "Could not set parent.";
472 Destroy();
473 return false;
474 }
475
476 command_buffer_->SetPutOffsetChangeCallback( 452 command_buffer_->SetPutOffsetChangeCallback(
477 base::Bind(&GLInProcessContext::PumpCommands, base::Unretained(this))); 453 base::Bind(&GLInProcessContext::PumpCommands, base::Unretained(this)));
478 command_buffer_->SetGetBufferChangeCallback( 454 command_buffer_->SetGetBufferChangeCallback(
479 base::Bind( 455 base::Bind(
480 &GLInProcessContext::GetBufferChanged, base::Unretained(this))); 456 &GLInProcessContext::GetBufferChanged, base::Unretained(this)));
481 command_buffer_->SetParseErrorCallback( 457 command_buffer_->SetParseErrorCallback(
482 base::Bind(&GLInProcessContext::OnContextLost, base::Unretained(this))); 458 base::Bind(&GLInProcessContext::OnContextLost, base::Unretained(this)));
483 459
484 // Create the GLES2 helper, which writes the command buffer protocol. 460 // Create the GLES2 helper, which writes the command buffer protocol.
485 gles2_helper_.reset(new GLES2CmdHelper(command_buffer_.get())); 461 gles2_helper_.reset(new GLES2CmdHelper(command_buffer_.get()));
(...skipping 19 matching lines...) Expand all
505 kMaxTransferBufferSize)) { 481 kMaxTransferBufferSize)) {
506 return false; 482 return false;
507 } 483 }
508 484
509 return true; 485 return true;
510 } 486 }
511 487
512 void GLInProcessContext::Destroy() { 488 void GLInProcessContext::Destroy() {
513 bool context_lost = IsCommandBufferContextLost(); 489 bool context_lost = IsCommandBufferContextLost();
514 490
515 if (parent_.get() && parent_texture_id_ != 0) {
516 parent_->gles2_implementation_->FreeTextureId(parent_texture_id_);
517 parent_texture_id_ = 0;
518 }
519
520 if (gles2_implementation_.get()) { 491 if (gles2_implementation_.get()) {
521 // First flush the context to ensure that any pending frees of resources 492 // First flush the context to ensure that any pending frees of resources
522 // are completed. Otherwise, if this context is part of a share group, 493 // are completed. Otherwise, if this context is part of a share group,
523 // those resources might leak. Also, any remaining side effects of commands 494 // those resources might leak. Also, any remaining side effects of commands
524 // issued on this context might not be visible to other contexts in the 495 // issued on this context might not be visible to other contexts in the
525 // share group. 496 // share group.
526 gles2_implementation_->Flush(); 497 gles2_implementation_->Flush();
527 498
528 gles2_implementation_.reset(); 499 gles2_implementation_.reset();
529 } 500 }
530 501
531 transfer_buffer_.reset(); 502 transfer_buffer_.reset();
532 gles2_helper_.reset(); 503 gles2_helper_.reset();
533 command_buffer_.reset(); 504 command_buffer_.reset();
534 505
535 if (decoder_.get()) { 506 if (decoder_.get()) {
536 decoder_->Destroy(!context_lost); 507 decoder_->Destroy(!context_lost);
537 } 508 }
538 } 509 }
539 510
540 void GLInProcessContext::OnContextLost() { 511 void GLInProcessContext::OnContextLost() {
541 if (!context_lost_callback_.is_null()) 512 if (!context_lost_callback_.is_null())
542 context_lost_callback_.Run(); 513 context_lost_callback_.Run();
543 } 514 }
544 515
545 WebGraphicsContext3DInProcessCommandBufferImpl:: 516 WebGraphicsContext3DInProcessCommandBufferImpl::
546 WebGraphicsContext3DInProcessCommandBufferImpl() 517 WebGraphicsContext3DInProcessCommandBufferImpl(
547 : context_(NULL), 518 const WebKit::WebGraphicsContext3D::Attributes& attributes)
519 : initialized_(false),
520 initialize_failed_(false),
521 context_(NULL),
548 gl_(NULL), 522 gl_(NULL),
549 context_lost_callback_(NULL), 523 context_lost_callback_(NULL),
550 context_lost_reason_(GL_NO_ERROR), 524 context_lost_reason_(GL_NO_ERROR),
525 attributes_(attributes),
551 cached_width_(0), 526 cached_width_(0),
552 cached_height_(0), 527 cached_height_(0),
553 bound_fbo_(0) { 528 bound_fbo_(0) {
554 } 529 }
555 530
556 WebGraphicsContext3DInProcessCommandBufferImpl:: 531 WebGraphicsContext3DInProcessCommandBufferImpl::
557 ~WebGraphicsContext3DInProcessCommandBufferImpl() { 532 ~WebGraphicsContext3DInProcessCommandBufferImpl() {
558 base::AutoLock a(g_all_shared_contexts_lock.Get()); 533 base::AutoLock a(g_all_shared_contexts_lock.Get());
559 g_all_shared_contexts.Pointer()->erase(this); 534 g_all_shared_contexts.Pointer()->erase(this);
560 } 535 }
561 536
562 bool WebGraphicsContext3DInProcessCommandBufferImpl::Initialize( 537 bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
563 WebGraphicsContext3D::Attributes attributes, 538 if (initialized_)
564 WebKit::WebGraphicsContext3D* view_context) { 539 return true;
540
541 if (initialize_failed_)
542 return false;
543
565 // Convert WebGL context creation attributes into GLInProcessContext / EGL 544 // Convert WebGL context creation attributes into GLInProcessContext / EGL
566 // size requests. 545 // size requests.
567 const int alpha_size = attributes.alpha ? 8 : 0; 546 const int alpha_size = attributes_.alpha ? 8 : 0;
568 const int depth_size = attributes.depth ? 24 : 0; 547 const int depth_size = attributes_.depth ? 24 : 0;
569 const int stencil_size = attributes.stencil ? 8 : 0; 548 const int stencil_size = attributes_.stencil ? 8 : 0;
570 const int samples = attributes.antialias ? 4 : 0; 549 const int samples = attributes_.antialias ? 4 : 0;
571 const int sample_buffers = attributes.antialias ? 1 : 0; 550 const int sample_buffers = attributes_.antialias ? 1 : 0;
572 const int32 attribs[] = { 551 const int32 attribs[] = {
573 GLInProcessContext::ALPHA_SIZE, alpha_size, 552 GLInProcessContext::ALPHA_SIZE, alpha_size,
574 GLInProcessContext::DEPTH_SIZE, depth_size, 553 GLInProcessContext::DEPTH_SIZE, depth_size,
575 GLInProcessContext::STENCIL_SIZE, stencil_size, 554 GLInProcessContext::STENCIL_SIZE, stencil_size,
576 GLInProcessContext::SAMPLES, samples, 555 GLInProcessContext::SAMPLES, samples,
577 GLInProcessContext::SAMPLE_BUFFERS, sample_buffers, 556 GLInProcessContext::SAMPLE_BUFFERS, sample_buffers,
578 GLInProcessContext::NONE, 557 GLInProcessContext::NONE,
579 }; 558 };
580 559
581 const char* preferred_extensions = "*"; 560 const char* preferred_extensions = "*";
582 561
583 // TODO(kbr): More work will be needed in this implementation to 562 // TODO(kbr): More work will be needed in this implementation to
584 // properly support GPU switching. Like in the out-of-process 563 // properly support GPU switching. Like in the out-of-process
585 // command buffer implementation, all previously created contexts 564 // command buffer implementation, all previously created contexts
586 // will need to be lost either when the first context requesting the 565 // will need to be lost either when the first context requesting the
587 // discrete GPU is created, or the last one is destroyed. 566 // discrete GPU is created, or the last one is destroyed.
588 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 567 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
589 568
590 GLInProcessContext* parent_context = NULL;
591 if (view_context) {
592 WebGraphicsContext3DInProcessCommandBufferImpl* context_impl =
593 static_cast<WebGraphicsContext3DInProcessCommandBufferImpl*>(
594 view_context);
595 parent_context = context_impl->context_;
596 }
597
598 WebGraphicsContext3DInProcessCommandBufferImpl* context_group = NULL; 569 WebGraphicsContext3DInProcessCommandBufferImpl* context_group = NULL;
599 base::AutoLock lock(g_all_shared_contexts_lock.Get()); 570 base::AutoLock lock(g_all_shared_contexts_lock.Get());
600 if (attributes.shareResources) 571 if (attributes_.shareResources)
601 context_group = g_all_shared_contexts.Pointer()->empty() ? 572 context_group = g_all_shared_contexts.Pointer()->empty() ?
602 NULL : *g_all_shared_contexts.Pointer()->begin(); 573 NULL : *g_all_shared_contexts.Pointer()->begin();
603 574
604 context_ = GLInProcessContext::CreateOffscreenContext( 575 context_ = GLInProcessContext::CreateOffscreenContext(
605 parent_context,
606 gfx::Size(1, 1), 576 gfx::Size(1, 1),
607 context_group ? context_group->context_ : NULL, 577 context_group ? context_group->context_ : NULL,
608 preferred_extensions, 578 preferred_extensions,
609 attribs, 579 attribs,
610 gpu_preference); 580 gpu_preference);
611 581
612 if (!context_) 582 if (!context_) {
583 initialize_failed_ = true;
613 return false; 584 return false;
585 }
614 586
615 gl_ = context_->GetImplementation(); 587 gl_ = context_->GetImplementation();
616 588
617 if (gl_ && attributes.noExtensions) 589 if (gl_ && attributes_.noExtensions)
618 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); 590 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
619 591
620 context_->SetContextLostCallback( 592 context_->SetContextLostCallback(
621 base::Bind( 593 base::Bind(
622 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost, 594 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost,
623 base::Unretained(this))); 595 base::Unretained(this)));
624 596
625 // Set attributes_ from created offscreen context. 597 // Set attributes_ from created offscreen context.
626 { 598 {
627 attributes_ = attributes;
628 GLint alpha_bits = 0; 599 GLint alpha_bits = 0;
629 getIntegerv(GL_ALPHA_BITS, &alpha_bits); 600 getIntegerv(GL_ALPHA_BITS, &alpha_bits);
630 attributes_.alpha = alpha_bits > 0; 601 attributes_.alpha = alpha_bits > 0;
631 GLint depth_bits = 0; 602 GLint depth_bits = 0;
632 getIntegerv(GL_DEPTH_BITS, &depth_bits); 603 getIntegerv(GL_DEPTH_BITS, &depth_bits);
633 attributes_.depth = depth_bits > 0; 604 attributes_.depth = depth_bits > 0;
634 GLint stencil_bits = 0; 605 GLint stencil_bits = 0;
635 getIntegerv(GL_STENCIL_BITS, &stencil_bits); 606 getIntegerv(GL_STENCIL_BITS, &stencil_bits);
636 attributes_.stencil = stencil_bits > 0; 607 attributes_.stencil = stencil_bits > 0;
637 GLint sample_buffers = 0; 608 GLint sample_buffers = 0;
638 getIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers); 609 getIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers);
639 attributes_.antialias = sample_buffers > 0; 610 attributes_.antialias = sample_buffers > 0;
640 } 611 }
641 makeContextCurrent();
642 612
643 if (attributes.shareResources) 613 if (attributes_.shareResources)
644 g_all_shared_contexts.Pointer()->insert(this); 614 g_all_shared_contexts.Pointer()->insert(this);
645 615
616 initialized_ = false;
jamesr 2013/03/21 23:19:18 did you mean "initialized_ = true;" ?
646 return true; 617 return true;
647 } 618 }
648 619
649 bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() { 620 bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() {
621 if (!MaybeInitializeGL())
622 return false;
623
650 return GLInProcessContext::MakeCurrent(context_); 624 return GLInProcessContext::MakeCurrent(context_);
651 } 625 }
652 626
653 void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() { 627 void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() {
654 // NOTE: Comment in the line below to check for code that is not calling 628 // NOTE: Comment in the line below to check for code that is not calling
655 // eglMakeCurrent where appropriate. The issue is code using 629 // eglMakeCurrent where appropriate. The issue is code using
656 // WebGraphicsContext3D does not need to call makeContextCurrent. Code using 630 // WebGraphicsContext3D does not need to call makeContextCurrent. Code using
657 // direct OpenGL bindings needs to call the appropriate form of 631 // direct OpenGL bindings needs to call the appropriate form of
658 // eglMakeCurrent. If it doesn't it will be issuing commands on the wrong 632 // eglMakeCurrent. If it doesn't it will be issuing commands on the wrong
659 // context. Uncommenting the line below clears the current context so that 633 // context. Uncommenting the line below clears the current context so that
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*) 1658 DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*)
1685 DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM, 1659 DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM,
1686 WGC3Denum, const WGC3Dbyte*) 1660 WGC3Denum, const WGC3Dbyte*)
1687 DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM, 1661 DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM,
1688 WGC3Denum, const WGC3Dbyte*) 1662 WGC3Denum, const WGC3Dbyte*)
1689 1663
1690 DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT, 1664 DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT,
1691 WGC3Dsizei, const WGC3Denum*) 1665 WGC3Dsizei, const WGC3Denum*)
1692 } // namespace gpu 1666 } // namespace gpu
1693 } // namespace webkit 1667 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h ('k') | webkit/support/test_webkit_platform_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698