#include "content/browser/android/in_process/synchronous_compositor_output_surface.h"
#include "content/public/browser/browser_thread.h"
+#include "content/renderer/gpu/frame_swap_message_queue.h"
#include "gpu/command_buffer/client/gl_in_process_context.h"
+#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "ui/gl/android/surface_texture.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_stub.h"
}
using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
+using webkit::gpu::WebGraphicsContext3DImpl;
scoped_ptr<gpu::GLInProcessContext> CreateOffscreenContext(
const blink::WebGraphicsContext3D::Attributes& attributes) {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
- gpu::GLInProcessContextAttribs in_process_attribs;
- WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
+ gpu::gles2::ContextCreationAttribHelper in_process_attribs;
+ WebGraphicsContext3DImpl::ConvertAttributes(
attributes, &in_process_attribs);
- in_process_attribs.lose_context_when_out_of_memory = 1;
+ in_process_attribs.lose_context_when_out_of_memory = true;
scoped_ptr<gpu::GLInProcessContext> context(
gpu::GLInProcessContext::Create(NULL /* service */,
scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
gpu::GLInProcessContext* share_context) {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
- gpu::GLInProcessContextAttribs in_process_attribs;
- WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
+ gpu::gles2::ContextCreationAttribHelper in_process_attribs;
+ WebGraphicsContext3DImpl::ConvertAttributes(
GetDefaultAttribs(), &in_process_attribs);
- in_process_attribs.lose_context_when_out_of_memory = 1;
+ in_process_attribs.lose_context_when_out_of_memory = true;
scoped_ptr<gpu::GLInProcessContext> context(
gpu::GLInProcessContext::Create(service,
context.Pass(), GetDefaultAttribs()));
}
+scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
+WrapContextWithAttributes(
+ scoped_ptr<gpu::GLInProcessContext> context,
+ const blink::WebGraphicsContext3D::Attributes& attributes) {
+ if (!context.get())
+ return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>();
+
+ return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(
+ WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
+ context.Pass(), attributes));
+}
+
class VideoContextProvider
: public StreamTextureFactorySynchronousImpl::ContextProvider {
public:
}
scoped_ptr<cc::OutputSurface>
-SynchronousCompositorFactoryImpl::CreateOutputSurface(int routing_id) {
+SynchronousCompositorFactoryImpl::CreateOutputSurface(
+ int routing_id,
+ scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue) {
scoped_ptr<SynchronousCompositorOutputSurface> output_surface(
- new SynchronousCompositorOutputSurface(routing_id));
+ new SynchronousCompositorOutputSurface(routing_id,
+ frame_swap_message_queue));
return output_surface.PassAs<cc::OutputSurface>();
}
return synchronous_input_event_filter();
}
-scoped_refptr<ContextProviderWebContext> SynchronousCompositorFactoryImpl::
- GetSharedOffscreenContextProviderForMainThread() {
- bool failed = false;
- if ((!offscreen_context_for_main_thread_.get() ||
- offscreen_context_for_main_thread_->DestroyedOnMainThread())) {
- scoped_ptr<gpu::GLInProcessContext> context =
- CreateOffscreenContext(GetDefaultAttribs());
- offscreen_context_for_main_thread_ =
- webkit::gpu::ContextProviderInProcess::Create(
- WrapContext(context.Pass()),
- "Compositor-Offscreen-main-thread");
- failed = !offscreen_context_for_main_thread_.get() ||
- !offscreen_context_for_main_thread_->BindToCurrentThread();
- }
-
- if (failed) {
- offscreen_context_for_main_thread_ = NULL;
- }
- return offscreen_context_for_main_thread_;
+scoped_refptr<ContextProviderWebContext>
+SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider(
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ const std::string& debug_name) {
+ scoped_ptr<gpu::GLInProcessContext> context =
+ CreateOffscreenContext(attributes);
+ return webkit::gpu::ContextProviderInProcess::Create(
+ WrapContext(context.Pass()), debug_name);
}
scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
blink::WebGraphicsContext3D*
SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
const blink::WebGraphicsContext3D::Attributes& attributes) {
- return WrapContext(CreateOffscreenContext(attributes)).release();
+ return WrapContextWithAttributes(CreateOffscreenContext(attributes),
+ attributes).release();
}
void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() {
base::AutoLock lock(num_hardware_compositor_lock_);
DCHECK_GT(num_hardware_compositors_, 0u);
num_hardware_compositors_--;
+ if (num_hardware_compositors_ == 0) {
+ // Nullify the video_context_provider_ now so that it is not null only if
+ // there is at least 1 hardware compositor
+ video_context_provider_ = NULL;
+ }
}
bool SynchronousCompositorFactoryImpl::CanCreateMainThreadContext() {
context_provider;
// This check only guarantees the main thread context is created after
// a compositor did successfully initialize hardware draw in the past.
- // In particular this does not guarantee that the main thread context
- // will fail creation when all compositors release hardware draw.
+ // When all compositors have released hardware draw, main thread context
+ // creation is guaranteed to fail.
if (CanCreateMainThreadContext() && !video_context_provider_) {
DCHECK(service_);
DCHECK(share_context_.get());
service_ = service;
}
-void SynchronousCompositorFactoryImpl::DisableRecordFullLayer() {
- record_full_layer_ = false;
+void SynchronousCompositorFactoryImpl::SetRecordFullDocument(
+ bool record_full_document) {
+ record_full_layer_ = record_full_document;
}
} // namespace content