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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } else { | 391 } else { |
392 return false; | 392 return false; |
393 } | 393 } |
394 gesture_params->distances.push_back(distance); | 394 gesture_params->distances.push_back(distance); |
395 | 395 |
396 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in | 396 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
397 // progress, we will leak the callback and context. This needs to be fixed, | 397 // progress, we will leak the callback and context. This needs to be fixed, |
398 // somehow. | 398 // somehow. |
399 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 399 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
400 std::move(gesture_params), | 400 std::move(gesture_params), |
401 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); | 401 base::Bind(&OnSyntheticGestureCompleted, |
| 402 base::RetainedRef(callback_and_context))); |
402 | 403 |
403 return true; | 404 return true; |
404 } | 405 } |
405 | 406 |
406 bool BeginSmoothDrag(v8::Isolate* isolate, | 407 bool BeginSmoothDrag(v8::Isolate* isolate, |
407 float start_x, | 408 float start_x, |
408 float start_y, | 409 float start_y, |
409 float end_x, | 410 float end_x, |
410 float end_y, | 411 float end_y, |
411 v8::Local<v8::Function> callback, | 412 v8::Local<v8::Function> callback, |
(...skipping 21 matching lines...) Expand all Loading... |
433 gesture_params->speed_in_pixels_s = speed_in_pixels_s * page_scale_factor; | 434 gesture_params->speed_in_pixels_s = speed_in_pixels_s * page_scale_factor; |
434 gesture_params->gesture_source_type = | 435 gesture_params->gesture_source_type = |
435 static_cast<SyntheticGestureParams::GestureSourceType>( | 436 static_cast<SyntheticGestureParams::GestureSourceType>( |
436 gesture_source_type); | 437 gesture_source_type); |
437 | 438 |
438 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in | 439 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
439 // progress, we will leak the callback and context. This needs to be fixed, | 440 // progress, we will leak the callback and context. This needs to be fixed, |
440 // somehow. | 441 // somehow. |
441 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 442 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
442 std::move(gesture_params), | 443 std::move(gesture_params), |
443 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); | 444 base::Bind(&OnSyntheticGestureCompleted, |
| 445 base::RetainedRef(callback_and_context))); |
444 | 446 |
445 return true; | 447 return true; |
446 } | 448 } |
447 | 449 |
448 } // namespace | 450 } // namespace |
449 | 451 |
450 gin::WrapperInfo GpuBenchmarking::kWrapperInfo = {gin::kEmbedderNativeGin}; | 452 gin::WrapperInfo GpuBenchmarking::kWrapperInfo = {gin::kEmbedderNativeGin}; |
451 | 453 |
452 // static | 454 // static |
453 void GpuBenchmarking::Install(blink::WebFrame* frame) { | 455 void GpuBenchmarking::Install(blink::WebFrame* frame) { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 for (int i = 0; i < repeat_count; i++) { | 726 for (int i = 0; i < repeat_count; i++) { |
725 gesture_params->distances.push_back(distance); | 727 gesture_params->distances.push_back(distance); |
726 gesture_params->distances.push_back(-distance + overscroll); | 728 gesture_params->distances.push_back(-distance + overscroll); |
727 } | 729 } |
728 | 730 |
729 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in | 731 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
730 // progress, we will leak the callback and context. This needs to be fixed, | 732 // progress, we will leak the callback and context. This needs to be fixed, |
731 // somehow. | 733 // somehow. |
732 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 734 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
733 std::move(gesture_params), | 735 std::move(gesture_params), |
734 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); | 736 base::Bind(&OnSyntheticGestureCompleted, |
| 737 base::RetainedRef(callback_and_context))); |
735 | 738 |
736 return true; | 739 return true; |
737 } | 740 } |
738 | 741 |
739 bool GpuBenchmarking::PinchBy(gin::Arguments* args) { | 742 bool GpuBenchmarking::PinchBy(gin::Arguments* args) { |
740 GpuBenchmarkingContext context; | 743 GpuBenchmarkingContext context; |
741 if (!context.Init(false)) | 744 if (!context.Init(false)) |
742 return false; | 745 return false; |
743 | 746 |
744 float scale_factor; | 747 float scale_factor; |
(...skipping 27 matching lines...) Expand all Loading... |
772 new CallbackAndContext(args->isolate(), | 775 new CallbackAndContext(args->isolate(), |
773 callback, | 776 callback, |
774 context.web_frame()->mainWorldScriptContext()); | 777 context.web_frame()->mainWorldScriptContext()); |
775 | 778 |
776 | 779 |
777 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in | 780 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
778 // progress, we will leak the callback and context. This needs to be fixed, | 781 // progress, we will leak the callback and context. This needs to be fixed, |
779 // somehow. | 782 // somehow. |
780 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 783 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
781 std::move(gesture_params), | 784 std::move(gesture_params), |
782 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); | 785 base::Bind(&OnSyntheticGestureCompleted, |
| 786 base::RetainedRef(callback_and_context))); |
783 | 787 |
784 return true; | 788 return true; |
785 } | 789 } |
786 | 790 |
787 float GpuBenchmarking::VisualViewportHeight() { | 791 float GpuBenchmarking::VisualViewportHeight() { |
788 GpuBenchmarkingContext context; | 792 GpuBenchmarkingContext context; |
789 if (!context.Init(false)) | 793 if (!context.Init(false)) |
790 return 0.0; | 794 return 0.0; |
791 return context.web_view()->visualViewportSize().height; | 795 return context.web_view()->visualViewportSize().height; |
792 } | 796 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 scoped_refptr<CallbackAndContext> callback_and_context = | 842 scoped_refptr<CallbackAndContext> callback_and_context = |
839 new CallbackAndContext(args->isolate(), | 843 new CallbackAndContext(args->isolate(), |
840 callback, | 844 callback, |
841 context.web_frame()->mainWorldScriptContext()); | 845 context.web_frame()->mainWorldScriptContext()); |
842 | 846 |
843 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in | 847 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
844 // progress, we will leak the callback and context. This needs to be fixed, | 848 // progress, we will leak the callback and context. This needs to be fixed, |
845 // somehow. | 849 // somehow. |
846 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 850 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
847 std::move(gesture_params), | 851 std::move(gesture_params), |
848 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); | 852 base::Bind(&OnSyntheticGestureCompleted, |
| 853 base::RetainedRef(callback_and_context))); |
849 | 854 |
850 return true; | 855 return true; |
851 } | 856 } |
852 | 857 |
853 void GpuBenchmarking::ClearImageCache() { | 858 void GpuBenchmarking::ClearImageCache() { |
854 WebImageCache::clear(); | 859 WebImageCache::clear(); |
855 } | 860 } |
856 | 861 |
857 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) { | 862 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) { |
858 GpuBenchmarkingContext context; | 863 GpuBenchmarkingContext context; |
(...skipping 15 matching lines...) Expand all Loading... |
874 context.web_frame()->mainWorldScriptContext()); | 879 context.web_frame()->mainWorldScriptContext()); |
875 | 880 |
876 scoped_ptr<V8ValueConverter> converter = | 881 scoped_ptr<V8ValueConverter> converter = |
877 make_scoped_ptr(V8ValueConverter::create()); | 882 make_scoped_ptr(V8ValueConverter::create()); |
878 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); | 883 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); |
879 scoped_ptr<base::Value> value = | 884 scoped_ptr<base::Value> value = |
880 make_scoped_ptr(converter->FromV8Value(arguments, v8_context)); | 885 make_scoped_ptr(converter->FromV8Value(arguments, v8_context)); |
881 | 886 |
882 return context.compositor()->ScheduleMicroBenchmark( | 887 return context.compositor()->ScheduleMicroBenchmark( |
883 name, std::move(value), | 888 name, std::move(value), |
884 base::Bind(&OnMicroBenchmarkCompleted, callback_and_context)); | 889 base::Bind(&OnMicroBenchmarkCompleted, |
| 890 base::RetainedRef(callback_and_context))); |
885 } | 891 } |
886 | 892 |
887 bool GpuBenchmarking::SendMessageToMicroBenchmark( | 893 bool GpuBenchmarking::SendMessageToMicroBenchmark( |
888 int id, | 894 int id, |
889 v8::Local<v8::Object> message) { | 895 v8::Local<v8::Object> message) { |
890 GpuBenchmarkingContext context; | 896 GpuBenchmarkingContext context; |
891 if (!context.Init(true)) | 897 if (!context.Init(true)) |
892 return false; | 898 return false; |
893 | 899 |
894 scoped_ptr<V8ValueConverter> converter = | 900 scoped_ptr<V8ValueConverter> converter = |
(...skipping 15 matching lines...) Expand all Loading... |
910 bool GpuBenchmarking::HasGpuProcess() { | 916 bool GpuBenchmarking::HasGpuProcess() { |
911 bool has_gpu_process = false; | 917 bool has_gpu_process = false; |
912 if (!RenderThreadImpl::current()->Send( | 918 if (!RenderThreadImpl::current()->Send( |
913 new ChildProcessHostMsg_HasGpuProcess(&has_gpu_process))) | 919 new ChildProcessHostMsg_HasGpuProcess(&has_gpu_process))) |
914 return false; | 920 return false; |
915 | 921 |
916 return has_gpu_process; | 922 return has_gpu_process; |
917 } | 923 } |
918 | 924 |
919 } // namespace content | 925 } // namespace content |
OLD | NEW |