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..8cc92dbce838ca281c2c8c395499a3d449fac0ac 100644 |
--- a/content/browser/android/in_process/synchronous_compositor_output_surface.cc |
+++ b/content/browser/android/in_process/synchronous_compositor_output_surface.cc |
@@ -15,30 +15,54 @@ |
#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" |
#include "ui/gfx/skia_util.h" |
#include "ui/gfx/transform.h" |
-#include "ui/gl/gl_context.h" |
+#include "ui/gl/gl_surface.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>(); |
no sievers
2013/08/07 01:52:38
return
boliu
2013/08/07 02:58:48
Done.
|
+ |
+ const bool offscreen = false; |
+ const gfx::Size size(1, 1); |
+ const char* allowed_extensions = "*"; |
+ const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; |
+ |
WebKit::WebGraphicsContext3D::Attributes attributes; |
attributes.antialias = false; |
attributes.shareResources = true; |
attributes.noAutomaticFlushes = true; |
+ gpu::GLInProcessContextAttribs in_process_attribs; |
+ WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( |
+ attributes, &in_process_attribs); |
+ scoped_ptr<gpu::GLInProcessContext> context( |
+ gpu::GLInProcessContext::CreateWithSurface(surface, |
+ offscreen, |
+ size, |
+ attributes.shareResources, |
+ allowed_extensions, |
+ in_process_attribs, |
+ gpu_preference)); |
+ |
+ if (!context.get()) |
+ scoped_ptr<WebKit::WebGraphicsContext3D>(); |
no sievers
2013/08/07 01:52:38
return
boliu
2013/08/07 02:58:48
Done.
|
+ |
return scoped_ptr<WebKit::WebGraphicsContext3D>( |
- WebGraphicsContext3DInProcessCommandBufferImpl |
- ::CreateViewContext(attributes, NULL)); |
+ WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( |
+ context.Pass(), attributes)); |
} |
void DidActivatePendingTree(int routing_id) { |
@@ -176,13 +200,15 @@ void AdjustTransformForClip(gfx::Transform* transform, gfx::Rect clip) { |
} // namespace |
bool SynchronousCompositorOutputSurface::InitializeHwDraw( |
+ scoped_refptr<gfx::GLSurface> surface, |
scoped_refptr<cc::ContextProvider> offscreen_context) { |
DCHECK(CalledOnValidThread()); |
DCHECK(HasClient()); |
DCHECK(!context3d_); |
+ DCHECK(surface); |
- return InitializeAndSetContext3D(CreateWebGraphicsContext3D().Pass(), |
- offscreen_context); |
+ return InitializeAndSetContext3D( |
+ CreateWebGraphicsContext3D(surface).Pass(), offscreen_context); |
} |
void SynchronousCompositorOutputSurface::ReleaseHwDraw() { |
@@ -205,8 +231,6 @@ bool SynchronousCompositorOutputSurface::DemandDrawHw( |
SetExternalStencilTest(stencil_enabled); |
InvokeComposite(clip.size()); |
- // TODO(boliu): Check if context is lost here. |
- |
return did_swap_buffer_; |
} |