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

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

Issue 10382184: [Chromoting] Initial plumbing for cursor shape. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ClientStub instead of CursorShapeStub Created 8 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #include <dlfcn.h> 8 #include <dlfcn.h>
9 #include <IOKit/pwr_mgt/IOPMLib.h> 9 #include <IOKit/pwr_mgt/IOPMLib.h>
10 #include <OpenGL/CGLMacro.h> 10 #include <OpenGL/CGLMacro.h>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 // A class to perform capturing for mac. 152 // A class to perform capturing for mac.
153 class CapturerMac : public Capturer { 153 class CapturerMac : public Capturer {
154 public: 154 public:
155 CapturerMac(); 155 CapturerMac();
156 virtual ~CapturerMac(); 156 virtual ~CapturerMac();
157 157
158 bool Init(); 158 bool Init();
159 159
160 // Capturer interface. 160 // Capturer interface.
161 virtual void Start() OVERRIDE; 161 virtual void Start(const CursorShapeChangedCallback& callback) OVERRIDE;
162 virtual void Stop() OVERRIDE; 162 virtual void Stop() OVERRIDE;
163 virtual void ScreenConfigurationChanged() OVERRIDE; 163 virtual void ScreenConfigurationChanged() OVERRIDE;
164 virtual media::VideoFrame::Format pixel_format() const OVERRIDE; 164 virtual media::VideoFrame::Format pixel_format() const OVERRIDE;
165 virtual void ClearInvalidRegion() OVERRIDE; 165 virtual void ClearInvalidRegion() OVERRIDE;
166 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; 166 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
167 virtual void InvalidateScreen(const SkISize& size) OVERRIDE; 167 virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
168 virtual void InvalidateFullScreen() OVERRIDE; 168 virtual void InvalidateFullScreen() OVERRIDE;
169 virtual void CaptureInvalidRegion( 169 virtual void CaptureInvalidRegion(
170 const CaptureCompletedCallback& callback) OVERRIDE; 170 const CaptureCompletedCallback& callback) OVERRIDE;
171 virtual const SkISize& size_most_recent() const OVERRIDE; 171 virtual const SkISize& size_most_recent() const OVERRIDE;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 cgl_context_ = NULL; 299 cgl_context_ = NULL;
300 } 300 }
301 // The buffers might be in use by the encoder, so don't delete them here. 301 // The buffers might be in use by the encoder, so don't delete them here.
302 // Instead, mark them as "needs update"; next time the buffers are used by 302 // Instead, mark them as "needs update"; next time the buffers are used by
303 // the capturer, they will be recreated if necessary. 303 // the capturer, they will be recreated if necessary.
304 for (int i = 0; i < kNumBuffers; ++i) { 304 for (int i = 0; i < kNumBuffers; ++i) {
305 buffers_[i].set_needs_update(); 305 buffers_[i].set_needs_update();
306 } 306 }
307 } 307 }
308 308
309 void CapturerMac::Start() { 309 void CapturerMac::Start(
310 const CursorShapeChangedCallback& callback) {
311 cursor_shape_changed_callback_ = callback;
312
310 // Create power management assertions to wake the display and prevent it from 313 // Create power management assertions to wake the display and prevent it from
311 // going to sleep on user idle. 314 // going to sleep on user idle.
312 IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, 315 IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep,
313 kIOPMAssertionLevelOn, 316 kIOPMAssertionLevelOn,
314 &power_assertion_id_display_); 317 &power_assertion_id_display_);
315 IOPMAssertionCreate(CFSTR("UserIsActive"), 318 IOPMAssertionCreate(CFSTR("UserIsActive"),
316 kIOPMAssertionLevelOn, 319 kIOPMAssertionLevelOn,
317 &power_assertion_id_user_); 320 &power_assertion_id_user_);
318 } 321 }
319 322
320 void CapturerMac::Stop() { 323 void CapturerMac::Stop() {
321 if (power_assertion_id_display_ != kIOPMNullAssertionID) { 324 if (power_assertion_id_display_ != kIOPMNullAssertionID) {
322 IOPMAssertionRelease(power_assertion_id_display_); 325 IOPMAssertionRelease(power_assertion_id_display_);
323 power_assertion_id_display_ = kIOPMNullAssertionID; 326 power_assertion_id_display_ = kIOPMNullAssertionID;
324 } 327 }
325 if (power_assertion_id_user_ != kIOPMNullAssertionID) { 328 if (power_assertion_id_user_ != kIOPMNullAssertionID) {
326 IOPMAssertionRelease(power_assertion_id_user_); 329 IOPMAssertionRelease(power_assertion_id_user_);
327 power_assertion_id_user_ = kIOPMNullAssertionID; 330 power_assertion_id_user_ = kIOPMNullAssertionID;
328 } 331 }
329 } 332 }
330 333
334 void CapturerMac::SetCursorShapeChangedCallback(
335 const CursorShapeChangedCallback& callback) {
336 // TODO(garykac) Implement cursor shape for Mac. (crbug.com/116299)
337 }
338
331 void CapturerMac::ScreenConfigurationChanged() { 339 void CapturerMac::ScreenConfigurationChanged() {
332 ReleaseBuffers(); 340 ReleaseBuffers();
333 helper_.ClearInvalidRegion(); 341 helper_.ClearInvalidRegion();
334 last_buffer_ = NULL; 342 last_buffer_ = NULL;
335 343
336 CGDirectDisplayID mainDevice = CGMainDisplayID(); 344 CGDirectDisplayID mainDevice = CGMainDisplayID();
337 int width = CGDisplayPixelsWide(mainDevice); 345 int width = CGDisplayPixelsWide(mainDevice);
338 int height = CGDisplayPixelsHigh(mainDevice); 346 int height = CGDisplayPixelsHigh(mainDevice);
339 InvalidateScreen(SkISize::Make(width, height)); 347 InvalidateScreen(SkISize::Make(width, height));
340 348
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 Capturer* Capturer::Create() { 675 Capturer* Capturer::Create() {
668 CapturerMac* capturer = new CapturerMac(); 676 CapturerMac* capturer = new CapturerMac();
669 if (!capturer->Init()) { 677 if (!capturer->Init()) {
670 delete capturer; 678 delete capturer;
671 capturer = NULL; 679 capturer = NULL;
672 } 680 }
673 return capturer; 681 return capturer;
674 } 682 }
675 683
676 } // namespace remoting 684 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698