| 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 "remoting/capturer/video_frame_capturer.h" | 5 #include "remoting/capturer/video_frame_capturer.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/Xutil.h> | 8 #include <X11/Xutil.h> |
| 9 #include <X11/extensions/Xdamage.h> | 9 #include <X11/extensions/Xdamage.h> |
| 10 #include <X11/extensions/Xfixes.h> | 10 #include <X11/extensions/Xfixes.h> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 VideoFrameCapturerLinux(); | 55 VideoFrameCapturerLinux(); |
| 56 virtual ~VideoFrameCapturerLinux(); | 56 virtual ~VideoFrameCapturerLinux(); |
| 57 | 57 |
| 58 bool Init(); // TODO(ajwong): Do we really want this to be synchronous? | 58 bool Init(); // TODO(ajwong): Do we really want this to be synchronous? |
| 59 | 59 |
| 60 // Capturer interface. | 60 // Capturer interface. |
| 61 virtual void Start(Delegate* delegate) OVERRIDE; | 61 virtual void Start(Delegate* delegate) OVERRIDE; |
| 62 virtual void Stop() OVERRIDE; | 62 virtual void Stop() OVERRIDE; |
| 63 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; | 63 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; |
| 64 virtual void CaptureFrame() OVERRIDE; | 64 virtual void CaptureFrame() OVERRIDE; |
| 65 virtual const SkISize& size_most_recent() const OVERRIDE; | |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 void InitXDamage(); | 67 void InitXDamage(); |
| 69 | 68 |
| 70 // Read and handle all currently-pending XEvents. | 69 // Read and handle all currently-pending XEvents. |
| 71 // In the DAMAGE case, process the XDamage events and store the resulting | 70 // In the DAMAGE case, process the XDamage events and store the resulting |
| 72 // damage rectangles in the VideoFrameCapturerHelper. | 71 // damage rectangles in the VideoFrameCapturerHelper. |
| 73 // In all cases, call ScreenConfigurationChanged() in response to any | 72 // In all cases, call ScreenConfigurationChanged() in response to any |
| 74 // ConfigNotify events. | 73 // ConfigNotify events. |
| 75 void ProcessPendingXEvents(); | 74 void ProcessPendingXEvents(); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 uint32_t b = (((pixel & blue_mask) >> blue_shift) * 255) / max_blue; | 581 uint32_t b = (((pixel & blue_mask) >> blue_shift) * 255) / max_blue; |
| 583 uint32_t g = (((pixel & green_mask) >> green_shift) * 255) / max_green; | 582 uint32_t g = (((pixel & green_mask) >> green_shift) * 255) / max_green; |
| 584 // Write as 32-bit RGB. | 583 // Write as 32-bit RGB. |
| 585 dst_pos_32[x] = r << 16 | g << 8 | b; | 584 dst_pos_32[x] = r << 16 | g << 8 | b; |
| 586 } | 585 } |
| 587 dst_pos += capture_data->stride(); | 586 dst_pos += capture_data->stride(); |
| 588 src_pos += src_stride; | 587 src_pos += src_stride; |
| 589 } | 588 } |
| 590 } | 589 } |
| 591 | 590 |
| 592 const SkISize& VideoFrameCapturerLinux::size_most_recent() const { | |
| 593 return helper_.size_most_recent(); | |
| 594 } | |
| 595 | |
| 596 } // namespace | 591 } // namespace |
| 597 | 592 |
| 598 // static | 593 // static |
| 599 scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::Create() { | 594 scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::Create() { |
| 600 scoped_ptr<VideoFrameCapturerLinux> capturer(new VideoFrameCapturerLinux()); | 595 scoped_ptr<VideoFrameCapturerLinux> capturer(new VideoFrameCapturerLinux()); |
| 601 if (!capturer->Init()) | 596 if (!capturer->Init()) |
| 602 capturer.reset(); | 597 capturer.reset(); |
| 603 return capturer.PassAs<VideoFrameCapturer>(); | 598 return capturer.PassAs<VideoFrameCapturer>(); |
| 604 } | 599 } |
| 605 | 600 |
| 606 // static | 601 // static |
| 607 scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::CreateWithFactory( | 602 scoped_ptr<VideoFrameCapturer> VideoFrameCapturer::CreateWithFactory( |
| 608 SharedBufferFactory* shared_buffer_factory) { | 603 SharedBufferFactory* shared_buffer_factory) { |
| 609 NOTIMPLEMENTED(); | 604 NOTIMPLEMENTED(); |
| 610 return scoped_ptr<VideoFrameCapturer>(); | 605 return scoped_ptr<VideoFrameCapturer>(); |
| 611 } | 606 } |
| 612 | 607 |
| 613 // static | 608 // static |
| 614 void VideoFrameCapturer::EnableXDamage(bool enable) { | 609 void VideoFrameCapturer::EnableXDamage(bool enable) { |
| 615 g_should_use_x_damage = enable; | 610 g_should_use_x_damage = enable; |
| 616 } | 611 } |
| 617 | 612 |
| 618 } // namespace remoting | 613 } // namespace remoting |
| OLD | NEW |