Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / android_webview / browser / hardware_renderer.cc
index df7e361..6a3d54b 100644 (file)
@@ -20,6 +20,7 @@
 #include "cc/trees/layer_tree_host.h"
 #include "cc/trees/layer_tree_settings.h"
 #include "gpu/command_buffer/client/gl_in_process_context.h"
+#include "gpu/command_buffer/common/gles2_cmd_utils.h"
 #include "ui/gfx/frame_time.h"
 #include "ui/gfx/geometry/rect_conversions.h"
 #include "ui/gfx/geometry/rect_f.h"
@@ -33,6 +34,7 @@ namespace android_webview {
 namespace {
 
 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
+using webkit::gpu::WebGraphicsContext3DImpl;
 
 scoped_refptr<cc::ContextProvider> CreateContext(
     scoped_refptr<gfx::GLSurface> surface,
@@ -46,10 +48,10 @@ scoped_refptr<cc::ContextProvider> CreateContext(
   attributes.stencil = false;
   attributes.shareResources = true;
   attributes.noAutomaticFlushes = true;
-  gpu::GLInProcessContextAttribs in_process_attribs;
-  WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
-      attributes, &in_process_attribs);
-  in_process_attribs.lose_context_when_out_of_memory = 1;
+  gpu::gles2::ContextCreationAttribHelper attribs_for_gles2;
+  WebGraphicsContext3DImpl::ConvertAttributes(
+      attributes, &attribs_for_gles2);
+  attribs_for_gles2.lose_context_when_out_of_memory = true;
 
   scoped_ptr<gpu::GLInProcessContext> context(
       gpu::GLInProcessContext::Create(service,
@@ -59,7 +61,7 @@ scoped_refptr<cc::ContextProvider> CreateContext(
                                       surface->GetSize(),
                                       share_context,
                                       false /* share_resources */,
-                                      in_process_attribs,
+                                      attribs_for_gles2,
                                       gpu_preference));
   DCHECK(context.get());
 
@@ -94,7 +96,7 @@ HardwareRenderer::HardwareRenderer(SharedRendererState* state)
   settings.should_clear_root_render_pass = false;
 
   layer_tree_host_ =
-      cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings);
+      cc::LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings, NULL);
   layer_tree_host_->SetRootLayer(root_layer_);
   layer_tree_host_->SetLayerTreeHostClientReady();
   layer_tree_host_->set_has_transparent_background(true);
@@ -116,6 +118,10 @@ HardwareRenderer::~HardwareRenderer() {
 #endif  // DCHECK_IS_ON
 
   resource_collection_->SetClient(NULL);
+
+  // Reset draw constraints.
+  shared_renderer_state_->UpdateDrawConstraints(
+      ParentCompositorDrawConstraints());
 }
 
 void HardwareRenderer::DidBeginMainFrame() {
@@ -191,6 +197,21 @@ void HardwareRenderer::DrawGL(bool stencil_enabled,
   if (last_egl_context_ != current_context)
     DLOG(WARNING) << "EGLContextChanged";
 
+  gfx::Transform transform(gfx::Transform::kSkipInitialization);
+  transform.matrix().setColMajorf(draw_info->transform);
+  transform.Translate(scroll_offset_.x(), scroll_offset_.y());
+
+  // Need to post the new transform matrix back to child compositor
+  // because there is no onDraw during a Render Thread animation, and child
+  // compositor might not have the tiles rasterized as the animation goes on.
+  ParentCompositorDrawConstraints draw_constraints(
+      draw_info->is_layer, transform, gfx::Rect(viewport_));
+  if (!draw_constraints_.Equals(draw_constraints)) {
+    draw_constraints_ = draw_constraints;
+    shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor(
+        draw_constraints);
+  }
+
   viewport_.SetSize(draw_info->width, draw_info->height);
   layer_tree_host_->SetViewportSize(viewport_);
   clip_.SetRect(draw_info->clip_left,
@@ -199,9 +220,6 @@ void HardwareRenderer::DrawGL(bool stencil_enabled,
                 draw_info->clip_bottom - draw_info->clip_top);
   stencil_enabled_ = stencil_enabled;
 
-  gfx::Transform transform(gfx::Transform::kSkipInitialization);
-  transform.matrix().setColMajorf(draw_info->transform);
-  transform.Translate(scroll_offset_.x(), scroll_offset_.y());
   delegated_layer_->SetTransform(transform);
 
   gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext);