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

Side by Side Diff: cc/gl_renderer.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/gl_renderer.h" 7 #include "cc/gl_renderer.h"
8 8
9 #include "CCDamageTracker.h" 9 #include "CCDamageTracker.h"
10 #include "CCLayerQuad.h" 10 #include "CCLayerQuad.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 m_capabilities.usingAcceleratedPainting = true; 103 m_capabilities.usingAcceleratedPainting = true;
104 else 104 else
105 m_capabilities.usingAcceleratedPainting = false; 105 m_capabilities.usingAcceleratedPainting = false;
106 106
107 107
108 m_capabilities.contextHasCachedFrontBuffer = extensions.count("GL_CHROMIUM_f ront_buffer_cached"); 108 m_capabilities.contextHasCachedFrontBuffer = extensions.count("GL_CHROMIUM_f ront_buffer_cached");
109 109
110 m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensio ns.count("GL_CHROMIUM_post_sub_buffer"); 110 m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensio ns.count("GL_CHROMIUM_post_sub_buffer");
111 111
112 // Use the swapBuffers callback only with the threaded proxy. 112 // Use the swapBuffers callback only with the threaded proxy.
113 if (CCProxy::hasImplThread()) 113 if (m_proxy->hasImplThread())
114 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback"); 114 m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM _swapbuffers_complete_callback");
115 if (m_capabilities.usingSwapCompleteCallback) 115 if (m_capabilities.usingSwapCompleteCallback)
116 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); 116 m_context->setSwapBuffersCompleteCallbackCHROMIUM(this);
117 117
118 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity"); 118 m_capabilities.usingSetVisibility = extensions.count("GL_CHROMIUM_set_visibi lity");
119 119
120 if (extensions.count("GL_CHROMIUM_iosurface")) 120 if (extensions.count("GL_CHROMIUM_iosurface"))
121 DCHECK(extensions.count("GL_ARB_texture_rectangle")); 121 DCHECK(extensions.count("GL_ARB_texture_rectangle"));
122 122
123 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager"); 123 m_capabilities.usingGpuMemoryManager = extensions.count("GL_CHROMIUM_gpu_mem ory_manager");
(...skipping 12 matching lines...) Expand all
136 if (!initializeSharedObjects()) 136 if (!initializeSharedObjects())
137 return false; 137 return false;
138 138
139 // Make sure the viewport and context gets initialized, even if it is to zer o. 139 // Make sure the viewport and context gets initialized, even if it is to zer o.
140 viewportChanged(); 140 viewportChanged();
141 return true; 141 return true;
142 } 142 }
143 143
144 CCRendererGL::~CCRendererGL() 144 CCRendererGL::~CCRendererGL()
145 { 145 {
146 DCHECK(CCProxy::isImplThread()); 146 DCHECK(m_proxy->isImplThread());
147 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); 147 m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
148 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); 148 m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
149 m_context->setContextLostCallback(0); 149 m_context->setContextLostCallback(0);
150 cleanupSharedObjects(); 150 cleanupSharedObjects();
151 } 151 }
152 152
153 const RendererCapabilities& CCRendererGL::capabilities() const 153 const RendererCapabilities& CCRendererGL::capabilities() const
154 { 154 {
155 return m_capabilities; 155 return m_capabilities;
156 } 156 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 // The indices for the line are stored in the same array as the triangle ind ices. 330 // The indices for the line are stored in the same array as the triangle ind ices.
331 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short))); 331 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short)));
332 } 332 }
333 333
334 static inline SkBitmap applyFilters(CCRendererGL* renderer, const WebKit::WebFil terOperations& filters, CCScopedTexture* sourceTexture) 334 static inline SkBitmap applyFilters(CCRendererGL* renderer, const WebKit::WebFil terOperations& filters, CCScopedTexture* sourceTexture)
335 { 335 {
336 if (filters.isEmpty()) 336 if (filters.isEmpty())
337 return SkBitmap(); 337 return SkBitmap();
338 338
339 WebGraphicsContext3D* filterContext = CCProxy::hasImplThread() ? WebSharedGr aphicsContext3D::compositorThreadContext() : WebSharedGraphicsContext3D::mainThr eadContext(); 339 bool hasImplThread = renderer->resourceProvider()->proxy()->hasImplThread();
340 GrContext* filterGrContext = CCProxy::hasImplThread() ? WebSharedGraphicsCon text3D::compositorThreadGrContext() : WebSharedGraphicsContext3D::mainThreadGrCo ntext(); 340 WebGraphicsContext3D* filterContext = hasImplThread ? WebSharedGraphicsConte xt3D::compositorThreadContext() : WebSharedGraphicsContext3D::mainThreadContext( );
341 GrContext* filterGrContext = hasImplThread ? WebSharedGraphicsContext3D::com positorThreadGrContext() : WebSharedGraphicsContext3D::mainThreadGrContext();
341 342
342 if (!filterContext || !filterGrContext) 343 if (!filterContext || !filterGrContext)
343 return SkBitmap(); 344 return SkBitmap();
344 345
345 renderer->context()->flush(); 346 renderer->context()->flush();
346 347
347 CCResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sou rceTexture->id()); 348 CCResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sou rceTexture->id());
348 SkBitmap source = CCRenderSurfaceFilters::apply(filters, lock.textureId(), s ourceTexture->size(), filterContext, filterGrContext); 349 SkBitmap source = CCRenderSurfaceFilters::apply(filters, lock.textureId(), s ourceTexture->size(), filterContext, filterGrContext);
349 return source; 350 return source;
350 } 351 }
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 template<class Program> void set(Program* program) 865 template<class Program> void set(Program* program)
865 { 866 {
866 TextureProgramBinding::set(program); 867 TextureProgramBinding::set(program);
867 texTransformLocation = program->vertexShader().texTransformLocation(); 868 texTransformLocation = program->vertexShader().texTransformLocation();
868 } 869 }
869 int texTransformLocation; 870 int texTransformLocation;
870 }; 871 };
871 872
872 void CCRendererGL::drawTextureQuad(const DrawingFrame& frame, const CCTextureDra wQuad* quad) 873 void CCRendererGL::drawTextureQuad(const DrawingFrame& frame, const CCTextureDra wQuad* quad)
873 { 874 {
874 DCHECK(CCProxy::isImplThread()); 875 DCHECK(m_proxy->isImplThread());
875 876
876 TexTransformTextureProgramBinding binding; 877 TexTransformTextureProgramBinding binding;
877 if (quad->flipped()) 878 if (quad->flipped())
878 binding.set(textureProgramFlip()); 879 binding.set(textureProgramFlip());
879 else 880 else
880 binding.set(textureProgram()); 881 binding.set(textureProgram());
881 GLC(context(), context()->useProgram(binding.programId)); 882 GLC(context(), context()->useProgram(binding.programId));
882 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 883 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
883 const gfx::RectF& uvRect = quad->uvRect(); 884 const gfx::RectF& uvRect = quad->uvRect();
884 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); 885 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height()));
(...skipping 23 matching lines...) Expand all
908 909
909 setShaderOpacity(quad->opacity(), binding.alphaLocation); 910 setShaderOpacity(quad->opacity(), binding.alphaLocation);
910 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation); 911 drawQuadGeometry(frame, quad->quadTransform(), quad->quadRect(), binding.mat rixLocation);
911 912
912 if (!quad->premultipliedAlpha()) 913 if (!quad->premultipliedAlpha())
913 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 914 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
914 } 915 }
915 916
916 void CCRendererGL::drawIOSurfaceQuad(const DrawingFrame& frame, const CCIOSurfac eDrawQuad* quad) 917 void CCRendererGL::drawIOSurfaceQuad(const DrawingFrame& frame, const CCIOSurfac eDrawQuad* quad)
917 { 918 {
918 DCHECK(CCProxy::isImplThread()); 919 DCHECK(m_proxy->isImplThread());
919 TexTransformTextureProgramBinding binding; 920 TexTransformTextureProgramBinding binding;
920 binding.set(textureIOSurfaceProgram()); 921 binding.set(textureIOSurfaceProgram());
921 922
922 GLC(context(), context()->useProgram(binding.programId)); 923 GLC(context(), context()->useProgram(binding.programId));
923 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); 924 GLC(context(), context()->uniform1i(binding.samplerLocation, 0));
924 if (quad->orientation() == CCIOSurfaceDrawQuad::Flipped) 925 if (quad->orientation() == CCIOSurfaceDrawQuad::Flipped)
925 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0)); 926 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua d->ioSurfaceSize().height(), quad->ioSurfaceSize().width(), quad->ioSurfaceSize( ).height() * -1.0));
926 else 927 else
927 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height())); 928 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->ioSurfaceSize().width(), quad->ioSurfaceSize().height()));
928 929
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 } 1052 }
1052 1053
1053 void CCRendererGL::onSwapBuffersComplete() 1054 void CCRendererGL::onSwapBuffersComplete()
1054 { 1055 {
1055 m_client->onSwapBuffersComplete(); 1056 m_client->onSwapBuffersComplete();
1056 } 1057 }
1057 1058
1058 void CCRendererGL::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocat ion) 1059 void CCRendererGL::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocat ion)
1059 { 1060 {
1060 // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread. 1061 // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread.
1061 if (!CCProxy::hasImplThread()) { 1062 if (!m_proxy->hasImplThread()) {
1062 DCHECK(CCProxy::isMainThread()); 1063 DCHECK(m_proxy->isMainThread());
1063 DebugScopedSetImplThread impl; 1064 DebugScopedSetImplThread impl;
1064 onMemoryAllocationChangedOnImplThread(allocation); 1065 onMemoryAllocationChangedOnImplThread(allocation);
1065 } else { 1066 } else {
1066 DCHECK(CCProxy::isImplThread()); 1067 DCHECK(m_proxy->isImplThread());
1067 onMemoryAllocationChangedOnImplThread(allocation); 1068 onMemoryAllocationChangedOnImplThread(allocation);
1068 } 1069 }
1069 } 1070 }
1070 1071
1071 void CCRendererGL::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemo ryAllocation allocation) 1072 void CCRendererGL::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemo ryAllocation allocation)
1072 { 1073 {
1073 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer; 1074 m_discardFramebufferWhenNotVisible = !allocation.suggestHaveBackbuffer;
1074 // Just ignore the memory manager when it says to set the limit to zero 1075 // Just ignore the memory manager when it says to set the limit to zero
1075 // bytes. This will happen when the memory manager thinks that the renderer 1076 // bytes. This will happen when the memory manager thinks that the renderer
1076 // is not visible (which the renderer knows better). 1077 // is not visible (which the renderer knows better).
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 1514
1514 releaseRenderPassTextures(); 1515 releaseRenderPassTextures();
1515 } 1516 }
1516 1517
1517 bool CCRendererGL::isContextLost() 1518 bool CCRendererGL::isContextLost()
1518 { 1519 {
1519 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1520 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1520 } 1521 }
1521 1522
1522 } // namespace cc 1523 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698