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

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

Issue 1750863002: Revert of Separate RenderView from RenderWidget, part 1: inheritance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderwidgettest
Patch Set: Created 4 years, 9 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 render_view_impl_ = RenderViewImpl::FromWebView(web_view_); 202 render_view_impl_ = RenderViewImpl::FromWebView(web_view_);
203 if (!render_view_impl_) { 203 if (!render_view_impl_) {
204 web_frame_ = NULL; 204 web_frame_ = NULL;
205 web_view_ = NULL; 205 web_view_ = NULL;
206 return false; 206 return false;
207 } 207 }
208 208
209 if (!init_compositor) 209 if (!init_compositor)
210 return true; 210 return true;
211 211
212 compositor_ = render_view_impl_->GetWidget()->compositor(); 212 compositor_ = render_view_impl_->compositor();
213 if (!compositor_) { 213 if (!compositor_) {
214 web_frame_ = NULL; 214 web_frame_ = NULL;
215 web_view_ = NULL; 215 web_view_ = NULL;
216 render_view_impl_ = NULL; 216 render_view_impl_ = NULL;
217 return false; 217 return false;
218 } 218 }
219 219
220 return true; 220 return true;
221 } 221 }
222 222
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 distance.set_y(-distance_length); 354 distance.set_y(-distance_length);
355 distance.set_x(-distance_length); 355 distance.set_x(-distance_length);
356 } else { 356 } else {
357 return false; 357 return false;
358 } 358 }
359 gesture_params->distances.push_back(distance); 359 gesture_params->distances.push_back(distance);
360 360
361 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in 361 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
362 // progress, we will leak the callback and context. This needs to be fixed, 362 // progress, we will leak the callback and context. This needs to be fixed,
363 // somehow. 363 // somehow.
364 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( 364 context.render_view_impl()->QueueSyntheticGesture(
365 std::move(gesture_params), 365 std::move(gesture_params),
366 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); 366 base::Bind(&OnSyntheticGestureCompleted, callback_and_context));
367 367
368 return true; 368 return true;
369 } 369 }
370 370
371 bool BeginSmoothDrag(v8::Isolate* isolate, 371 bool BeginSmoothDrag(v8::Isolate* isolate,
372 float start_x, 372 float start_x,
373 float start_y, 373 float start_y,
374 float end_x, 374 float end_x,
(...skipping 21 matching lines...) Expand all
396 gfx::Vector2dF distance = end_point - gesture_params->start_point; 396 gfx::Vector2dF distance = end_point - gesture_params->start_point;
397 gesture_params->distances.push_back(distance); 397 gesture_params->distances.push_back(distance);
398 gesture_params->speed_in_pixels_s = speed_in_pixels_s * page_scale_factor; 398 gesture_params->speed_in_pixels_s = speed_in_pixels_s * page_scale_factor;
399 gesture_params->gesture_source_type = 399 gesture_params->gesture_source_type =
400 static_cast<SyntheticGestureParams::GestureSourceType>( 400 static_cast<SyntheticGestureParams::GestureSourceType>(
401 gesture_source_type); 401 gesture_source_type);
402 402
403 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in 403 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
404 // progress, we will leak the callback and context. This needs to be fixed, 404 // progress, we will leak the callback and context. This needs to be fixed,
405 // somehow. 405 // somehow.
406 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( 406 context.render_view_impl()->QueueSyntheticGesture(
407 std::move(gesture_params), 407 std::move(gesture_params),
408 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); 408 base::Bind(&OnSyntheticGestureCompleted, callback_and_context));
409 409
410 return true; 410 return true;
411 } 411 }
412 412
413 } // namespace 413 } // namespace
414 414
415 gin::WrapperInfo GpuBenchmarking::kWrapperInfo = {gin::kEmbedderNativeGin}; 415 gin::WrapperInfo GpuBenchmarking::kWrapperInfo = {gin::kEmbedderNativeGin};
416 416
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 static_cast<SyntheticGestureParams::GestureSourceType>( 519 static_cast<SyntheticGestureParams::GestureSourceType>(
520 gesture_source_type)); 520 gesture_source_type));
521 } 521 }
522 522
523 bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) { 523 bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) {
524 GpuBenchmarkingContext context; 524 GpuBenchmarkingContext context;
525 if (!context.Init(true)) 525 if (!context.Init(true))
526 return false; 526 return false;
527 527
528 float page_scale_factor = context.web_view()->pageScaleFactor(); 528 float page_scale_factor = context.web_view()->pageScaleFactor();
529 blink::WebRect rect = context.render_view_impl()->GetWidget()->windowRect(); 529 blink::WebRect rect = context.render_view_impl()->windowRect();
530 530
531 float pixels_to_scroll = 0; 531 float pixels_to_scroll = 0;
532 v8::Local<v8::Function> callback; 532 v8::Local<v8::Function> callback;
533 float start_x = rect.width / (page_scale_factor * 2); 533 float start_x = rect.width / (page_scale_factor * 2);
534 float start_y = rect.height / (page_scale_factor * 2); 534 float start_y = rect.height / (page_scale_factor * 2);
535 int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; 535 int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
536 std::string direction = "down"; 536 std::string direction = "down";
537 float speed_in_pixels_s = 800; 537 float speed_in_pixels_s = 800;
538 538
539 if (!GetOptionalArg(args, &pixels_to_scroll) || 539 if (!GetOptionalArg(args, &pixels_to_scroll) ||
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 gesture_source_type, 589 gesture_source_type,
590 speed_in_pixels_s); 590 speed_in_pixels_s);
591 } 591 }
592 592
593 bool GpuBenchmarking::Swipe(gin::Arguments* args) { 593 bool GpuBenchmarking::Swipe(gin::Arguments* args) {
594 GpuBenchmarkingContext context; 594 GpuBenchmarkingContext context;
595 if (!context.Init(true)) 595 if (!context.Init(true))
596 return false; 596 return false;
597 597
598 float page_scale_factor = context.web_view()->pageScaleFactor(); 598 float page_scale_factor = context.web_view()->pageScaleFactor();
599 blink::WebRect rect = context.render_view_impl()->GetWidget()->windowRect(); 599 blink::WebRect rect = context.render_view_impl()->windowRect();
600 600
601 std::string direction = "up"; 601 std::string direction = "up";
602 float pixels_to_scroll = 0; 602 float pixels_to_scroll = 0;
603 v8::Local<v8::Function> callback; 603 v8::Local<v8::Function> callback;
604 float start_x = rect.width / (page_scale_factor * 2); 604 float start_x = rect.width / (page_scale_factor * 2);
605 float start_y = rect.height / (page_scale_factor * 2); 605 float start_y = rect.height / (page_scale_factor * 2);
606 float speed_in_pixels_s = 800; 606 float speed_in_pixels_s = 800;
607 607
608 if (!GetOptionalArg(args, &direction) || 608 if (!GetOptionalArg(args, &direction) ||
609 !GetOptionalArg(args, &pixels_to_scroll) || 609 !GetOptionalArg(args, &pixels_to_scroll) ||
(...skipping 14 matching lines...) Expand all
624 start_x, 624 start_x,
625 start_y); 625 start_y);
626 } 626 }
627 627
628 bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) { 628 bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) {
629 GpuBenchmarkingContext context; 629 GpuBenchmarkingContext context;
630 if (!context.Init(false)) 630 if (!context.Init(false))
631 return false; 631 return false;
632 632
633 float page_scale_factor = context.web_view()->pageScaleFactor(); 633 float page_scale_factor = context.web_view()->pageScaleFactor();
634 blink::WebRect rect = context.render_view_impl()->GetWidget()->windowRect(); 634 blink::WebRect rect = context.render_view_impl()->windowRect();
635 635
636 std::string direction = "down"; 636 std::string direction = "down";
637 float distance_length = 0; 637 float distance_length = 0;
638 float overscroll_length = 0; 638 float overscroll_length = 0;
639 int repeat_count = 1; 639 int repeat_count = 1;
640 v8::Local<v8::Function> callback; 640 v8::Local<v8::Function> callback;
641 float start_x = rect.width / (page_scale_factor * 2); 641 float start_x = rect.width / (page_scale_factor * 2);
642 float start_y = rect.height / (page_scale_factor * 2); 642 float start_y = rect.height / (page_scale_factor * 2);
643 float speed_in_pixels_s = 800; 643 float speed_in_pixels_s = 800;
644 644
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 687 }
688 688
689 for (int i = 0; i < repeat_count; i++) { 689 for (int i = 0; i < repeat_count; i++) {
690 gesture_params->distances.push_back(distance); 690 gesture_params->distances.push_back(distance);
691 gesture_params->distances.push_back(-distance + overscroll); 691 gesture_params->distances.push_back(-distance + overscroll);
692 } 692 }
693 693
694 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in 694 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
695 // progress, we will leak the callback and context. This needs to be fixed, 695 // progress, we will leak the callback and context. This needs to be fixed,
696 // somehow. 696 // somehow.
697 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( 697 context.render_view_impl()->QueueSyntheticGesture(
698 std::move(gesture_params), 698 std::move(gesture_params),
699 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); 699 base::Bind(&OnSyntheticGestureCompleted, callback_and_context));
700 700
701 return true; 701 return true;
702 } 702 }
703 703
704 bool GpuBenchmarking::PinchBy(gin::Arguments* args) { 704 bool GpuBenchmarking::PinchBy(gin::Arguments* args) {
705 GpuBenchmarkingContext context; 705 GpuBenchmarkingContext context;
706 if (!context.Init(false)) 706 if (!context.Init(false))
707 return false; 707 return false;
(...skipping 27 matching lines...) Expand all
735 735
736 scoped_refptr<CallbackAndContext> callback_and_context = 736 scoped_refptr<CallbackAndContext> callback_and_context =
737 new CallbackAndContext(args->isolate(), 737 new CallbackAndContext(args->isolate(),
738 callback, 738 callback,
739 context.web_frame()->mainWorldScriptContext()); 739 context.web_frame()->mainWorldScriptContext());
740 740
741 741
742 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in 742 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
743 // progress, we will leak the callback and context. This needs to be fixed, 743 // progress, we will leak the callback and context. This needs to be fixed,
744 // somehow. 744 // somehow.
745 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( 745 context.render_view_impl()->QueueSyntheticGesture(
746 std::move(gesture_params), 746 std::move(gesture_params),
747 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); 747 base::Bind(&OnSyntheticGestureCompleted, callback_and_context));
748 748
749 return true; 749 return true;
750 } 750 }
751 751
752 float GpuBenchmarking::VisualViewportHeight() { 752 float GpuBenchmarking::VisualViewportHeight() {
753 GpuBenchmarkingContext context; 753 GpuBenchmarkingContext context;
754 if (!context.Init(false)) 754 if (!context.Init(false))
755 return 0.0; 755 return 0.0;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 gesture_source_type); 801 gesture_source_type);
802 802
803 scoped_refptr<CallbackAndContext> callback_and_context = 803 scoped_refptr<CallbackAndContext> callback_and_context =
804 new CallbackAndContext(args->isolate(), 804 new CallbackAndContext(args->isolate(),
805 callback, 805 callback,
806 context.web_frame()->mainWorldScriptContext()); 806 context.web_frame()->mainWorldScriptContext());
807 807
808 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in 808 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
809 // progress, we will leak the callback and context. This needs to be fixed, 809 // progress, we will leak the callback and context. This needs to be fixed,
810 // somehow. 810 // somehow.
811 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( 811 context.render_view_impl()->QueueSyntheticGesture(
812 std::move(gesture_params), 812 std::move(gesture_params),
813 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); 813 base::Bind(&OnSyntheticGestureCompleted, callback_and_context));
814 814
815 return true; 815 return true;
816 } 816 }
817 817
818 void GpuBenchmarking::ClearImageCache() { 818 void GpuBenchmarking::ClearImageCache() {
819 WebImageCache::clear(); 819 WebImageCache::clear();
820 } 820 }
821 821
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 bool GpuBenchmarking::HasGpuProcess() { 875 bool GpuBenchmarking::HasGpuProcess() {
876 bool has_gpu_process = false; 876 bool has_gpu_process = false;
877 if (!RenderThreadImpl::current()->Send( 877 if (!RenderThreadImpl::current()->Send(
878 new GpuHostMsg_HasGpuProcess(&has_gpu_process))) 878 new GpuHostMsg_HasGpuProcess(&has_gpu_process)))
879 return false; 879 return false;
880 880
881 return has_gpu_process; 881 return has_gpu_process;
882 } 882 }
883 883
884 } // namespace content 884 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/external_popup_menu_browsertest.cc ('k') | content/renderer/npapi/webplugin_delegate_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698