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

Side by Side Diff: media/video/capture/screen/screen_capturer_helper.h

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: q Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_ 5 #ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_
6 #define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_ 6 #define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
11 #include "third_party/skia/include/core/SkRegion.h" 11 #include "third_party/skia/include/core/SkRegion.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
13 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
12 14
13 namespace media { 15 namespace media {
14 16
15 // ScreenCapturerHelper is intended to be used by an implementation of the 17 // ScreenCapturerHelper is intended to be used by an implementation of the
16 // ScreenCapturer interface. It maintains a thread-safe invalid region, and 18 // ScreenCapturer interface. It maintains a thread-safe invalid region, and
17 // the size of the most recently captured screen, on behalf of the 19 // the size of the most recently captured screen, on behalf of the
18 // ScreenCapturer that owns it. 20 // ScreenCapturer that owns it.
19 class MEDIA_EXPORT ScreenCapturerHelper { 21 class MEDIA_EXPORT ScreenCapturerHelper {
20 public: 22 public:
21 ScreenCapturerHelper(); 23 ScreenCapturerHelper();
22 ~ScreenCapturerHelper(); 24 ~ScreenCapturerHelper();
23 25
24 // Clear out the invalid region. 26 // Clear out the invalid region.
25 void ClearInvalidRegion(); 27 void ClearInvalidRegion();
26 28
27 // Invalidate the specified region. 29 // Invalidate the specified region.
28 void InvalidateRegion(const SkRegion& invalid_region); 30 void InvalidateRegion(const webrtc::DesktopRegion& invalid_region);
29 31
30 // Invalidate the entire screen, of a given size. 32 // Invalidate the entire screen, of a given size.
31 void InvalidateScreen(const SkISize& size); 33 void InvalidateScreen(const webrtc::DesktopSize& size);
32 34
33 // Invalidate the entire screen, using the size of the most recently 35 // Invalidate the entire screen, using the size of the most recently
34 // captured screen. 36 // captured screen.
35 void InvalidateFullScreen(); 37 void InvalidateFullScreen();
36 38
37 // Swap the given region with the stored invalid region. 39 // Swap the given region with the stored invalid region.
38 void SwapInvalidRegion(SkRegion* invalid_region); 40 void SwapInvalidRegion(webrtc::DesktopRegion* invalid_region);
39 41
40 // Access the size of the most recently captured screen. 42 // Access the size of the most recently captured screen.
41 const SkISize& size_most_recent() const; 43 const webrtc::DesktopSize& size_most_recent() const;
42 void set_size_most_recent(const SkISize& size); 44 void set_size_most_recent(const webrtc::DesktopSize& size);
43 45
44 // Lossy compression can result in color values leaking between pixels in one 46 // Lossy compression can result in color values leaking between pixels in one
45 // block. If part of a block changes, then unchanged parts of that block can 47 // block. If part of a block changes, then unchanged parts of that block can
46 // be changed in the compressed output. So we need to re-render an entire 48 // be changed in the compressed output. So we need to re-render an entire
47 // block whenever part of the block changes. 49 // block whenever part of the block changes.
48 // 50 //
49 // If |log_grid_size| is >= 1, then this function makes SwapInvalidRegion 51 // If |log_grid_size| is >= 1, then this function makes SwapInvalidRegion
50 // produce an invalid region expanded so that its vertices lie on a grid of 52 // produce an invalid region expanded so that its vertices lie on a grid of
51 // size 2 ^ |log_grid_size|. The expanded region is then clipped to the size 53 // size 2 ^ |log_grid_size|. The expanded region is then clipped to the size
52 // of the most recently captured screen, as previously set by 54 // of the most recently captured screen, as previously set by
53 // set_size_most_recent(). 55 // set_size_most_recent().
54 // If |log_grid_size| is <= 0, then the invalid region is not expanded. 56 // If |log_grid_size| is <= 0, then the invalid region is not expanded.
55 void SetLogGridSize(int log_grid_size); 57 void SetLogGridSize(int log_grid_size);
56 58
57 // Expands a region so that its vertices all lie on a grid. 59 // Expands a region so that its vertices all lie on a grid.
58 // The grid size must be >= 2, so |log_grid_size| must be >= 1. 60 // The grid size must be >= 2, so |log_grid_size| must be >= 1.
59 static scoped_ptr<SkRegion> ExpandToGrid(const SkRegion& region, 61 static scoped_ptr<SkRegion> ExpandToGrid(const SkRegion& region,
60 int log_grid_size); 62 int log_grid_size);
61 63
62 private: 64 private:
63 // A region that has been manually invalidated (through InvalidateRegion). 65 // A region that has been manually invalidated (through InvalidateRegion).
64 // These will be returned as dirty_region in the capture data during the next 66 // These will be returned as dirty_region in the capture data during the next
65 // capture. 67 // capture.
66 SkRegion invalid_region_; 68 SkRegion invalid_region_;
67 69
68 // A lock protecting |invalid_region_| across threads. 70 // A lock protecting |invalid_region_| across threads.
69 base::Lock invalid_region_lock_; 71 base::Lock invalid_region_lock_;
70 72
71 // The size of the most recently captured screen. 73 // The size of the most recently captured screen.
72 SkISize size_most_recent_; 74 webrtc::DesktopSize size_most_recent_;
73 75
74 // The log (base 2) of the size of the grid to which the invalid region is 76 // The log (base 2) of the size of the grid to which the invalid region is
75 // expanded. 77 // expanded.
76 // If the value is <= 0, then the invalid region is not expanded to a grid. 78 // If the value is <= 0, then the invalid region is not expanded to a grid.
77 int log_grid_size_; 79 int log_grid_size_;
78 80
79 DISALLOW_COPY_AND_ASSIGN(ScreenCapturerHelper); 81 DISALLOW_COPY_AND_ASSIGN(ScreenCapturerHelper);
80 }; 82 };
81 83
82 } // namespace media 84 } // namespace media
83 85
84 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_ 86 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698