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 "media/video/capture/screen/screen_capturer.h" | 5 #include "media/video/capture/screen/screen_capturer.h" |
6 | 6 |
7 #include <X11/extensions/Xdamage.h> | 7 #include <X11/extensions/Xdamage.h> |
8 #include <X11/extensions/Xfixes.h> | 8 #include <X11/extensions/Xfixes.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/Xutil.h> | 10 #include <X11/Xutil.h> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 class ScreenCapturerLinux : public ScreenCapturer { | 45 class ScreenCapturerLinux : public ScreenCapturer { |
46 public: | 46 public: |
47 ScreenCapturerLinux(); | 47 ScreenCapturerLinux(); |
48 virtual ~ScreenCapturerLinux(); | 48 virtual ~ScreenCapturerLinux(); |
49 | 49 |
50 // TODO(ajwong): Do we really want this to be synchronous? | 50 // TODO(ajwong): Do we really want this to be synchronous? |
51 bool Init(bool use_x_damage); | 51 bool Init(bool use_x_damage); |
52 | 52 |
53 // Capturer interface. | 53 // Capturer interface. |
54 virtual void Start(Delegate* delegate) OVERRIDE; | 54 virtual void Start(Delegate* delegate) OVERRIDE; |
55 virtual void Stop() OVERRIDE; | |
56 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; | |
57 virtual void CaptureFrame() OVERRIDE; | 55 virtual void CaptureFrame() OVERRIDE; |
58 | 56 |
59 private: | 57 private: |
60 void InitXDamage(); | 58 void InitXDamage(); |
61 | 59 |
62 // Read and handle all currently-pending XEvents. | 60 // Read and handle all currently-pending XEvents. |
63 // In the DAMAGE case, process the XDamage events and store the resulting | 61 // In the DAMAGE case, process the XDamage events and store the resulting |
64 // damage rectangles in the ScreenCapturerHelper. | 62 // damage rectangles in the ScreenCapturerHelper. |
65 // In all cases, call ScreenConfigurationChanged() in response to any | 63 // In all cases, call ScreenConfigurationChanged() in response to any |
66 // ConfigNotify events. | 64 // ConfigNotify events. |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 use_damage_ = true; | 269 use_damage_ = true; |
272 LOG(INFO) << "Using XDamage extension."; | 270 LOG(INFO) << "Using XDamage extension."; |
273 } | 271 } |
274 | 272 |
275 void ScreenCapturerLinux::Start(Delegate* delegate) { | 273 void ScreenCapturerLinux::Start(Delegate* delegate) { |
276 DCHECK(delegate_ == NULL); | 274 DCHECK(delegate_ == NULL); |
277 | 275 |
278 delegate_ = delegate; | 276 delegate_ = delegate; |
279 } | 277 } |
280 | 278 |
281 void ScreenCapturerLinux::Stop() { | |
282 } | |
283 | |
284 void ScreenCapturerLinux::InvalidateRegion(const SkRegion& invalid_region) { | |
285 helper_.InvalidateRegion(invalid_region); | |
286 } | |
287 | |
288 void ScreenCapturerLinux::CaptureFrame() { | 279 void ScreenCapturerLinux::CaptureFrame() { |
289 base::Time capture_start_time = base::Time::Now(); | 280 base::Time capture_start_time = base::Time::Now(); |
290 | 281 |
291 // Process XEvents for XDamage and cursor shape tracking. | 282 // Process XEvents for XDamage and cursor shape tracking. |
292 ProcessPendingXEvents(); | 283 ProcessPendingXEvents(); |
293 | 284 |
294 // If the current buffer is from an older generation then allocate a new one. | 285 // If the current buffer is from an older generation then allocate a new one. |
295 // Note that we can't reallocate other buffers at this point, since the caller | 286 // Note that we can't reallocate other buffers at this point, since the caller |
296 // may still be reading from them. | 287 // may still be reading from them. |
297 if (queue_.current_frame_needs_update()) { | 288 if (queue_.current_frame_needs_update()) { |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 // static | 629 // static |
639 scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithXDamage( | 630 scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithXDamage( |
640 bool use_x_damage) { | 631 bool use_x_damage) { |
641 scoped_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); | 632 scoped_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux()); |
642 if (!capturer->Init(use_x_damage)) | 633 if (!capturer->Init(use_x_damage)) |
643 capturer.reset(); | 634 capturer.reset(); |
644 return capturer.PassAs<ScreenCapturer>(); | 635 return capturer.PassAs<ScreenCapturer>(); |
645 } | 636 } |
646 | 637 |
647 } // namespace media | 638 } // namespace media |
OLD | NEW |