| 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 "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (!hardware_enabled_) { | 209 if (!hardware_enabled_) { |
| 210 TRACE_EVENT0("android_webview", "InitializeHwDraw"); | 210 TRACE_EVENT0("android_webview", "InitializeHwDraw"); |
| 211 hardware_enabled_ = compositor_->InitializeHwDraw(); | 211 hardware_enabled_ = compositor_->InitializeHwDraw(); |
| 212 } | 212 } |
| 213 if (!hardware_enabled_) { | 213 if (!hardware_enabled_) { |
| 214 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_HardwareNotEnabled", | 214 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_HardwareNotEnabled", |
| 215 TRACE_EVENT_SCOPE_THREAD); | 215 TRACE_EVENT_SCOPE_THREAD); |
| 216 return false; | 216 return false; |
| 217 } | 217 } |
| 218 | 218 |
| 219 if (last_on_draw_global_visible_rect_.IsEmpty()) { |
| 220 // WebView could be offscreen. Need to make sure WebView invalidates when |
| 221 // it is animated into the screen again. |
| 222 shared_renderer_state_.SetForceInvalidateOnNextDrawGLOnUI(true); |
| 223 } |
| 224 |
| 219 ReturnResourceFromParent(); | 225 ReturnResourceFromParent(); |
| 220 if (shared_renderer_state_.HasCompositorFrameOnUI()) { | 226 if (shared_renderer_state_.HasCompositorFrameOnUI()) { |
| 221 TRACE_EVENT_INSTANT0("android_webview", | 227 TRACE_EVENT_INSTANT0("android_webview", |
| 222 "EarlyOut_PreviousFrameUnconsumed", | 228 "EarlyOut_PreviousFrameUnconsumed", |
| 223 TRACE_EVENT_SCOPE_THREAD); | 229 TRACE_EVENT_SCOPE_THREAD); |
| 224 DidSkipCompositeInDraw(); | 230 DidSkipCompositeInDraw(); |
| 225 return true; | 231 return true; |
| 226 } | 232 } |
| 227 | 233 |
| 228 scoped_ptr<cc::CompositorFrame> frame = CompositeHw(); | 234 scoped_ptr<cc::CompositorFrame> frame = CompositeHw(); |
| 229 if (!frame.get()) { | 235 if (!frame.get()) { |
| 230 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", | 236 TRACE_EVENT_INSTANT0("android_webview", "NoNewFrame", |
| 231 TRACE_EVENT_SCOPE_THREAD); | 237 TRACE_EVENT_SCOPE_THREAD); |
| 232 return false; | 238 return false; |
| 233 } | 239 } |
| 234 | 240 |
| 235 shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), false); | 241 shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), false); |
| 236 return true; | 242 return true; |
| 237 } | 243 } |
| 238 | 244 |
| 239 scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() { | 245 scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() { |
| 240 compositor_->SetMemoryPolicy(CalculateDesiredMemoryPolicy()); | 246 compositor_->SetMemoryPolicy(CalculateDesiredMemoryPolicy()); |
| 241 | 247 |
| 242 parent_draw_constraints_ = | 248 parent_draw_constraints_ = |
| 243 shared_renderer_state_.GetParentDrawConstraintsOnUI(); | 249 shared_renderer_state_.GetParentDrawConstraintsOnUI(); |
| 250 |
| 251 client_->ParentDrawConstraintsUpdated(); |
| 252 |
| 244 gfx::Size surface_size(size_); | 253 gfx::Size surface_size(size_); |
| 245 gfx::Rect viewport(surface_size); | 254 gfx::Rect viewport(surface_size); |
| 246 gfx::Rect clip = viewport; | 255 gfx::Rect clip = viewport; |
| 247 gfx::Transform transform_for_tile_priority = | 256 gfx::Transform transform_for_tile_priority = |
| 248 parent_draw_constraints_.transform; | 257 parent_draw_constraints_.transform; |
| 249 | 258 |
| 250 // If the WebView is on a layer, WebView does not know what transform is | 259 // If the WebView is on a layer, WebView does not know what transform is |
| 251 // applied onto the layer so global visible rect does not make sense here. | 260 // applied onto the layer so global visible rect does not make sense here. |
| 252 // In this case, just use the surface rect for tiling. | 261 // In this case, just use the surface rect for tiling. |
| 253 gfx::Rect viewport_rect_for_tile_priority; | 262 gfx::Rect viewport_rect_for_tile_priority; |
| 254 | 263 |
| 255 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. | 264 // Leave viewport_rect_for_tile_priority empty if offscreen_pre_raster_ is on. |
| 256 if (!offscreen_pre_raster_) { | 265 if (!offscreen_pre_raster_) { |
| 257 if (parent_draw_constraints_.is_layer || | 266 if (parent_draw_constraints_.is_layer || |
| 258 last_on_draw_global_visible_rect_.IsEmpty()) { | 267 last_on_draw_global_visible_rect_.IsEmpty()) { |
| 259 viewport_rect_for_tile_priority = parent_draw_constraints_.surface_rect; | 268 viewport_rect_for_tile_priority = parent_draw_constraints_.surface_rect; |
| 260 } else { | 269 } else { |
| 261 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; | 270 viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_; |
| 262 } | 271 } |
| 263 } | 272 } |
| 264 | 273 |
| 265 scoped_ptr<cc::CompositorFrame> frame = | 274 scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw( |
| 266 compositor_->DemandDrawHw(surface_size, | 275 surface_size, gfx::Transform(), viewport, clip, |
| 267 gfx::Transform(), | 276 viewport_rect_for_tile_priority, transform_for_tile_priority); |
| 268 viewport, | |
| 269 clip, | |
| 270 viewport_rect_for_tile_priority, | |
| 271 transform_for_tile_priority); | |
| 272 if (frame.get()) | 277 if (frame.get()) |
| 273 DidComposite(); | 278 DidComposite(); |
| 274 return frame.Pass(); | 279 return frame.Pass(); |
| 275 } | 280 } |
| 276 | 281 |
| 277 void BrowserViewRenderer::UpdateParentDrawConstraints() { | 282 void BrowserViewRenderer::UpdateParentDrawConstraints() { |
| 278 // Post an invalidate if the parent draw constraints are stale and there is | 283 // Post an invalidate if the parent draw constraints are stale and there is |
| 279 // no pending invalidate. | 284 // no pending invalidate. |
| 280 bool needs_force_invalidate = | 285 bool needs_force_invalidate = |
| 281 shared_renderer_state_.NeedsForceInvalidateOnNextDrawGLOnUI(); | 286 shared_renderer_state_.NeedsForceInvalidateOnNextDrawGLOnUI(); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 base::StringAppendF(&str, | 789 base::StringAppendF(&str, |
| 785 "overscroll_rounding_error_: %s ", | 790 "overscroll_rounding_error_: %s ", |
| 786 overscroll_rounding_error_.ToString().c_str()); | 791 overscroll_rounding_error_.ToString().c_str()); |
| 787 base::StringAppendF( | 792 base::StringAppendF( |
| 788 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 793 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
| 789 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 794 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
| 790 return str; | 795 return str; |
| 791 } | 796 } |
| 792 | 797 |
| 793 } // namespace android_webview | 798 } // namespace android_webview |
| OLD | NEW |