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

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

Issue 8493020: Move code in src/remoting to the new callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: - Created 9 years, 1 month 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
« no previous file with comments | « remoting/host/capturer_fake_ascii.cc ('k') | remoting/host/capturer_mac.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/capturer.h" 5 #include "remoting/host/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 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 bool Init(); // TODO(ajwong): Do we really want this to be synchronous? 73 bool Init(); // TODO(ajwong): Do we really want this to be synchronous?
74 74
75 // Capturer interface. 75 // Capturer interface.
76 virtual void ScreenConfigurationChanged() OVERRIDE; 76 virtual void ScreenConfigurationChanged() OVERRIDE;
77 virtual media::VideoFrame::Format pixel_format() const OVERRIDE; 77 virtual media::VideoFrame::Format pixel_format() const OVERRIDE;
78 virtual void ClearInvalidRegion() OVERRIDE; 78 virtual void ClearInvalidRegion() OVERRIDE;
79 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; 79 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
80 virtual void InvalidateScreen(const SkISize& size) OVERRIDE; 80 virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
81 virtual void InvalidateFullScreen() OVERRIDE; 81 virtual void InvalidateFullScreen() OVERRIDE;
82 virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) 82 virtual void CaptureInvalidRegion(
83 OVERRIDE; 83 const CaptureCompletedCallback& callback) OVERRIDE;
84 virtual const SkISize& size_most_recent() const OVERRIDE; 84 virtual const SkISize& size_most_recent() const OVERRIDE;
85 85
86 private: 86 private:
87 void InitXDamage(); 87 void InitXDamage();
88 88
89 // Read and handle all currently-pending XEvents. 89 // Read and handle all currently-pending XEvents.
90 // In the DAMAGE case, process the XDamage events and store the resulting 90 // In the DAMAGE case, process the XDamage events and store the resulting
91 // damage rectangles in the CapturerHelper. 91 // damage rectangles in the CapturerHelper.
92 // In all cases, call ScreenConfigurationChanged() in response to any 92 // In all cases, call ScreenConfigurationChanged() in response to any
93 // ConfigNotify events. 93 // ConfigNotify events.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void CapturerLinux::InvalidateScreen(const SkISize& size) { 257 void CapturerLinux::InvalidateScreen(const SkISize& size) {
258 helper_.InvalidateScreen(size); 258 helper_.InvalidateScreen(size);
259 } 259 }
260 260
261 void CapturerLinux::InvalidateFullScreen() { 261 void CapturerLinux::InvalidateFullScreen() {
262 helper_.InvalidateFullScreen(); 262 helper_.InvalidateFullScreen();
263 last_buffer_ = NULL; 263 last_buffer_ = NULL;
264 } 264 }
265 265
266 void CapturerLinux::CaptureInvalidRegion( 266 void CapturerLinux::CaptureInvalidRegion(
267 CaptureCompletedCallback* callback) { 267 const CaptureCompletedCallback& callback) {
268 scoped_ptr<CaptureCompletedCallback> callback_deleter(callback);
269
270 // TODO(lambroslambrou): In the non-DAMAGE case, there should be no need 268 // TODO(lambroslambrou): In the non-DAMAGE case, there should be no need
271 // for any X event processing in this class. 269 // for any X event processing in this class.
272 ProcessPendingXEvents(); 270 ProcessPendingXEvents();
273 271
274 // Resize the current buffer if there was a recent change of 272 // Resize the current buffer if there was a recent change of
275 // screen-resolution. 273 // screen-resolution.
276 VideoFrameBuffer &current = buffers_[current_buffer_]; 274 VideoFrameBuffer &current = buffers_[current_buffer_];
277 current.Update(display_, root_window_); 275 current.Update(display_, root_window_);
278 // Also refresh the Differ helper used by CaptureFrame(), if needed. 276 // Also refresh the Differ helper used by CaptureFrame(), if needed.
279 if (!use_damage_ && !last_buffer_) { 277 if (!use_damage_ && !last_buffer_) {
280 differ_.reset(new Differ(current.size().width(), current.size().height(), 278 differ_.reset(new Differ(current.size().width(), current.size().height(),
281 kBytesPerPixel, current.bytes_per_row())); 279 kBytesPerPixel, current.bytes_per_row()));
282 } 280 }
283 281
284 scoped_refptr<CaptureData> capture_data(CaptureFrame()); 282 scoped_refptr<CaptureData> capture_data(CaptureFrame());
285 283
286 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; 284 current_buffer_ = (current_buffer_ + 1) % kNumBuffers;
287 helper_.set_size_most_recent(capture_data->size()); 285 helper_.set_size_most_recent(capture_data->size());
288 286
289 callback->Run(capture_data); 287 callback.Run(capture_data);
290 } 288 }
291 289
292 void CapturerLinux::ProcessPendingXEvents() { 290 void CapturerLinux::ProcessPendingXEvents() {
293 // Find the number of events that are outstanding "now." We don't just loop 291 // Find the number of events that are outstanding "now." We don't just loop
294 // on XPending because we want to guarantee this terminates. 292 // on XPending because we want to guarantee this terminates.
295 int events_to_process = XPending(display_); 293 int events_to_process = XPending(display_);
296 XEvent e; 294 XEvent e;
297 SkRegion invalid_region; 295 SkRegion invalid_region;
298 296
299 for (int i = 0; i < events_to_process; i++) { 297 for (int i = 0; i < events_to_process; i++) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 Capturer* Capturer::Create() { 507 Capturer* Capturer::Create() {
510 CapturerLinux* capturer = new CapturerLinux(); 508 CapturerLinux* capturer = new CapturerLinux();
511 if (!capturer->Init()) { 509 if (!capturer->Init()) {
512 delete capturer; 510 delete capturer;
513 capturer = NULL; 511 capturer = NULL;
514 } 512 }
515 return capturer; 513 return capturer;
516 } 514 }
517 515
518 } // namespace remoting 516 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/capturer_fake_ascii.cc ('k') | remoting/host/capturer_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698