Chromium Code Reviews| Index: android_webview/browser/in_process_view_renderer.cc |
| diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc |
| index a714956e08064795b9da15890fab5f8cddc411f6..f889d10c45506e0b92d4db76c22f92118038e7a2 100644 |
| --- a/android_webview/browser/in_process_view_renderer.cc |
| +++ b/android_webview/browser/in_process_view_renderer.cc |
| @@ -6,6 +6,8 @@ |
| #include <android/bitmap.h> |
| +#include "android_webview/browser/aw_gl_surface.h" |
| +#include "android_webview/browser/gl_surface_factory.h" |
| #include "android_webview/browser/scoped_app_gl_state_restore.h" |
| #include "android_webview/common/aw_switches.h" |
| #include "android_webview/public/browser/draw_gl.h" |
| @@ -186,6 +188,9 @@ void BrowserViewRenderer::SetAwDrawSWFunctionTable( |
| gpu::InProcessCommandBuffer::SetScheduleCallback( |
| base::Bind(&ScheduleGpuWork)); |
| + |
| + DCHECK(!gfx::SurfaceFactoryAndroid::GetInstance()); |
| + gfx::SurfaceFactoryAndroid::SetInstance(GLSurfaceFactory::GetInstance()); |
| } |
| // static |
| @@ -289,6 +294,27 @@ bool InProcessViewRenderer::OnDraw(jobject java_canvas, |
| return result; |
| } |
| + |
| +scoped_refptr<gfx::GLSurface> InProcessViewRenderer::CreateGLSurface() { |
| + DCHECK(!hardware_initialized_); |
| + DCHECK(!gl_surface_); |
| + gl_surface_ = new AwGLSurface; |
| + return gl_surface_; |
| +} |
| + |
| +bool InProcessViewRenderer::InitializeHwDraw() { |
| + TRACE_EVENT0("android_webview", "InitializeHwDraw"); |
|
no sievers
2013/08/06 17:30:07
Do you need GLSurfaceFactory if you are doing this
boliu
2013/08/06 18:11:16
This brought up something else. We should always h
|
| + GLSurfaceFactory::GetInstance()->SetNextCallback(base::Bind( |
| + &InProcessViewRenderer::CreateGLSurface, base::Unretained(this))); |
| + |
| + hardware_failed_ = !compositor_->InitializeHwDraw(); |
| + hardware_initialized_ = true; |
| + |
| + GLSurfaceFactory::GetInstance()->ResetCallback(); |
| + |
| + return !hardware_failed_; |
| +} |
| + |
| void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| TRACE_EVENT0("android_webview", "InProcessViewRenderer::DrawGL"); |
| DCHECK(visible_); |
| @@ -309,12 +335,9 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| ScopedAllowGL allow_gl; |
| if (attached_to_window_ && compositor_ && !hardware_initialized_) { |
| - TRACE_EVENT0("android_webview", "InitializeHwDraw"); |
| - hardware_failed_ = !compositor_->InitializeHwDraw(); |
| - hardware_initialized_ = true; |
| - last_egl_context_ = current_context; |
| - |
| - if (hardware_failed_) |
| + if (InitializeHwDraw()) |
| + last_egl_context_ = current_context; |
| + else |
| return; |
| } |
| @@ -330,7 +353,6 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| TRACE_EVENT_INSTANT0( |
| "android_webview", "EGLContextChanged", TRACE_EVENT_SCOPE_THREAD); |
| } |
| - last_egl_context_ = current_context; |
| if (!compositor_) { |
| TRACE_EVENT_INSTANT0( |
| @@ -338,21 +360,26 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| return; |
| } |
| + DCHECK(gl_surface_); |
| + gl_surface_->SetBackingFrameBufferObject( |
| + state_restore.framebuffer_binding_ext()); |
| + |
| gfx::Transform transform; |
| transform.matrix().setColMajorf(draw_info->transform); |
| transform.Translate(scroll_at_start_of_frame_.x(), |
| scroll_at_start_of_frame_.y()); |
| - // TODO(joth): Check return value. |
| - block_invalidates_ = true; |
| gfx::Rect clip_rect(draw_info->clip_left, |
| draw_info->clip_top, |
| draw_info->clip_right - draw_info->clip_left, |
| draw_info->clip_bottom - draw_info->clip_top); |
| + block_invalidates_ = true; |
| + // TODO(joth): Check return value. |
| compositor_->DemandDrawHw(gfx::Size(draw_info->width, draw_info->height), |
| transform, |
| clip_rect, |
| state_restore.stencil_enabled()); |
| block_invalidates_ = false; |
| + gl_surface_->ResetBackingFrameBufferObject(); |
| UpdateCachedGlobalVisibleRect(); |
| bool drew_full_visible_rect = clip_rect.Contains(cached_global_visible_rect_); |
| @@ -552,6 +579,7 @@ void InProcessViewRenderer::OnDetachedFromWindow() { |
| ScopedAllowGL allow_gl; |
| compositor_->ReleaseHwDraw(); |
| hardware_initialized_ = false; |
| + gl_surface_ = NULL; |
| } |
| attached_to_window_ = false; |