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

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

Issue 11470028: Move screen capturers to remoting/capturer. (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
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/host/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>
11 11
12 #include <set> 12 #include <set>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/stl_util.h"
17 #include "base/time.h" 18 #include "base/time.h"
18 #include "remoting/base/capture_data.h" 19 #include "remoting/capturer/capture_data.h"
19 #include "remoting/host/differ.h" 20 #include "remoting/capturer/differ.h"
20 #include "remoting/host/linux/x_server_pixel_buffer.h" 21 #include "remoting/capturer/linux/x_server_pixel_buffer.h"
21 #include "remoting/host/video_frame.h" 22 #include "remoting/capturer/mouse_cursor_shape.h"
22 #include "remoting/host/video_frame_capturer_helper.h" 23 #include "remoting/capturer/video_frame.h"
23 #include "remoting/host/video_frame_queue.h" 24 #include "remoting/capturer/video_frame_capturer_helper.h"
24 #include "remoting/proto/control.pb.h" 25 #include "remoting/capturer/video_frame_queue.h"
25 26
26 namespace remoting { 27 namespace remoting {
27 28
28 namespace { 29 namespace {
29 30
30 static const int kBytesPerPixel = 4; 31 static const int kBytesPerPixel = 4;
31 32
32 // Default to false, since many systems have broken XDamage support - see 33 // Default to false, since many systems have broken XDamage support - see
33 // http://crbug.com/73423. 34 // http://crbug.com/73423.
34 static bool g_should_use_x_damage = false; 35 static bool g_should_use_x_damage = false;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 368 }
368 369
369 void VideoFrameCapturerLinux::CaptureCursor() { 370 void VideoFrameCapturerLinux::CaptureCursor() {
370 DCHECK(has_xfixes_); 371 DCHECK(has_xfixes_);
371 372
372 XFixesCursorImage* img = XFixesGetCursorImage(display_); 373 XFixesCursorImage* img = XFixesGetCursorImage(display_);
373 if (!img) { 374 if (!img) {
374 return; 375 return;
375 } 376 }
376 377
377 int width = img->width; 378 MouseCursorShape cursor;
378 int height = img->height; 379 cursor.width = img->width;
379 int total_bytes = width * height * kBytesPerPixel; 380 cursor.height = img->height;
381 cursor.hotspot_x = img->xhot;
382 cursor.hotspot_y = img->yhot;
380 383
381 scoped_ptr<protocol::CursorShapeInfo> cursor_proto( 384 int total_bytes = cursor.width * cursor.height * kBytesPerPixel;
382 new protocol::CursorShapeInfo()); 385 cursor.data.resize(total_bytes);
383 cursor_proto->set_width(width);
384 cursor_proto->set_height(height);
385 cursor_proto->set_hotspot_x(img->xhot);
386 cursor_proto->set_hotspot_y(img->yhot);
387
388 cursor_proto->mutable_data()->resize(total_bytes);
389 uint8* proto_data = const_cast<uint8*>(reinterpret_cast<const uint8*>(
390 cursor_proto->mutable_data()->data()));
391 386
392 // Xlib stores 32-bit data in longs, even if longs are 64-bits long. 387 // Xlib stores 32-bit data in longs, even if longs are 64-bits long.
393 unsigned long* src = img->pixels; 388 unsigned long* src = img->pixels;
394 uint32* dst = reinterpret_cast<uint32*>(proto_data); 389 uint32* dst = reinterpret_cast<uint32*>(string_as_array(&cursor.data));
395 uint32* dst_end = dst + (width * height); 390 uint32* dst_end = dst + (img->width * img->height);
396 while (dst < dst_end) { 391 while (dst < dst_end) {
397 *dst++ = static_cast<uint32>(*src++); 392 *dst++ = static_cast<uint32>(*src++);
398 } 393 }
399 XFree(img); 394 XFree(img);
400 395
401 delegate_->OnCursorShapeChanged(cursor_proto.Pass()); 396 delegate_->OnCursorShapeChanged(cursor);
Wez 2012/12/11 05:23:18 We deliberately had the recipient own the cursor,
Sergey Ulanov 2012/12/12 18:31:12 Changed it to passing pointers, though I don't thi
402 } 397 }
403 398
404 CaptureData* VideoFrameCapturerLinux::CaptureScreen() { 399 CaptureData* VideoFrameCapturerLinux::CaptureScreen() {
405 VideoFrame* current = queue_.current_frame(); 400 VideoFrame* current = queue_.current_frame();
406 DataPlanes planes; 401 DataPlanes planes;
407 planes.data[0] = current->pixels(); 402 planes.data[0] = current->pixels();
408 planes.strides[0] = current->bytes_per_row(); 403 planes.strides[0] = current->bytes_per_row();
409 404
410 CaptureData* capture_data = new CaptureData(planes, current->dimensions(), 405 CaptureData* capture_data = new CaptureData(planes, current->dimensions(),
411 media::VideoFrame::RGB32); 406 media::VideoFrame::RGB32);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 NOTIMPLEMENTED(); 629 NOTIMPLEMENTED();
635 return scoped_ptr<VideoFrameCapturer>(); 630 return scoped_ptr<VideoFrameCapturer>();
636 } 631 }
637 632
638 // static 633 // static
639 void VideoFrameCapturer::EnableXDamage(bool enable) { 634 void VideoFrameCapturer::EnableXDamage(bool enable) {
640 g_should_use_x_damage = enable; 635 g_should_use_x_damage = enable;
641 } 636 }
642 637
643 } // namespace remoting 638 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698