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

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 scoped_ptr<MouseCursorShape> cursor(new MouseCursorShape());
378 int height = img->height; 379 cursor->size.set(img->width, img->height);
379 int total_bytes = width * height * kBytesPerPixel; 380 cursor->hotspot.set(img->xhot, img->yhot);
380 381
381 scoped_ptr<protocol::CursorShapeInfo> cursor_proto( 382 int total_bytes =
382 new protocol::CursorShapeInfo()); 383 cursor->size.width() * cursor->size.height() * kBytesPerPixel;
383 cursor_proto->set_width(width); 384 cursor->data.resize(total_bytes);
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 385
392 // Xlib stores 32-bit data in longs, even if longs are 64-bits long. 386 // Xlib stores 32-bit data in longs, even if longs are 64-bits long.
393 unsigned long* src = img->pixels; 387 unsigned long* src = img->pixels;
394 uint32* dst = reinterpret_cast<uint32*>(proto_data); 388 uint32* dst = reinterpret_cast<uint32*>(string_as_array(&cursor->data));
395 uint32* dst_end = dst + (width * height); 389 uint32* dst_end = dst + (img->width * img->height);
396 while (dst < dst_end) { 390 while (dst < dst_end) {
397 *dst++ = static_cast<uint32>(*src++); 391 *dst++ = static_cast<uint32>(*src++);
398 } 392 }
399 XFree(img); 393 XFree(img);
400 394
401 delegate_->OnCursorShapeChanged(cursor_proto.Pass()); 395 delegate_->OnCursorShapeChanged(cursor.Pass());
402 } 396 }
403 397
404 CaptureData* VideoFrameCapturerLinux::CaptureScreen() { 398 CaptureData* VideoFrameCapturerLinux::CaptureScreen() {
405 VideoFrame* current = queue_.current_frame(); 399 VideoFrame* current = queue_.current_frame();
406 DataPlanes planes; 400 DataPlanes planes;
407 planes.data[0] = current->pixels(); 401 planes.data[0] = current->pixels();
408 planes.strides[0] = current->bytes_per_row(); 402 planes.strides[0] = current->bytes_per_row();
409 403
410 CaptureData* capture_data = new CaptureData(planes, current->dimensions(), 404 CaptureData* capture_data = new CaptureData(planes, current->dimensions(),
411 media::VideoFrame::RGB32); 405 media::VideoFrame::RGB32);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 NOTIMPLEMENTED(); 628 NOTIMPLEMENTED();
635 return scoped_ptr<VideoFrameCapturer>(); 629 return scoped_ptr<VideoFrameCapturer>();
636 } 630 }
637 631
638 // static 632 // static
639 void VideoFrameCapturer::EnableXDamage(bool enable) { 633 void VideoFrameCapturer::EnableXDamage(bool enable) {
640 g_should_use_x_damage = enable; 634 g_should_use_x_damage = enable;
641 } 635 }
642 636
643 } // namespace remoting 637 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/capturer/video_frame_capturer_helper_unittest.cc ('k') | remoting/capturer/video_frame_capturer_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698