| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 .SetValue("DEFAULT_INPUT", 0) | 488 .SetValue("DEFAULT_INPUT", 0) |
| 489 .SetValue("TOUCH_INPUT", 1) | 489 .SetValue("TOUCH_INPUT", 1) |
| 490 .SetValue("MOUSE_INPUT", 2) | 490 .SetValue("MOUSE_INPUT", 2) |
| 491 .SetMethod("gestureSourceTypeSupported", | 491 .SetMethod("gestureSourceTypeSupported", |
| 492 &GpuBenchmarking::GestureSourceTypeSupported) | 492 &GpuBenchmarking::GestureSourceTypeSupported) |
| 493 .SetMethod("smoothScrollBy", &GpuBenchmarking::SmoothScrollBy) | 493 .SetMethod("smoothScrollBy", &GpuBenchmarking::SmoothScrollBy) |
| 494 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) | 494 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) |
| 495 .SetMethod("swipe", &GpuBenchmarking::Swipe) | 495 .SetMethod("swipe", &GpuBenchmarking::Swipe) |
| 496 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) | 496 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) |
| 497 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) | 497 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) |
| 498 .SetMethod("pageScaleFactor", &GpuBenchmarking::PageScaleFactor) |
| 499 .SetMethod("visualViewportX", &GpuBenchmarking::VisualViewportX) |
| 500 .SetMethod("visualViewportY", &GpuBenchmarking::VisualViewportY) |
| 498 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) | 501 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) |
| 499 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) | 502 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) |
| 500 .SetMethod("tap", &GpuBenchmarking::Tap) | 503 .SetMethod("tap", &GpuBenchmarking::Tap) |
| 501 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) | 504 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) |
| 502 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) | 505 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) |
| 503 .SetMethod("sendMessageToMicroBenchmark", | 506 .SetMethod("sendMessageToMicroBenchmark", |
| 504 &GpuBenchmarking::SendMessageToMicroBenchmark) | 507 &GpuBenchmarking::SendMessageToMicroBenchmark) |
| 505 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) | 508 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) |
| 506 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess); | 509 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess); |
| 507 } | 510 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 !GetArg(args, &anchor_x) || | 758 !GetArg(args, &anchor_x) || |
| 756 !GetArg(args, &anchor_y) || | 759 !GetArg(args, &anchor_y) || |
| 757 !GetOptionalArg(args, &callback) || | 760 !GetOptionalArg(args, &callback) || |
| 758 !GetOptionalArg(args, &relative_pointer_speed_in_pixels_s)) { | 761 !GetOptionalArg(args, &relative_pointer_speed_in_pixels_s)) { |
| 759 return false; | 762 return false; |
| 760 } | 763 } |
| 761 | 764 |
| 762 scoped_ptr<SyntheticPinchGestureParams> gesture_params( | 765 scoped_ptr<SyntheticPinchGestureParams> gesture_params( |
| 763 new SyntheticPinchGestureParams); | 766 new SyntheticPinchGestureParams); |
| 764 | 767 |
| 768 // TODO(bokan): Remove page scale here when change land in Catapult. |
| 765 // Convert coordinates from CSS pixels to density independent pixels (DIPs). | 769 // Convert coordinates from CSS pixels to density independent pixels (DIPs). |
| 766 float page_scale_factor = context.web_view()->pageScaleFactor(); | 770 float page_scale_factor = context.web_view()->pageScaleFactor(); |
| 767 | 771 |
| 768 gesture_params->scale_factor = scale_factor; | 772 gesture_params->scale_factor = scale_factor; |
| 769 gesture_params->anchor.SetPoint(anchor_x * page_scale_factor, | 773 gesture_params->anchor.SetPoint(anchor_x * page_scale_factor, |
| 770 anchor_y * page_scale_factor); | 774 anchor_y * page_scale_factor); |
| 771 gesture_params->relative_pointer_speed_in_pixels_s = | 775 gesture_params->relative_pointer_speed_in_pixels_s = |
| 772 relative_pointer_speed_in_pixels_s; | 776 relative_pointer_speed_in_pixels_s; |
| 773 | 777 |
| 774 scoped_refptr<CallbackAndContext> callback_and_context = | 778 scoped_refptr<CallbackAndContext> callback_and_context = |
| 775 new CallbackAndContext(args->isolate(), | 779 new CallbackAndContext(args->isolate(), |
| 776 callback, | 780 callback, |
| 777 context.web_frame()->mainWorldScriptContext()); | 781 context.web_frame()->mainWorldScriptContext()); |
| 778 | 782 |
| 779 | 783 |
| 780 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in | 784 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
| 781 // progress, we will leak the callback and context. This needs to be fixed, | 785 // progress, we will leak the callback and context. This needs to be fixed, |
| 782 // somehow. | 786 // somehow. |
| 783 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 787 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
| 784 std::move(gesture_params), | 788 std::move(gesture_params), |
| 785 base::Bind(&OnSyntheticGestureCompleted, | 789 base::Bind(&OnSyntheticGestureCompleted, |
| 786 base::RetainedRef(callback_and_context))); | 790 base::RetainedRef(callback_and_context))); |
| 787 | 791 |
| 788 return true; | 792 return true; |
| 789 } | 793 } |
| 790 | 794 |
| 795 float GpuBenchmarking::PageScaleFactor() { |
| 796 GpuBenchmarkingContext context; |
| 797 if (!context.Init(false)) |
| 798 return 0.0; |
| 799 return context.web_view()->pageScaleFactor(); |
| 800 } |
| 801 |
| 802 float GpuBenchmarking::VisualViewportY() { |
| 803 GpuBenchmarkingContext context; |
| 804 if (!context.Init(false)) |
| 805 return 0.0; |
| 806 return context.web_view()->visualViewportOffset().y; |
| 807 } |
| 808 |
| 809 float GpuBenchmarking::VisualViewportX() { |
| 810 GpuBenchmarkingContext context; |
| 811 if (!context.Init(false)) |
| 812 return 0.0; |
| 813 return context.web_view()->visualViewportOffset().x; |
| 814 } |
| 815 |
| 791 float GpuBenchmarking::VisualViewportHeight() { | 816 float GpuBenchmarking::VisualViewportHeight() { |
| 792 GpuBenchmarkingContext context; | 817 GpuBenchmarkingContext context; |
| 793 if (!context.Init(false)) | 818 if (!context.Init(false)) |
| 794 return 0.0; | 819 return 0.0; |
| 795 return context.web_view()->visualViewportSize().height; | 820 return context.web_view()->visualViewportSize().height; |
| 796 } | 821 } |
| 797 | 822 |
| 798 float GpuBenchmarking::VisualViewportWidth() { | 823 float GpuBenchmarking::VisualViewportWidth() { |
| 799 GpuBenchmarkingContext context; | 824 GpuBenchmarkingContext context; |
| 800 if (!context.Init(false)) | 825 if (!context.Init(false)) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 bool GpuBenchmarking::HasGpuProcess() { | 942 bool GpuBenchmarking::HasGpuProcess() { |
| 918 bool has_gpu_process = false; | 943 bool has_gpu_process = false; |
| 919 if (!RenderThreadImpl::current()->Send( | 944 if (!RenderThreadImpl::current()->Send( |
| 920 new ChildProcessHostMsg_HasGpuProcess(&has_gpu_process))) | 945 new ChildProcessHostMsg_HasGpuProcess(&has_gpu_process))) |
| 921 return false; | 946 return false; |
| 922 | 947 |
| 923 return has_gpu_process; | 948 return has_gpu_process; |
| 924 } | 949 } |
| 925 | 950 |
| 926 } // namespace content | 951 } // namespace content |
| OLD | NEW |