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

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

Issue 7782038: Prepare WebGL contexts for resource sharing with the compositor context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add an additional feature to GLES2DecoderImpl that is used to force the context to obey WebGL fea... Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #ifndef GL_GLEXT_PROTOTYPES 10 #ifndef GL_GLEXT_PROTOTYPES
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 cached_width_(0), 583 cached_width_(0),
584 cached_height_(0), 584 cached_height_(0),
585 bound_fbo_(0) { 585 bound_fbo_(0) {
586 } 586 }
587 587
588 WebGraphicsContext3DInProcessCommandBufferImpl:: 588 WebGraphicsContext3DInProcessCommandBufferImpl::
589 ~WebGraphicsContext3DInProcessCommandBufferImpl() { 589 ~WebGraphicsContext3DInProcessCommandBufferImpl() {
590 g_all_shared_contexts.Pointer()->erase(this); 590 g_all_shared_contexts.Pointer()->erase(this);
591 } 591 }
592 592
593 // This string should only be passed for WebGL contexts. Nothing ELSE!!!
594 // Compositor contexts, Canvas2D contexts, Pepper Contexts, nor any other use of
595 // a context should not pass this string.
596 static const char* kWebGLPreferredGLExtensions =
597 "GL_OES_packed_depth_stencil "
598 "GL_OES_depth24 "
599 "GL_CHROMIUM_webglsl";
600
601 bool WebGraphicsContext3DInProcessCommandBufferImpl::initialize( 593 bool WebGraphicsContext3DInProcessCommandBufferImpl::initialize(
602 WebGraphicsContext3D::Attributes attributes, 594 WebGraphicsContext3D::Attributes attributes,
603 WebKit::WebView* web_view, 595 WebKit::WebView* web_view,
604 bool render_directly_to_web_view) { 596 bool render_directly_to_web_view) {
605 597
606 // Convert WebGL context creation attributes into GLInProcessContext / EGL 598 // Convert WebGL context creation attributes into GLInProcessContext / EGL
607 // size requests. 599 // size requests.
608 const int alpha_size = attributes.alpha ? 8 : 0; 600 const int alpha_size = attributes.alpha ? 8 : 0;
609 const int depth_size = attributes.depth ? 24 : 0; 601 const int depth_size = attributes.depth ? 24 : 0;
610 const int stencil_size = attributes.stencil ? 8 : 0; 602 const int stencil_size = attributes.stencil ? 8 : 0;
611 const int samples = attributes.antialias ? 4 : 0; 603 const int samples = attributes.antialias ? 4 : 0;
612 const int sample_buffers = attributes.antialias ? 1 : 0; 604 const int sample_buffers = attributes.antialias ? 1 : 0;
613 const int32 attribs[] = { 605 const int32 attribs[] = {
614 GLInProcessContext::ALPHA_SIZE, alpha_size, 606 GLInProcessContext::ALPHA_SIZE, alpha_size,
615 GLInProcessContext::DEPTH_SIZE, depth_size, 607 GLInProcessContext::DEPTH_SIZE, depth_size,
616 GLInProcessContext::STENCIL_SIZE, stencil_size, 608 GLInProcessContext::STENCIL_SIZE, stencil_size,
617 GLInProcessContext::SAMPLES, samples, 609 GLInProcessContext::SAMPLES, samples,
618 GLInProcessContext::SAMPLE_BUFFERS, sample_buffers, 610 GLInProcessContext::SAMPLE_BUFFERS, sample_buffers,
619 GLInProcessContext::NONE, 611 GLInProcessContext::NONE,
620 }; 612 };
621 613
622 const char* preferred_extensions = attributes.noExtensions ? 614 const char* preferred_extensions = "*";
623 kWebGLPreferredGLExtensions : "*";
624 615
625 GURL active_url; 616 GURL active_url;
626 if (web_view && web_view->mainFrame()) 617 if (web_view && web_view->mainFrame())
627 active_url = GURL(web_view->mainFrame()->document().url()); 618 active_url = GURL(web_view->mainFrame()->document().url());
628 619
629 GLInProcessContext* parent_context = NULL; 620 GLInProcessContext* parent_context = NULL;
630 if (!render_directly_to_web_view) { 621 if (!render_directly_to_web_view) {
631 WebKit::WebGraphicsContext3D* view_context = 622 WebKit::WebGraphicsContext3D* view_context =
632 web_view ? web_view->graphicsContext3D() : NULL; 623 web_view ? web_view->graphicsContext3D() : NULL;
633 if (view_context) { 624 if (view_context) {
(...skipping 15 matching lines...) Expand all
649 context_group ? context_group->context_ : NULL, 640 context_group ? context_group->context_ : NULL,
650 preferred_extensions, 641 preferred_extensions,
651 attribs, 642 attribs,
652 active_url); 643 active_url);
653 web_view_ = NULL; 644 web_view_ = NULL;
654 645
655 if (!context_) 646 if (!context_)
656 return false; 647 return false;
657 648
658 gl_ = context_->GetImplementation(); 649 gl_ = context_->GetImplementation();
650
651 if (gl_ && attributes.noExtensions)
652 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
653
659 context_->SetContextLostCallback( 654 context_->SetContextLostCallback(
660 NewCallback( 655 NewCallback(
661 this, 656 this,
662 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost)); 657 &WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost));
663 658
664 // Set attributes_ from created offscreen context. 659 // Set attributes_ from created offscreen context.
665 { 660 {
666 attributes_ = attributes; 661 attributes_ = attributes;
667 GLint alpha_bits = 0; 662 GLint alpha_bits = 0;
668 getIntegerv(GL_ALPHA_BITS, &alpha_bits); 663 getIntegerv(GL_ALPHA_BITS, &alpha_bits);
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; 1596 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB;
1602 if (context_lost_callback_) { 1597 if (context_lost_callback_) {
1603 context_lost_callback_->onContextLost(); 1598 context_lost_callback_->onContextLost();
1604 } 1599 }
1605 } 1600 }
1606 1601
1607 } // namespace gpu 1602 } // namespace gpu
1608 } // namespace webkit 1603 } // namespace webkit
1609 1604
1610 #endif // defined(ENABLE_GPU) 1605 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698