Chromium Code Reviews| Index: remoting/host/capturer_mac.mm |
| diff --git a/remoting/host/capturer_mac.mm b/remoting/host/capturer_mac.mm |
| index 9b38b9218dcd0e2970a8af9996ae5ed59ae326b1..040ec6c108289b144cffb10ae6df34ee7ee61a85 100644 |
| --- a/remoting/host/capturer_mac.mm |
| +++ b/remoting/host/capturer_mac.mm |
| @@ -177,12 +177,8 @@ class CapturerMac : public Capturer { |
| // Capturer interface. |
| virtual void Start(const CursorShapeChangedCallback& callback) OVERRIDE; |
| virtual void Stop() OVERRIDE; |
| - virtual void ScreenConfigurationChanged() OVERRIDE; |
| virtual media::VideoFrame::Format pixel_format() const OVERRIDE; |
| - virtual void ClearInvalidRegion() OVERRIDE; |
| virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; |
| - virtual void InvalidateScreen(const SkISize& size) OVERRIDE; |
| - virtual void InvalidateFullScreen() OVERRIDE; |
| virtual void CaptureInvalidRegion( |
| const CaptureCompletedCallback& callback) OVERRIDE; |
| virtual const SkISize& size_most_recent() const OVERRIDE; |
| @@ -197,6 +193,8 @@ class CapturerMac : public Capturer { |
| void CaptureRegion(const SkRegion& region, |
| const CaptureCompletedCallback& callback); |
| + // Called when the screen configuration is changed. |
| + void ScreenConfigurationChanged(); |
|
Wez
2012/07/18 20:31:19
Add a blank line after this so it's clear that the
alexeypa (please no reviews)
2012/07/18 20:51:26
Done.
|
| void ScreenRefresh(CGRectCount count, const CGRect *rect_array); |
| void ScreenUpdateMove(CGScreenUpdateMoveDelta delta, |
| size_t count, |
| @@ -356,68 +354,14 @@ void CapturerMac::Stop() { |
| } |
| } |
| -void CapturerMac::ScreenConfigurationChanged() { |
| - ReleaseBuffers(); |
| - helper_.ClearInvalidRegion(); |
| - last_buffer_ = NULL; |
| - |
| - CGDirectDisplayID mainDevice = CGMainDisplayID(); |
| - int width = CGDisplayPixelsWide(mainDevice); |
| - int height = CGDisplayPixelsHigh(mainDevice); |
| - InvalidateScreen(SkISize::Make(width, height)); |
| - |
| - if (!CGDisplayUsesOpenGLAcceleration(mainDevice)) { |
| - VLOG(3) << "OpenGL support not available."; |
| - return; |
| - } |
| - |
| - if (display_create_image_func_ != NULL) { |
| - // No need for any OpenGL support on Lion |
| - return; |
| - } |
| - |
| - CGLPixelFormatAttribute attributes[] = { |
| - kCGLPFAFullScreen, |
| - kCGLPFADisplayMask, |
| - (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(mainDevice), |
| - (CGLPixelFormatAttribute)0 |
| - }; |
| - CGLPixelFormatObj pixel_format = NULL; |
| - GLint matching_pixel_format_count = 0; |
| - CGLError err = CGLChoosePixelFormat(attributes, |
| - &pixel_format, |
| - &matching_pixel_format_count); |
| - DCHECK_EQ(err, kCGLNoError); |
| - err = CGLCreateContext(pixel_format, NULL, &cgl_context_); |
| - DCHECK_EQ(err, kCGLNoError); |
| - CGLDestroyPixelFormat(pixel_format); |
| - CGLSetFullScreen(cgl_context_); |
| - CGLSetCurrentContext(cgl_context_); |
| - |
| - size_t buffer_size = width * height * sizeof(uint32_t); |
| - pixel_buffer_object_.Init(cgl_context_, buffer_size); |
| -} |
| - |
| media::VideoFrame::Format CapturerMac::pixel_format() const { |
| return pixel_format_; |
| } |
| -void CapturerMac::ClearInvalidRegion() { |
| - helper_.ClearInvalidRegion(); |
| -} |
| - |
| void CapturerMac::InvalidateRegion(const SkRegion& invalid_region) { |
| helper_.InvalidateRegion(invalid_region); |
| } |
| -void CapturerMac::InvalidateScreen(const SkISize& size) { |
| - helper_.InvalidateScreen(size); |
| -} |
| - |
| -void CapturerMac::InvalidateFullScreen() { |
| - helper_.InvalidateFullScreen(); |
| -} |
| - |
| void CapturerMac::CaptureInvalidRegion( |
| const CaptureCompletedCallback& callback) { |
| // Only allow captures when the display configuration is not occurring. |
| @@ -712,6 +656,48 @@ const SkISize& CapturerMac::size_most_recent() const { |
| return helper_.size_most_recent(); |
| } |
| +void CapturerMac::ScreenConfigurationChanged() { |
| + ReleaseBuffers(); |
| + helper_.ClearInvalidRegion(); |
| + last_buffer_ = NULL; |
| + |
| + CGDirectDisplayID mainDevice = CGMainDisplayID(); |
| + int width = CGDisplayPixelsWide(mainDevice); |
| + int height = CGDisplayPixelsHigh(mainDevice); |
| + helper_.InvalidateScreen(SkISize::Make(width, height)); |
| + |
| + if (!CGDisplayUsesOpenGLAcceleration(mainDevice)) { |
| + VLOG(3) << "OpenGL support not available."; |
| + return; |
| + } |
| + |
| + if (display_create_image_func_ != NULL) { |
| + // No need for any OpenGL support on Lion |
| + return; |
| + } |
| + |
| + CGLPixelFormatAttribute attributes[] = { |
| + kCGLPFAFullScreen, |
| + kCGLPFADisplayMask, |
| + (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(mainDevice), |
| + (CGLPixelFormatAttribute)0 |
| + }; |
| + CGLPixelFormatObj pixel_format = NULL; |
| + GLint matching_pixel_format_count = 0; |
| + CGLError err = CGLChoosePixelFormat(attributes, |
| + &pixel_format, |
| + &matching_pixel_format_count); |
| + DCHECK_EQ(err, kCGLNoError); |
| + err = CGLCreateContext(pixel_format, NULL, &cgl_context_); |
| + DCHECK_EQ(err, kCGLNoError); |
| + CGLDestroyPixelFormat(pixel_format); |
| + CGLSetFullScreen(cgl_context_); |
| + CGLSetCurrentContext(cgl_context_); |
| + |
| + size_t buffer_size = width * height * sizeof(uint32_t); |
| + pixel_buffer_object_.Init(cgl_context_, buffer_size); |
| +} |
| + |
| void CapturerMac::ScreenRefresh(CGRectCount count, const CGRect *rect_array) { |
| SkIRect skirect_array[count]; |
| for (CGRectCount i = 0; i < count; ++i) { |