OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/gpu/gpu_benchmarking_extension.h" | 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 int gesture_source_type, | 282 int gesture_source_type, |
283 const std::string& direction, | 283 const std::string& direction, |
284 float speed_in_pixels_s, | 284 float speed_in_pixels_s, |
285 bool prevent_fling, | 285 bool prevent_fling, |
286 float start_x, | 286 float start_x, |
287 float start_y) { | 287 float start_y) { |
288 GpuBenchmarkingContext context; | 288 GpuBenchmarkingContext context; |
289 if (!context.Init(false)) | 289 if (!context.Init(false)) |
290 return false; | 290 return false; |
291 | 291 |
| 292 // Convert coordinates from CSS pixels to density independent pixels (DIPs). |
| 293 float page_scale_factor = context.web_view()->pageScaleFactor(); |
| 294 |
| 295 if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT) { |
| 296 // Ensure the mouse is centered and visible, in case it will |
| 297 // trigger any hover or mousemove effects. |
| 298 blink::WebRect contentRect = |
| 299 context.web_view()->mainFrame()->visibleContentRect(); |
| 300 blink::WebMouseEvent mouseMove; |
| 301 mouseMove.type = blink::WebInputEvent::MouseMove; |
| 302 mouseMove.x = (contentRect.x + contentRect.width / 2) * page_scale_factor; |
| 303 mouseMove.y = (contentRect.y + contentRect.height / 2) * page_scale_factor; |
| 304 context.web_view()->handleInputEvent(mouseMove); |
| 305 context.web_view()->setCursorVisibilityState(true); |
| 306 } |
| 307 |
292 scoped_refptr<CallbackAndContext> callback_and_context = | 308 scoped_refptr<CallbackAndContext> callback_and_context = |
293 new CallbackAndContext( | 309 new CallbackAndContext( |
294 isolate, callback, context.web_frame()->mainWorldScriptContext()); | 310 isolate, callback, context.web_frame()->mainWorldScriptContext()); |
295 | 311 |
296 scoped_ptr<SyntheticSmoothScrollGestureParams> gesture_params( | 312 scoped_ptr<SyntheticSmoothScrollGestureParams> gesture_params( |
297 new SyntheticSmoothScrollGestureParams); | 313 new SyntheticSmoothScrollGestureParams); |
298 | 314 |
299 // Convert coordinates from CSS pixels to density independent pixels (DIPs). | |
300 float page_scale_factor = context.web_view()->pageScaleFactor(); | |
301 | |
302 if (gesture_source_type < 0 || | 315 if (gesture_source_type < 0 || |
303 gesture_source_type > SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX) { | 316 gesture_source_type > SyntheticGestureParams::GESTURE_SOURCE_TYPE_MAX) { |
304 return false; | 317 return false; |
305 } | 318 } |
306 gesture_params->gesture_source_type = | 319 gesture_params->gesture_source_type = |
307 static_cast<SyntheticGestureParams::GestureSourceType>( | 320 static_cast<SyntheticGestureParams::GestureSourceType>( |
308 gesture_source_type); | 321 gesture_source_type); |
309 | 322 |
310 gesture_params->speed_in_pixels_s = speed_in_pixels_s; | 323 gesture_params->speed_in_pixels_s = speed_in_pixels_s; |
311 gesture_params->prevent_fling = prevent_fling; | 324 gesture_params->prevent_fling = prevent_fling; |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 847 |
835 return context.compositor()->SendMessageToMicroBenchmark(id, value.Pass()); | 848 return context.compositor()->SendMessageToMicroBenchmark(id, value.Pass()); |
836 } | 849 } |
837 | 850 |
838 bool GpuBenchmarking::HasGpuProcess() { | 851 bool GpuBenchmarking::HasGpuProcess() { |
839 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 852 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
840 return !!gpu_channel; | 853 return !!gpu_channel; |
841 } | 854 } |
842 | 855 |
843 } // namespace content | 856 } // namespace content |
OLD | NEW |