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