Commit 6b65b358 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

aw: Default surface_rect_empty to true

The default for an "is empty" value should be true to better match
reality. This is breaking the case where an offscreen webview is
directly translated on-screen without another onDraw recording on the UI
thread. The comparison in BVR::OnParentDrawConstraintsUpdated is
supposed to catch this case and cause another invalidate.

This CL refers to internal bug b/117560442

Change-Id: Ic03f91631780a2057931cb39cdecd04d32f52b1d
Reviewed-on: https://chromium-review.googlesource.com/c/1295315
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604297}
parent 37ccda19
...@@ -251,6 +251,70 @@ class TestAnimateInAndOutOfScreen : public RenderingTest { ...@@ -251,6 +251,70 @@ class TestAnimateInAndOutOfScreen : public RenderingTest {
RENDERING_TEST_F(TestAnimateInAndOutOfScreen); RENDERING_TEST_F(TestAnimateInAndOutOfScreen);
class TestAnimateOnScreenWithoutOnDraw : public RenderingTest {
public:
void StartTest() override {
browser_view_renderer_->PostInvalidate(ActiveCompositor());
}
void WillOnDraw() override {
RenderingTest::WillOnDraw();
// Set empty tile viewport on first frame.
browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect());
}
void DidOnDraw(bool success) override {
EXPECT_TRUE(success);
on_draw_count_++;
}
bool WillDrawOnRT(AwDrawGLInfo* draw_info) override {
will_draw_on_rt_count_++;
// What happens in practice is draw functor is skipped initially since
// it is offscreen so entirely clipped. Then later, the webview is moved
// onscreen without another OnDrawon UI thread, and draw functor is called
// with non-empty clip. Here in the test we pretend this second draw happens
// immediately.
bool result = RenderingTest::WillDrawOnRT(draw_info);
assertNonEmptyClip(draw_info);
return result;
}
void OnParentDrawConstraintsUpdated() override {
switch (on_draw_count_) {
case 0:
// This OnParentDrawConstraintsUpdated is generated by
// connecting the compositor frame consumer to the producer.
break;
case 1:
// DrawOnRT skipped for frame 1 so this should not happen.
EXPECT_TRUE(window_->on_draw_hardware_pending());
EndTest();
break;
case 2:
// Might happen due to invalidate on_draw_hardware_pending from
// previous frame.
break;
default:
FAIL();
break;
}
}
private:
void assertNonEmptyClip(AwDrawGLInfo* draw_info) {
gfx::Rect clip(draw_info->clip_left, draw_info->clip_top,
draw_info->clip_right - draw_info->clip_left,
draw_info->clip_bottom - draw_info->clip_top);
ASSERT_FALSE(clip.IsEmpty());
}
int on_draw_count_ = 0;
int will_draw_on_rt_count_ = 0;
};
RENDERING_TEST_F(TestAnimateOnScreenWithoutOnDraw);
class CompositorNoFrameTest : public RenderingTest { class CompositorNoFrameTest : public RenderingTest {
public: public:
CompositorNoFrameTest() : on_draw_count_(0) {} CompositorNoFrameTest() : on_draw_count_(0) {}
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
namespace android_webview { namespace android_webview {
ParentCompositorDrawConstraints::ParentCompositorDrawConstraints() ParentCompositorDrawConstraints::ParentCompositorDrawConstraints()
: is_layer(false), surface_rect_empty(false) { : is_layer(false), surface_rect_empty(true) {}
}
ParentCompositorDrawConstraints::ParentCompositorDrawConstraints( ParentCompositorDrawConstraints::ParentCompositorDrawConstraints(
bool is_layer, bool is_layer,
......
...@@ -58,6 +58,8 @@ class FakeWindow { ...@@ -58,6 +58,8 @@ class FakeWindow {
void RequestDrawGL(FakeFunctor* functor); void RequestDrawGL(FakeFunctor* functor);
bool on_draw_hardware_pending() const { return on_draw_hardware_pending_; }
private: private:
class ScopedMakeCurrent; class ScopedMakeCurrent;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment