| 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/shell/renderer/webkit_test_runner.h" | 5 #include "content/shell/renderer/webkit_test_runner.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <clocale> | 8 #include <clocale> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 if (interfaces->testRunner()->shouldDumpAsAudio()) { | 641 if (interfaces->testRunner()->shouldDumpAsAudio()) { |
| 642 std::vector<unsigned char> vector_data; | 642 std::vector<unsigned char> vector_data; |
| 643 interfaces->testRunner()->getAudioData(&vector_data); | 643 interfaces->testRunner()->getAudioData(&vector_data); |
| 644 Send(new ShellViewHostMsg_AudioDump(routing_id(), vector_data)); | 644 Send(new ShellViewHostMsg_AudioDump(routing_id(), vector_data)); |
| 645 } else { | 645 } else { |
| 646 Send(new ShellViewHostMsg_TextDump(routing_id(), | 646 Send(new ShellViewHostMsg_TextDump(routing_id(), |
| 647 proxy()->captureTree(false))); | 647 proxy()->captureTree(false))); |
| 648 | 648 |
| 649 if (test_config_.enable_pixel_dumping && | 649 if (test_config_.enable_pixel_dumping && |
| 650 interfaces->testRunner()->shouldGeneratePixelResults()) { | 650 interfaces->testRunner()->shouldGeneratePixelResults()) { |
| 651 proxy()->CapturePixelsAsync(base::Bind( | 651 // TODO(danakj): Remove when kForceCompositingMode is everywhere. |
| 652 &WebKitTestRunner::CaptureDumpPixels, base::Unretained(this))); | 652 if (!render_view()->GetWebView()->isAcceleratedCompositingActive()) { |
| 653 SkBitmap snapshot; |
| 654 CopyCanvasToBitmap(proxy()->capturePixels(), &snapshot); |
| 655 CaptureDumpPixels(snapshot); |
| 656 } else { |
| 657 proxy()->CapturePixelsAsync(base::Bind( |
| 658 &WebKitTestRunner::CaptureDumpPixels, base::Unretained(this))); |
| 659 } |
| 653 return; | 660 return; |
| 654 } | 661 } |
| 655 } | 662 } |
| 656 | 663 |
| 657 CaptureDumpComplete(); | 664 CaptureDumpComplete(); |
| 658 } | 665 } |
| 659 | 666 |
| 660 void WebKitTestRunner::CaptureDumpPixels(const SkBitmap& compositor_snapshot) { | 667 void WebKitTestRunner::CaptureDumpPixels(const SkBitmap& snapshot) { |
| 661 SkBitmap snapshot = compositor_snapshot; | |
| 662 | |
| 663 CommandLine* cmd = CommandLine::ForCurrentProcess(); | |
| 664 if (!cmd->HasSwitch(switches::kForceCompositingMode) && | |
| 665 !cmd->HasSwitch(switches::kEnableThreadedCompositing)) { | |
| 666 // If the readback fails because we're not in compositing mode, do a | |
| 667 // synchronous software readback here. This can go away when we have FCM | |
| 668 // always. | |
| 669 if (!snapshot.info().fWidth || !snapshot.info().fHeight) | |
| 670 CopyCanvasToBitmap(proxy()->capturePixels(), &snapshot); | |
| 671 } | |
| 672 | |
| 673 DCHECK_NE(0, snapshot.info().fWidth); | 668 DCHECK_NE(0, snapshot.info().fWidth); |
| 674 DCHECK_NE(0, snapshot.info().fHeight); | 669 DCHECK_NE(0, snapshot.info().fHeight); |
| 675 | 670 |
| 676 SkAutoLockPixels snapshot_lock(snapshot); | 671 SkAutoLockPixels snapshot_lock(snapshot); |
| 677 base::MD5Digest digest; | 672 base::MD5Digest digest; |
| 678 base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); | 673 base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); |
| 679 std::string actual_pixel_hash = base::MD5DigestToBase16(digest); | 674 std::string actual_pixel_hash = base::MD5DigestToBase16(digest); |
| 680 | 675 |
| 681 if (actual_pixel_hash == test_config_.expected_pixel_hash) { | 676 if (actual_pixel_hash == test_config_.expected_pixel_hash) { |
| 682 SkBitmap empty_image; | 677 SkBitmap empty_image; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 745 |
| 751 leak_detector_->TryLeakDetection(main_frame); | 746 leak_detector_->TryLeakDetection(main_frame); |
| 752 } | 747 } |
| 753 | 748 |
| 754 void WebKitTestRunner::ReportLeakDetectionResult( | 749 void WebKitTestRunner::ReportLeakDetectionResult( |
| 755 const LeakDetectionResult& report) { | 750 const LeakDetectionResult& report) { |
| 756 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 751 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
| 757 } | 752 } |
| 758 | 753 |
| 759 } // namespace content | 754 } // namespace content |
| OLD | NEW |