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

Unified Diff: cc/gl_renderer.cc

Issue 11369071: A speculative Revert for r165872 - Remove static thread pointers from CC, attempt 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/gl_renderer.cc
===================================================================
--- cc/gl_renderer.cc (revision 165906)
+++ cc/gl_renderer.cc (working copy)
@@ -111,7 +111,7 @@
m_capabilities.usingPartialSwap = Settings::partialSwapEnabled() && extensions.count("GL_CHROMIUM_post_sub_buffer");
// Use the swapBuffers callback only with the threaded proxy.
- if (m_client->hasImplThread())
+ if (Proxy::hasImplThread())
m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM_swapbuffers_complete_callback");
if (m_capabilities.usingSwapCompleteCallback)
m_context->setSwapBuffersCompleteCallbackCHROMIUM(this);
@@ -144,6 +144,7 @@
GLRenderer::~GLRenderer()
{
+ DCHECK(Proxy::isImplThread());
m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
m_context->setContextLostCallback(0);
@@ -341,29 +342,29 @@
GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short)));
}
-static WebGraphicsContext3D* getFilterContext(bool hasImplThread)
+static WebGraphicsContext3D* getFilterContext()
{
- if (hasImplThread)
+ if (Proxy::hasImplThread())
return WebSharedGraphicsContext3D::compositorThreadContext();
else
return WebSharedGraphicsContext3D::mainThreadContext();
}
-static GrContext* getFilterGrContext(bool hasImplThread)
+static GrContext* getFilterGrContext()
{
- if (hasImplThread)
+ if (Proxy::hasImplThread())
return WebSharedGraphicsContext3D::compositorThreadGrContext();
else
return WebSharedGraphicsContext3D::mainThreadGrContext();
}
-static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedTexture* sourceTexture, bool hasImplThread)
+static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedTexture* sourceTexture)
{
if (filters.isEmpty())
return SkBitmap();
- WebGraphicsContext3D* filterContext = getFilterContext(hasImplThread);
- GrContext* filterGrContext = getFilterGrContext(hasImplThread);
+ WebGraphicsContext3D* filterContext = getFilterContext();
+ GrContext* filterGrContext = getFilterGrContext();
if (!filterContext || !filterGrContext)
return SkBitmap();
@@ -375,13 +376,13 @@
return source;
}
-static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedTexture* sourceTexture, bool hasImplThread)
+static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedTexture* sourceTexture)
{
if (!filter)
return SkBitmap();
- WebGraphicsContext3D* context3d = getFilterContext(hasImplThread);
- GrContext* grContext = getFilterGrContext(hasImplThread);
+ WebGraphicsContext3D* context3d = getFilterContext();
+ GrContext* grContext = getFilterGrContext();
if (!context3d || !grContext)
return SkBitmap();
@@ -467,7 +468,7 @@
if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
return scoped_ptr<ScopedTexture>();
- SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread());
+ SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get());
if (!filteredDeviceBackground.getTexture())
return scoped_ptr<ScopedTexture>();
@@ -522,9 +523,9 @@
// Apply filters to the contents texture.
SkBitmap filterBitmap;
if (renderPass->filter()) {
- filterBitmap = applyImageFilter(this, renderPass->filter(), contentsTexture, m_client->hasImplThread());
+ filterBitmap = applyImageFilter(this, renderPass->filter(), contentsTexture);
} else {
- filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture, m_client->hasImplThread());
+ filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture);
}
scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock;
unsigned contentsTextureId = 0;
@@ -952,6 +953,8 @@
void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQuad* quad)
{
+ DCHECK(Proxy::isImplThread());
+
TexTransformTextureProgramBinding binding;
if (quad->flipped())
binding.set(textureProgramFlip());
@@ -994,6 +997,7 @@
void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDrawQuad* quad)
{
+ DCHECK(Proxy::isImplThread());
TexTransformTextureProgramBinding binding;
binding.set(textureIOSurfaceProgram());
@@ -1135,6 +1139,35 @@
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).
@@ -1158,22 +1191,6 @@
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) {
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698