| 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/test/fake_window.h" | 5 #include "android_webview/browser/test/fake_window.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/browser_view_renderer.h" | 7 #include "android_webview/browser/browser_view_renderer.h" |
| 8 #include "android_webview/public/browser/draw_gl.h" | |
| 9 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 12 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 13 | 12 |
| 14 namespace android_webview { | 13 namespace android_webview { |
| 15 | 14 |
| 16 class FakeWindow::ScopedMakeCurrent { | 15 class FakeWindow::ScopedMakeCurrent { |
| 17 public: | 16 public: |
| 18 ScopedMakeCurrent(FakeWindow* view_root) : view_root_(view_root) { | 17 ScopedMakeCurrent(FakeWindow* view_root) : view_root_(view_root) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 hooks_->DidProcessOnRT(functor_); | 100 hooks_->DidProcessOnRT(functor_); |
| 102 | 101 |
| 103 if (sync) | 102 if (sync) |
| 104 sync->Signal(); | 103 sync->Signal(); |
| 105 } | 104 } |
| 106 | 105 |
| 107 void FakeWindow::PostInvalidate() { | 106 void FakeWindow::PostInvalidate() { |
| 108 CheckCurrentlyOnUIThread(); | 107 CheckCurrentlyOnUIThread(); |
| 109 if (on_draw_hardware_pending_) | 108 if (on_draw_hardware_pending_) |
| 110 return; | 109 return; |
| 110 |
| 111 on_draw_hardware_pending_ = true; | 111 on_draw_hardware_pending_ = true; |
| 112 base::MessageLoopProxy::current()->PostTask( | 112 base::MessageLoopProxy::current()->PostTask( |
| 113 FROM_HERE, | 113 FROM_HERE, |
| 114 base::Bind(&FakeWindow::OnDrawHardware, weak_ptr_factory_.GetWeakPtr())); | 114 base::Bind(&FakeWindow::OnDrawHardware, weak_ptr_factory_.GetWeakPtr())); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void FakeWindow::OnDrawHardware() { | 117 void FakeWindow::OnDrawHardware() { |
| 118 CheckCurrentlyOnUIThread(); | 118 CheckCurrentlyOnUIThread(); |
| 119 DCHECK(on_draw_hardware_pending_); | 119 DCHECK(on_draw_hardware_pending_); |
| 120 on_draw_hardware_pending_ = false; | 120 on_draw_hardware_pending_ = false; |
| 121 | 121 |
| 122 view_->PrepareToDraw(gfx::Vector2d(), location_); |
| 122 hooks_->WillOnDraw(); | 123 hooks_->WillOnDraw(); |
| 123 view_->PrepareToDraw(gfx::Vector2d(), location_); | |
| 124 bool success = view_->OnDrawHardware(); | 124 bool success = view_->OnDrawHardware(); |
| 125 hooks_->DidOnDraw(success); | 125 hooks_->DidOnDraw(success); |
| 126 if (success) { | 126 if (success) { |
| 127 CreateRenderThreadIfNeeded(); | 127 CreateRenderThreadIfNeeded(); |
| 128 | 128 |
| 129 base::WaitableEvent completion(true, false); | 129 base::WaitableEvent completion(true, false); |
| 130 render_thread_loop_->PostTask( | 130 render_thread_loop_->PostTask( |
| 131 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, | 131 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, |
| 132 base::Unretained(this), &completion)); | 132 base::Unretained(this), &completion)); |
| 133 completion.Wait(); | 133 completion.Wait(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 } | 149 } |
| 150 sync->Signal(); | 150 sync->Signal(); |
| 151 | 151 |
| 152 AwDrawGLInfo draw_info; | 152 AwDrawGLInfo draw_info; |
| 153 draw_info.version = kAwDrawGLInfoVersion; | 153 draw_info.version = kAwDrawGLInfoVersion; |
| 154 draw_info.mode = AwDrawGLInfo::kModeDraw; | 154 draw_info.mode = AwDrawGLInfo::kModeDraw; |
| 155 draw_info.clip_left = location.x(); | 155 draw_info.clip_left = location.x(); |
| 156 draw_info.clip_top = location.y(); | 156 draw_info.clip_top = location.y(); |
| 157 draw_info.clip_right = location.x() + location.width(); | 157 draw_info.clip_right = location.x() + location.width(); |
| 158 draw_info.clip_bottom = location.y() + location.height(); | 158 draw_info.clip_bottom = location.y() + location.height(); |
| 159 draw_info.width = surface_size_.width(); | |
| 160 draw_info.height = surface_size_.height(); | |
| 161 draw_info.is_layer = false; | |
| 162 | 159 |
| 163 draw_info.transform[0] = 1.0; | 160 if (!hooks_->WillDrawOnRT(functor_, draw_info)) |
| 164 draw_info.transform[1] = 0.0; | 161 return; |
| 165 draw_info.transform[2] = 0.0; | |
| 166 draw_info.transform[3] = 0.0; | |
| 167 | 162 |
| 168 draw_info.transform[4] = 0.0; | |
| 169 draw_info.transform[5] = 1.0; | |
| 170 draw_info.transform[6] = 0.0; | |
| 171 draw_info.transform[7] = 0.0; | |
| 172 | |
| 173 draw_info.transform[8] = 0.0; | |
| 174 draw_info.transform[9] = 0.0; | |
| 175 draw_info.transform[10] = 1.0; | |
| 176 draw_info.transform[11] = 0.0; | |
| 177 | |
| 178 draw_info.transform[12] = 0.0; | |
| 179 draw_info.transform[13] = 0.0; | |
| 180 draw_info.transform[14] = 0.0; | |
| 181 draw_info.transform[15] = 1.0; | |
| 182 | |
| 183 hooks_->WillDrawOnRT(functor_); | |
| 184 { | 163 { |
| 185 ScopedMakeCurrent make_current(this); | 164 ScopedMakeCurrent make_current(this); |
| 186 functor_->DrawGL(&draw_info); | 165 functor_->DrawGL(&draw_info); |
| 187 } | 166 } |
| 188 hooks_->DidDrawOnRT(functor_); | 167 hooks_->DidDrawOnRT(functor_); |
| 189 } | 168 } |
| 190 | 169 |
| 191 void FakeWindow::CheckCurrentlyOnUIThread() { | 170 void FakeWindow::CheckCurrentlyOnUIThread() { |
| 192 DCHECK(ui_checker_.CalledOnValidSequencedThread()); | 171 DCHECK(ui_checker_.CalledOnValidSequencedThread()); |
| 193 } | 172 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 surface_ = nullptr; | 210 surface_ = nullptr; |
| 232 } | 211 } |
| 233 sync->Signal(); | 212 sync->Signal(); |
| 234 } | 213 } |
| 235 | 214 |
| 236 void FakeWindow::CheckCurrentlyOnRT() { | 215 void FakeWindow::CheckCurrentlyOnRT() { |
| 237 DCHECK(rt_checker_.CalledOnValidSequencedThread()); | 216 DCHECK(rt_checker_.CalledOnValidSequencedThread()); |
| 238 } | 217 } |
| 239 | 218 |
| 240 } // namespace android_webview | 219 } // namespace android_webview |
| OLD | NEW |