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

Side by Side Diff: remoting/host/video_frame_capturer_linux.cc

Issue 11638006: Return scoped_refptr<CaptureData> from VideoFrameCapturerLinux::CaptureScreen() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
Sergey Ulanov 2012/12/19 01:07:30 FYI: I moved this file to remoting/capturer
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/host/video_frame_capturer.h" 5 #include "remoting/host/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>
11 11
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Capture the cursor image and notify the delegate if it was captured. 79 // Capture the cursor image and notify the delegate if it was captured.
80 void CaptureCursor(); 80 void CaptureCursor();
81 81
82 // Capture screen pixels, and return the data in a new CaptureData object, 82 // Capture screen pixels, and return the data in a new CaptureData object,
83 // to be freed by the caller. 83 // to be freed by the caller.
84 // In the DAMAGE case, the VideoFrameCapturerHelper already holds the list of 84 // In the DAMAGE case, the VideoFrameCapturerHelper already holds the list of
85 // invalid rectangles from ProcessPendingXEvents(). 85 // invalid rectangles from ProcessPendingXEvents().
86 // In the non-DAMAGE case, this captures the whole screen, then calculates 86 // In the non-DAMAGE case, this captures the whole screen, then calculates
87 // some invalid rectangles that include any differences between this and the 87 // some invalid rectangles that include any differences between this and the
88 // previous capture. 88 // previous capture.
89 CaptureData* CaptureScreen(); 89 scoped_refptr<CaptureData> CaptureScreen();
90 90
91 // Called when the screen configuration is changed. |root_window_size| 91 // Called when the screen configuration is changed. |root_window_size|
92 // specifies size the most recent size of the root window. 92 // specifies size the most recent size of the root window.
93 void ScreenConfigurationChanged(const SkISize& root_window_size); 93 void ScreenConfigurationChanged(const SkISize& root_window_size);
94 94
95 // Synchronize the current buffer with |last_buffer_|, by copying pixels from 95 // Synchronize the current buffer with |last_buffer_|, by copying pixels from
96 // the area of |last_invalid_rects|. 96 // the area of |last_invalid_rects|.
97 // Note this only works on the assumption that kNumBuffers == 2, as 97 // Note this only works on the assumption that kNumBuffers == 2, as
98 // |last_invalid_rects| holds the differences from the previous buffer and 98 // |last_invalid_rects| holds the differences from the previous buffer and
99 // the one prior to that (which will then be the current buffer). 99 // the one prior to that (which will then be the current buffer).
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 uint32* dst = reinterpret_cast<uint32*>(proto_data); 394 uint32* dst = reinterpret_cast<uint32*>(proto_data);
395 uint32* dst_end = dst + (width * height); 395 uint32* dst_end = dst + (width * height);
396 while (dst < dst_end) { 396 while (dst < dst_end) {
397 *dst++ = static_cast<uint32>(*src++); 397 *dst++ = static_cast<uint32>(*src++);
398 } 398 }
399 XFree(img); 399 XFree(img);
400 400
401 delegate_->OnCursorShapeChanged(cursor_proto.Pass()); 401 delegate_->OnCursorShapeChanged(cursor_proto.Pass());
402 } 402 }
403 403
404 CaptureData* VideoFrameCapturerLinux::CaptureScreen() { 404 scoped_refptr<CaptureData> VideoFrameCapturerLinux::CaptureScreen() {
405 VideoFrame* current = queue_.current_frame(); 405 VideoFrame* current = queue_.current_frame();
406 DataPlanes planes; 406 DataPlanes planes;
407 planes.data[0] = current->pixels(); 407 planes.data[0] = current->pixels();
408 planes.strides[0] = current->bytes_per_row(); 408 planes.strides[0] = current->bytes_per_row();
409 409
410 CaptureData* capture_data = new CaptureData(planes, current->dimensions(), 410 scoped_refptr<CaptureData> capture_data(
411 media::VideoFrame::RGB32); 411 new CaptureData(planes, current->dimensions(), media::VideoFrame::RGB32));
412 412
413 // Pass the screen size to the helper, so it can clip the invalid region if it 413 // Pass the screen size to the helper, so it can clip the invalid region if it
414 // expands that region to a grid. 414 // expands that region to a grid.
415 helper_.set_size_most_recent(capture_data->size()); 415 helper_.set_size_most_recent(capture_data->size());
416 416
417 // In the DAMAGE case, ensure the frame is up-to-date with the previous frame 417 // In the DAMAGE case, ensure the frame is up-to-date with the previous frame
418 // if any. If there isn't a previous frame, that means a screen-resolution 418 // if any. If there isn't a previous frame, that means a screen-resolution
419 // change occurred, and |invalid_rects| will be updated to include the whole 419 // change occurred, and |invalid_rects| will be updated to include the whole
420 // screen. 420 // screen.
421 if (use_damage_ && queue_.previous_frame()) 421 if (use_damage_ && queue_.previous_frame())
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 NOTIMPLEMENTED(); 634 NOTIMPLEMENTED();
635 return scoped_ptr<VideoFrameCapturer>(); 635 return scoped_ptr<VideoFrameCapturer>();
636 } 636 }
637 637
638 // static 638 // static
639 void VideoFrameCapturer::EnableXDamage(bool enable) { 639 void VideoFrameCapturer::EnableXDamage(bool enable) {
640 g_should_use_x_damage = enable; 640 g_should_use_x_damage = enable;
641 } 641 }
642 642
643 } // namespace remoting 643 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698