Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 293683002: Synthetic pinch gesture take scale factor as parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 10 #include "base/file_util.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 " overscroll = overscroll || 0;" 279 " overscroll = overscroll || 0;"
280 " repeat_count = opt_repeat_count || 1;" 280 " repeat_count = opt_repeat_count || 1;"
281 " callback = opt_callback || function() { };" 281 " callback = opt_callback || function() { };"
282 " speed_in_pixels_s = opt_speed_in_pixels_s || 800;" 282 " speed_in_pixels_s = opt_speed_in_pixels_s || 800;"
283 " native function BeginScrollBounce();" 283 " native function BeginScrollBounce();"
284 " return BeginScrollBounce(direction, distance, overscroll," 284 " return BeginScrollBounce(direction, distance, overscroll,"
285 " repeat_count, callback," 285 " repeat_count, callback,"
286 " speed_in_pixels_s," 286 " speed_in_pixels_s,"
287 " opt_start_x, opt_start_y);" 287 " opt_start_x, opt_start_y);"
288 "};" 288 "};"
289 // TODO(dominikg): Remove once JS interface changes have rolled into
290 // stable.
291 "chrome.gpuBenchmarking.newPinchInterface = true;"
289 "chrome.gpuBenchmarking.pinchBy = " 292 "chrome.gpuBenchmarking.pinchBy = "
290 " function(zoom_in, pixels_to_cover, anchor_x, anchor_y," 293 " function(scale_factor, anchor_x, anchor_y,"
291 " opt_callback, opt_relative_pointer_speed_in_pixels_s) {" 294 " opt_callback, opt_relative_pointer_speed_in_pixels_s) {"
292 " callback = opt_callback || function() { };" 295 " callback = opt_callback || function() { };"
293 " relative_pointer_speed_in_pixels_s =" 296 " relative_pointer_speed_in_pixels_s ="
294 " opt_relative_pointer_speed_in_pixels_s || 800;" 297 " opt_relative_pointer_speed_in_pixels_s || 800;"
295 " native function BeginPinch();" 298 " native function BeginPinch();"
296 " return BeginPinch(zoom_in, pixels_to_cover," 299 " return BeginPinch(scale_factor, anchor_x, anchor_y, callback,"
297 " anchor_x, anchor_y, callback,"
298 " relative_pointer_speed_in_pixels_s);" 300 " relative_pointer_speed_in_pixels_s);"
299 "};" 301 "};"
300 "chrome.gpuBenchmarking.tap = " 302 "chrome.gpuBenchmarking.tap = "
301 " function(position_x, position_y, opt_callback, opt_duration_ms," 303 " function(position_x, position_y, opt_callback, opt_duration_ms,"
302 " opt_gesture_source_type) {" 304 " opt_gesture_source_type) {"
303 " callback = opt_callback || function() { };" 305 " callback = opt_callback || function() { };"
304 " duration_ms = opt_duration_ms || 50;" 306 " duration_ms = opt_duration_ms || 50;"
305 " gesture_source_type = opt_gesture_source_type ||" 307 " gesture_source_type = opt_gesture_source_type ||"
306 " chrome.gpuBenchmarking.DEFAULT_INPUT;" 308 " chrome.gpuBenchmarking.DEFAULT_INPUT;"
307 " native function BeginTap();" 309 " native function BeginTap();"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 args.GetReturnValue().Set(true); 635 args.GetReturnValue().Set(true);
634 } 636 }
635 637
636 static void BeginPinch( 638 static void BeginPinch(
637 const v8::FunctionCallbackInfo<v8::Value>& args) { 639 const v8::FunctionCallbackInfo<v8::Value>& args) {
638 GpuBenchmarkingContext context; 640 GpuBenchmarkingContext context;
639 if (!context.Init(false)) 641 if (!context.Init(false))
640 return; 642 return;
641 643
642 int arglen = args.Length(); 644 int arglen = args.Length();
643 if (arglen < 6 || 645 if (arglen < 5 ||
644 !args[0]->IsBoolean() || 646 !args[0]->IsNumber() ||
645 !args[1]->IsNumber() || 647 !args[1]->IsNumber() ||
646 !args[2]->IsNumber() || 648 !args[2]->IsNumber() ||
647 !args[3]->IsNumber() || 649 !args[3]->IsFunction() ||
648 !args[4]->IsFunction() || 650 !args[4]->IsNumber()) {
649 !args[5]->IsNumber()) {
650 args.GetReturnValue().Set(false); 651 args.GetReturnValue().Set(false);
651 return; 652 return;
652 } 653 }
653 654
654 scoped_ptr<SyntheticPinchGestureParams> gesture_params( 655 scoped_ptr<SyntheticPinchGestureParams> gesture_params(
655 new SyntheticPinchGestureParams); 656 new SyntheticPinchGestureParams);
656 657
657 // Convert coordinates from CSS pixels to density independent pixels (DIPs). 658 // Convert coordinates from CSS pixels to density independent pixels (DIPs).
658 float page_scale_factor = context.web_view()->pageScaleFactor(); 659 float page_scale_factor = context.web_view()->pageScaleFactor();
659 660
660 gesture_params->zoom_in = args[0]->BooleanValue(); 661 gesture_params->scale_factor = args[0]->NumberValue();
661 gesture_params->total_num_pixels_covered =
662 args[1]->IntegerValue() * page_scale_factor;
663 gesture_params->anchor.SetPoint( 662 gesture_params->anchor.SetPoint(
664 args[2]->IntegerValue() * page_scale_factor, 663 args[1]->IntegerValue() * page_scale_factor,
665 args[3]->IntegerValue() * page_scale_factor); 664 args[2]->IntegerValue() * page_scale_factor);
666 gesture_params->relative_pointer_speed_in_pixels_s = 665 gesture_params->relative_pointer_speed_in_pixels_s =
667 args[5]->IntegerValue(); 666 args[4]->IntegerValue();
668 667
669 v8::Local<v8::Function> callback_local = 668 v8::Local<v8::Function> callback_local =
670 v8::Local<v8::Function>::Cast(args[4]); 669 v8::Local<v8::Function>::Cast(args[3]);
671 670
672 scoped_refptr<CallbackAndContext> callback_and_context = 671 scoped_refptr<CallbackAndContext> callback_and_context =
673 new CallbackAndContext(args.GetIsolate(), 672 new CallbackAndContext(args.GetIsolate(),
674 callback_local, 673 callback_local,
675 context.web_frame()->mainWorldScriptContext()); 674 context.web_frame()->mainWorldScriptContext());
676 675
677 676
678 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in 677 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
679 // progress, we will leak the callback and context. This needs to be fixed, 678 // progress, we will leak the callback and context. This needs to be fixed,
680 // somehow. 679 // somehow.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); 880 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
882 args.GetReturnValue().Set(!!gpu_channel); 881 args.GetReturnValue().Set(!!gpu_channel);
883 } 882 }
884 }; 883 };
885 884
886 v8::Extension* GpuBenchmarkingExtension::Get() { 885 v8::Extension* GpuBenchmarkingExtension::Get() {
887 return new GpuBenchmarkingWrapper(); 886 return new GpuBenchmarkingWrapper();
888 } 887 }
889 888
890 } // namespace content 889 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698