| 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 "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 |
| 11 #include <stddef.h> | 11 #include <stddef.h> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/mac/mac_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "remoting/host/capturer_helper.h" | 16 #include "remoting/host/capturer_helper.h" |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class scoped_pixel_buffer_object { | 22 class scoped_pixel_buffer_object { |
| 22 public: | 23 public: |
| 23 scoped_pixel_buffer_object(); | 24 scoped_pixel_buffer_object(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 39 : cgl_context_(NULL), | 40 : cgl_context_(NULL), |
| 40 pixel_buffer_object_(0) { | 41 pixel_buffer_object_(0) { |
| 41 } | 42 } |
| 42 | 43 |
| 43 scoped_pixel_buffer_object::~scoped_pixel_buffer_object() { | 44 scoped_pixel_buffer_object::~scoped_pixel_buffer_object() { |
| 44 Release(); | 45 Release(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 bool scoped_pixel_buffer_object::Init(CGLContextObj cgl_context, | 48 bool scoped_pixel_buffer_object::Init(CGLContextObj cgl_context, |
| 48 int size_in_bytes) { | 49 int size_in_bytes) { |
| 50 // The PBO path is only done on 10.6 (SnowLeopard) and above due to |
| 51 // a driver issue that was found on 10.5 |
| 52 // (specifically on a NVIDIA GeForce 7300 GT). |
| 53 // http://crbug.com/87283 |
| 54 if (base::mac::IsOSLeopardOrEarlier()) { |
| 55 return false; |
| 56 } |
| 49 cgl_context_ = cgl_context; | 57 cgl_context_ = cgl_context; |
| 50 CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; | 58 CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; |
| 51 glGenBuffersARB(1, &pixel_buffer_object_); | 59 glGenBuffersARB(1, &pixel_buffer_object_); |
| 52 if (glGetError() == GL_NO_ERROR) { | 60 if (glGetError() == GL_NO_ERROR) { |
| 53 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pixel_buffer_object_); | 61 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pixel_buffer_object_); |
| 54 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, size_in_bytes, NULL, | 62 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, size_in_bytes, NULL, |
| 55 GL_STREAM_READ_ARB); | 63 GL_STREAM_READ_ARB); |
| 56 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); | 64 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); |
| 57 if (glGetError() != GL_NO_ERROR) { | 65 if (glGetError() != GL_NO_ERROR) { |
| 58 Release(); | 66 Release(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 InvalidRects rects; | 298 InvalidRects rects; |
| 291 helper_.SwapInvalidRects(rects); | 299 helper_.SwapInvalidRects(rects); |
| 292 VideoFrameBuffer& current_buffer = buffers_[current_buffer_]; | 300 VideoFrameBuffer& current_buffer = buffers_[current_buffer_]; |
| 293 current_buffer.Update(); | 301 current_buffer.Update(); |
| 294 | 302 |
| 295 bool flip = true; // GL capturers need flipping. | 303 bool flip = true; // GL capturers need flipping. |
| 296 if (cgl_context_) { | 304 if (cgl_context_) { |
| 297 if (pixel_buffer_object_.get() != 0) { | 305 if (pixel_buffer_object_.get() != 0) { |
| 298 GlBlitFast(current_buffer); | 306 GlBlitFast(current_buffer); |
| 299 } else { | 307 } else { |
| 308 // See comment in scoped_pixel_buffer_object::Init about why the slow |
| 309 // path is always used on 10.5. |
| 300 GlBlitSlow(current_buffer); | 310 GlBlitSlow(current_buffer); |
| 301 } | 311 } |
| 302 } else { | 312 } else { |
| 303 CgBlit(current_buffer, rects); | 313 CgBlit(current_buffer, rects); |
| 304 flip = false; | 314 flip = false; |
| 305 } | 315 } |
| 306 | 316 |
| 307 DataPlanes planes; | 317 DataPlanes planes; |
| 308 planes.data[0] = current_buffer.ptr(); | 318 planes.data[0] = current_buffer.ptr(); |
| 309 planes.strides[0] = current_buffer.bytes_per_row(); | 319 planes.strides[0] = current_buffer.bytes_per_row(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 454 } |
| 445 | 455 |
| 446 } // namespace | 456 } // namespace |
| 447 | 457 |
| 448 // static | 458 // static |
| 449 Capturer* Capturer::Create() { | 459 Capturer* Capturer::Create() { |
| 450 return new CapturerMac(); | 460 return new CapturerMac(); |
| 451 } | 461 } |
| 452 | 462 |
| 453 } // namespace remoting | 463 } // namespace remoting |
| OLD | NEW |