OLD | NEW |
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 #include "remoting/host/capturer_mac.h" | 5 #include "remoting/host/capturer_mac.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <OpenGL/CGLMacro.h> | 9 #include <OpenGL/CGLMacro.h> |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 CapturerMac::CapturerMac() : cgl_context_(NULL) { | 13 CapturerMac::CapturerMac() : cgl_context_(NULL) { |
14 // TODO(dmaclach): move this initialization out into session_manager, | 14 // TODO(dmaclach): move this initialization out into session_manager, |
15 // or at least have session_manager call into here to initialize it. | 15 // or at least have session_manager call into here to initialize it. |
16 CGError err | 16 CGError err = |
17 = CGRegisterScreenRefreshCallback(CapturerMac::ScreenRefreshCallback, | 17 CGRegisterScreenRefreshCallback(CapturerMac::ScreenRefreshCallback, |
18 this); | 18 this); |
19 DCHECK_EQ(err, kCGErrorSuccess); | 19 DCHECK_EQ(err, kCGErrorSuccess); |
20 err = CGScreenRegisterMoveCallback(CapturerMac::ScreenUpdateMoveCallback, | 20 err = CGScreenRegisterMoveCallback(CapturerMac::ScreenUpdateMoveCallback, |
21 this); | 21 this); |
22 DCHECK_EQ(err, kCGErrorSuccess); | 22 DCHECK_EQ(err, kCGErrorSuccess); |
23 err = CGDisplayRegisterReconfigurationCallback( | 23 err = CGDisplayRegisterReconfigurationCallback( |
24 CapturerMac::DisplaysReconfiguredCallback, this); | 24 CapturerMac::DisplaysReconfiguredCallback, this); |
25 DCHECK_EQ(err, kCGErrorSuccess); | 25 DCHECK_EQ(err, kCGErrorSuccess); |
26 } | 26 } |
27 | 27 |
28 CapturerMac::~CapturerMac() { | 28 CapturerMac::~CapturerMac() { |
(...skipping 11 matching lines...) Expand all Loading... |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 void CapturerMac::ScreenConfigurationChanged() { | 43 void CapturerMac::ScreenConfigurationChanged() { |
44 ReleaseBuffers(); | 44 ReleaseBuffers(); |
45 CGDirectDisplayID mainDevice = CGMainDisplayID(); | 45 CGDirectDisplayID mainDevice = CGMainDisplayID(); |
46 | 46 |
47 width_ = CGDisplayPixelsWide(mainDevice); | 47 width_ = CGDisplayPixelsWide(mainDevice); |
48 height_ = CGDisplayPixelsHigh(mainDevice); | 48 height_ = CGDisplayPixelsHigh(mainDevice); |
49 bytes_per_row_ = width_ * sizeof(uint32_t); | 49 bytes_per_row_ = width_ * sizeof(uint32_t); |
50 pixel_format_ = PIXEL_FORMAT_RGB32; | |
51 size_t buffer_size = height() * bytes_per_row_; | 50 size_t buffer_size = height() * bytes_per_row_; |
52 for (int i = 0; i < kNumBuffers; ++i) { | 51 for (int i = 0; i < kNumBuffers; ++i) { |
53 buffers_[i].reset(new uint8[buffer_size]); | 52 buffers_[i].reset(new uint8[buffer_size]); |
54 } | 53 } |
55 CGLPixelFormatAttribute attributes[] = { | 54 CGLPixelFormatAttribute attributes[] = { |
56 kCGLPFAFullScreen, | 55 kCGLPFAFullScreen, |
57 kCGLPFADisplayMask, | 56 kCGLPFADisplayMask, |
58 (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(mainDevice), | 57 (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(mainDevice), |
59 (CGLPixelFormatAttribute)0 | 58 (CGLPixelFormatAttribute)0 |
60 }; | 59 }; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 CGDisplayChangeSummaryFlags flags, | 155 CGDisplayChangeSummaryFlags flags, |
157 void *user_parameter) { | 156 void *user_parameter) { |
158 if ((display == CGMainDisplayID()) && | 157 if ((display == CGMainDisplayID()) && |
159 !(flags & kCGDisplayBeginConfigurationFlag)) { | 158 !(flags & kCGDisplayBeginConfigurationFlag)) { |
160 CapturerMac *capturer = reinterpret_cast<CapturerMac *>(user_parameter); | 159 CapturerMac *capturer = reinterpret_cast<CapturerMac *>(user_parameter); |
161 capturer->ScreenConfigurationChanged(); | 160 capturer->ScreenConfigurationChanged(); |
162 } | 161 } |
163 } | 162 } |
164 | 163 |
165 } // namespace remoting | 164 } // namespace remoting |
OLD | NEW |