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

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

Issue 7669072: Use 3D graphics context shareResources flag to decide whether a context should share resources. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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 | 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 }; 206 };
207 207
208 namespace { 208 namespace {
209 209
210 const int32 kCommandBufferSize = 1024 * 1024; 210 const int32 kCommandBufferSize = 1024 * 1024;
211 // TODO(kbr): make the transfer buffer size configurable via context 211 // TODO(kbr): make the transfer buffer size configurable via context
212 // creation attributes. 212 // creation attributes.
213 const int32 kTransferBufferSize = 1024 * 1024; 213 const int32 kTransferBufferSize = 1024 * 1024;
214 214
215 static base::LazyInstance< 215 static base::LazyInstance<
216 std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> > g_all_contexts( 216 std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> >
217 base::LINKER_INITIALIZED); 217 g_all_shared_contexts(base::LINKER_INITIALIZED);
218 218
219 // Singleton used to initialize and terminate the gles2 library. 219 // Singleton used to initialize and terminate the gles2 library.
220 class GLES2Initializer { 220 class GLES2Initializer {
221 public: 221 public:
222 GLES2Initializer() { 222 GLES2Initializer() {
223 gles2::Initialize(); 223 gles2::Initialize();
224 } 224 }
225 225
226 ~GLES2Initializer() { 226 ~GLES2Initializer() {
227 gles2::Terminate(); 227 gles2::Terminate();
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 #endif // defined(OS_MACOSX) 602 #endif // defined(OS_MACOSX)
603 context_lost_callback_(0), 603 context_lost_callback_(0),
604 context_lost_reason_(GL_NO_ERROR), 604 context_lost_reason_(GL_NO_ERROR),
605 cached_width_(0), 605 cached_width_(0),
606 cached_height_(0), 606 cached_height_(0),
607 bound_fbo_(0) { 607 bound_fbo_(0) {
608 } 608 }
609 609
610 WebGraphicsContext3DInProcessCommandBufferImpl:: 610 WebGraphicsContext3DInProcessCommandBufferImpl::
611 ~WebGraphicsContext3DInProcessCommandBufferImpl() { 611 ~WebGraphicsContext3DInProcessCommandBufferImpl() {
612 g_all_contexts.Pointer()->erase(this); 612 g_all_shared_contexts.Pointer()->erase(this);
613 } 613 }
614 614
615 // This string should only be passed for WebGL contexts. Nothing ELSE!!! 615 // This string should only be passed for WebGL contexts. Nothing ELSE!!!
616 // Compositor contexts, Canvas2D contexts, Pepper Contexts, nor any other use of 616 // Compositor contexts, Canvas2D contexts, Pepper Contexts, nor any other use of
617 // a context should not pass this string. 617 // a context should not pass this string.
618 static const char* kWebGLPreferredGLExtensions = 618 static const char* kWebGLPreferredGLExtensions =
619 "GL_OES_packed_depth_stencil " 619 "GL_OES_packed_depth_stencil "
620 "GL_OES_depth24 " 620 "GL_OES_depth24 "
621 "GL_CHROMIUM_webglsl"; 621 "GL_CHROMIUM_webglsl";
622 622
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 WebKit::WebGraphicsContext3D* view_context = 654 WebKit::WebGraphicsContext3D* view_context =
655 web_view ? web_view->graphicsContext3D() : NULL; 655 web_view ? web_view->graphicsContext3D() : NULL;
656 if (view_context) { 656 if (view_context) {
657 WebGraphicsContext3DInProcessCommandBufferImpl* context_impl = 657 WebGraphicsContext3DInProcessCommandBufferImpl* context_impl =
658 static_cast<WebGraphicsContext3DInProcessCommandBufferImpl*>( 658 static_cast<WebGraphicsContext3DInProcessCommandBufferImpl*>(
659 view_context); 659 view_context);
660 parent_context = context_impl->context_; 660 parent_context = context_impl->context_;
661 } 661 }
662 } 662 }
663 663
664 // HACK: Assume this is a WebGL context by looking for the noExtensions
665 // attribute. WebGL contexts must not go in the share group because they
666 // rely on destruction of the context to clean up owned resources. Putting
667 // them in a share group would prevent this from happening.
668 WebGraphicsContext3DInProcessCommandBufferImpl* context_group = NULL; 664 WebGraphicsContext3DInProcessCommandBufferImpl* context_group = NULL;
669 if (!attributes.noExtensions) 665 if (attributes.shareResources)
670 context_group = g_all_contexts.Pointer()->empty() ? 666 context_group = g_all_shared_contexts.Pointer()->empty() ?
671 NULL : *g_all_contexts.Pointer()->begin(); 667 NULL : *g_all_shared_contexts.Pointer()->begin();
672 668
673 context_ = GLInProcessContext::CreateOffscreenContext( 669 context_ = GLInProcessContext::CreateOffscreenContext(
674 parent_context, 670 parent_context,
675 gfx::Size(1, 1), 671 gfx::Size(1, 1),
676 context_group ? context_group->context_ : NULL, 672 context_group ? context_group->context_ : NULL,
677 preferred_extensions, 673 preferred_extensions,
678 attribs, 674 attribs,
679 active_url); 675 active_url);
680 web_view_ = NULL; 676 web_view_ = NULL;
681 677
(...skipping 17 matching lines...) Expand all
699 attributes_.depth = depth_bits > 0; 695 attributes_.depth = depth_bits > 0;
700 GLint stencil_bits = 0; 696 GLint stencil_bits = 0;
701 getIntegerv(GL_STENCIL_BITS, &stencil_bits); 697 getIntegerv(GL_STENCIL_BITS, &stencil_bits);
702 attributes_.stencil = stencil_bits > 0; 698 attributes_.stencil = stencil_bits > 0;
703 GLint samples = 0; 699 GLint samples = 0;
704 getIntegerv(GL_SAMPLES, &samples); 700 getIntegerv(GL_SAMPLES, &samples);
705 attributes_.antialias = samples > 0; 701 attributes_.antialias = samples > 0;
706 } 702 }
707 makeContextCurrent(); 703 makeContextCurrent();
708 704
709 if (!attributes.noExtensions) 705 if (attributes.shareResources)
710 g_all_contexts.Pointer()->insert(this); 706 g_all_shared_contexts.Pointer()->insert(this);
711 707
712 return true; 708 return true;
713 } 709 }
714 710
715 bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() { 711 bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() {
716 return GLInProcessContext::MakeCurrent(context_); 712 return GLInProcessContext::MakeCurrent(context_);
717 } 713 }
718 714
719 void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() { 715 void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() {
720 // NOTE: Comment in the line below to check for code that is not calling 716 // NOTE: Comment in the line below to check for code that is not calling
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 if (context_lost_callback_) { 1628 if (context_lost_callback_) {
1633 context_lost_callback_->onContextLost(); 1629 context_lost_callback_->onContextLost();
1634 } 1630 }
1635 } 1631 }
1636 1632
1637 } // namespace gpu 1633 } // namespace gpu
1638 } // namespace webkit 1634 } // namespace webkit
1639 1635
1640 #endif // defined(ENABLE_GPU) 1636 #endif // defined(ENABLE_GPU)
1641 1637
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698