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

Side by Side Diff: media/video/capture/screen/screen_capturer_mac.mm

Issue 12221103: Fix ScreenCapturerMac handling of secondary configurations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments. Created 7 years, 10 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 "media/video/capture/screen/screen_capturer.h" 5 #include "media/video/capture/screen/screen_capturer.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #include <Cocoa/Cocoa.h> 8 #include <Cocoa/Cocoa.h>
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <IOKit/pwr_mgt/IOPMLib.h> 10 #include <IOKit/pwr_mgt/IOPMLib.h>
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 SkIRect display_bounds = display_config.pixel_bounds; 578 SkIRect display_bounds = display_config.pixel_bounds;
579 display_bounds.offset(-desktop_config_.pixel_bounds.left(), 579 display_bounds.offset(-desktop_config_.pixel_bounds.left(),
580 -desktop_config_.pixel_bounds.top()); 580 -desktop_config_.pixel_bounds.top());
581 581
582 // Determine which parts of the blit region, if any, lay within the monitor. 582 // Determine which parts of the blit region, if any, lay within the monitor.
583 SkRegion copy_region; 583 SkRegion copy_region;
584 if (!copy_region.op(region, display_bounds, SkRegion::kIntersect_Op)) 584 if (!copy_region.op(region, display_bounds, SkRegion::kIntersect_Op))
585 continue; 585 continue;
586 586
587 // Translate the region to be copied into display-relative coordinates. 587 // Translate the region to be copied into display-relative coordinates.
588 copy_region.translate(-desktop_config_.pixel_bounds.left(), 588 copy_region.translate(-display_bounds.left(), -display_bounds.top());
589 -desktop_config_.pixel_bounds.top());
590 589
591 // Calculate where in the output buffer the display's origin is. 590 // Calculate where in the output buffer the display's origin is.
592 uint8* out_ptr = buffer.pixels() + 591 uint8* out_ptr = buffer.pixels() +
593 (display_bounds.left() * src_bytes_per_pixel) + 592 (display_bounds.left() * src_bytes_per_pixel) +
594 (display_bounds.top() * buffer.bytes_per_row()); 593 (display_bounds.top() * buffer.bytes_per_row());
595 594
596 // Copy the dirty region from the display buffer into our desktop buffer. 595 // Copy the dirty region from the display buffer into our desktop buffer.
597 for(SkRegion::Iterator i(copy_region); !i.done(); i.next()) { 596 for(SkRegion::Iterator i(copy_region); !i.done(); i.next()) {
598 CopyRect(display_base_address, 597 CopyRect(display_base_address,
599 src_bytes_per_row, 598 src_bytes_per_row,
600 out_ptr, 599 out_ptr,
601 buffer.bytes_per_row(), 600 buffer.bytes_per_row(),
602 src_bytes_per_pixel, 601 src_bytes_per_pixel,
603 i.rect()); 602 i.rect());
604 } 603 }
605 } 604 }
606 } 605 }
607 606
608 void ScreenCapturerMac::CgBlitPostLion(const ScreenCaptureFrame& buffer, 607 void ScreenCapturerMac::CgBlitPostLion(const ScreenCaptureFrame& buffer,
609 const SkRegion& region) { 608 const SkRegion& region) {
610 const int buffer_height = buffer.dimensions().height(); 609 const int buffer_height = buffer.dimensions().height();
611 610
612 // Copy the entire contents of the previous capture buffer, to capture over. 611 // Copy the entire contents of the previous capture buffer, to capture over.
613 // TODO(wez): Get rid of this as per crbug.com/145064, or implement 612 // TODO(wez): Get rid of this as per crbug.com/145064, or implement
614 // crbug.com/92354. 613 // crbug.com/92354.
615 if (queue_.previous_frame()) { 614 if (queue_.previous_frame()) {
616 memcpy(buffer.pixels(), 615 memcpy(buffer.pixels(),
617 queue_.previous_frame()->pixels(), 616 queue_.previous_frame()->pixels(),
618 buffer.bytes_per_row() * buffer_height); 617 buffer.bytes_per_row() * buffer_height);
619 } 618 }
620 619
621 for (size_t i = 0; i < desktop_config_.displays.size(); ++i) { 620 for (size_t i = 0; i < desktop_config_.displays.size(); ++i) {
622 const MacDisplayConfiguration& display_config = desktop_config_.displays[i]; 621 const MacDisplayConfiguration& display_config = desktop_config_.displays[i];
623 622
624 // Determine the display's position relative to the desktop, in pixels. 623 // Determine the display's position relative to the desktop, in pixels.
625 SkIRect display_bounds = display_config.pixel_bounds; 624 SkIRect display_bounds = display_config.pixel_bounds;
626 display_bounds.offset(-desktop_config_.pixel_bounds.left(), 625 display_bounds.offset(-desktop_config_.pixel_bounds.left(),
627 -desktop_config_.pixel_bounds.top()); 626 -desktop_config_.pixel_bounds.top());
628 627
629 // Determine which parts of the blit region, if any, lay within the monitor. 628 // Determine which parts of the blit region, if any, lay within the monitor.
630 SkRegion copy_region; 629 SkRegion copy_region;
631 if (!copy_region.op(region, display_bounds, SkRegion::kIntersect_Op)) 630 if (!copy_region.op(region, display_bounds, SkRegion::kIntersect_Op))
632 continue; 631 continue;
633 632
634 // Translate the region to be copied into display-relative coordinates. 633 // Translate the region to be copied into display-relative coordinates.
635 copy_region.translate(-desktop_config_.pixel_bounds.left(), 634 copy_region.translate(-display_bounds.left(), -display_bounds.top());
636 -desktop_config_.pixel_bounds.top());
637 635
638 // Create an image containing a snapshot of the display. 636 // Create an image containing a snapshot of the display.
639 base::mac::ScopedCFTypeRef<CGImageRef> image( 637 base::mac::ScopedCFTypeRef<CGImageRef> image(
640 CGDisplayCreateImage(display_config.id)); 638 CGDisplayCreateImage(display_config.id));
641 if (image.get() == NULL) 639 if (image.get() == NULL)
642 continue; 640 continue;
643 641
644 // Request access to the raw pixel data via the image's DataProvider. 642 // Request access to the raw pixel data via the image's DataProvider.
645 CGDataProviderRef provider = CGImageGetDataProvider(image); 643 CGDataProviderRef provider = CGImageGetDataProvider(image);
646 base::mac::ScopedCFTypeRef<CFDataRef> data( 644 base::mac::ScopedCFTypeRef<CFDataRef> data(
(...skipping 23 matching lines...) Expand all
670 } 668 }
671 669
672 void ScreenCapturerMac::ScreenConfigurationChanged() { 670 void ScreenCapturerMac::ScreenConfigurationChanged() {
673 // Release existing buffers, which will be of the wrong size. 671 // Release existing buffers, which will be of the wrong size.
674 ReleaseBuffers(); 672 ReleaseBuffers();
675 673
676 // Clear the dirty region, in case the display is down-sizing. 674 // Clear the dirty region, in case the display is down-sizing.
677 helper_.ClearInvalidRegion(); 675 helper_.ClearInvalidRegion();
678 676
679 // Refresh the cached desktop configuration. 677 // Refresh the cached desktop configuration.
680 desktop_config_ = MacDesktopConfiguration::GetCurrent(); 678 desktop_config_ = MacDesktopConfiguration::GetCurrent(
679 MacDesktopConfiguration::TopLeftOrigin);
681 680
682 // Re-mark the entire desktop as dirty. 681 // Re-mark the entire desktop as dirty.
683 helper_.InvalidateScreen( 682 helper_.InvalidateScreen(
684 SkISize::Make(desktop_config_.pixel_bounds.width(), 683 SkISize::Make(desktop_config_.pixel_bounds.width(),
685 desktop_config_.pixel_bounds.height())); 684 desktop_config_.pixel_bounds.height()));
686 685
687 // Make sure the frame buffers will be reallocated. 686 // Make sure the frame buffers will be reallocated.
688 queue_.SetAllFramesNeedUpdate(); 687 queue_.SetAllFramesNeedUpdate();
689 688
690 // CgBlitPostLion uses CGDisplayCreateImage() to snapshot each display's 689 // CgBlitPostLion uses CGDisplayCreateImage() to snapshot each display's
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 } 861 }
863 862
864 // static 863 // static
865 scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithFactory( 864 scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithFactory(
866 SharedBufferFactory* shared_buffer_factory) { 865 SharedBufferFactory* shared_buffer_factory) {
867 NOTIMPLEMENTED(); 866 NOTIMPLEMENTED();
868 return scoped_ptr<ScreenCapturer>(); 867 return scoped_ptr<ScreenCapturer>();
869 } 868 }
870 869
871 } // namespace media 870 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698