OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser_view_renderer.h" | 5 #include "android_webview/browser/browser_view_renderer.h" |
6 | 6 |
7 #include "android_webview/browser/browser_view_renderer_client.h" | 7 #include "android_webview/browser/browser_view_renderer_client.h" |
8 #include "android_webview/browser/shared_renderer_state.h" | 8 #include "android_webview/browser/shared_renderer_state.h" |
9 #include "android_webview/common/aw_switches.h" | 9 #include "android_webview/common/aw_switches.h" |
10 #include "android_webview/public/browser/draw_gl.h" | 10 #include "android_webview/public/browser/draw_gl.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 if (is_hardware_canvas && attached_to_window_ && | 243 if (is_hardware_canvas && attached_to_window_ && |
244 !switches::ForceAuxiliaryBitmap()) { | 244 !switches::ForceAuxiliaryBitmap()) { |
245 return OnDrawHardware(java_canvas); | 245 return OnDrawHardware(java_canvas); |
246 } | 246 } |
247 | 247 |
248 // Perform a software draw | 248 // Perform a software draw |
249 return OnDrawSoftware(java_canvas); | 249 return OnDrawSoftware(java_canvas); |
250 } | 250 } |
251 | 251 |
252 bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { | 252 bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { |
253 TRACE_EVENT0("android_webview", "BrowserViewRenderer::OnDrawHardware"); | |
253 if (!compositor_) | 254 if (!compositor_) |
254 return false; | 255 return false; |
255 | 256 |
256 if (last_on_draw_global_visible_rect_.IsEmpty()) | 257 if (last_on_draw_global_visible_rect_.IsEmpty()) { |
258 TRACE_EVENT_INSTANT0("android_webview", | |
259 "EarlyOut_EmptyVisibleRect", | |
260 TRACE_EVENT_SCOPE_THREAD); | |
257 return client_->RequestDrawGL(java_canvas, false); | 261 return client_->RequestDrawGL(java_canvas, false); |
262 } | |
258 | 263 |
259 if (!hardware_enabled_) { | 264 if (!hardware_enabled_) { |
260 hardware_enabled_ = compositor_->InitializeHwDraw(); | 265 hardware_enabled_ = compositor_->InitializeHwDraw(); |
261 if (hardware_enabled_) { | 266 if (hardware_enabled_) { |
262 tile_manager_key_ = GlobalTileManager::GetInstance()->PushBack(this); | 267 tile_manager_key_ = GlobalTileManager::GetInstance()->PushBack(this); |
263 } | 268 } |
264 } | 269 } |
265 if (!hardware_enabled_) | 270 if (!hardware_enabled_) |
266 return false; | 271 return false; |
267 | 272 |
273 | |
268 ReturnResourceFromParent(); | 274 ReturnResourceFromParent(); |
269 SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy(); | 275 SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy(); |
270 RequestMemoryPolicy(new_policy); | 276 RequestMemoryPolicy(new_policy); |
271 compositor_->SetMemoryPolicy(memory_policy_); | 277 compositor_->SetMemoryPolicy(memory_policy_); |
272 | 278 |
279 if (shared_renderer_state_->HasDrawGLInput()) { | |
280 TRACE_EVENT_INSTANT0("android_webview", | |
281 "EarlyOut_PreviousFrameUnconsumed", | |
282 TRACE_EVENT_SCOPE_THREAD); | |
283 // TODO(boliu): Rename this method. We didn't actually composite here. | |
284 DidComposite(); | |
285 return client_->RequestDrawGL(java_canvas, false); | |
286 } | |
287 | |
273 scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput); | 288 scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput); |
274 draw_gl_input->scroll_offset = last_on_draw_scroll_offset_; | 289 draw_gl_input->scroll_offset = last_on_draw_scroll_offset_; |
275 draw_gl_input->width = width_; | 290 draw_gl_input->width = width_; |
276 draw_gl_input->height = height_; | 291 draw_gl_input->height = height_; |
277 | 292 |
278 parent_draw_constraints_ = shared_renderer_state_->ParentDrawConstraints(); | 293 parent_draw_constraints_ = shared_renderer_state_->ParentDrawConstraints(); |
279 gfx::Size surface_size(width_, height_); | 294 gfx::Size surface_size(width_, height_); |
280 gfx::Rect viewport(surface_size); | 295 gfx::Rect viewport(surface_size); |
281 gfx::Rect clip = viewport; | 296 gfx::Rect clip = viewport; |
282 gfx::Transform transform_for_tile_priority = | 297 gfx::Transform transform_for_tile_priority = |
(...skipping 14 matching lines...) Expand all Loading... | |
297 viewport, | 312 viewport, |
298 clip, | 313 clip, |
299 viewport_rect_for_tile_priority, | 314 viewport_rect_for_tile_priority, |
300 transform_for_tile_priority); | 315 transform_for_tile_priority); |
301 if (!frame.get()) | 316 if (!frame.get()) |
302 return false; | 317 return false; |
303 | 318 |
304 GlobalTileManager::GetInstance()->DidUse(tile_manager_key_); | 319 GlobalTileManager::GetInstance()->DidUse(tile_manager_key_); |
305 | 320 |
306 frame->AssignTo(&draw_gl_input->frame); | 321 frame->AssignTo(&draw_gl_input->frame); |
307 ReturnUnusedResource(shared_renderer_state_->PassDrawGLInput()); | |
hush (inactive)
2014/09/20 02:15:53
why is this removed?
boliu
2014/09/20 02:20:21
If we are consuming the input, we can't detect whe
| |
308 shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass()); | 322 shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass()); |
309 DidComposite(); | 323 DidComposite(); |
310 return client_->RequestDrawGL(java_canvas, false); | 324 return client_->RequestDrawGL(java_canvas, false); |
311 } | 325 } |
312 | 326 |
313 void BrowserViewRenderer::UpdateParentDrawConstraints() { | 327 void BrowserViewRenderer::UpdateParentDrawConstraints() { |
314 // Post an invalidate if the parent draw constraints are stale and there is | 328 // Post an invalidate if the parent draw constraints are stale and there is |
315 // no pending invalidate. | 329 // no pending invalidate. |
316 if (!parent_draw_constraints_.Equals( | 330 if (!parent_draw_constraints_.Equals( |
317 shared_renderer_state_->ParentDrawConstraints())) | 331 shared_renderer_state_->ParentDrawConstraints())) |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 base::StringAppendF(&str, | 817 base::StringAppendF(&str, |
804 "surface width height: [%d %d] ", | 818 "surface width height: [%d %d] ", |
805 draw_info->width, | 819 draw_info->width, |
806 draw_info->height); | 820 draw_info->height); |
807 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 821 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
808 } | 822 } |
809 return str; | 823 return str; |
810 } | 824 } |
811 | 825 |
812 } // namespace android_webview | 826 } // namespace android_webview |
OLD | NEW |