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 #include "android_webview/browser/child_frame.h" | 6 #include "android_webview/browser/child_frame.h" |
7 #include "android_webview/browser/test/rendering_test.h" | 7 #include "android_webview/browser/test/rendering_test.h" |
8 | 8 |
9 namespace android_webview { | 9 namespace android_webview { |
10 | 10 |
11 class SmokeTest : public RenderingTest { | 11 class SmokeTest : public RenderingTest { |
12 void StartTest() override { | 12 void StartTest() override { browser_view_renderer_->PostInvalidate(); } |
13 browser_view_renderer_->SetContinuousInvalidate(true); | |
14 } | |
15 | |
16 void WillOnDraw() override { | |
17 browser_view_renderer_->SetContinuousInvalidate(false); | |
18 } | |
19 | 13 |
20 void DidDrawOnRT(SharedRendererState* functor) override { | 14 void DidDrawOnRT(SharedRendererState* functor) override { |
21 EndTest(); | 15 EndTest(); |
22 } | 16 } |
23 }; | 17 }; |
24 | 18 |
25 RENDERING_TEST_F(SmokeTest); | 19 RENDERING_TEST_F(SmokeTest); |
26 | 20 |
27 class ClearViewTest : public RenderingTest { | 21 class ClearViewTest : public RenderingTest { |
28 public: | 22 public: |
29 ClearViewTest() : on_draw_count_(0u) {} | 23 ClearViewTest() : on_draw_count_(0) {} |
30 | 24 |
31 void StartTest() override { | 25 void StartTest() override { |
32 browser_view_renderer_->SetContinuousInvalidate(true); | 26 browser_view_renderer_->PostInvalidate(); |
33 browser_view_renderer_->ClearView(); | 27 browser_view_renderer_->ClearView(); |
34 } | 28 } |
35 | 29 |
36 void WillOnDraw() override { | 30 void DidOnDraw(bool success) override { |
37 on_draw_count_++; | 31 on_draw_count_++; |
38 if (on_draw_count_ == 2u) { | 32 if (on_draw_count_ == 1) { |
39 browser_view_renderer_->SetContinuousInvalidate(false); | |
40 } | |
41 } | |
42 | |
43 void DidOnDraw(bool success) override { | |
44 if (on_draw_count_ == 1u) { | |
45 // First OnDraw should be skipped due to ClearView. | 33 // First OnDraw should be skipped due to ClearView. |
46 EXPECT_FALSE(success); | 34 EXPECT_FALSE(success); |
47 browser_view_renderer_->DidUpdateContent(); // Unset ClearView. | 35 browser_view_renderer_->DidUpdateContent(); // Unset ClearView. |
| 36 browser_view_renderer_->PostInvalidate(); |
48 } else { | 37 } else { |
49 // Following OnDraws should succeed. | 38 // Following OnDraws should succeed. |
50 EXPECT_TRUE(success); | 39 EXPECT_TRUE(success); |
51 } | 40 } |
52 } | 41 } |
53 | 42 |
54 void DidDrawOnRT(SharedRendererState* functor) override { | 43 void DidDrawOnRT(SharedRendererState* functor) override { |
55 EndTest(); | 44 EndTest(); |
56 } | 45 } |
57 private: | 46 private: |
58 size_t on_draw_count_; | 47 int on_draw_count_; |
59 }; | 48 }; |
60 | 49 |
61 RENDERING_TEST_F(ClearViewTest); | 50 RENDERING_TEST_F(ClearViewTest); |
62 | 51 |
63 class TestAnimateInAndOutOfScreen : public RenderingTest { | 52 class TestAnimateInAndOutOfScreen : public RenderingTest { |
64 public: | 53 public: |
65 TestAnimateInAndOutOfScreen() | 54 TestAnimateInAndOutOfScreen() : on_draw_count_(0), draw_gl_count_on_rt_(0) {} |
66 : on_draw_count_(0u), draw_gl_count_on_rt_(0u) {} | |
67 | 55 |
68 void StartTest() override { | 56 void StartTest() override { |
69 new_constraints_ = ParentCompositorDrawConstraints( | 57 new_constraints_ = ParentCompositorDrawConstraints( |
70 false, gfx::Transform(), gfx::Rect(window_->surface_size())); | 58 false, gfx::Transform(), gfx::Rect(window_->surface_size())); |
71 new_constraints_.transform.Scale(2.0, 2.0); | 59 new_constraints_.transform.Scale(2.0, 2.0); |
72 browser_view_renderer_->SetContinuousInvalidate(true); | 60 browser_view_renderer_->PostInvalidate(); |
73 } | 61 } |
74 | 62 |
75 void WillOnDraw() override { | 63 void WillOnDraw() override { |
76 browser_view_renderer_->SetContinuousInvalidate(false); | |
77 // Step 0: A single onDraw on screen. The parent draw constraints | 64 // Step 0: A single onDraw on screen. The parent draw constraints |
78 // of the BVR will updated to be the initial constraints. | 65 // of the BVR will updated to be the initial constraints. |
79 // Step 1: A single onDrraw off screen. The parent draw constraints of the | 66 // Step 1: A single onDrraw off screen. The parent draw constraints of the |
80 // BVR will be updated to the new constraints. | 67 // BVR will be updated to the new constraints. |
81 // Step 2: This onDraw is to introduce the DrawGL that animates the | 68 // Step 2: This onDraw is to introduce the DrawGL that animates the |
82 // webview onto the screen on render thread. End the test when the parent | 69 // webview onto the screen on render thread. End the test when the parent |
83 // draw constraints of BVR is updated to initial constraints. | 70 // draw constraints of BVR is updated to initial constraints. |
84 if (on_draw_count_ == 1u || on_draw_count_ == 2u) | 71 if (on_draw_count_ == 1 || on_draw_count_ == 2) |
85 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); | 72 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); |
86 } | 73 } |
87 | 74 |
88 void DidOnDraw(bool success) override { | 75 void DidOnDraw(bool success) override { |
89 EXPECT_TRUE(success); | 76 EXPECT_TRUE(success); |
90 on_draw_count_++; | 77 on_draw_count_++; |
91 } | 78 } |
92 | 79 |
93 bool WillDrawOnRT(SharedRendererState* functor, | 80 bool WillDrawOnRT(SharedRendererState* functor, |
94 AwDrawGLInfo* draw_info) override { | 81 AwDrawGLInfo* draw_info) override { |
95 if (draw_gl_count_on_rt_ == 1u) { | 82 if (draw_gl_count_on_rt_ == 1) { |
96 draw_gl_count_on_rt_++; | 83 draw_gl_count_on_rt_++; |
97 ui_proxy_->PostTask(FROM_HERE, base::Bind(&RenderingTest::PostInvalidate, | 84 ui_proxy_->PostTask(FROM_HERE, base::Bind(&RenderingTest::PostInvalidate, |
98 base::Unretained(this))); | 85 base::Unretained(this))); |
99 return false; | 86 return false; |
100 } | 87 } |
101 | 88 |
102 draw_info->width = window_->surface_size().width(); | 89 draw_info->width = window_->surface_size().width(); |
103 draw_info->height = window_->surface_size().height(); | 90 draw_info->height = window_->surface_size().height(); |
104 draw_info->is_layer = false; | 91 draw_info->is_layer = false; |
105 | 92 |
106 gfx::Transform transform; | 93 gfx::Transform transform; |
107 if (draw_gl_count_on_rt_ == 0u) | 94 if (draw_gl_count_on_rt_ == 0) |
108 transform = new_constraints_.transform; | 95 transform = new_constraints_.transform; |
109 | 96 |
110 transform.matrix().asColMajorf(draw_info->transform); | 97 transform.matrix().asColMajorf(draw_info->transform); |
111 return true; | 98 return true; |
112 } | 99 } |
113 | 100 |
114 void DidDrawOnRT(SharedRendererState* functor) override { | 101 void DidDrawOnRT(SharedRendererState* functor) override { |
115 draw_gl_count_on_rt_++; | 102 draw_gl_count_on_rt_++; |
116 } | 103 } |
117 | 104 |
(...skipping 20 matching lines...) Expand all Loading... |
138 break; | 125 break; |
139 // There will be a following 4th onDraw. But the hardware renderer won't | 126 // There will be a following 4th onDraw. But the hardware renderer won't |
140 // post back the draw constraints in DrawGL because the constraints | 127 // post back the draw constraints in DrawGL because the constraints |
141 // don't change. | 128 // don't change. |
142 default: | 129 default: |
143 FAIL(); | 130 FAIL(); |
144 } | 131 } |
145 } | 132 } |
146 | 133 |
147 private: | 134 private: |
148 size_t on_draw_count_; | 135 int on_draw_count_; |
149 size_t draw_gl_count_on_rt_; | 136 int draw_gl_count_on_rt_; |
150 ParentCompositorDrawConstraints initial_constraints_; | 137 ParentCompositorDrawConstraints initial_constraints_; |
151 ParentCompositorDrawConstraints new_constraints_; | 138 ParentCompositorDrawConstraints new_constraints_; |
152 }; | 139 }; |
153 | 140 |
154 RENDERING_TEST_F(TestAnimateInAndOutOfScreen); | 141 RENDERING_TEST_F(TestAnimateInAndOutOfScreen); |
155 | 142 |
156 } // namespace android_webview | 143 } // namespace android_webview |
OLD | NEW |