OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_renderer/in_process_view_renderer.h
" | 5 #include "android_webview/browser/in_process_renderer/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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 web_contents_->SetUserData(kUserDataKey, new UserData(this)); | 176 web_contents_->SetUserData(kUserDataKey, new UserData(this)); |
177 } | 177 } |
178 | 178 |
179 void InProcessViewRenderer::WebContentsGone() { | 179 void InProcessViewRenderer::WebContentsGone() { |
180 web_contents_ = NULL; | 180 web_contents_ = NULL; |
181 } | 181 } |
182 | 182 |
183 bool InProcessViewRenderer::PrepareDrawGL(int x, int y) { | 183 bool InProcessViewRenderer::PrepareDrawGL(int x, int y) { |
184 // No harm in updating |hw_rendering_scroll_| even if we return false. | 184 // No harm in updating |hw_rendering_scroll_| even if we return false. |
185 hw_rendering_scroll_ = gfx::Point(x, y); | 185 hw_rendering_scroll_ = gfx::Point(x, y); |
186 return attached_to_window_ && compositor_ && compositor_->IsHwReady() && | 186 return attached_to_window_ && compositor_ && !hardware_failed_; |
187 !hardware_failed_; | |
188 } | 187 } |
189 | 188 |
190 void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { | 189 void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
191 DCHECK(view_visible_); | 190 DCHECK(view_visible_); |
192 | 191 |
193 // We need to watch if the current Android context has changed and enforce | 192 // We need to watch if the current Android context has changed and enforce |
194 // a clean-up in the compositor. | 193 // a clean-up in the compositor. |
195 EGLContext current_context = eglGetCurrentContext(); | 194 EGLContext current_context = eglGetCurrentContext(); |
196 if (!current_context) { | 195 if (!current_context) { |
197 LOG(WARNING) << "No current context attached. Skipping composite."; | 196 LOG(WARNING) << "No current context attached. Skipping composite."; |
198 return; | 197 return; |
199 } | 198 } |
200 | 199 |
201 if (attached_to_window_ && compositor_ && !hardware_initialized_) { | 200 if (attached_to_window_ && compositor_ && !hardware_initialized_) { |
202 // TODO(boliu): Actually initialize the compositor GL path. | 201 hardware_failed_ = !compositor_->InitializeHwDraw(); |
203 hardware_initialized_ = true; | 202 hardware_initialized_ = true; |
204 egl_context_at_init_ = current_context; | 203 egl_context_at_init_ = current_context; |
| 204 |
| 205 if (hardware_failed_) |
| 206 return; |
205 } | 207 } |
206 | 208 |
207 if (draw_info->mode == AwDrawGLInfo::kModeProcess) | 209 if (draw_info->mode == AwDrawGLInfo::kModeProcess) |
208 return; | 210 return; |
209 | 211 |
210 if (egl_context_at_init_ != current_context) { | 212 if (egl_context_at_init_ != current_context) { |
211 // TODO(boliu): Handle context lost | 213 // TODO(boliu): Handle context lost |
212 } | 214 } |
213 | 215 |
214 // TODO(boliu): Make sure this is not called before compositor is initialized | 216 // TODO(boliu): Make sure this is not called before compositor is initialized |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page | 438 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page |
437 // scale here. Determine what if any needs bringing over to this class. | 439 // scale here. Determine what if any needs bringing over to this class. |
438 return CompositeSW(canvas); | 440 return CompositeSW(canvas); |
439 } | 441 } |
440 | 442 |
441 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { | 443 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { |
442 return compositor_ && compositor_->DemandDrawSw(canvas); | 444 return compositor_ && compositor_->DemandDrawSw(canvas); |
443 } | 445 } |
444 | 446 |
445 } // namespace android_webview | 447 } // namespace android_webview |
OLD | NEW |