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

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

Issue 8430019: Make LazyInstance managed Locks leaky. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « ui/gfx/gl/gl_implementation_linux.cc ('k') | webkit/plugins/npapi/webplugin_ime_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Return the current error. 160 // Return the current error.
161 Error GetError(); 161 Error GetError();
162 162
163 // Return true if GPU process reported GLInProcessContext lost or there was a 163 // Return true if GPU process reported GLInProcessContext lost or there was a
164 // problem communicating with the GPU process. 164 // problem communicating with the GPU process.
165 bool IsCommandBufferContextLost(); 165 bool IsCommandBufferContextLost();
166 166
167 CommandBufferService* GetCommandBufferService(); 167 CommandBufferService* GetCommandBufferService();
168 168
169 private: 169 private:
170 GLInProcessContext(GLInProcessContext* parent); 170 explicit GLInProcessContext(GLInProcessContext* parent);
171 171
172 bool Initialize(bool onscreen, 172 bool Initialize(bool onscreen,
173 gfx::PluginWindowHandle render_surface, 173 gfx::PluginWindowHandle render_surface,
174 const gfx::Size& size, 174 const gfx::Size& size,
175 GLInProcessContext* context_group, 175 GLInProcessContext* context_group,
176 const char* allowed_extensions, 176 const char* allowed_extensions,
177 const int32* attrib_list, 177 const int32* attrib_list,
178 const GURL& active_url, 178 const GURL& active_url,
179 gfx::GpuPreference gpu_preference); 179 gfx::GpuPreference gpu_preference);
180 void Destroy(); 180 void Destroy();
(...skipping 21 matching lines...) Expand all
202 namespace { 202 namespace {
203 203
204 const int32 kCommandBufferSize = 1024 * 1024; 204 const int32 kCommandBufferSize = 1024 * 1024;
205 // TODO(kbr): make the transfer buffer size configurable via context 205 // TODO(kbr): make the transfer buffer size configurable via context
206 // creation attributes. 206 // creation attributes.
207 const int32 kTransferBufferSize = 1024 * 1024; 207 const int32 kTransferBufferSize = 1024 * 1024;
208 208
209 static base::LazyInstance< 209 static base::LazyInstance<
210 std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> > 210 std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> >
211 g_all_shared_contexts(base::LINKER_INITIALIZED); 211 g_all_shared_contexts(base::LINKER_INITIALIZED);
212 static base::LazyInstance<base::Lock> 212 static base::LazyInstance<base::Lock,
213 base::LeakyLazyInstanceTraits<base::Lock> >
213 g_all_shared_contexts_lock(base::LINKER_INITIALIZED); 214 g_all_shared_contexts_lock(base::LINKER_INITIALIZED);
214 215
215 // Singleton used to initialize and terminate the gles2 library. 216 // Singleton used to initialize and terminate the gles2 library.
216 class GLES2Initializer { 217 class GLES2Initializer {
217 public: 218 public:
218 GLES2Initializer() { 219 GLES2Initializer() {
219 gles2::Initialize(); 220 gles2::Initialize();
220 } 221 }
221 222
222 ~GLES2Initializer() { 223 ~GLES2Initializer() {
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 // framebuffer vertically before reading it back for compositing 831 // framebuffer vertically before reading it back for compositing
831 // via software. This code was quite complicated, used a lot of 832 // via software. This code was quite complicated, used a lot of
832 // GPU memory, and didn't provide an obvious speedup. Since this 833 // GPU memory, and didn't provide an obvious speedup. Since this
833 // vertical flip is only a temporary solution anyway until Chrome 834 // vertical flip is only a temporary solution anyway until Chrome
834 // is fully GPU composited, it wasn't worth the complexity. 835 // is fully GPU composited, it wasn't worth the complexity.
835 836
836 bool mustRestoreFBO = (bound_fbo_ != framebuffer); 837 bool mustRestoreFBO = (bound_fbo_ != framebuffer);
837 if (mustRestoreFBO) { 838 if (mustRestoreFBO) {
838 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer); 839 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer);
839 } 840 }
840 gl_->ReadPixels(0, 0, width, height, 841 gl_->ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
841 GL_RGBA, GL_UNSIGNED_BYTE, pixels);
842 842
843 // Swizzle red and blue channels 843 // Swizzle red and blue channels
844 // TODO(kbr): expose GL_BGRA as extension 844 // TODO(kbr): expose GL_BGRA as extension
845 for (size_t i = 0; i < buffer_size; i += 4) { 845 for (size_t i = 0; i < buffer_size; i += 4) {
846 std::swap(pixels[i], pixels[i + 2]); 846 std::swap(pixels[i], pixels[i + 2]);
847 } 847 }
848 848
849 if (mustRestoreFBO) { 849 if (mustRestoreFBO) {
850 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); 850 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_);
851 } 851 }
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 1630
1631 void WebGraphicsContext3DInProcessCommandBufferImpl::copyTextureToCompositor( 1631 void WebGraphicsContext3DInProcessCommandBufferImpl::copyTextureToCompositor(
1632 WebGLId texture, WebGLId parentTexture) { 1632 WebGLId texture, WebGLId parentTexture) {
1633 NOTIMPLEMENTED(); 1633 NOTIMPLEMENTED();
1634 } 1634 }
1635 1635
1636 void WebGraphicsContext3DInProcessCommandBufferImpl::OnSwapBuffersComplete() { 1636 void WebGraphicsContext3DInProcessCommandBufferImpl::OnSwapBuffersComplete() {
1637 } 1637 }
1638 1638
1639 void WebGraphicsContext3DInProcessCommandBufferImpl::setContextLostCallback( 1639 void WebGraphicsContext3DInProcessCommandBufferImpl::setContextLostCallback(
1640 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) 1640 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) {
1641 {
1642 context_lost_callback_ = cb; 1641 context_lost_callback_ = cb;
1643 } 1642 }
1644 1643
1645 WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl:: 1644 WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::
1646 getGraphicsResetStatusARB() { 1645 getGraphicsResetStatusARB() {
1647 return context_lost_reason_; 1646 return context_lost_reason_;
1648 } 1647 }
1649 1648
1650 #if WEBKIT_USING_SKIA 1649 #if WEBKIT_USING_SKIA
1651 GrGLInterface* WebGraphicsContext3DInProcessCommandBufferImpl:: 1650 GrGLInterface* WebGraphicsContext3DInProcessCommandBufferImpl::
1652 onCreateGrGLInterface() { 1651 onCreateGrGLInterface() {
1653 return webkit_glue::CreateCommandBufferSkiaGLBinding(); 1652 return webkit_glue::CreateCommandBufferSkiaGLBinding();
1654 } 1653 }
1655 #endif 1654 #endif
1656 1655
1657 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { 1656 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
1658 // TODO(kbr): improve the precision here. 1657 // TODO(kbr): improve the precision here.
1659 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; 1658 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB;
1660 if (context_lost_callback_) { 1659 if (context_lost_callback_) {
1661 context_lost_callback_->onContextLost(); 1660 context_lost_callback_->onContextLost();
1662 } 1661 }
1663 } 1662 }
1664 1663
1665 } // namespace gpu 1664 } // namespace gpu
1666 } // namespace webkit 1665 } // namespace webkit
1667 1666
1668 #endif // defined(ENABLE_GPU) 1667 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « ui/gfx/gl/gl_implementation_linux.cc ('k') | webkit/plugins/npapi/webplugin_ime_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698