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

Unified Diff: content/browser/android/in_process/synchronous_compositor_output_surface.cc

Issue 22066002: Add FBO support in Android WebView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove blank line Created 7 years, 4 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: content/browser/android/in_process/synchronous_compositor_output_surface.cc
diff --git a/content/browser/android/in_process/synchronous_compositor_output_surface.cc b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
index fafd06fda22c7268b4f5d38024cee0196389259e..71afad6a6ffd572b671a6c5f05966bb59e9d741c 100644
--- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc
+++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc
@@ -15,6 +15,7 @@
#include "content/browser/android/in_process/synchronous_compositor_impl.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/public/browser/browser_thread.h"
+#include "gpu/command_buffer/client/gl_in_process_context.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"
#include "ui/gfx/rect_conversions.h"
@@ -23,22 +24,55 @@
#include "ui/gl/gl_context.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
-using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
namespace content {
namespace {
-// TODO(boliu): RenderThreadImpl should create in process contexts as well.
-scoped_ptr<WebKit::WebGraphicsContext3D> CreateWebGraphicsContext3D() {
+scoped_ptr<WebKit::WebGraphicsContext3D> CreateWebGraphicsContext3D(
+ scoped_refptr<gfx::GLSurface> surface) {
+ using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
+ if (!gfx::GLSurface::InitializeOneOff())
+ scoped_ptr<WebKit::WebGraphicsContext3D>();
+
+ bool offscreen = false;
+ gfx::Size size(1, 1);
joth 2013/08/04 00:45:16 const all these? comment where the values came fr
boliu 2013/08/05 16:58:24 Actually I'm not sure. I'm inclined to say it's no
+ const char* allowed_extensions = "*";
+ gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
+
WebKit::WebGraphicsContext3D::Attributes attributes;
attributes.antialias = false;
attributes.shareResources = true;
attributes.noAutomaticFlushes = true;
+ const int alpha_size = attributes.alpha ? 8 : 0;
+ const int depth_size = attributes.depth ? 24 : 0;
+ const int stencil_size = attributes.stencil ? 8 : 0;
+ const int samples = attributes.antialias ? 4 : 0;
+ const int sample_buffers = attributes.antialias ? 1 : 0;
+ const int32 attribs[] = {
+ gpu::GLInProcessContext::ALPHA_SIZE, alpha_size,
+ gpu::GLInProcessContext::DEPTH_SIZE, depth_size,
+ gpu::GLInProcessContext::STENCIL_SIZE, stencil_size,
+ gpu::GLInProcessContext::SAMPLES, samples,
+ gpu::GLInProcessContext::SAMPLE_BUFFERS, sample_buffers,
+ gpu::GLInProcessContext::NONE,
+ };
joth 2013/08/04 00:45:16 this chunk smells like is was c&p from somewhere.
+
+ scoped_ptr<gpu::GLInProcessContext> context(
+ gpu::GLInProcessContext::CreateWithSurface(surface,
+ offscreen,
+ size,
+ attributes.shareResources,
+ allowed_extensions,
+ attribs,
+ gpu_preference));
+
+ if (!context.get())
+ scoped_ptr<WebKit::WebGraphicsContext3D>();
return scoped_ptr<WebKit::WebGraphicsContext3D>(
- WebGraphicsContext3DInProcessCommandBufferImpl
- ::CreateViewContext(attributes, NULL));
+ WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
+ context.Pass(), attributes));
joth 2013/08/04 00:45:16 nit: tend to line these up like line 62-68
boliu 2013/08/05 16:58:24 It doesn't fit on 80 characters. Also this is not
}
void DidActivatePendingTree(int routing_id) {
@@ -180,13 +214,17 @@ bool SynchronousCompositorOutputSurface::InitializeHwDraw(
DCHECK(CalledOnValidThread());
DCHECK(HasClient());
DCHECK(!context3d_);
+ DCHECK(!surface_);
- return InitializeAndSetContext3D(CreateWebGraphicsContext3D().Pass(),
+ surface_ = new gfx::GLSurfaceStub;
+ return InitializeAndSetContext3D(CreateWebGraphicsContext3D(surface_).Pass(),
offscreen_context);
}
void SynchronousCompositorOutputSurface::ReleaseHwDraw() {
+ DCHECK(surface_);
cc::OutputSurface::ReleaseGL();
+ surface_ = NULL;
}
bool SynchronousCompositorOutputSurface::DemandDrawHw(
@@ -197,6 +235,9 @@ bool SynchronousCompositorOutputSurface::DemandDrawHw(
DCHECK(CalledOnValidThread());
DCHECK(HasClient());
DCHECK(context3d());
+ DCHECK(surface_);
+
+ surface_->UpdateFBO();
gfx::Transform adjusted_transform = transform;
AdjustTransformForClip(&adjusted_transform, clip);

Powered by Google App Engine
This is Rietveld 408576698