diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 19:48:47 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 19:48:47 +0000 |
commit | b375853a5b2305fe3cc689e2b3712bf42258ef4d (patch) | |
tree | ed1707a941a96624ba442f4360b736e5416a3158 /cc/gl_renderer.cc | |
parent | b2b06c4f160763133874468c5f6715afc8832e06 (diff) | |
download | chromium_src-b375853a5b2305fe3cc689e2b3712bf42258ef4d.zip chromium_src-b375853a5b2305fe3cc689e2b3712bf42258ef4d.tar.gz chromium_src-b375853a5b2305fe3cc689e2b3712bf42258ef4d.tar.bz2 |
Remove static thread pointers from CC
BUG=152904
Review URL: https://codereview.chromium.org/11232051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/gl_renderer.cc')
-rw-r--r-- | cc/gl_renderer.cc | 77 |
1 files changed, 30 insertions, 47 deletions
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index 6b78e04..4faa422 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -112,7 +112,7 @@ bool GLRenderer::initialize() m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensions.count("GL_CHROMIUM_post_sub_buffer"); // Use the swapBuffers callback only with the threaded proxy. - if (Proxy::hasImplThread()) + if (m_client->hasImplThread()) m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM_swapbuffers_complete_callback"); if (m_capabilities.usingSwapCompleteCallback) m_context->setSwapBuffersCompleteCallbackCHROMIUM(this); @@ -145,7 +145,6 @@ bool GLRenderer::initialize() GLRenderer::~GLRenderer() { - DCHECK(Proxy::isImplThread()); m_context->setSwapBuffersCompleteCallbackCHROMIUM(0); m_context->setMemoryAllocationChangedCallbackCHROMIUM(0); m_context->setContextLostCallback(0); @@ -343,29 +342,29 @@ void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short))); } -static WebGraphicsContext3D* getFilterContext() +static WebGraphicsContext3D* getFilterContext(bool hasImplThread) { - if (Proxy::hasImplThread()) + if (hasImplThread) return WebSharedGraphicsContext3D::compositorThreadContext(); else return WebSharedGraphicsContext3D::mainThreadContext(); } -static GrContext* getFilterGrContext() +static GrContext* getFilterGrContext(bool hasImplThread) { - if (Proxy::hasImplThread()) + if (hasImplThread) return WebSharedGraphicsContext3D::compositorThreadGrContext(); else return WebSharedGraphicsContext3D::mainThreadGrContext(); } -static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedTexture* sourceTexture) +static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedTexture* sourceTexture, bool hasImplThread) { if (filters.isEmpty()) return SkBitmap(); - WebGraphicsContext3D* filterContext = getFilterContext(); - GrContext* filterGrContext = getFilterGrContext(); + WebGraphicsContext3D* filterContext = getFilterContext(hasImplThread); + GrContext* filterGrContext = getFilterGrContext(hasImplThread); if (!filterContext || !filterGrContext) return SkBitmap(); @@ -377,13 +376,13 @@ static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte return source; } -static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedTexture* sourceTexture) +static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedTexture* sourceTexture, bool hasImplThread) { if (!filter) return SkBitmap(); - WebGraphicsContext3D* context3d = getFilterContext(); - GrContext* grContext = getFilterGrContext(); + WebGraphicsContext3D* context3d = getFilterContext(hasImplThread); + GrContext* grContext = getFilterGrContext(hasImplThread); if (!context3d || !grContext) return SkBitmap(); @@ -469,7 +468,7 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(DrawingFrame& frame, if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect)) return scoped_ptr<ScopedTexture>(); - SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get()); + SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread()); if (!filteredDeviceBackground.getTexture()) return scoped_ptr<ScopedTexture>(); @@ -524,9 +523,9 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua // Apply filters to the contents texture. SkBitmap filterBitmap; if (renderPass->filter()) { - filterBitmap = applyImageFilter(this, renderPass->filter(), contentsTexture); + filterBitmap = applyImageFilter(this, renderPass->filter(), contentsTexture, m_client->hasImplThread()); } else { - filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture); + filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture, m_client->hasImplThread()); } scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; unsigned contentsTextureId = 0; @@ -954,8 +953,6 @@ struct TexTransformTextureProgramBinding : TextureProgramBinding { void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQuad* quad) { - DCHECK(Proxy::isImplThread()); - TexTransformTextureProgramBinding binding; if (quad->flipped()) binding.set(textureProgramFlip()); @@ -998,7 +995,6 @@ void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDrawQuad* quad) { - DCHECK(Proxy::isImplThread()); TexTransformTextureProgramBinding binding; binding.set(textureIOSurfaceProgram()); @@ -1140,35 +1136,6 @@ void GLRenderer::onSwapBuffersComplete() void GLRenderer::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocation) { - // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread. - if (!Proxy::hasImplThread()) { - DCHECK(Proxy::isMainThread()); - DebugScopedSetImplThread impl; - onMemoryAllocationChangedOnImplThread(allocation); - } else { - DCHECK(Proxy::isImplThread()); - onMemoryAllocationChangedOnImplThread(allocation); - } -} - -int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priorityCutoff) -{ - switch (priorityCutoff) { - case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing: - return PriorityCalculator::allowNothingCutoff(); - case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly: - return PriorityCalculator::allowVisibleOnlyCutoff(); - case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby: - return PriorityCalculator::allowVisibleAndNearbyCutoff(); - case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: - return PriorityCalculator::allowEverythingCutoff(); - } - NOTREACHED(); - return 0; -} - -void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation allocation) -{ // Just ignore the memory manager when it says to set the limit to zero // bytes. This will happen when the memory manager thinks that the renderer // is not visible (which the renderer knows better). @@ -1192,6 +1159,22 @@ void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemory m_discardFramebufferWhenNotVisible = oldDiscardFramebufferWhenNotVisible; } +int GLRenderer::priorityCutoffValue(WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priorityCutoff) +{ + switch (priorityCutoff) { + case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing: + return PriorityCalculator::allowNothingCutoff(); + case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly: + return PriorityCalculator::allowVisibleOnlyCutoff(); + case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby: + return PriorityCalculator::allowVisibleAndNearbyCutoff(); + case WebKit::WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything: + return PriorityCalculator::allowEverythingCutoff(); + } + NOTREACHED(); + return 0; +} + void GLRenderer::enforceMemoryPolicy() { if (!m_visible) { |