scoped_refptr<cc::ContextProvider> CreateContext(
scoped_refptr<gfx::GLSurface> surface,
- scoped_refptr<gpu::InProcessCommandBuffer::Service> service,
- gpu::GLInProcessContext* share_context) {
+ scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
blink::WebGraphicsContext3D::Attributes attributes;
surface->IsOffscreen(),
gfx::kNullAcceleratedWidget,
surface->GetSize(),
- share_context,
+ NULL /* share_context */,
false /* share_resources */,
attribs_for_gles2,
gpu_preference,
// Webview does not own the surface so should not clear it.
settings.should_clear_root_render_pass = false;
+ // TODO(enne): Update this this compositor to use a synchronous scheduler.
+ settings.single_thread_proxy_scheduler = false;
+
layer_tree_host_ =
cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings, NULL);
layer_tree_host_->SetRootLayer(root_layer_);
}
HardwareRenderer::~HardwareRenderer() {
+ SetFrameData();
+
// Must reset everything before |resource_collection_| to ensure all
// resources are returned before resetting |resource_collection_| client.
layer_tree_host_.reset();
}
void HardwareRenderer::CommitFrame() {
- scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput();
+ if (committed_input_.get()) {
+ TRACE_EVENT_INSTANT0("android_webview",
+ "EarlyOut_PreviousFrameUnconsumed",
+ TRACE_EVENT_SCOPE_THREAD);
+ return;
+ }
+
+ committed_input_ = shared_renderer_state_->PassDrawGLInput();
// Happens with empty global visible rect.
- if (!input.get())
+ if (!committed_input_.get())
return;
- DCHECK(!input->frame.gl_frame_data);
- DCHECK(!input->frame.software_frame_data);
+ DCHECK(!committed_input_->frame.gl_frame_data);
+ DCHECK(!committed_input_->frame.software_frame_data);
// DelegatedRendererLayerImpl applies the inverse device_scale_factor of the
// renderer frame, assuming that the browser compositor will scale
// it back up to device scale. But on Android we put our browser layers in
// physical pixels and set our browser CC device_scale_factor to 1, so this
// suppresses the transform.
- input->frame.delegated_frame_data->device_scale_factor = 1.0f;
+ committed_input_->frame.delegated_frame_data->device_scale_factor = 1.0f;
+}
+
+void HardwareRenderer::SetFrameData() {
+ if (!committed_input_.get())
+ return;
+ scoped_ptr<DrawGLInput> input = committed_input_.Pass();
gfx::Size frame_size =
input->frame.delegated_frame_data->render_pass_list.back()
->output_rect.size();
// We need to watch if the current Android context has changed and enforce
// a clean-up in the compositor.
EGLContext current_context = eglGetCurrentContext();
- if (!current_context) {
- DLOG(ERROR) << "DrawGL called without EGLContext";
- return;
- }
+ DCHECK(current_context) << "DrawGL called without EGLContext";
// TODO(boliu): Handle context loss.
if (last_egl_context_ != current_context)
DLOG(WARNING) << "EGLContextChanged";
+ SetFrameData();
gfx::Transform transform(gfx::Transform::kSkipInitialization);
transform.matrix().setColMajorf(draw_info->transform);
transform.Translate(scroll_offset_.x(), scroll_offset_.y());
gl_surface_->ResetBackingFrameBufferObject();
}
-scoped_ptr<cc::OutputSurface> HardwareRenderer::CreateOutputSurface(
- bool fallback) {
+void HardwareRenderer::RequestNewOutputSurface(bool fallback) {
// Android webview does not support losing output surface.
DCHECK(!fallback);
scoped_refptr<cc::ContextProvider> context_provider =
CreateContext(gl_surface_,
- DeferredGpuCommandService::GetInstance(),
- shared_renderer_state_->GetSharedContext());
+ DeferredGpuCommandService::GetInstance());
scoped_ptr<ParentOutputSurface> output_surface_holder(
new ParentOutputSurface(context_provider));
output_surface_ = output_surface_holder.get();
- return output_surface_holder.PassAs<cc::OutputSurface>();
+ layer_tree_host_->SetOutputSurface(
+ output_surface_holder.PassAs<cc::OutputSurface>());
}
void HardwareRenderer::UnusedResourcesAreAvailable() {