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

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

Issue 7992011: Move us fully from gfx:: over to skia types for consistency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for bad DEPS Created 9 years, 2 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/host/capturer_linux.cc ('k') | remoting/host/capturer_win.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) 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 "remoting/host/capturer.h" 5 #include "remoting/host/capturer.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #include <OpenGL/CGLMacro.h> 8 #include <OpenGL/CGLMacro.h>
9 #include <OpenGL/OpenGL.h> 9 #include <OpenGL/OpenGL.h>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // If the buffer is marked as needing to be updated (for example after the 95 // If the buffer is marked as needing to be updated (for example after the
96 // screen mode changes) and is the wrong size, then release the old buffer 96 // screen mode changes) and is the wrong size, then release the old buffer
97 // and create a new one. 97 // and create a new one.
98 void Update() { 98 void Update() {
99 if (needs_update_) { 99 if (needs_update_) {
100 needs_update_ = false; 100 needs_update_ = false;
101 CGDirectDisplayID mainDevice = CGMainDisplayID(); 101 CGDirectDisplayID mainDevice = CGMainDisplayID();
102 int width = CGDisplayPixelsWide(mainDevice); 102 int width = CGDisplayPixelsWide(mainDevice);
103 int height = CGDisplayPixelsHigh(mainDevice); 103 int height = CGDisplayPixelsHigh(mainDevice);
104 if (width != size_.width() || height != size_.height()) { 104 if (width != size_.width() || height != size_.height()) {
105 size_.SetSize(width, height); 105 size_.set(width, height);
106 bytes_per_row_ = width * sizeof(uint32_t); 106 bytes_per_row_ = width * sizeof(uint32_t);
107 size_t buffer_size = width * height * sizeof(uint32_t); 107 size_t buffer_size = width * height * sizeof(uint32_t);
108 ptr_.reset(new uint8[buffer_size]); 108 ptr_.reset(new uint8[buffer_size]);
109 } 109 }
110 } 110 }
111 } 111 }
112 112
113 gfx::Size size() const { return size_; } 113 SkISize size() const { return size_; }
114 int bytes_per_row() const { return bytes_per_row_; } 114 int bytes_per_row() const { return bytes_per_row_; }
115 uint8* ptr() const { return ptr_.get(); } 115 uint8* ptr() const { return ptr_.get(); }
116 116
117 void set_needs_update() { needs_update_ = true; } 117 void set_needs_update() { needs_update_ = true; }
118 118
119 private: 119 private:
120 gfx::Size size_; 120 SkISize size_;
121 int bytes_per_row_; 121 int bytes_per_row_;
122 scoped_array<uint8> ptr_; 122 scoped_array<uint8> ptr_;
123 bool needs_update_; 123 bool needs_update_;
124 124
125 DISALLOW_COPY_AND_ASSIGN(VideoFrameBuffer); 125 DISALLOW_COPY_AND_ASSIGN(VideoFrameBuffer);
126 }; 126 };
127 127
128 // A class to perform capturing for mac. 128 // A class to perform capturing for mac.
129 class CapturerMac : public Capturer { 129 class CapturerMac : public Capturer {
130 public: 130 public:
131 CapturerMac(); 131 CapturerMac();
132 virtual ~CapturerMac(); 132 virtual ~CapturerMac();
133 133
134 bool Init(); 134 bool Init();
135 135
136 // Capturer interface. 136 // Capturer interface.
137 virtual void ScreenConfigurationChanged() OVERRIDE; 137 virtual void ScreenConfigurationChanged() OVERRIDE;
138 virtual media::VideoFrame::Format pixel_format() const OVERRIDE; 138 virtual media::VideoFrame::Format pixel_format() const OVERRIDE;
139 virtual void ClearInvalidRegion() OVERRIDE; 139 virtual void ClearInvalidRegion() OVERRIDE;
140 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE; 140 virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
141 virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; 141 virtual void InvalidateScreen(const SkISize& size) OVERRIDE;
142 virtual void InvalidateFullScreen() OVERRIDE; 142 virtual void InvalidateFullScreen() OVERRIDE;
143 virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback) 143 virtual void CaptureInvalidRegion(CaptureCompletedCallback* callback)
144 OVERRIDE; 144 OVERRIDE;
145 virtual const gfx::Size& size_most_recent() const OVERRIDE; 145 virtual const SkISize& size_most_recent() const OVERRIDE;
146 146
147 private: 147 private:
148 void GlBlitFast(const VideoFrameBuffer& buffer, const SkRegion& region); 148 void GlBlitFast(const VideoFrameBuffer& buffer, const SkRegion& region);
149 void GlBlitSlow(const VideoFrameBuffer& buffer); 149 void GlBlitSlow(const VideoFrameBuffer& buffer);
150 void CgBlit(const VideoFrameBuffer& buffer, const SkRegion& region); 150 void CgBlit(const VideoFrameBuffer& buffer, const SkRegion& region);
151 void CaptureRegion(const SkRegion& region, 151 void CaptureRegion(const SkRegion& region,
152 CaptureCompletedCallback* callback); 152 CaptureCompletedCallback* callback);
153 153
154 void ScreenRefresh(CGRectCount count, const CGRect *rect_array); 154 void ScreenRefresh(CGRectCount count, const CGRect *rect_array);
155 void ScreenUpdateMove(CGScreenUpdateMoveDelta delta, 155 void ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 void CapturerMac::ScreenConfigurationChanged() { 257 void CapturerMac::ScreenConfigurationChanged() {
258 ReleaseBuffers(); 258 ReleaseBuffers();
259 helper_.ClearInvalidRegion(); 259 helper_.ClearInvalidRegion();
260 last_buffer_ = NULL; 260 last_buffer_ = NULL;
261 261
262 CGDirectDisplayID mainDevice = CGMainDisplayID(); 262 CGDirectDisplayID mainDevice = CGMainDisplayID();
263 int width = CGDisplayPixelsWide(mainDevice); 263 int width = CGDisplayPixelsWide(mainDevice);
264 int height = CGDisplayPixelsHigh(mainDevice); 264 int height = CGDisplayPixelsHigh(mainDevice);
265 InvalidateScreen(gfx::Size(width, height)); 265 InvalidateScreen(SkISize::Make(width, height));
266 266
267 if (!CGDisplayUsesOpenGLAcceleration(mainDevice)) { 267 if (!CGDisplayUsesOpenGLAcceleration(mainDevice)) {
268 VLOG(3) << "OpenGL support not available."; 268 VLOG(3) << "OpenGL support not available.";
269 return; 269 return;
270 } 270 }
271 271
272 CGLPixelFormatAttribute attributes[] = { 272 CGLPixelFormatAttribute attributes[] = {
273 kCGLPFAFullScreen, 273 kCGLPFAFullScreen,
274 kCGLPFADisplayMask, 274 kCGLPFADisplayMask,
275 (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(mainDevice), 275 (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(mainDevice),
(...skipping 20 matching lines...) Expand all
296 } 296 }
297 297
298 void CapturerMac::ClearInvalidRegion() { 298 void CapturerMac::ClearInvalidRegion() {
299 helper_.ClearInvalidRegion(); 299 helper_.ClearInvalidRegion();
300 } 300 }
301 301
302 void CapturerMac::InvalidateRegion(const SkRegion& invalid_region) { 302 void CapturerMac::InvalidateRegion(const SkRegion& invalid_region) {
303 helper_.InvalidateRegion(invalid_region); 303 helper_.InvalidateRegion(invalid_region);
304 } 304 }
305 305
306 void CapturerMac::InvalidateScreen(const gfx::Size& size) { 306 void CapturerMac::InvalidateScreen(const SkISize& size) {
307 helper_.InvalidateScreen(size); 307 helper_.InvalidateScreen(size);
308 } 308 }
309 309
310 void CapturerMac::InvalidateFullScreen() { 310 void CapturerMac::InvalidateFullScreen() {
311 helper_.InvalidateFullScreen(); 311 helper_.InvalidateFullScreen();
312 } 312 }
313 313
314 void CapturerMac::CaptureInvalidRegion(CaptureCompletedCallback* callback) { 314 void CapturerMac::CaptureInvalidRegion(CaptureCompletedCallback* callback) {
315 // Only allow captures when the display configuration is not occurring. 315 // Only allow captures when the display configuration is not occurring.
316 scoped_refptr<CaptureData> data; 316 scoped_refptr<CaptureData> data;
(...skipping 22 matching lines...) Expand all
339 339
340 DataPlanes planes; 340 DataPlanes planes;
341 planes.data[0] = current_buffer.ptr(); 341 planes.data[0] = current_buffer.ptr();
342 planes.strides[0] = current_buffer.bytes_per_row(); 342 planes.strides[0] = current_buffer.bytes_per_row();
343 if (flip) { 343 if (flip) {
344 planes.strides[0] = -planes.strides[0]; 344 planes.strides[0] = -planes.strides[0];
345 planes.data[0] += 345 planes.data[0] +=
346 (current_buffer.size().height() - 1) * current_buffer.bytes_per_row(); 346 (current_buffer.size().height() - 1) * current_buffer.bytes_per_row();
347 } 347 }
348 348
349 data = new CaptureData(planes, gfx::Size(current_buffer.size()), 349 data = new CaptureData(planes, current_buffer.size(), pixel_format());
350 pixel_format());
351 data->mutable_dirty_region() = region; 350 data->mutable_dirty_region() = region;
352 351
353 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; 352 current_buffer_ = (current_buffer_ + 1) % kNumBuffers;
354 helper_.set_size_most_recent(data->size()); 353 helper_.set_size_most_recent(data->size());
355 display_configuration_capture_event_.Signal(); 354 display_configuration_capture_event_.Signal();
356 355
357 callback->Run(data); 356 callback->Run(data);
358 delete callback; 357 delete callback;
359 } 358 }
360 359
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 CopyRect(display_base_address, 465 CopyRect(display_base_address,
467 src_bytes_per_row, 466 src_bytes_per_row,
468 buffer.ptr(), 467 buffer.ptr(),
469 buffer.bytes_per_row(), 468 buffer.bytes_per_row(),
470 src_bytes_per_pixel, 469 src_bytes_per_pixel,
471 copy_rect); 470 copy_rect);
472 } 471 }
473 } 472 }
474 } 473 }
475 474
476 const gfx::Size& CapturerMac::size_most_recent() const { 475 const SkISize& CapturerMac::size_most_recent() const {
477 return helper_.size_most_recent(); 476 return helper_.size_most_recent();
478 } 477 }
479 478
480 void CapturerMac::ScreenRefresh(CGRectCount count, const CGRect *rect_array) { 479 void CapturerMac::ScreenRefresh(CGRectCount count, const CGRect *rect_array) {
481 SkIRect skirect_array[count]; 480 SkIRect skirect_array[count];
482 for (CGRectCount i = 0; i < count; ++i) { 481 for (CGRectCount i = 0; i < count; ++i) {
483 skirect_array[i] = gfx::CGRectToSkIRect(rect_array[i]); 482 skirect_array[i] = gfx::CGRectToSkIRect(rect_array[i]);
484 } 483 }
485 SkRegion region; 484 SkRegion region;
486 region.setRects(skirect_array, count); 485 region.setRects(skirect_array, count);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 Capturer* Capturer::Create() { 547 Capturer* Capturer::Create() {
549 CapturerMac* capturer = new CapturerMac(); 548 CapturerMac* capturer = new CapturerMac();
550 if (!capturer->Init()) { 549 if (!capturer->Init()) {
551 delete capturer; 550 delete capturer;
552 capturer = NULL; 551 capturer = NULL;
553 } 552 }
554 return capturer; 553 return capturer;
555 } 554 }
556 555
557 } // namespace remoting 556 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/capturer_linux.cc ('k') | remoting/host/capturer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698