| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/message_loop/message_loop_proxy.h" | 6 #include "base/message_loop/message_loop_proxy.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "content/browser/gpu/compositor_util.h" | 9 #include "content/browser/gpu/compositor_util.h" |
| 10 #include "content/browser/gpu/gpu_data_manager_impl.h" | 10 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "content/public/test/content_browser_test.h" | 22 #include "content/public/test/content_browser_test.h" |
| 23 #include "content/public/test/content_browser_test_utils.h" | 23 #include "content/public/test/content_browser_test_utils.h" |
| 24 #include "content/shell/browser/shell.h" | 24 #include "content/shell/browser/shell.h" |
| 25 #include "media/base/video_frame.h" | 25 #include "media/base/video_frame.h" |
| 26 #include "media/filters/skcanvas_video_renderer.h" | 26 #include "media/filters/skcanvas_video_renderer.h" |
| 27 #include "net/base/filename_util.h" | 27 #include "net/base/filename_util.h" |
| 28 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
| 29 #include "third_party/skia/include/core/SkCanvas.h" | 29 #include "third_party/skia/include/core/SkCanvas.h" |
| 30 #include "ui/base/layout.h" | 30 #include "ui/base/layout.h" |
| 31 #include "ui/base/ui_base_switches.h" | 31 #include "ui/base/ui_base_switches.h" |
| 32 #include "ui/gfx/size_conversions.h" | 32 #include "ui/gfx/geometry/size_conversions.h" |
| 33 #include "ui/gfx/switches.h" | 33 #include "ui/gfx/switches.h" |
| 34 #include "ui/gl/gl_switches.h" | 34 #include "ui/gl/gl_switches.h" |
| 35 | 35 |
| 36 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 37 #include "base/win/windows_version.h" | 37 #include "base/win/windows_version.h" |
| 38 #include "ui/gfx/win/dpi.h" | 38 #include "ui/gfx/win/dpi.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace content { | 41 namespace content { |
| 42 namespace { | 42 namespace { |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 516 |
| 517 virtual GURL TestUrl() OVERRIDE { | 517 virtual GURL TestUrl() OVERRIDE { |
| 518 return GURL(test_url_); | 518 return GURL(test_url_); |
| 519 } | 519 } |
| 520 | 520 |
| 521 void SetTestUrl(std::string url) { test_url_ = url; } | 521 void SetTestUrl(std::string url) { test_url_ = url; } |
| 522 | 522 |
| 523 // Loads a page two boxes side-by-side, each half the width of | 523 // Loads a page two boxes side-by-side, each half the width of |
| 524 // |html_rect_size|, and with different background colors. The test then | 524 // |html_rect_size|, and with different background colors. The test then |
| 525 // copies from |copy_rect| region of the page into a bitmap of size | 525 // copies from |copy_rect| region of the page into a bitmap of size |
| 526 // |output_size|, and compares that with a bitmap of size | 526 // |output_size|, and examines the resulting bitmap/VideoFrame. |
| 527 // |expected_bitmap_size|. | |
| 528 // Note that |output_size| may not have the same size as |copy_rect| (e.g. | 527 // Note that |output_size| may not have the same size as |copy_rect| (e.g. |
| 529 // when the output is scaled). Also note that |expected_bitmap_size| may not | 528 // when the output is scaled). |
| 530 // be the same as |output_size| (e.g. when the device scale factor is not 1). | |
| 531 void PerformTestWithLeftRightRects(const gfx::Size& html_rect_size, | 529 void PerformTestWithLeftRightRects(const gfx::Size& html_rect_size, |
| 532 const gfx::Rect& copy_rect, | 530 const gfx::Rect& copy_rect, |
| 533 const gfx::Size& output_size, | 531 const gfx::Size& output_size, |
| 534 const gfx::Size& expected_bitmap_size, | |
| 535 bool video_frame) { | 532 bool video_frame) { |
| 536 const gfx::Size box_size(html_rect_size.width() / 2, | 533 const gfx::Size box_size(html_rect_size.width() / 2, |
| 537 html_rect_size.height()); | 534 html_rect_size.height()); |
| 538 SetTestUrl(base::StringPrintf( | 535 SetTestUrl(base::StringPrintf( |
| 539 "data:text/html,<!doctype html>" | 536 "data:text/html,<!doctype html>" |
| 540 "<div class='left'>" | 537 "<div class='left'>" |
| 541 " <div class='right'></div>" | 538 " <div class='right'></div>" |
| 542 "</div>" | 539 "</div>" |
| 543 "<style>" | 540 "<style>" |
| 544 "body { padding: 0; margin: 0; }" | 541 "body { padding: 0; margin: 0; }" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 } | 582 } |
| 586 | 583 |
| 587 // The page is loaded in the renderer, wait for a new frame to arrive. | 584 // The page is loaded in the renderer, wait for a new frame to arrive. |
| 588 uint32 frame = rwhvp->RendererFrameNumber(); | 585 uint32 frame = rwhvp->RendererFrameNumber(); |
| 589 while (!GetRenderWidgetHost()->ScheduleComposite()) | 586 while (!GetRenderWidgetHost()->ScheduleComposite()) |
| 590 GiveItSomeTime(); | 587 GiveItSomeTime(); |
| 591 while (rwhvp->RendererFrameNumber() == frame) | 588 while (rwhvp->RendererFrameNumber() == frame) |
| 592 GiveItSomeTime(); | 589 GiveItSomeTime(); |
| 593 | 590 |
| 594 SkBitmap expected_bitmap; | 591 SkBitmap expected_bitmap; |
| 595 SetupLeftRightBitmap(expected_bitmap_size, &expected_bitmap); | 592 SetupLeftRightBitmap(output_size, &expected_bitmap); |
| 596 SetExpectedCopyFromCompositingSurfaceResult(true, expected_bitmap); | 593 SetExpectedCopyFromCompositingSurfaceResult(true, expected_bitmap); |
| 597 | 594 |
| 598 base::RunLoop run_loop; | 595 base::RunLoop run_loop; |
| 599 if (video_frame) { | 596 if (video_frame) { |
| 600 // Allow pixel differences as long as we have the right idea. | 597 // Allow pixel differences as long as we have the right idea. |
| 601 SetAllowableError(0x10); | 598 SetAllowableError(0x10); |
| 602 // Exclude the middle two columns which are blended between the two sides. | 599 // Exclude the middle two columns which are blended between the two sides. |
| 603 SetExcludeRect( | 600 SetExcludeRect( |
| 604 gfx::Rect(output_size.width() / 2 - 1, 0, 2, output_size.height())); | 601 gfx::Rect(output_size.width() / 2 - 1, 0, 2, output_size.height())); |
| 605 | 602 |
| 606 scoped_refptr<media::VideoFrame> video_frame = | 603 scoped_refptr<media::VideoFrame> video_frame = |
| 607 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | 604 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| 608 expected_bitmap_size, | 605 output_size, |
| 609 gfx::Rect(expected_bitmap_size), | 606 gfx::Rect(output_size), |
| 610 expected_bitmap_size, | 607 output_size, |
| 611 base::TimeDelta()); | 608 base::TimeDelta()); |
| 612 | 609 |
| 613 base::Callback<void(bool success)> callback = | 610 base::Callback<void(bool success)> callback = |
| 614 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: | 611 base::Bind(&CompositingRenderWidgetHostViewBrowserTestTabCapture:: |
| 615 CopyFromCompositingSurfaceCallbackForVideo, | 612 CopyFromCompositingSurfaceCallbackForVideo, |
| 616 base::Unretained(this), | 613 base::Unretained(this), |
| 617 video_frame, | 614 video_frame, |
| 618 run_loop.QuitClosure()); | 615 run_loop.QuitClosure()); |
| 619 rwhvp->CopyFromCompositingSurfaceToVideoFrame(copy_rect, | 616 rwhvp->CopyFromCompositingSurfaceToVideoFrame(copy_rect, |
| 620 video_frame, | 617 video_frame, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 SkBitmap expected_copy_from_compositing_surface_bitmap_; | 669 SkBitmap expected_copy_from_compositing_surface_bitmap_; |
| 673 int allowable_error_; | 670 int allowable_error_; |
| 674 gfx::Rect exclude_rect_; | 671 gfx::Rect exclude_rect_; |
| 675 std::string test_url_; | 672 std::string test_url_; |
| 676 }; | 673 }; |
| 677 | 674 |
| 678 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 675 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 679 CopyFromCompositingSurface_Origin_Unscaled) { | 676 CopyFromCompositingSurface_Origin_Unscaled) { |
| 680 gfx::Rect copy_rect(400, 300); | 677 gfx::Rect copy_rect(400, 300); |
| 681 gfx::Size output_size = copy_rect.size(); | 678 gfx::Size output_size = copy_rect.size(); |
| 682 gfx::Size expected_bitmap_size = output_size; | |
| 683 gfx::Size html_rect_size(400, 300); | 679 gfx::Size html_rect_size(400, 300); |
| 684 bool video_frame = false; | 680 bool video_frame = false; |
| 685 PerformTestWithLeftRightRects(html_rect_size, | 681 PerformTestWithLeftRightRects(html_rect_size, |
| 686 copy_rect, | 682 copy_rect, |
| 687 output_size, | 683 output_size, |
| 688 expected_bitmap_size, | |
| 689 video_frame); | 684 video_frame); |
| 690 } | 685 } |
| 691 | 686 |
| 692 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 687 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 693 CopyFromCompositingSurface_Origin_Scaled) { | 688 CopyFromCompositingSurface_Origin_Scaled) { |
| 694 gfx::Rect copy_rect(400, 300); | 689 gfx::Rect copy_rect(400, 300); |
| 695 gfx::Size output_size(200, 100); | 690 gfx::Size output_size(200, 100); |
| 696 gfx::Size expected_bitmap_size = output_size; | |
| 697 gfx::Size html_rect_size(400, 300); | 691 gfx::Size html_rect_size(400, 300); |
| 698 bool video_frame = false; | 692 bool video_frame = false; |
| 699 PerformTestWithLeftRightRects(html_rect_size, | 693 PerformTestWithLeftRightRects(html_rect_size, |
| 700 copy_rect, | 694 copy_rect, |
| 701 output_size, | 695 output_size, |
| 702 expected_bitmap_size, | |
| 703 video_frame); | 696 video_frame); |
| 704 } | 697 } |
| 705 | 698 |
| 706 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 699 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 707 CopyFromCompositingSurface_Cropped_Unscaled) { | 700 CopyFromCompositingSurface_Cropped_Unscaled) { |
| 708 // Grab 60x60 pixels from the center of the tab contents. | 701 // Grab 60x60 pixels from the center of the tab contents. |
| 709 gfx::Rect copy_rect(400, 300); | 702 gfx::Rect copy_rect(400, 300); |
| 710 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), | 703 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), |
| 711 gfx::Size(60, 60)); | 704 gfx::Size(60, 60)); |
| 712 gfx::Size output_size = copy_rect.size(); | 705 gfx::Size output_size = copy_rect.size(); |
| 713 gfx::Size expected_bitmap_size = output_size; | |
| 714 gfx::Size html_rect_size(400, 300); | 706 gfx::Size html_rect_size(400, 300); |
| 715 bool video_frame = false; | 707 bool video_frame = false; |
| 716 PerformTestWithLeftRightRects(html_rect_size, | 708 PerformTestWithLeftRightRects(html_rect_size, |
| 717 copy_rect, | 709 copy_rect, |
| 718 output_size, | 710 output_size, |
| 719 expected_bitmap_size, | |
| 720 video_frame); | 711 video_frame); |
| 721 } | 712 } |
| 722 | 713 |
| 723 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 714 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 724 CopyFromCompositingSurface_Cropped_Scaled) { | 715 CopyFromCompositingSurface_Cropped_Scaled) { |
| 725 // Grab 60x60 pixels from the center of the tab contents. | 716 // Grab 60x60 pixels from the center of the tab contents. |
| 726 gfx::Rect copy_rect(400, 300); | 717 gfx::Rect copy_rect(400, 300); |
| 727 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), | 718 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(30, 30), |
| 728 gfx::Size(60, 60)); | 719 gfx::Size(60, 60)); |
| 729 gfx::Size output_size(20, 10); | 720 gfx::Size output_size(20, 10); |
| 730 gfx::Size expected_bitmap_size = output_size; | |
| 731 gfx::Size html_rect_size(400, 300); | 721 gfx::Size html_rect_size(400, 300); |
| 732 bool video_frame = false; | 722 bool video_frame = false; |
| 733 PerformTestWithLeftRightRects(html_rect_size, | 723 PerformTestWithLeftRightRects(html_rect_size, |
| 734 copy_rect, | 724 copy_rect, |
| 735 output_size, | 725 output_size, |
| 736 expected_bitmap_size, | |
| 737 video_frame); | 726 video_frame); |
| 738 } | 727 } |
| 739 | 728 |
| 740 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 729 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 741 CopyFromCompositingSurface_ForVideoFrame) { | 730 CopyFromCompositingSurface_ForVideoFrame) { |
| 742 // Grab 90x60 pixels from the center of the tab contents. | 731 // Grab 90x60 pixels from the center of the tab contents. |
| 743 gfx::Rect copy_rect(400, 300); | 732 gfx::Rect copy_rect(400, 300); |
| 744 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), | 733 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), |
| 745 gfx::Size(90, 60)); | 734 gfx::Size(90, 60)); |
| 746 gfx::Size output_size = copy_rect.size(); | 735 gfx::Size output_size = copy_rect.size(); |
| 747 gfx::Size expected_bitmap_size = output_size; | |
| 748 gfx::Size html_rect_size(400, 300); | 736 gfx::Size html_rect_size(400, 300); |
| 749 bool video_frame = true; | 737 bool video_frame = true; |
| 750 PerformTestWithLeftRightRects(html_rect_size, | 738 PerformTestWithLeftRightRects(html_rect_size, |
| 751 copy_rect, | 739 copy_rect, |
| 752 output_size, | 740 output_size, |
| 753 expected_bitmap_size, | |
| 754 video_frame); | 741 video_frame); |
| 755 } | 742 } |
| 756 | 743 |
| 757 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, | 744 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 758 CopyFromCompositingSurface_ForVideoFrame_Scaled) { | 745 CopyFromCompositingSurface_ForVideoFrame_Scaled) { |
| 759 // Grab 90x60 pixels from the center of the tab contents. | 746 // Grab 90x60 pixels from the center of the tab contents. |
| 760 gfx::Rect copy_rect(400, 300); | 747 gfx::Rect copy_rect(400, 300); |
| 761 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), | 748 copy_rect = gfx::Rect(copy_rect.CenterPoint() - gfx::Vector2d(45, 30), |
| 762 gfx::Size(90, 60)); | 749 gfx::Size(90, 60)); |
| 763 // Scale to 30 x 20 (preserve aspect ratio). | 750 // Scale to 30 x 20 (preserve aspect ratio). |
| 764 gfx::Size output_size(30, 20); | 751 gfx::Size output_size(30, 20); |
| 765 gfx::Size expected_bitmap_size = output_size; | |
| 766 gfx::Size html_rect_size(400, 300); | 752 gfx::Size html_rect_size(400, 300); |
| 767 bool video_frame = true; | 753 bool video_frame = true; |
| 768 PerformTestWithLeftRightRects(html_rect_size, | 754 PerformTestWithLeftRightRects(html_rect_size, |
| 769 copy_rect, | 755 copy_rect, |
| 770 output_size, | 756 output_size, |
| 771 expected_bitmap_size, | |
| 772 video_frame); | 757 video_frame); |
| 773 } | 758 } |
| 774 | 759 |
| 775 class CompositingRenderWidgetHostViewTabCaptureHighDPI | 760 class CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI |
| 776 : public CompositingRenderWidgetHostViewBrowserTestTabCapture { | 761 : public CompositingRenderWidgetHostViewBrowserTestTabCapture { |
| 777 public: | 762 public: |
| 778 CompositingRenderWidgetHostViewTabCaptureHighDPI() : kScale(2.f) {} | 763 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI() {} |
| 779 | 764 |
| 780 virtual void SetUpOnMainThread() OVERRIDE { | 765 protected: |
| 781 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 766 virtual void SetUpCommandLine(base::CommandLine* cmd) OVERRIDE { |
| 767 CompositingRenderWidgetHostViewBrowserTestTabCapture::SetUpCommandLine(cmd); |
| 782 cmd->AppendSwitchASCII(switches::kForceDeviceScaleFactor, | 768 cmd->AppendSwitchASCII(switches::kForceDeviceScaleFactor, |
| 783 base::StringPrintf("%f", scale())); | 769 base::StringPrintf("%f", scale())); |
| 784 #if defined(OS_WIN) | |
| 785 gfx::ForceHighDPISupportForTesting(scale()); | |
| 786 gfx::EnableHighDPISupport(); | |
| 787 #endif | |
| 788 } | 770 } |
| 789 | 771 |
| 790 float scale() const { return kScale; } | |
| 791 | |
| 792 private: | |
| 793 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE { | 772 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE { |
| 794 // Short-circuit a pass for platforms where setting up high-DPI fails. | 773 // Short-circuit a pass for platforms where setting up high-DPI fails. |
| 795 if (ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor( | 774 const float actual_scale_factor = |
| 796 GetScaleFactorForView(GetRenderWidgetHostView()))) != scale()) { | 775 GetScaleFactorForView(GetRenderWidgetHostView()); |
| 797 LOG(WARNING) << "Blindly passing this test: failed to set up " | 776 if (actual_scale_factor != scale()) { |
| 798 "scale factor: " << scale(); | 777 LOG(WARNING) << "Blindly passing this test; unable to force device scale " |
| 778 << "factor: seems to be " << actual_scale_factor |
| 779 << " but expected " << scale(); |
| 799 return false; | 780 return false; |
| 800 } | 781 } |
| 782 VLOG(1) << ("Successfully forced device scale factor. Moving forward with " |
| 783 "this test! :-)"); |
| 801 return true; | 784 return true; |
| 802 } | 785 } |
| 803 | 786 |
| 804 const float kScale; | 787 static float scale() { return 2.0f; } |
| 805 | 788 |
| 806 DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewTabCaptureHighDPI); | 789 private: |
| 790 DISALLOW_COPY_AND_ASSIGN( |
| 791 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI); |
| 807 }; | 792 }; |
| 808 | 793 |
| 809 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI, | 794 // ImageSkia (related to ResourceBundle) implementation crashes the process on |
| 810 CopyFromCompositingSurface) { | 795 // Windows when this content_browsertest forces a device scale factor. |
| 796 // http://crbug.com/399349 |
| 797 #if defined(OS_WIN) |
| 798 #define MAYBE_CopyToBitmap_EntireRegion DISABLED_CopyToBitmap_EntireRegion |
| 799 #define MAYBE_CopyToBitmap_CenterRegion DISABLED_CopyToBitmap_CenterRegion |
| 800 #define MAYBE_CopyToBitmap_ScaledResult DISABLED_CopyToBitmap_ScaledResult |
| 801 #define MAYBE_CopyToVideoFrame_EntireRegion \ |
| 802 DISABLED_CopyToVideoFrame_EntireRegion |
| 803 #define MAYBE_CopyToVideoFrame_CenterRegion \ |
| 804 DISABLED_CopyToVideoFrame_CenterRegion |
| 805 #define MAYBE_CopyToVideoFrame_ScaledResult \ |
| 806 DISABLED_CopyToVideoFrame_ScaledResult |
| 807 #else |
| 808 #define MAYBE_CopyToBitmap_EntireRegion CopyToBitmap_EntireRegion |
| 809 #define MAYBE_CopyToBitmap_CenterRegion CopyToBitmap_CenterRegion |
| 810 #define MAYBE_CopyToBitmap_ScaledResult CopyToBitmap_ScaledResult |
| 811 #define MAYBE_CopyToVideoFrame_EntireRegion CopyToVideoFrame_EntireRegion |
| 812 #define MAYBE_CopyToVideoFrame_CenterRegion CopyToVideoFrame_CenterRegion |
| 813 #define MAYBE_CopyToVideoFrame_ScaledResult CopyToVideoFrame_ScaledResult |
| 814 #endif |
| 815 |
| 816 IN_PROC_BROWSER_TEST_P( |
| 817 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 818 MAYBE_CopyToBitmap_EntireRegion) { |
| 819 gfx::Size html_rect_size(200, 150); |
| 811 gfx::Rect copy_rect(200, 150); | 820 gfx::Rect copy_rect(200, 150); |
| 812 gfx::Size output_size = copy_rect.size(); | 821 // Scale the output size so that, internally, scaling is not occurring. |
| 813 gfx::Size expected_bitmap_size = | 822 gfx::Size output_size = |
| 814 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale())); | 823 gfx::ToRoundedSize(gfx::ScaleSize(copy_rect.size(), scale())); |
| 815 gfx::Size html_rect_size(200, 150); | |
| 816 bool video_frame = false; | 824 bool video_frame = false; |
| 817 PerformTestWithLeftRightRects(html_rect_size, | 825 PerformTestWithLeftRightRects(html_rect_size, |
| 818 copy_rect, | 826 copy_rect, |
| 819 output_size, | 827 output_size, |
| 820 expected_bitmap_size, | |
| 821 video_frame); | 828 video_frame); |
| 822 } | 829 } |
| 823 | 830 |
| 824 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI, | 831 IN_PROC_BROWSER_TEST_P( |
| 825 CopyFromCompositingSurfaceVideoFrame) { | 832 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 833 MAYBE_CopyToBitmap_CenterRegion) { |
| 826 gfx::Size html_rect_size(200, 150); | 834 gfx::Size html_rect_size(200, 150); |
| 827 // Grab 90x60 pixels from the center of the tab contents. | 835 // Grab 90x60 pixels from the center of the tab contents. |
| 828 gfx::Rect copy_rect = | 836 gfx::Rect copy_rect = |
| 829 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30), | 837 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30), |
| 830 gfx::Size(90, 60)); | 838 gfx::Size(90, 60)); |
| 831 gfx::Size output_size = copy_rect.size(); | 839 // Scale the output size so that, internally, scaling is not occurring. |
| 832 gfx::Size expected_bitmap_size = | 840 gfx::Size output_size = |
| 833 gfx::ToFlooredSize(gfx::ScaleSize(output_size, scale(), scale())); | 841 gfx::ToRoundedSize(gfx::ScaleSize(copy_rect.size(), scale())); |
| 842 bool video_frame = false; |
| 843 PerformTestWithLeftRightRects(html_rect_size, |
| 844 copy_rect, |
| 845 output_size, |
| 846 video_frame); |
| 847 } |
| 848 |
| 849 IN_PROC_BROWSER_TEST_P( |
| 850 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 851 MAYBE_CopyToBitmap_ScaledResult) { |
| 852 gfx::Size html_rect_size(200, 100); |
| 853 gfx::Rect copy_rect(200, 100); |
| 854 // Output is being down-scaled since output_size is in phyiscal pixels. |
| 855 gfx::Size output_size(200, 100); |
| 856 bool video_frame = false; |
| 857 PerformTestWithLeftRightRects(html_rect_size, |
| 858 copy_rect, |
| 859 output_size, |
| 860 video_frame); |
| 861 } |
| 862 |
| 863 IN_PROC_BROWSER_TEST_P( |
| 864 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 865 MAYBE_CopyToVideoFrame_EntireRegion) { |
| 866 gfx::Size html_rect_size(200, 150); |
| 867 gfx::Rect copy_rect(200, 150); |
| 868 // Scale the output size so that, internally, scaling is not occurring. |
| 869 gfx::Size output_size = |
| 870 gfx::ToRoundedSize(gfx::ScaleSize(copy_rect.size(), scale())); |
| 834 bool video_frame = true; | 871 bool video_frame = true; |
| 835 PerformTestWithLeftRightRects(html_rect_size, | 872 PerformTestWithLeftRightRects(html_rect_size, |
| 836 copy_rect, | 873 copy_rect, |
| 837 output_size, | 874 output_size, |
| 838 expected_bitmap_size, | |
| 839 video_frame); | 875 video_frame); |
| 840 } | 876 } |
| 841 | 877 |
| 842 #if !defined(USE_AURA) && !defined(OS_MACOSX) | 878 IN_PROC_BROWSER_TEST_P( |
| 843 // TODO(danakj): Remove this case when GTK linux is no more and move the | 879 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 844 // values inline to testing::Values() below. | 880 MAYBE_CopyToVideoFrame_CenterRegion) { |
| 845 static const CompositingMode kAllCompositingModes[] = {GL_COMPOSITING}; | 881 gfx::Size html_rect_size(200, 150); |
| 846 #else | 882 // Grab 90x60 pixels from the center of the tab contents. |
| 847 static const CompositingMode kAllCompositingModes[] = {GL_COMPOSITING, | 883 gfx::Rect copy_rect = |
| 848 SOFTWARE_COMPOSITING}; | 884 gfx::Rect(gfx::Rect(html_rect_size).CenterPoint() - gfx::Vector2d(45, 30), |
| 849 #endif | 885 gfx::Size(90, 60)); |
| 886 // Scale the output size so that, internally, scaling is not occurring. |
| 887 gfx::Size output_size = |
| 888 gfx::ToRoundedSize(gfx::ScaleSize(copy_rect.size(), scale())); |
| 889 bool video_frame = true; |
| 890 PerformTestWithLeftRightRects(html_rect_size, |
| 891 copy_rect, |
| 892 output_size, |
| 893 video_frame); |
| 894 } |
| 895 |
| 896 IN_PROC_BROWSER_TEST_P( |
| 897 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 898 MAYBE_CopyToVideoFrame_ScaledResult) { |
| 899 gfx::Size html_rect_size(200, 100); |
| 900 gfx::Rect copy_rect(200, 100); |
| 901 // Output is being down-scaled since output_size is in phyiscal pixels. |
| 902 gfx::Size output_size(200, 100); |
| 903 bool video_frame = true; |
| 904 PerformTestWithLeftRightRects(html_rect_size, |
| 905 copy_rect, |
| 906 output_size, |
| 907 video_frame); |
| 908 } |
| 850 | 909 |
| 851 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, | 910 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, |
| 852 CompositingRenderWidgetHostViewBrowserTest, | 911 CompositingRenderWidgetHostViewBrowserTest, |
| 853 testing::ValuesIn(kAllCompositingModes)); | 912 testing::Values(GL_COMPOSITING, SOFTWARE_COMPOSITING)); |
| 854 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, | 913 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, |
| 855 CompositingRenderWidgetHostViewBrowserTestTabCapture, | 914 CompositingRenderWidgetHostViewBrowserTestTabCapture, |
| 856 testing::ValuesIn(kAllCompositingModes)); | 915 testing::Values(GL_COMPOSITING, SOFTWARE_COMPOSITING)); |
| 857 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, | 916 INSTANTIATE_TEST_CASE_P( |
| 858 CompositingRenderWidgetHostViewTabCaptureHighDPI, | 917 GLAndSoftwareCompositing, |
| 859 testing::ValuesIn(kAllCompositingModes)); | 918 CompositingRenderWidgetHostViewBrowserTestTabCaptureHighDPI, |
| 919 testing::Values(GL_COMPOSITING, SOFTWARE_COMPOSITING)); |
| 860 | 920 |
| 861 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 921 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 862 | 922 |
| 863 } // namespace | 923 } // namespace |
| 864 } // namespace content | 924 } // namespace content |
| OLD | NEW |