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

Unified 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: Address code review comments and fix all cc_unittests 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 side-by-side diff with in-line comments
Download patch
Index: cc/gl_renderer.cc
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index 361ced1b2b588d8eb0ef326140d164cfa57a9686..7af7a38e76ddcc10b7118ad78be904ff02d99f07 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -64,9 +64,9 @@ bool needsIOSurfaceReadbackWorkaround()
} // anonymous namespace
-scoped_ptr<GLRenderer> GLRenderer::create(RendererClient* client, ResourceProvider* resourceProvider)
+scoped_ptr<GLRenderer> GLRenderer::create(RendererClient* client, ResourceProvider* resourceProvider, bool hasImplThread)
{
- scoped_ptr<GLRenderer> renderer(make_scoped_ptr(new GLRenderer(client, resourceProvider)));
+ scoped_ptr<GLRenderer> renderer(make_scoped_ptr(new GLRenderer(client, resourceProvider, hasImplThread)));
if (!renderer->initialize())
return scoped_ptr<GLRenderer>();
@@ -74,8 +74,10 @@ scoped_ptr<GLRenderer> GLRenderer::create(RendererClient* client, ResourceProvid
}
GLRenderer::GLRenderer(RendererClient* client,
- ResourceProvider* resourceProvider)
+ ResourceProvider* resourceProvider,
+ bool hasImplThread)
: DirectRenderer(client, resourceProvider)
+ , m_hasImplThread(hasImplThread)
, m_offscreenFramebufferId(0)
, m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f))
, m_context(resourceProvider->graphicsContext3D())
@@ -113,7 +115,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_hasImplThread)
m_capabilities.usingSwapCompleteCallback = extensions.count("GL_CHROMIUM_swapbuffers_complete_callback");
if (m_capabilities.usingSwapCompleteCallback)
m_context->setSwapBuffersCompleteCallbackCHROMIUM(this);
@@ -146,7 +148,6 @@ bool GLRenderer::initialize()
GLRenderer::~GLRenderer()
{
- DCHECK(Proxy::isImplThread());
m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
m_context->setContextLostCallback(0);
@@ -334,29 +335,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();
@@ -368,13 +369,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();
@@ -459,7 +460,7 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(DrawingFrame& frame,
if (!getFramebufferTexture(deviceBackgroundTexture.get(), cc::IntRect(deviceRect)))
return scoped_ptr<ScopedTexture>();
- SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get());
+ SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_hasImplThread);
if (!filteredDeviceBackground.getTexture())
return scoped_ptr<ScopedTexture>();
@@ -514,9 +515,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_hasImplThread);
} else {
- filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture);
+ filterBitmap = applyFilters(this, renderPass->filters(), contentsTexture, m_hasImplThread);
}
scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock;
unsigned contentsTextureId = 0;
@@ -946,8 +947,6 @@ struct TexTransformTextureProgramBinding : TextureProgramBinding {
void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQuad* quad)
{
- DCHECK(Proxy::isImplThread());
-
TexTransformTextureProgramBinding binding;
if (quad->flipped())
binding.set(textureProgramFlip());
@@ -990,7 +989,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());
@@ -1132,15 +1130,7 @@ 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);
- }
+ onMemoryAllocationChangedOnImplThread(allocation);
danakj 2012/10/25 05:06:06 Is there a reason to keep the OnImplThread functio
}
void GLRenderer::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation allocation)
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_unittest.cc » ('j') | cc/gl_renderer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698