OLD | NEW |
---|---|
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 "base/logging.h" | 5 #include "remoting/host/capturer.h" |
6 #include "remoting/host/capturer_mac.h" | 6 |
7 #include <ApplicationServices/ApplicationServices.h> | |
8 #include <OpenGL/OpenGL.h> | |
Lambros
2011/04/01 15:54:00
Nit: alphabetize
dmac
2011/04/01 21:15:07
Done.
| |
9 #include <OpenGL/CGLMacro.h> | |
7 | 10 |
8 #include <stddef.h> | 11 #include <stddef.h> |
9 | 12 |
10 #include <OpenGL/CGLMacro.h> | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "remoting/host/capturer_helper.h" | |
11 | 16 |
12 namespace remoting { | 17 namespace remoting { |
13 | 18 |
19 namespace { | |
20 // A class to perform capturing for mac. | |
21 class CapturerMac : public Capturer { | |
22 public: | |
23 CapturerMac(); | |
24 virtual ~CapturerMac(); | |
25 | |
26 // Capturer interface. | |
27 virtual void ScreenConfigurationChanged() OVERRIDE; | |
28 virtual media::VideoFrame::Format pixel_format() const OVERRIDE; | |
29 virtual void ClearInvalidRects() OVERRIDE; | |
30 virtual void InvalidateRects(const InvalidRects& inval_rects) OVERRIDE; | |
31 virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; | |
32 virtual void InvalidateFullScreen() OVERRIDE; | |
33 virtual void CaptureInvalidRects(CaptureCompletedCallback* callback) OVERRIDE; | |
34 virtual const gfx::Size& size_most_recent() const OVERRIDE; | |
35 | |
36 private: | |
37 void CaptureRects(const InvalidRects& rects, | |
38 CaptureCompletedCallback* callback); | |
39 | |
40 void ScreenRefresh(CGRectCount count, const CGRect *rect_array); | |
41 void ScreenUpdateMove(CGScreenUpdateMoveDelta delta, | |
42 size_t count, | |
43 const CGRect *rect_array); | |
44 static void ScreenRefreshCallback(CGRectCount count, | |
45 const CGRect *rect_array, | |
46 void *user_parameter); | |
47 static void ScreenUpdateMoveCallback(CGScreenUpdateMoveDelta delta, | |
48 size_t count, | |
49 const CGRect *rect_array, | |
50 void *user_parameter); | |
51 static void DisplaysReconfiguredCallback(CGDirectDisplayID display, | |
52 CGDisplayChangeSummaryFlags flags, | |
53 void *user_parameter); | |
54 | |
55 void ReleaseBuffers(); | |
56 CGLContextObj cgl_context_; | |
57 static const int kNumBuffers = 2; | |
58 scoped_array<uint8> buffers_[kNumBuffers]; | |
59 scoped_array<uint8> flip_buffer_; | |
60 | |
61 // A thread-safe list of invalid rectangles, and the size of the most | |
62 // recently captured screen. | |
63 CapturerHelper helper_; | |
64 | |
65 // Screen size. | |
66 int width_; | |
67 int height_; | |
68 | |
69 int bytes_per_row_; | |
70 | |
71 // The current buffer with valid data for reading. | |
72 int current_buffer_; | |
73 | |
74 // Format of pixels returned in buffer. | |
75 media::VideoFrame::Format pixel_format_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(CapturerMac); | |
78 }; | |
79 | |
14 CapturerMac::CapturerMac() | 80 CapturerMac::CapturerMac() |
15 : cgl_context_(NULL), | 81 : cgl_context_(NULL), |
16 width_(0), | 82 width_(0), |
17 height_(0), | 83 height_(0), |
18 bytes_per_row_(0), | 84 bytes_per_row_(0), |
19 current_buffer_(0), | 85 current_buffer_(0), |
20 pixel_format_(media::VideoFrame::RGB32) { | 86 pixel_format_(media::VideoFrame::RGB32) { |
21 // TODO(dmaclach): move this initialization out into session_manager, | 87 // TODO(dmaclach): move this initialization out into session_manager, |
22 // or at least have session_manager call into here to initialize it. | 88 // or at least have session_manager call into here to initialize it. |
23 CGError err = | 89 CGError err = |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 CGDirectDisplayID display, | 254 CGDirectDisplayID display, |
189 CGDisplayChangeSummaryFlags flags, | 255 CGDisplayChangeSummaryFlags flags, |
190 void *user_parameter) { | 256 void *user_parameter) { |
191 if ((display == CGMainDisplayID()) && | 257 if ((display == CGMainDisplayID()) && |
192 !(flags & kCGDisplayBeginConfigurationFlag)) { | 258 !(flags & kCGDisplayBeginConfigurationFlag)) { |
193 CapturerMac *capturer = reinterpret_cast<CapturerMac *>(user_parameter); | 259 CapturerMac *capturer = reinterpret_cast<CapturerMac *>(user_parameter); |
194 capturer->ScreenConfigurationChanged(); | 260 capturer->ScreenConfigurationChanged(); |
195 } | 261 } |
196 } | 262 } |
197 | 263 |
264 } // namespace | |
265 | |
198 // static | 266 // static |
199 Capturer* Capturer::Create() { | 267 Capturer* Capturer::Create() { |
200 return new CapturerMac(); | 268 return new CapturerMac(); |
201 } | 269 } |
202 | 270 |
203 } // namespace remoting | 271 } // namespace remoting |
OLD | NEW |