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

Side by Side Diff: remoting/host/capturer.h

Issue 3013015: Initial pass at integrating Differ into the chromoting host code.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months 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 | « remoting/base/types.h ('k') | remoting/host/capturer.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef REMOTING_HOST_CAPTURER_H_ 5 #ifndef REMOTING_HOST_CAPTURER_H_
6 #define REMOTING_HOST_CAPTURER_H_ 6 #define REMOTING_HOST_CAPTURER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/lock.h" 10 #include "base/lock.h"
11 #include "base/task.h" 11 #include "base/task.h"
12 #include "remoting/base/capture_data.h" 12 #include "remoting/base/capture_data.h"
13 #include "remoting/base/types.h"
13 14
14 namespace remoting { 15 namespace remoting {
15 16
16 // A class to perform the task of capturing the image of a window. 17 // A class to perform the task of capturing the image of a window.
17 // The capture action is asynchronous to allow maximum throughput. 18 // The capture action is asynchronous to allow maximum throughput.
18 // 19 //
19 // Implementation has to ensure the following gurantees: 20 // The full capture process is as follows:
21 //
22 // (1) InvalidateRects
23 // This is an optional step where regions of the screen are marked as
24 // invalid. Some platforms (Windows, for now) won't use this and will
25 // instead calculate the diff-regions later (in step (2). Other
26 // platforms (Mac) will use this to mark all the changed regions of the
27 // screen. Some limited rect-merging (e.g., to eliminate exact
28 // duplicates) may be done here.
29 //
30 // (2) CaptureInvalidRects
31 // This is where the bits for the invalid rects are packaged up and sent
32 // to the encoder.
33 // A screen capture is performed if needed. For example, Windows requires
34 // a capture to calculate the diff from the previous screen, whereas the
35 // Mac version does not.
36 //
37 // Implementation has to ensure the following guarantees:
20 // 1. Double buffering 38 // 1. Double buffering
21 // Since data can be read while another capture action is 39 // Since data can be read while another capture action is happening.
22 // happening.
23 class Capturer { 40 class Capturer {
24 public: 41 public:
25 // CaptureCompletedCallback is called when the capturer has completed. 42 // CaptureCompletedCallback is called when the capturer has completed.
26 typedef Callback1<scoped_refptr<CaptureData> >::Type CaptureCompletedCallback; 43 typedef Callback1<scoped_refptr<CaptureData> >::Type CaptureCompletedCallback;
27 44
28 Capturer(); 45 Capturer();
29 virtual ~Capturer(); 46 virtual ~Capturer();
30 47
48 // Called when the screen configuration is changed.
49 virtual void ScreenConfigurationChanged() = 0;
31 50
32 // Capture the updated regions since last capture. If the last 51 // Return the width of the screen.
33 // capture doesn't exist, the full window is captured. 52 virtual int width() const { return width_; }
53
54 // Return the height of the screen.
55 virtual int height() const { return height_; }
56
57 // Return the pixel format of the screen.
58 virtual PixelFormat pixel_format() const { return pixel_format_; }
59
60 // Clear out the list of invalid rects.
61 void ClearInvalidRects();
62
63 // Invalidate the specified screen rects.
64 void InvalidateRects(const InvalidRects& inval_rects);
65
66 // Invalidate the entire screen.
67 virtual void InvalidateFullScreen();
68
69 // Capture the screen data associated with each of the accumulated
70 // rects in |inval_rects|.
71 // This routine will first call CalculateInvalidRects to update the
72 // list of |inval_rects|.
73 // When the capture is complete, |callback| is called.
34 // 74 //
35 // When complete |callback| is called. 75 // If |inval_rects_| is empty, then this does nothing except
76 // call the |callback| routine.
36 // 77 //
37 // It is OK to call this method while another thread is reading 78 // It is OK to call this method while another thread is reading
38 // data of the last capture. 79 // data of the last capture.
39 // There can be at most one concurrent read going on when this 80 // There can be at most one concurrent read going on when this
40 // method is called. 81 // method is called.
41 virtual void CaptureInvalidRects(CaptureCompletedCallback* callback); 82 virtual void CaptureInvalidRects(CaptureCompletedCallback* callback);
42 83
84 protected:
85 // Update the list of |invalid_rects| to prepare for capturing the
86 // screen data.
87 // Depending on the platform implementation, this routine might:
88 // (a) Analyze screen and calculate the list of rects that have changed
89 // since the last capture.
90 // (b) Merge already-acculumated rects into a more optimal list (for
91 // example, by combining or removing rects).
92 virtual void CalculateInvalidRects() = 0;
93
43 // Capture the specified screen rects and call |callback| when complete. 94 // Capture the specified screen rects and call |callback| when complete.
44 // Dirty or invalid regions are ignored and only the given |rects| areas are 95 // Dirty or invalid regions are ignored and only the given |rects| areas are
45 // captured. 96 // captured.
46 // 97 // This routine is used internally by CaptureInvalidRects().
47 // It is OK to call this method while another thread is reading 98 virtual void CaptureRects(const InvalidRects& rects,
48 // data of the last capture.
49 // There can be at most one concurrent read going on when this
50 // method is called.
51 virtual void CaptureRects(const RectVector& rects,
52 CaptureCompletedCallback* callback) = 0; 99 CaptureCompletedCallback* callback) = 0;
53 100
54 // Invalidate the specified screen rects.
55 virtual void InvalidateRects(const RectVector& inval_rects);
56
57 // Invalidate the entire screen.
58 virtual void InvalidateFullScreen();
59
60 // Called when the screen configuration is changed.
61 virtual void ScreenConfigurationChanged() = 0;
62
63 // Return the width of the screen.
64 virtual int width() const { return width_; }
65
66 // Return the height of the screen
67 virtual int height() const { return height_; }
68
69 // Return the pixel format of the screen
70 virtual PixelFormat pixel_format() const { return pixel_format_; }
71
72 protected:
73 // Finish/cleanup capture task. 101 // Finish/cleanup capture task.
74 // This should be called at the end of each of the CaptureXxx() routines. 102 // This should be called by CaptureRects() when it finishes.
75 // This routine should (at least): 103 // This routine should (at least):
76 // (1) Call the |callback| routine. 104 // (1) Call the |callback| routine.
77 // (2) Select the next screen buffer. 105 // (2) Select the next screen buffer.
78 // Note that capturers are required to be double-buffered so that we can 106 // Note that capturers are required to be double-buffered so that we can
79 // read from one which capturing into another. 107 // read from one which capturing into another.
80 virtual void FinishCapture(scoped_refptr<CaptureData> data, 108 void FinishCapture(scoped_refptr<CaptureData> data,
81 CaptureCompletedCallback* callback); 109 CaptureCompletedCallback* callback);
82 110
83 // Number of screen buffers. 111 // Number of screen buffers.
84 static const int kNumBuffers = 2; 112 static const int kNumBuffers = 2;
85 113
86 // Capture screen dimensions. 114 // Capture screen dimensions.
87 int width_; 115 int width_;
88 int height_; 116 int height_;
89 117
90 // Format of pixels returned in buffer. 118 // Format of pixels returned in buffer.
91 PixelFormat pixel_format_; 119 PixelFormat pixel_format_;
92 int bytes_per_row_; 120 int bytes_per_row_;
93 121
94 // The current buffer with valid data for reading. 122 // The current buffer with valid data for reading.
95 int current_buffer_; 123 int current_buffer_;
96 124
97 private: 125 private:
98
99 // Rects that have been manually invalidated (through InvalidateRect). 126 // Rects that have been manually invalidated (through InvalidateRect).
100 // These will be returned as dirty_rects in the capture data during the next 127 // These will be returned as dirty_rects in the capture data during the next
101 // capture. 128 // capture.
102 RectVector inval_rects_; 129 InvalidRects inval_rects_;
103 130
104 // A lock protecting |inval_rects_| across threads. 131 // A lock protecting |inval_rects_| across threads.
105 Lock inval_rects_lock_; 132 Lock inval_rects_lock_;
106 }; 133 };
107 134
108 } // namespace remoting 135 } // namespace remoting
109 136
110 #endif // REMOTING_HOST_CAPTURER_H_ 137 #endif // REMOTING_HOST_CAPTURER_H_
OLDNEW
« no previous file with comments | « remoting/base/types.h ('k') | remoting/host/capturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698