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

Unified Diff: cc/gl_renderer.cc

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add cc::GaneshResourceProvider Created 7 years, 10 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
« no previous file with comments | « cc/ganesh_resource_provider.cc ('k') | cc/layer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/gl_renderer.cc
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index b3bad726fbef27b43eb65f2414cddf9aa8695f15..606884ed8a01dbc0202ed6d39f3ba53e63c47d42 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -16,6 +16,7 @@
#include "cc/compositor_frame.h"
#include "cc/compositor_frame_metadata.h"
#include "cc/damage_tracker.h"
+#include "cc/ganesh_resource_provider.h"
#include "cc/geometry_binding.h"
#include "cc/gl_frame_data.h"
#include "cc/layer_quad.h"
@@ -31,7 +32,6 @@
#include "cc/video_layer_impl.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -45,7 +45,6 @@
using WebKit::WebGraphicsContext3D;
using WebKit::WebGraphicsMemoryAllocation;
-using WebKit::WebSharedGraphicsContext3D;
namespace cc {
@@ -133,6 +132,8 @@ bool GLRenderer::initialize()
// The updater can access textures while the GLRenderer is using them.
m_capabilities.allowPartialTextureUpdates = true;
+ m_capabilities.usingOffscreenContext3d = true;
+
m_isUsingBindUniform = extensions.count("GL_CHROMIUM_bind_uniform_location");
// Make sure scissoring starts as disabled.
@@ -350,66 +351,44 @@ void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde
GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0));
}
-static WebGraphicsContext3D* getFilterContext(bool hasImplThread)
-{
- if (hasImplThread)
- return WebSharedGraphicsContext3D::compositorThreadContext();
- else
- return WebSharedGraphicsContext3D::mainThreadContext();
-}
-
-static GrContext* getFilterGrContext(bool hasImplThread)
-{
- if (hasImplThread)
- return WebSharedGraphicsContext3D::compositorThreadGrContext();
- else
- return WebSharedGraphicsContext3D::mainThreadGrContext();
-}
-
-static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedResource* sourceTexture, bool hasImplThread)
+static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedResource* sourceResource)
{
if (filters.isEmpty())
return SkBitmap();
- WebGraphicsContext3D* filterContext = getFilterContext(hasImplThread);
- GrContext* filterGrContext = getFilterGrContext(hasImplThread);
-
- if (!filterContext || !filterGrContext)
+ if (!renderer->resourceProvider()->ganeshResourceProvider()->has_contexts())
return SkBitmap();
- renderer->context()->flush();
-
- ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourceTexture->id());
- SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), sourceTexture->size(), filterContext, filterGrContext);
+ ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourceResource->id());
+ GaneshResourceProvider::ScopedContextsFlushed ganeshContexts(renderer->resourceProvider(), renderer->resourceProvider()->ganeshResourceProvider());
+ SkBitmap source = RenderSurfaceFilters::apply(filters, lock.textureId(), sourceResource->size(), ganeshContexts.gr_context());
return source;
}
-static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedResource* sourceTexture, bool hasImplThread)
+static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedResource* sourceResource)
{
if (!filter)
return SkBitmap();
- WebGraphicsContext3D* context3d = getFilterContext(hasImplThread);
- GrContext* grContext = getFilterGrContext(hasImplThread);
-
- if (!context3d || !grContext)
+ if (!renderer->resourceProvider()->ganeshResourceProvider()->has_contexts())
return SkBitmap();
- renderer->context()->flush();
+ ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourceResource->id());
- ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourceTexture->id());
+ // Flush after locking the resource on the compositor context.
+ GaneshResourceProvider::ScopedContextsFlushed ganeshContexts(renderer->resourceProvider(), renderer->resourceProvider()->ganeshResourceProvider());
// Wrap the source texture in a Ganesh platform texture.
GrPlatformTextureDesc platformTextureDescription;
- platformTextureDescription.fWidth = sourceTexture->size().width();
- platformTextureDescription.fHeight = sourceTexture->size().height();
+ platformTextureDescription.fWidth = sourceResource->size().width();
+ platformTextureDescription.fHeight = sourceResource->size().height();
platformTextureDescription.fConfig = kSkia8888_GrPixelConfig;
platformTextureDescription.fTextureHandle = lock.textureId();
- skia::RefPtr<GrTexture> texture = skia::AdoptRef(grContext->createPlatformTexture(platformTextureDescription));
+ skia::RefPtr<GrTexture> texture = skia::AdoptRef(ganeshContexts.gr_context()->createPlatformTexture(platformTextureDescription));
// Place the platform texture inside an SkBitmap.
SkBitmap source;
- source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(), sourceTexture->size().height());
+ source.setConfig(SkBitmap::kARGB_8888_Config, sourceResource->size().width(), sourceResource->size().height());
skia::RefPtr<SkGrPixelRef> pixelRef = skia::AdoptRef(new SkGrPixelRef(texture.get()));
source.setPixelRef(pixelRef.get());
@@ -420,11 +399,11 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
desc.fWidth = source.width();
desc.fHeight = source.height();
desc.fConfig = kSkia8888_GrPixelConfig;
- GrAutoScratchTexture scratchTexture(grContext, desc, GrContext::kExact_ScratchTexMatch);
+ GrAutoScratchTexture scratchTexture(ganeshContexts.gr_context(), desc, GrContext::kExact_ScratchTexMatch);
skia::RefPtr<GrTexture> backingStore = skia::AdoptRef(scratchTexture.detach());
// Create a device and canvas using that backing store.
- SkGpuDevice device(grContext, backingStore.get());
+ SkGpuDevice device(ganeshContexts.gr_context(), backingStore.get());
SkCanvas canvas(&device);
// Draw the source bitmap through the filter to the canvas.
@@ -433,7 +412,6 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
canvas.clear(0x0);
canvas.drawSprite(source, 0, 0, &paint);
canvas.flush();
Stephen White 2013/02/07 22:07:52 I hate to be a pain, but couldn't this simply be f
danakj 2013/02/07 22:11:14 I like the guard class because it makes it impossi
bsalomon_chromium 2013/02/08 01:55:57 Calling GrContext::flush() is sufficient. You don'
- context3d->flush();
return device.accessBitmap(false);
}
@@ -481,7 +459,7 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
return scoped_ptr<ScopedResource>();
- SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread());
+ SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get());
if (!filteredDeviceBackground.getTexture())
return scoped_ptr<ScopedResource>();
@@ -534,9 +512,9 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
// Apply filters to the contents texture.
SkBitmap filterBitmap;
if (quad->filter) {
- filterBitmap = applyImageFilter(this, quad->filter.get(), contentsTexture, m_client->hasImplThread());
+ filterBitmap = applyImageFilter(this, quad->filter.get(), contentsTexture);
} else {
- filterBitmap = applyFilters(this, quad->filters, contentsTexture, m_client->hasImplThread());
+ filterBitmap = applyFilters(this, quad->filters, contentsTexture);
}
// Draw the background texture if there is one.
« no previous file with comments | « cc/ganesh_resource_provider.cc ('k') | cc/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698