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

Side by Side Diff: content/browser/aura/browser_compositor_output_surface_capturer.h

Issue 22935009: Add content::SurfaceCapturer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screencast_stride
Patch Set: cff149b4 WIP Created 7 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <list>
6
7 #include "base/id_map.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/common/gpu/surface_capturer.h"
11 #include "ui/gfx/size.h"
12
13 namespace base {
14
15 class MessageLoopProxy;
16
17 } // namespace base
18
19 namespace content {
20
21 class BrowserCompositorOutputSurface;
22
23 // This class implements the SurfaceCapturer interface for capturing from a
24 // BrowserCompositorOutputSurface. It essentially proxies the SurfaceCapturer
25 // between the compositor's impl thread (which BrowserCompositorOutputSurface
26 // runs on) and the compositor's own main thread (presently the UI thread).
27 class BrowserCompositorOutputSurfaceCapturer : public SurfaceCapturer,
28 public SurfaceCapturer::Client {
29 public:
30 BrowserCompositorOutputSurfaceCapturer(
31 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
32 int output_surface_id,
33 SurfaceCapturer::Client* client);
34 virtual ~BrowserCompositorOutputSurfaceCapturer();
35
36 // SurfaceCapturer implementation.
37 virtual void Initialize(media::VideoFrame::Format format) OVERRIDE;
38 virtual void Capture(const scoped_refptr<media::VideoFrame>& frame) OVERRIDE;
39 virtual void Destroy() OVERRIDE;
40
41 // SurfaceCapturer::Client implementation.
42 virtual void NotifyCaptureParameters(const gfx::Size& buffer_size,
43 const gfx::Rect& visible_rect) OVERRIDE;
44 virtual void NotifyError(Error error);
45
46 void NotifySwapBuffersOnImplThread();
47 void DoDestroyOnImplThread();
48
49 private:
50 void DoInitializeOnImplThread(media::VideoFrame::Format format);
51 void DoCaptureOnImplThread(const scoped_refptr<media::VideoFrame>& frame);
52
53 // Map to look up BrowserCompositorOutputSurfaces from their surface IDs.
54 // Must outlive |this|. Should only be accessed on
55 // |compositor_impl_message_loop_proxy_|.
56 const IDMap<BrowserCompositorOutputSurface>* output_surface_map_;
57
58 // The ID of the surface we will be capturing from.
59 const int output_surface_id_;
60
61 // Factory for weak pointers back to the SurfaceCapturer::Client, for
62 // callbacks posted back to |ui_compositor_message_loop_proxy_|.
63 base::WeakPtrFactory<SurfaceCapturer::Client> client_ptr_factory_;
64 base::WeakPtr<SurfaceCapturer::Client> client_;
65
66 // The main thread of the ui::Compositor. Presently the Browser process UI
67 // thread.
68 scoped_refptr<base::MessageLoopProxy> ui_compositor_message_loop_proxy_;
69
70 // The impl thread of the ui::Compositor.
71 scoped_refptr<base::MessageLoopProxy> compositor_impl_message_loop_proxy_;
72
73 // The underlying capturer we capture from.
74 scoped_ptr<SurfaceCapturer> capturer_;
75
76 // A queue of input frames ready to be captured to.
77 std::list<scoped_refptr<media::VideoFrame> > input_frames_;
78 };
79
80 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698