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

Side by Side Diff: remoting/capturer/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: rebase 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.
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Capture the cursor image and notify the delegate if it was captured. 80 // Capture the cursor image and notify the delegate if it was captured.
81 void CaptureCursor(); 81 void CaptureCursor();
82 82
83 // Capture screen pixels, and return the data in a new CaptureData object, 83 // Capture screen pixels, and return the data in a new CaptureData object,
84 // to be freed by the caller. 84 // to be freed by the caller.
85 // In the DAMAGE case, the VideoFrameCapturerHelper already holds the list of 85 // In the DAMAGE case, the VideoFrameCapturerHelper already holds the list of
86 // invalid rectangles from ProcessPendingXEvents(). 86 // invalid rectangles from ProcessPendingXEvents().
87 // In the non-DAMAGE case, this captures the whole screen, then calculates 87 // In the non-DAMAGE case, this captures the whole screen, then calculates
88 // some invalid rectangles that include any differences between this and the 88 // some invalid rectangles that include any differences between this and the
89 // previous capture. 89 // previous capture.
90 CaptureData* CaptureScreen(); 90 scoped_refptr<CaptureData> CaptureScreen();
91 91
92 // Called when the screen configuration is changed. |root_window_size| 92 // Called when the screen configuration is changed. |root_window_size|
93 // specifies size the most recent size of the root window. 93 // specifies size the most recent size of the root window.
94 void ScreenConfigurationChanged(const SkISize& root_window_size); 94 void ScreenConfigurationChanged(const SkISize& root_window_size);
95 95
96 // Synchronize the current buffer with |last_buffer_|, by copying pixels from 96 // Synchronize the current buffer with |last_buffer_|, by copying pixels from
97 // the area of |last_invalid_rects|. 97 // the area of |last_invalid_rects|.
98 // Note this only works on the assumption that kNumBuffers == 2, as 98 // Note this only works on the assumption that kNumBuffers == 2, as
99 // |last_invalid_rects| holds the differences from the previous buffer and 99 // |last_invalid_rects| holds the differences from the previous buffer and
100 // the one prior to that (which will then be the current buffer). 100 // the one prior to that (which will then be the current buffer).
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 uint32* dst = reinterpret_cast<uint32*>(string_as_array(&cursor->data)); 388 uint32* dst = reinterpret_cast<uint32*>(string_as_array(&cursor->data));
389 uint32* dst_end = dst + (img->width * img->height); 389 uint32* dst_end = dst + (img->width * img->height);
390 while (dst < dst_end) { 390 while (dst < dst_end) {
391 *dst++ = static_cast<uint32>(*src++); 391 *dst++ = static_cast<uint32>(*src++);
392 } 392 }
393 XFree(img); 393 XFree(img);
394 394
395 delegate_->OnCursorShapeChanged(cursor.Pass()); 395 delegate_->OnCursorShapeChanged(cursor.Pass());
396 } 396 }
397 397
398 CaptureData* VideoFrameCapturerLinux::CaptureScreen() { 398 scoped_refptr<CaptureData> VideoFrameCapturerLinux::CaptureScreen() {
399 VideoFrame* current = queue_.current_frame(); 399 VideoFrame* current = queue_.current_frame();
400 DataPlanes planes; 400 DataPlanes planes;
401 planes.data[0] = current->pixels(); 401 planes.data[0] = current->pixels();
402 planes.strides[0] = current->bytes_per_row(); 402 planes.strides[0] = current->bytes_per_row();
403 403
404 CaptureData* capture_data = new CaptureData(planes, current->dimensions(), 404 scoped_refptr<CaptureData> capture_data(
405 media::VideoFrame::RGB32); 405 new CaptureData(planes, current->dimensions(), media::VideoFrame::RGB32));
406 406
407 // Pass the screen size to the helper, so it can clip the invalid region if it 407 // Pass the screen size to the helper, so it can clip the invalid region if it
408 // expands that region to a grid. 408 // expands that region to a grid.
409 helper_.set_size_most_recent(capture_data->size()); 409 helper_.set_size_most_recent(capture_data->size());
410 410
411 // In the DAMAGE case, ensure the frame is up-to-date with the previous frame 411 // In the DAMAGE case, ensure the frame is up-to-date with the previous frame
412 // if any. If there isn't a previous frame, that means a screen-resolution 412 // if any. If there isn't a previous frame, that means a screen-resolution
413 // change occurred, and |invalid_rects| will be updated to include the whole 413 // change occurred, and |invalid_rects| will be updated to include the whole
414 // screen. 414 // screen.
415 if (use_damage_ && queue_.previous_frame()) 415 if (use_damage_ && queue_.previous_frame())
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 NOTIMPLEMENTED(); 628 NOTIMPLEMENTED();
629 return scoped_ptr<VideoFrameCapturer>(); 629 return scoped_ptr<VideoFrameCapturer>();
630 } 630 }
631 631
632 // static 632 // static
633 void VideoFrameCapturer::EnableXDamage(bool enable) { 633 void VideoFrameCapturer::EnableXDamage(bool enable) {
634 g_should_use_x_damage = enable; 634 g_should_use_x_damage = enable;
635 } 635 }
636 636
637 } // namespace remoting 637 } // 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