summaryrefslogtreecommitdiffstats
path: root/media/video
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 19:57:36 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 19:57:36 +0000
commit68cf5d990babb0a5ea79c312a21c23bf19989192 (patch)
tree2691101838a9ac1f26d518e2652e4a712fcf99b9 /media/video
parent84a3e66a531e5f059595a3aed1eb513f5b37d59c (diff)
downloadchromium_src-68cf5d990babb0a5ea79c312a21c23bf19989192.zip
chromium_src-68cf5d990babb0a5ea79c312a21c23bf19989192.tar.gz
chromium_src-68cf5d990babb0a5ea79c312a21c23bf19989192.tar.bz2
Simplify ScreenCapturer interface.
Removed Stop() and InvalidateRegion() from ScreenCapturer interface. Review URL: https://codereview.chromium.org/14305004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195887 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r--media/video/capture/screen/screen_capture_device.cc5
-rw-r--r--media/video/capture/screen/screen_capture_device_unittest.cc6
-rw-r--r--media/video/capture/screen/screen_capturer.h21
-rw-r--r--media/video/capture/screen/screen_capturer_fake.cc7
-rw-r--r--media/video/capture/screen/screen_capturer_fake.h2
-rw-r--r--media/video/capture/screen/screen_capturer_mac.mm28
-rw-r--r--media/video/capture/screen/screen_capturer_mac_unittest.cc10
-rw-r--r--media/video/capture/screen/screen_capturer_mock_objects.h2
-rw-r--r--media/video/capture/screen/screen_capturer_unittest.cc3
-rw-r--r--media/video/capture/screen/screen_capturer_win.cc21
-rw-r--r--media/video/capture/screen/screen_capturer_x11.cc9
11 files changed, 18 insertions, 96 deletions
diff --git a/media/video/capture/screen/screen_capture_device.cc b/media/video/capture/screen/screen_capture_device.cc
index b22466a..a4f55bd 100644
--- a/media/video/capture/screen/screen_capture_device.cc
+++ b/media/video/capture/screen/screen_capture_device.cc
@@ -313,10 +313,7 @@ void ScreenCaptureDevice::Core::DoStop() {
void ScreenCaptureDevice::Core::DoDeAllocate() {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
DoStop();
- if (screen_capturer_) {
- screen_capturer_->Stop();
- screen_capturer_.reset();
- }
+ screen_capturer_.reset();
waiting_for_frame_size_ = false;
}
diff --git a/media/video/capture/screen/screen_capture_device_unittest.cc b/media/video/capture/screen/screen_capture_device_unittest.cc
index 4689f4d..6b74465 100644
--- a/media/video/capture/screen/screen_capture_device_unittest.cc
+++ b/media/video/capture/screen/screen_capture_device_unittest.cc
@@ -67,12 +67,6 @@ class FakeScreenCapturer : public ScreenCapturer {
virtual void Start(Delegate* delegate) OVERRIDE {
delegate_ = delegate;
}
- virtual void Stop() OVERRIDE {
- delegate_ = NULL;
- }
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE {
- NOTIMPLEMENTED();
- }
virtual void CaptureFrame() OVERRIDE {
scoped_refptr<ScreenCaptureData> frame =
frames_[frame_index_ % arraysize(frames_)];
diff --git a/media/video/capture/screen/screen_capturer.h b/media/video/capture/screen/screen_capturer.h
index d28b935..bc3d454 100644
--- a/media/video/capture/screen/screen_capturer.h
+++ b/media/video/capture/screen/screen_capturer.h
@@ -11,7 +11,6 @@
#include "base/shared_memory.h"
#include "media/base/media_export.h"
#include "media/video/capture/screen/shared_buffer.h"
-#include "third_party/skia/include/core/SkRegion.h"
namespace media {
@@ -27,25 +26,13 @@ class SharedBuffer;
// This is when pre-capture steps are executed, such as flagging the
// display to prevent it from sleeping during a session.
//
-// (2) InvalidateRegion
-// This is an optional step where regions of the screen are marked as
-// invalid. Some platforms (Windows, for now) won't use this and will
-// instead calculate the diff-regions later (in step (2). Other
-// platforms (Mac) will use this to mark all the changed regions of the
-// screen. Some limited rect-merging (e.g., to eliminate exact
-// duplicates) may be done here.
-//
-// (3) CaptureFrame
+// (2) CaptureFrame
// This is where the bits for the invalid rects are packaged up and sent
// to the encoder.
// A screen capture is performed if needed. For example, Windows requires
// a capture to calculate the diff from the previous screen, whereas the
// Mac version does not.
//
-// (4) Stop
-// This is when post-capture steps are executed, such as releasing the
-// assertion that prevents the display from sleeping.
-//
// Implementation has to ensure the following guarantees:
// 1. Double buffering
// Since data can be read while another capture action is happening.
@@ -96,12 +83,6 @@ class MEDIA_EXPORT ScreenCapturer {
// valid until Stop() is called.
virtual void Start(Delegate* delegate) = 0;
- // Called at the end of a capturing session.
- virtual void Stop() = 0;
-
- // Invalidates the specified region.
- virtual void InvalidateRegion(const SkRegion& invalid_region) = 0;
-
// Captures the screen data associated with each of the accumulated
// dirty region. When the capture is complete, the delegate is notified even
// if the dirty region is empty.
diff --git a/media/video/capture/screen/screen_capturer_fake.cc b/media/video/capture/screen/screen_capturer_fake.cc
index 5db2765..ff4dedb 100644
--- a/media/video/capture/screen/screen_capturer_fake.cc
+++ b/media/video/capture/screen/screen_capturer_fake.cc
@@ -53,13 +53,6 @@ void ScreenCapturerFake::Start(Delegate* delegate) {
}
}
-void ScreenCapturerFake::Stop() {
-}
-
-void ScreenCapturerFake::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
-}
-
void ScreenCapturerFake::CaptureFrame() {
base::Time capture_start_time = base::Time::Now();
diff --git a/media/video/capture/screen/screen_capturer_fake.h b/media/video/capture/screen/screen_capturer_fake.h
index 561c62b..9a8dba9 100644
--- a/media/video/capture/screen/screen_capturer_fake.h
+++ b/media/video/capture/screen/screen_capturer_fake.h
@@ -26,8 +26,6 @@ class MEDIA_EXPORT ScreenCapturerFake : public ScreenCapturer {
// Overridden from ScreenCapturer:
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
diff --git a/media/video/capture/screen/screen_capturer_mac.mm b/media/video/capture/screen/screen_capturer_mac.mm
index 0e4f88d..8248e15 100644
--- a/media/video/capture/screen/screen_capturer_mac.mm
+++ b/media/video/capture/screen/screen_capturer_mac.mm
@@ -120,8 +120,6 @@ class ScreenCapturerMac : public ScreenCapturer {
// Overridden from ScreenCapturer:
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
@@ -235,6 +233,15 @@ ScreenCapturerMac::ScreenCapturerMac()
}
ScreenCapturerMac::~ScreenCapturerMac() {
+ if (power_assertion_id_display_ != kIOPMNullAssertionID) {
+ IOPMAssertionRelease(power_assertion_id_display_);
+ power_assertion_id_display_ = kIOPMNullAssertionID;
+ }
+ if (power_assertion_id_user_ != kIOPMNullAssertionID) {
+ IOPMAssertionRelease(power_assertion_id_user_);
+ power_assertion_id_user_ = kIOPMNullAssertionID;
+ }
+
ReleaseBuffers();
UnregisterRefreshAndMoveHandlers();
CGError err = CGDisplayRemoveReconfigurationCallback(
@@ -293,21 +300,6 @@ void ScreenCapturerMac::Start(Delegate* delegate) {
&power_assertion_id_user_);
}
-void ScreenCapturerMac::Stop() {
- if (power_assertion_id_display_ != kIOPMNullAssertionID) {
- IOPMAssertionRelease(power_assertion_id_display_);
- power_assertion_id_display_ = kIOPMNullAssertionID;
- }
- if (power_assertion_id_user_ != kIOPMNullAssertionID) {
- IOPMAssertionRelease(power_assertion_id_user_);
- power_assertion_id_user_ = kIOPMNullAssertionID;
- }
-}
-
-void ScreenCapturerMac::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
-}
-
void ScreenCapturerMac::CaptureFrame() {
// Only allow captures when the display configuration is not occurring.
scoped_refptr<ScreenCaptureData> data;
@@ -795,7 +787,7 @@ void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
SkRegion region;
region.setRects(skirect_array, count);
- InvalidateRegion(region);
+ helper_.InvalidateRegion(region);
}
void ScreenCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
diff --git a/media/video/capture/screen/screen_capturer_mac_unittest.cc b/media/video/capture/screen/screen_capturer_mac_unittest.cc
index e7c7730..b8fb5d9 100644
--- a/media/video/capture/screen/screen_capturer_mac_unittest.cc
+++ b/media/video/capture/screen/screen_capturer_mac_unittest.cc
@@ -36,14 +36,8 @@ class ScreenCapturerMacTest : public testing::Test {
capturer_ = ScreenCapturer::Create();
}
- void AddDirtyRect() {
- SkIRect rect = SkIRect::MakeXYWH(0, 0, 10, 10);
- region_.op(rect, SkRegion::kUnion_Op);
- }
-
scoped_ptr<ScreenCapturer> capturer_;
MockScreenCapturerDelegate delegate_;
- SkRegion region_;
};
void ScreenCapturerMacTest::CaptureDoneCallback1(
@@ -64,7 +58,6 @@ void ScreenCapturerMacTest::CaptureDoneCallback2(
int width = config.pixel_bounds.width();
int height = config.pixel_bounds.height();
- EXPECT_EQ(region_, capture_data->dirty_region());
EXPECT_EQ(width, capture_data->size().width());
EXPECT_EQ(height, capture_data->size().height());
EXPECT_TRUE(capture_data->data() != NULL);
@@ -93,10 +86,7 @@ TEST_F(ScreenCapturerMacTest, Capture) {
capturer_->CaptureFrame();
// Check that subsequent dirty rects are propagated correctly.
- AddDirtyRect();
- capturer_->InvalidateRegion(region_);
capturer_->CaptureFrame();
- capturer_->Stop();
}
} // namespace media
diff --git a/media/video/capture/screen/screen_capturer_mock_objects.h b/media/video/capture/screen/screen_capturer_mock_objects.h
index 4bf9890..907fa12 100644
--- a/media/video/capture/screen/screen_capturer_mock_objects.h
+++ b/media/video/capture/screen/screen_capturer_mock_objects.h
@@ -18,8 +18,6 @@ class MockScreenCapturer : public ScreenCapturer {
virtual ~MockScreenCapturer();
MOCK_METHOD1(Start, void(Delegate* delegate));
- MOCK_METHOD0(Stop, void());
- MOCK_METHOD1(InvalidateRegion, void(const SkRegion& invalid_region));
MOCK_METHOD0(CaptureFrame, void());
private:
diff --git a/media/video/capture/screen/screen_capturer_unittest.cc b/media/video/capture/screen/screen_capturer_unittest.cc
index 7d9ab95..4ed45d9 100644
--- a/media/video/capture/screen/screen_capturer_unittest.cc
+++ b/media/video/capture/screen/screen_capturer_unittest.cc
@@ -45,7 +45,6 @@ scoped_refptr<SharedBuffer> ScreenCapturerTest::CreateSharedBuffer(
TEST_F(ScreenCapturerTest, StartCapturer) {
capturer_ = ScreenCapturer::Create();
capturer_->Start(&delegate_);
- capturer_->Stop();
}
TEST_F(ScreenCapturerTest, Capture) {
@@ -62,7 +61,6 @@ TEST_F(ScreenCapturerTest, Capture) {
capturer_ = ScreenCapturer::Create();
capturer_->Start(&delegate_);
capturer_->CaptureFrame();
- capturer_->Stop();
}
#if defined(OS_WIN)
@@ -82,7 +80,6 @@ TEST_F(ScreenCapturerTest, UseSharedBuffers) {
capturer_ = ScreenCapturer::Create();
capturer_->Start(&delegate_);
capturer_->CaptureFrame();
- capturer_->Stop();
capturer_.reset();
}
diff --git a/media/video/capture/screen/screen_capturer_win.cc b/media/video/capture/screen/screen_capturer_win.cc
index 41257e9..ff148b1 100644
--- a/media/video/capture/screen/screen_capturer_win.cc
+++ b/media/video/capture/screen/screen_capturer_win.cc
@@ -80,8 +80,6 @@ class ScreenCapturerWin : public ScreenCapturer {
// Overridden from ScreenCapturer:
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
@@ -224,10 +222,12 @@ ScreenCapturerWin::ScreenCapturerWin(bool disable_aero)
}
ScreenCapturerWin::~ScreenCapturerWin() {
-}
+ // Restore Aero.
+ if (composition_func_ != NULL) {
+ (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
+ }
-void ScreenCapturerWin::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
+ delegate_ = NULL;
}
void ScreenCapturerWin::CaptureFrame() {
@@ -267,7 +267,7 @@ void ScreenCapturerWin::CaptureFrame() {
SkRegion region;
differ_->CalcDirtyRegion(last_buffer->pixels(), current_buffer->pixels(),
&region);
- InvalidateRegion(region);
+ helper_.InvalidateRegion(region);
} else {
// No previous frame is available. Invalidate the whole screen.
helper_.InvalidateScreen(current_buffer->dimensions());
@@ -296,15 +296,6 @@ void ScreenCapturerWin::Start(Delegate* delegate) {
}
}
-void ScreenCapturerWin::Stop() {
- // Restore Aero.
- if (composition_func_ != NULL) {
- (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
- }
-
- delegate_ = NULL;
-}
-
void ScreenCapturerWin::PrepareCaptureResources() {
// Switch to the desktop receiving user input if different from the current
// one.
diff --git a/media/video/capture/screen/screen_capturer_x11.cc b/media/video/capture/screen/screen_capturer_x11.cc
index b4bfaeb..f9da3b3 100644
--- a/media/video/capture/screen/screen_capturer_x11.cc
+++ b/media/video/capture/screen/screen_capturer_x11.cc
@@ -52,8 +52,6 @@ class ScreenCapturerLinux : public ScreenCapturer {
// Capturer interface.
virtual void Start(Delegate* delegate) OVERRIDE;
- virtual void Stop() OVERRIDE;
- virtual void InvalidateRegion(const SkRegion& invalid_region) OVERRIDE;
virtual void CaptureFrame() OVERRIDE;
private:
@@ -278,13 +276,6 @@ void ScreenCapturerLinux::Start(Delegate* delegate) {
delegate_ = delegate;
}
-void ScreenCapturerLinux::Stop() {
-}
-
-void ScreenCapturerLinux::InvalidateRegion(const SkRegion& invalid_region) {
- helper_.InvalidateRegion(invalid_region);
-}
-
void ScreenCapturerLinux::CaptureFrame() {
base::Time capture_start_time = base::Time::Now();