diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-25 00:16:32 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-25 00:16:32 +0000 |
commit | a4486873d6110b49680b6dede99633995221cacf (patch) | |
tree | 88c61ca9dd06074d4a73422bce73e0525cfb8b4e /remoting | |
parent | 7924b4592fcf32e47994586774434122b14a250c (diff) | |
download | chromium_src-a4486873d6110b49680b6dede99633995221cacf.zip chromium_src-a4486873d6110b49680b6dede99633995221cacf.tar.gz chromium_src-a4486873d6110b49680b6dede99633995221cacf.tar.bz2 |
Move ScopedPixelBuffer out of VideoFrameCapturer implementation for Mac.
TEST=Existing unit-tests and manual tests.
Review URL: https://chromiumcodereview.appspot.com/10868083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/mac/scoped_pixel_buffer_object.cc | 47 | ||||
-rw-r--r-- | remoting/host/mac/scoped_pixel_buffer_object.h | 33 | ||||
-rw-r--r-- | remoting/host/video_frame_capturer_mac.mm | 60 | ||||
-rw-r--r-- | remoting/remoting.gyp | 2 |
4 files changed, 85 insertions, 57 deletions
diff --git a/remoting/host/mac/scoped_pixel_buffer_object.cc b/remoting/host/mac/scoped_pixel_buffer_object.cc new file mode 100644 index 0000000..7ca2c27 --- /dev/null +++ b/remoting/host/mac/scoped_pixel_buffer_object.cc @@ -0,0 +1,47 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "remoting/host/mac/scoped_pixel_buffer_object.h" + +namespace remoting { + +ScopedPixelBufferObject::ScopedPixelBufferObject() + : cgl_context_(NULL), + pixel_buffer_object_(0) { +} + +ScopedPixelBufferObject::~ScopedPixelBufferObject() { + Release(); +} + +bool ScopedPixelBufferObject::Init(CGLContextObj cgl_context, + int size_in_bytes) { + cgl_context_ = cgl_context; + CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; + glGenBuffersARB(1, &pixel_buffer_object_); + if (glGetError() == GL_NO_ERROR) { + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pixel_buffer_object_); + glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, size_in_bytes, NULL, + GL_STREAM_READ_ARB); + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); + if (glGetError() != GL_NO_ERROR) { + Release(); + } + } else { + cgl_context_ = NULL; + pixel_buffer_object_ = 0; + } + return pixel_buffer_object_ != 0; +} + +void ScopedPixelBufferObject::Release() { + if (pixel_buffer_object_) { + CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; + glDeleteBuffersARB(1, &pixel_buffer_object_); + cgl_context_ = NULL; + pixel_buffer_object_ = 0; + } +} + +} // namespace remoting diff --git a/remoting/host/mac/scoped_pixel_buffer_object.h b/remoting/host/mac/scoped_pixel_buffer_object.h new file mode 100644 index 0000000..45ecfc1 --- /dev/null +++ b/remoting/host/mac/scoped_pixel_buffer_object.h @@ -0,0 +1,33 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef REMOTING_HOST_SCOPED_PIXEL_BUFFER_OBJECT_H_ +#define REMOTING_HOST_SCOPED_PIXEL_BUFFER_OBJECT_H_ + +#include <OpenGL/CGLMacro.h> +#include <OpenGL/OpenGL.h> +#include "base/basictypes.h" + +namespace remoting { + +class ScopedPixelBufferObject { + public: + ScopedPixelBufferObject(); + ~ScopedPixelBufferObject(); + + bool Init(CGLContextObj cgl_context, int size_in_bytes); + void Release(); + + GLuint get() const { return pixel_buffer_object_; } + + private: + CGLContextObj cgl_context_; + GLuint pixel_buffer_object_; + + DISALLOW_COPY_AND_ASSIGN(ScopedPixelBufferObject); +}; + +} // namespace remoting + +#endif // REMOTING_HOST_SCOPED_PIXEL_BUFFER_OBJECT_H_ diff --git a/remoting/host/video_frame_capturer_mac.mm b/remoting/host/video_frame_capturer_mac.mm index fce6612..8fec9bd 100644 --- a/remoting/host/video_frame_capturer_mac.mm +++ b/remoting/host/video_frame_capturer_mac.mm @@ -20,6 +20,7 @@ #include "base/time.h" #include "remoting/base/capture_data.h" #include "remoting/base/util.h" +#include "remoting/host/mac/scoped_pixel_buffer_object.h" #include "remoting/host/video_frame_capturer_helper.h" #include "remoting/proto/control.pb.h" @@ -40,61 +41,6 @@ SkIRect CGRectToSkIRect(const CGRect& rect) { // The amount of time allowed for displays to reconfigure. const int64 kDisplayReconfigurationTimeoutInSeconds = 10; -class scoped_pixel_buffer_object { - public: - scoped_pixel_buffer_object(); - ~scoped_pixel_buffer_object(); - - bool Init(CGLContextObj cgl_context, int size_in_bytes); - void Release(); - - GLuint get() const { return pixel_buffer_object_; } - - private: - CGLContextObj cgl_context_; - GLuint pixel_buffer_object_; - - DISALLOW_COPY_AND_ASSIGN(scoped_pixel_buffer_object); -}; - -scoped_pixel_buffer_object::scoped_pixel_buffer_object() - : cgl_context_(NULL), - pixel_buffer_object_(0) { -} - -scoped_pixel_buffer_object::~scoped_pixel_buffer_object() { - Release(); -} - -bool scoped_pixel_buffer_object::Init(CGLContextObj cgl_context, - int size_in_bytes) { - cgl_context_ = cgl_context; - CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; - glGenBuffersARB(1, &pixel_buffer_object_); - if (glGetError() == GL_NO_ERROR) { - glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pixel_buffer_object_); - glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, size_in_bytes, NULL, - GL_STREAM_READ_ARB); - glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); - if (glGetError() != GL_NO_ERROR) { - Release(); - } - } else { - cgl_context_ = NULL; - pixel_buffer_object_ = 0; - } - return pixel_buffer_object_ != 0; -} - -void scoped_pixel_buffer_object::Release() { - if (pixel_buffer_object_) { - CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; - glDeleteBuffersARB(1, &pixel_buffer_object_); - cgl_context_ = NULL; - pixel_buffer_object_ = 0; - } -} - // A class representing a full-frame pixel buffer. class VideoFrameBuffer { public: @@ -195,7 +141,7 @@ class VideoFrameCapturerMac : public VideoFrameCapturer { CGLContextObj cgl_context_; static const int kNumBuffers = 2; - scoped_pixel_buffer_object pixel_buffer_object_; + ScopedPixelBufferObject pixel_buffer_object_; VideoFrameBuffer buffers_[kNumBuffers]; // A thread-safe list of invalid rectangles, and the size of the most @@ -357,7 +303,7 @@ void VideoFrameCapturerMac::CaptureInvalidRegion( if (pixel_buffer_object_.get() != 0) { GlBlitFast(current_buffer, region); } else { - // See comment in scoped_pixel_buffer_object::Init about why the slow + // See comment in ScopedPixelBufferObject::Init about why the slow // path is always used on 10.5. GlBlitSlow(current_buffer); } diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index bce8633..6aee34a 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -1262,6 +1262,8 @@ 'host/local_input_monitor_win.cc', 'host/log_to_server.cc', 'host/log_to_server.h', + 'host/mac/scoped_pixel_buffer_object.cc', + 'host/mac/scoped_pixel_buffer_object.h', 'host/mouse_clamping_filter.cc', 'host/mouse_clamping_filter.h', 'host/mouse_move_observer.h', |