diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 22:44:11 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 22:44:11 +0000 |
commit | 0b7e42805341699a240997b202d4d23aed4b458b (patch) | |
tree | 44b31edf61ace0f552a113dd56368768d9774598 /remoting/host/capturer_linux.cc | |
parent | 167d52bbfbfc80f2232474eddfeb8bc587008d71 (diff) | |
download | chromium_src-0b7e42805341699a240997b202d4d23aed4b458b.zip chromium_src-0b7e42805341699a240997b202d4d23aed4b458b.tar.gz chromium_src-0b7e42805341699a240997b202d4d23aed4b458b.tar.bz2 |
Clean up remoting project
Cleaned up some file names so it simplifies our project, and gets us more inline with chromium standards.
Removed several unnecessary headers that were cluttering the remoting namespace.
Simplified some of the double pimpl implementations that we had on Linux to hide X11 stuff.
Got HostAuthentication working reasonably well as a mock.
BUG=NONE
TEST=BUILD
Review URL: http://codereview.chromium.org/6780014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/capturer_linux.cc')
-rw-r--r-- | remoting/host/capturer_linux.cc | 110 |
1 files changed, 38 insertions, 72 deletions
diff --git a/remoting/host/capturer_linux.cc b/remoting/host/capturer_linux.cc index 71de8fd..6aaff4e 100644 --- a/remoting/host/capturer_linux.cc +++ b/remoting/host/capturer_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/host/capturer_linux.h" +#include "remoting/host/capturer.h" #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -10,33 +10,36 @@ #include <set> +#include "base/basictypes.h" #include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "remoting/base/types.h" #include "remoting/host/capturer_helper.h" #include "remoting/host/x_server_pixel_buffer.h" namespace remoting { -// Private Implementation pattern to avoid leaking the X11 types into the header -// file. -class CapturerLinuxPimpl : public Capturer { +namespace { + +// A class to perform capturing for Linux. +class CapturerLinux : public Capturer { public: - CapturerLinuxPimpl(); - virtual ~CapturerLinuxPimpl(); + CapturerLinux(); + virtual ~CapturerLinux(); - bool Init(); // TODO(ajwong): Do we really want this to be synchronous? // Capturer interface. - virtual void ScreenConfigurationChanged(); - virtual media::VideoFrame::Format pixel_format() const; - virtual void ClearInvalidRects(); - virtual void InvalidateRects(const InvalidRects& inval_rects); - virtual void InvalidateScreen(const gfx::Size& size); - virtual void InvalidateFullScreen(); - virtual void CaptureInvalidRects(CaptureCompletedCallback* callback); - virtual const gfx::Size& size_most_recent() const; + virtual void ScreenConfigurationChanged() OVERRIDE; + virtual media::VideoFrame::Format pixel_format() const OVERRIDE; + virtual void ClearInvalidRects() OVERRIDE; + virtual void InvalidateRects(const InvalidRects& inval_rects) OVERRIDE; + virtual void InvalidateScreen(const gfx::Size& size) OVERRIDE; + virtual void InvalidateFullScreen() OVERRIDE; + virtual void CaptureInvalidRects(CaptureCompletedCallback* callback) OVERRIDE; + virtual const gfx::Size& size_most_recent() const OVERRIDE; private: + bool Init(); // TODO(ajwong): Do we really want this to be synchronous? void CalculateInvalidRects(); void CaptureRects(const InvalidRects& rects, Capturer::CaptureCompletedCallback* callback); @@ -84,51 +87,11 @@ class CapturerLinuxPimpl : public Capturer { // Last capture buffer used. uint8* last_buffer_; + + DISALLOW_COPY_AND_ASSIGN(CapturerLinux); }; CapturerLinux::CapturerLinux() - : pimpl_(new CapturerLinuxPimpl()) { - // TODO(ajwong): This should be moved into an Init() method on Capturer - // itself. Then we can remove the CHECK. - CHECK(pimpl_->Init()); -} - -CapturerLinux::~CapturerLinux() { -} - -void CapturerLinux::ScreenConfigurationChanged() { - pimpl_->ScreenConfigurationChanged(); -} - -media::VideoFrame::Format CapturerLinux::pixel_format() const { - return pimpl_->pixel_format(); -} - -void CapturerLinux::ClearInvalidRects() { - pimpl_->ClearInvalidRects(); -} - -void CapturerLinux::InvalidateRects(const InvalidRects& inval_rects) { - pimpl_->InvalidateRects(inval_rects); -} - -void CapturerLinux::InvalidateScreen(const gfx::Size& size) { - pimpl_->InvalidateScreen(size); -} - -void CapturerLinux::InvalidateFullScreen() { - pimpl_->InvalidateFullScreen(); -} - -void CapturerLinux::CaptureInvalidRects(CaptureCompletedCallback* callback) { - pimpl_->CaptureInvalidRects(callback); -} - -const gfx::Size& CapturerLinux::size_most_recent() const { - return pimpl_->size_most_recent(); -} - -CapturerLinuxPimpl::CapturerLinuxPimpl() : display_(NULL), gc_(NULL), root_window_(BadValue), @@ -145,9 +108,10 @@ CapturerLinuxPimpl::CapturerLinuxPimpl() for (int i = 0; i < kNumBuffers; i++) { buffers_[i] = NULL; } + CHECK(Init()); } -CapturerLinuxPimpl::~CapturerLinuxPimpl() { +CapturerLinux::~CapturerLinux() { DeinitXlib(); for (int i = 0; i < kNumBuffers; i++) { @@ -156,7 +120,7 @@ CapturerLinuxPimpl::~CapturerLinuxPimpl() { } } -bool CapturerLinuxPimpl::Init() { +bool CapturerLinux::Init() { // TODO(ajwong): We should specify the display string we are attaching to // in the constructor. display_ = XOpenDisplay(NULL); @@ -216,32 +180,32 @@ bool CapturerLinuxPimpl::Init() { return true; } -void CapturerLinuxPimpl::ScreenConfigurationChanged() { +void CapturerLinux::ScreenConfigurationChanged() { // TODO(ajwong): Support resolution changes. NOTIMPLEMENTED(); } -media::VideoFrame::Format CapturerLinuxPimpl::pixel_format() const { +media::VideoFrame::Format CapturerLinux::pixel_format() const { return pixel_format_; } -void CapturerLinuxPimpl::ClearInvalidRects() { +void CapturerLinux::ClearInvalidRects() { helper_.ClearInvalidRects(); } -void CapturerLinuxPimpl::InvalidateRects(const InvalidRects& inval_rects) { +void CapturerLinux::InvalidateRects(const InvalidRects& inval_rects) { helper_.InvalidateRects(inval_rects); } -void CapturerLinuxPimpl::InvalidateScreen(const gfx::Size& size) { +void CapturerLinux::InvalidateScreen(const gfx::Size& size) { helper_.InvalidateScreen(size); } -void CapturerLinuxPimpl::InvalidateFullScreen() { +void CapturerLinux::InvalidateFullScreen() { helper_.InvalidateFullScreen(); } -void CapturerLinuxPimpl::CaptureInvalidRects( +void CapturerLinux::CaptureInvalidRects( CaptureCompletedCallback* callback) { CalculateInvalidRects(); @@ -251,7 +215,7 @@ void CapturerLinuxPimpl::CaptureInvalidRects( CaptureRects(rects, callback); } -void CapturerLinuxPimpl::CalculateInvalidRects() { +void CapturerLinux::CalculateInvalidRects() { if (helper_.IsCaptureFullScreen(gfx::Size(width_, height_))) capture_fullscreen_ = true; @@ -294,7 +258,7 @@ void CapturerLinuxPimpl::CalculateInvalidRects() { } } -void CapturerLinuxPimpl::CaptureRects( +void CapturerLinux::CaptureRects( const InvalidRects& rects, Capturer::CaptureCompletedCallback* callback) { scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); @@ -354,7 +318,7 @@ void CapturerLinuxPimpl::CaptureRects( callback->Run(capture_data); } -void CapturerLinuxPimpl::DeinitXlib() { +void CapturerLinux::DeinitXlib() { if (gc_) { XFreeGC(display_, gc_); gc_ = NULL; @@ -366,7 +330,7 @@ void CapturerLinuxPimpl::DeinitXlib() { } } -void CapturerLinuxPimpl::FastBlit(uint8* image, const gfx::Rect& rect, +void CapturerLinux::FastBlit(uint8* image, const gfx::Rect& rect, CaptureData* capture_data) { uint8* src_pos = image; int src_stride = x_server_pixel_buffer_.GetStride(); @@ -388,7 +352,7 @@ void CapturerLinuxPimpl::FastBlit(uint8* image, const gfx::Rect& rect, } } -void CapturerLinuxPimpl::SlowBlit(uint8* image, const gfx::Rect& rect, +void CapturerLinux::SlowBlit(uint8* image, const gfx::Rect& rect, CaptureData* capture_data) { DataPlanes planes = capture_data->data_planes(); uint8* dst_buffer = planes.data[0]; @@ -439,10 +403,12 @@ void CapturerLinuxPimpl::SlowBlit(uint8* image, const gfx::Rect& rect, } } -const gfx::Size& CapturerLinuxPimpl::size_most_recent() const { +const gfx::Size& CapturerLinux::size_most_recent() const { return helper_.size_most_recent(); } +} // namespace + // static Capturer* Capturer::Create() { return new CapturerLinux(); |