@@ -85,6 +85,7 @@ BrowserViewRenderer::BrowserViewRenderer(
85
85
on_new_picture_enable_(false ),
86
86
clear_view_(false ),
87
87
compositor_needs_continuous_invalidate_(false ),
88
+ invalidate_after_composite_(false ),
88
89
block_invalidates_(false ),
89
90
fallback_tick_pending_(false ),
90
91
width_(0 ),
@@ -211,13 +212,6 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) {
211
212
return false ;
212
213
213
214
shared_renderer_state_->SetScrollOffset (last_on_draw_scroll_offset_);
214
- if (last_on_draw_global_visible_rect_.IsEmpty ()) {
215
- TRACE_EVENT_INSTANT0 (" android_webview" ,
216
- " EarlyOut_EmptyVisibleRect" ,
217
- TRACE_EVENT_SCOPE_THREAD);
218
- shared_renderer_state_->SetForceInvalidateOnNextDrawGL (true );
219
- return client_->RequestDrawGL (java_canvas, false );
220
- }
221
215
222
216
if (!hardware_enabled_) {
223
217
hardware_enabled_ = compositor_->InitializeHwDraw ();
@@ -228,12 +222,21 @@ bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) {
228
222
if (!hardware_enabled_)
229
223
return false ;
230
224
225
+ if (last_on_draw_global_visible_rect_.IsEmpty () &&
226
+ parent_draw_constraints_.surface_rect .IsEmpty ()) {
227
+ TRACE_EVENT_INSTANT0 (" android_webview" ,
228
+ " EarlyOut_EmptyVisibleRect" ,
229
+ TRACE_EVENT_SCOPE_THREAD);
230
+ shared_renderer_state_->SetForceInvalidateOnNextDrawGL (true );
231
+ return client_->RequestDrawGL (java_canvas, false );
232
+ }
233
+
231
234
ReturnResourceFromParent ();
232
235
if (shared_renderer_state_->HasCompositorFrame ()) {
233
236
TRACE_EVENT_INSTANT0 (" android_webview" ,
234
237
" EarlyOut_PreviousFrameUnconsumed" ,
235
238
TRACE_EVENT_SCOPE_THREAD);
236
- SkippedCompositeInDraw ();
239
+ DidSkipCompositeInDraw ();
237
240
return client_->RequestDrawGL (java_canvas, false );
238
241
}
239
242
@@ -262,10 +265,12 @@ scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() {
262
265
// applied onto the layer so global visible rect does not make sense here.
263
266
// In this case, just use the surface rect for tiling.
264
267
gfx::Rect viewport_rect_for_tile_priority;
265
- if (parent_draw_constraints_.is_layer )
268
+ if (parent_draw_constraints_.is_layer ||
269
+ last_on_draw_global_visible_rect_.IsEmpty ()) {
266
270
viewport_rect_for_tile_priority = parent_draw_constraints_.surface_rect ;
267
- else
271
+ } else {
268
272
viewport_rect_for_tile_priority = last_on_draw_global_visible_rect_;
273
+ }
269
274
270
275
scoped_ptr<cc::CompositorFrame> frame =
271
276
compositor_->DemandDrawHw (surface_size,
@@ -282,11 +287,13 @@ scoped_ptr<cc::CompositorFrame> BrowserViewRenderer::CompositeHw() {
282
287
void BrowserViewRenderer::UpdateParentDrawConstraints () {
283
288
// Post an invalidate if the parent draw constraints are stale and there is
284
289
// no pending invalidate.
285
- if (shared_renderer_state_->NeedsForceInvalidateOnNextDrawGL () ||
290
+ bool needs_force_invalidate =
291
+ shared_renderer_state_->NeedsForceInvalidateOnNextDrawGL ();
292
+ if (needs_force_invalidate ||
286
293
!parent_draw_constraints_.Equals (
287
- shared_renderer_state_->ParentDrawConstraints ())) {
294
+ shared_renderer_state_->ParentDrawConstraints ())) {
288
295
shared_renderer_state_->SetForceInvalidateOnNextDrawGL (false );
289
- EnsureContinuousInvalidation (true , false );
296
+ EnsureContinuousInvalidation (true , needs_force_invalidate );
290
297
}
291
298
}
292
299
@@ -310,6 +317,11 @@ void BrowserViewRenderer::ReturnResourceFromParent() {
310
317
}
311
318
}
312
319
320
+ void BrowserViewRenderer::DidSkipCommitFrame () {
321
+ // Treat it the same way as skipping onDraw.
322
+ DidSkipCompositeInDraw ();
323
+ }
324
+
313
325
bool BrowserViewRenderer::OnDrawSoftware (jobject java_canvas) {
314
326
if (!compositor_) {
315
327
TRACE_EVENT_INSTANT0 (
@@ -656,12 +668,18 @@ void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll,
656
668
void BrowserViewRenderer::EnsureContinuousInvalidation (
657
669
bool force_invalidate,
658
670
bool skip_reschedule_tick) {
671
+ if (force_invalidate)
672
+ invalidate_after_composite_ = true ;
673
+
659
674
// This method should be called again when any of these conditions change.
660
675
bool need_invalidate =
661
- compositor_needs_continuous_invalidate_ || force_invalidate ;
676
+ compositor_needs_continuous_invalidate_ || invalidate_after_composite_ ;
662
677
if (!need_invalidate || block_invalidates_)
663
678
return ;
664
679
680
+ if (!compositor_needs_continuous_invalidate_ && invalidate_after_composite_)
681
+ invalidate_after_composite_ = false ;
682
+
665
683
// Always call view invalidate. We rely the Android framework to ignore the
666
684
// invalidate when it's not needed such as when view is not visible.
667
685
client_->PostInvalidate ();
@@ -764,9 +782,9 @@ void BrowserViewRenderer::DidComposite() {
764
782
EnsureContinuousInvalidation (false , false );
765
783
}
766
784
767
- void BrowserViewRenderer::SkippedCompositeInDraw () {
785
+ void BrowserViewRenderer::DidSkipCompositeInDraw () {
768
786
block_invalidates_ = false ;
769
- EnsureContinuousInvalidation (false , true );
787
+ EnsureContinuousInvalidation (true , true );
770
788
}
771
789
772
790
std::string BrowserViewRenderer::ToString () const {
0 commit comments