| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 base::MessageLoopProxy::current()->PostTask( | 111 base::MessageLoopProxy::current()->PostTask( |
| 113 FROM_HERE, | 112 FROM_HERE, |
| 114 base::Bind(&FakeWindow::OnDrawHardware, weak_ptr_factory_.GetWeakPtr())); | 113 base::Bind(&FakeWindow::OnDrawHardware, weak_ptr_factory_.GetWeakPtr())); |
| 115 } | 114 } |
| 116 | 115 |
| 117 void FakeWindow::OnDrawHardware() { | 116 void FakeWindow::OnDrawHardware() { |
| 118 CheckCurrentlyOnUIThread(); | 117 CheckCurrentlyOnUIThread(); |
| 119 DCHECK(on_draw_hardware_pending_); | 118 DCHECK(on_draw_hardware_pending_); |
| 120 on_draw_hardware_pending_ = false; | 119 on_draw_hardware_pending_ = false; |
| 121 | 120 |
| 121 view_->PrepareToDraw(gfx::Vector2d(), location_); |
| 122 hooks_->WillOnDraw(); | 122 hooks_->WillOnDraw(); |
| 123 view_->PrepareToDraw(gfx::Vector2d(), location_); | |
| 124 bool success = view_->OnDrawHardware(); | 123 bool success = view_->OnDrawHardware(); |
| 125 hooks_->DidOnDraw(success); | 124 hooks_->DidOnDraw(success); |
| 126 if (success) { | 125 if (success) { |
| 127 CreateRenderThreadIfNeeded(); | 126 CreateRenderThreadIfNeeded(); |
| 128 | 127 |
| 129 base::WaitableEvent completion(true, false); | 128 base::WaitableEvent completion(true, false); |
| 130 render_thread_loop_->PostTask( | 129 render_thread_loop_->PostTask( |
| 131 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, | 130 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, |
| 132 base::Unretained(this), &completion)); | 131 base::Unretained(this), &completion)); |
| 133 completion.Wait(); | 132 completion.Wait(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 } | 148 } |
| 150 sync->Signal(); | 149 sync->Signal(); |
| 151 | 150 |
| 152 AwDrawGLInfo draw_info; | 151 AwDrawGLInfo draw_info; |
| 153 draw_info.version = kAwDrawGLInfoVersion; | 152 draw_info.version = kAwDrawGLInfoVersion; |
| 154 draw_info.mode = AwDrawGLInfo::kModeDraw; | 153 draw_info.mode = AwDrawGLInfo::kModeDraw; |
| 155 draw_info.clip_left = location.x(); | 154 draw_info.clip_left = location.x(); |
| 156 draw_info.clip_top = location.y(); | 155 draw_info.clip_top = location.y(); |
| 157 draw_info.clip_right = location.x() + location.width(); | 156 draw_info.clip_right = location.x() + location.width(); |
| 158 draw_info.clip_bottom = location.y() + location.height(); | 157 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 | 158 |
| 163 draw_info.transform[0] = 1.0; | 159 if (!hooks_->WillDrawOnRT(functor_, &draw_info)) |
| 164 draw_info.transform[1] = 0.0; | 160 return; |
| 165 draw_info.transform[2] = 0.0; | |
| 166 draw_info.transform[3] = 0.0; | |
| 167 | 161 |
| 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 { | 162 { |
| 185 ScopedMakeCurrent make_current(this); | 163 ScopedMakeCurrent make_current(this); |
| 186 functor_->DrawGL(&draw_info); | 164 functor_->DrawGL(&draw_info); |
| 187 } | 165 } |
| 188 hooks_->DidDrawOnRT(functor_); | 166 hooks_->DidDrawOnRT(functor_); |
| 189 } | 167 } |
| 190 | 168 |
| 191 void FakeWindow::CheckCurrentlyOnUIThread() { | 169 void FakeWindow::CheckCurrentlyOnUIThread() { |
| 192 DCHECK(ui_checker_.CalledOnValidSequencedThread()); | 170 DCHECK(ui_checker_.CalledOnValidSequencedThread()); |
| 193 } | 171 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 surface_ = nullptr; | 209 surface_ = nullptr; |
| 232 } | 210 } |
| 233 sync->Signal(); | 211 sync->Signal(); |
| 234 } | 212 } |
| 235 | 213 |
| 236 void FakeWindow::CheckCurrentlyOnRT() { | 214 void FakeWindow::CheckCurrentlyOnRT() { |
| 237 DCHECK(rt_checker_.CalledOnValidSequencedThread()); | 215 DCHECK(rt_checker_.CalledOnValidSequencedThread()); |
| 238 } | 216 } |
| 239 | 217 |
| 240 } // namespace android_webview | 218 } // namespace android_webview |
| OLD | NEW |