| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/browser/in_process_view_renderer.h" | 5 #include "android_webview/browser/in_process_view_renderer.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "android_webview/public/browser/draw_gl.h" | 9 #include "android_webview/public/browser/draw_gl.h" |
| 10 #include "android_webview/public/browser/draw_sw.h" | 10 #include "android_webview/public/browser/draw_sw.h" |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 309 } |
| 310 | 310 |
| 311 void InProcessViewRenderer::WebContentsGone() { | 311 void InProcessViewRenderer::WebContentsGone() { |
| 312 web_contents_ = NULL; | 312 web_contents_ = NULL; |
| 313 compositor_ = NULL; | 313 compositor_ = NULL; |
| 314 } | 314 } |
| 315 | 315 |
| 316 bool InProcessViewRenderer::PrepareDrawGL(int x, int y) { | 316 bool InProcessViewRenderer::PrepareDrawGL(int x, int y) { |
| 317 // No harm in updating |hw_rendering_scroll_| even if we return false. | 317 // No harm in updating |hw_rendering_scroll_| even if we return false. |
| 318 hw_rendering_scroll_ = gfx::Point(x, y); | 318 hw_rendering_scroll_ = gfx::Point(x, y); |
| 319 return attached_to_window_ && compositor_ && compositor_->IsHwReady() && | 319 return attached_to_window_ && compositor_ && !hardware_failed_; |
| 320 !hardware_failed_; | |
| 321 } | 320 } |
| 322 | 321 |
| 323 void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { | 322 void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| 324 DCHECK(view_visible_); | 323 DCHECK(view_visible_); |
| 325 | 324 |
| 326 // We need to watch if the current Android context has changed and enforce | 325 // We need to watch if the current Android context has changed and enforce |
| 327 // a clean-up in the compositor. | 326 // a clean-up in the compositor. |
| 328 EGLContext current_context = eglGetCurrentContext(); | 327 EGLContext current_context = eglGetCurrentContext(); |
| 329 if (!current_context) { | 328 if (!current_context) { |
| 330 LOG(WARNING) << "No current context attached. Skipping composite."; | 329 LOG(WARNING) << "No current context attached. Skipping composite."; |
| 331 return; | 330 return; |
| 332 } | 331 } |
| 333 | 332 |
| 334 GLStateRestore state_restore; | 333 GLStateRestore state_restore; |
| 335 | 334 |
| 336 if (attached_to_window_ && compositor_ && !hardware_initialized_) { | 335 if (attached_to_window_ && compositor_ && !hardware_initialized_) { |
| 337 // TODO(boliu): Actually initialize the compositor GL path. | 336 hardware_failed_ = !compositor_->InitializeHwDraw(); |
| 338 hardware_initialized_ = true; | 337 hardware_initialized_ = true; |
| 339 egl_context_at_init_ = current_context; | 338 egl_context_at_init_ = current_context; |
| 339 |
| 340 if (hardware_failed_) |
| 341 return; |
| 340 } | 342 } |
| 341 | 343 |
| 342 if (draw_info->mode == AwDrawGLInfo::kModeProcess) | 344 if (draw_info->mode == AwDrawGLInfo::kModeProcess) |
| 343 return; | 345 return; |
| 344 | 346 |
| 345 if (egl_context_at_init_ != current_context) { | 347 if (egl_context_at_init_ != current_context) { |
| 346 // TODO(boliu): Handle context lost | 348 // TODO(boliu): Handle context lost |
| 347 } | 349 } |
| 348 | 350 |
| 349 // TODO(boliu): Make sure this is not called before compositor is initialized | 351 // TODO(boliu): Make sure this is not called before compositor is initialized |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page | 578 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page |
| 577 // scale here. Determine what if any needs bringing over to this class. | 579 // scale here. Determine what if any needs bringing over to this class. |
| 578 return CompositeSW(canvas); | 580 return CompositeSW(canvas); |
| 579 } | 581 } |
| 580 | 582 |
| 581 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { | 583 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { |
| 582 return compositor_ && compositor_->DemandDrawSw(canvas); | 584 return compositor_ && compositor_->DemandDrawSw(canvas); |
| 583 } | 585 } |
| 584 | 586 |
| 585 } // namespace android_webview | 587 } // namespace android_webview |
| OLD | NEW |