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

Side by Side Diff: content/common/gpu/client/gl_surface_capturer_host.h

Issue 22935009: Add content::SurfaceCapturer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screencast_stride
Patch Set: af8f3e73 Separated from BrowserCompositorOutputSurface* components. Created 7 years, 3 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_
7
8 #include "base/containers/small_map.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
13 #include "content/common/gpu/surface_capturer.h"
14 #include "ipc/ipc_listener.h"
15
16 namespace gfx {
17
18 class Rect;
19 class Size;
20
21 } // namespace gfx
22
23 namespace media {
24
25 class VideoFrame;
26
27 } // namespace media
28
29 namespace content {
30
31 class GpuChannelHost;
32
33 // This class is the browser-side host for the SurfaceCapturer in the GPU
34 // process, coordinated over IPC.
35 class GLSurfaceCapturerHost : public IPC::Listener,
36 public SurfaceCapturer,
37 public CommandBufferProxyImpl::DeletionObserver {
38 public:
39 // |client| is expected to outlive this object. We are registered as a
40 // DeletionObserver with |impl|, so it will notify us when it is about to
41 // be destroyed.
42 GLSurfaceCapturerHost(int32 capturer_route_id,
43 SurfaceCapturer::Client* client,
44 CommandBufferProxyImpl* impl);
45
46 // IPC::Listener implementation.
47 virtual void OnChannelError() OVERRIDE;
48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
49
50 // SurfaceCapturer implementation.
51 virtual void Initialize(media::VideoFrame::Format format) OVERRIDE;
52 virtual void TryCapture() OVERRIDE;
53 virtual void CopyCaptureToVideoFrame(
54 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE;
55 virtual void Destroy() OVERRIDE;
56
57 // CommandBufferProxyImpl::DeletionObserver implementation.
58 virtual void OnWillDeleteImpl() OVERRIDE;
59
60 private:
61 virtual ~GLSurfaceCapturerHost();
62
63 // Notify |client_| when an error has occured. Used when notifying from
64 // within a media::VideoEncodeAccelerator entry point, to avoid re-entrancy.
65 void NotifyError(Error error);
66
67 // IPC handlers, proxying SurfaceCapturer::Client for the GPU process.
68 void OnNotifyCaptureParameters(const gfx::Size& buffer_size,
69 const gfx::Rect& visible_rect);
70 void OnNotifyCopyCaptureDone(int32 frame_id);
71 void OnNotifyError(Error error);
72
73 void Send(IPC::Message* message);
74
75 const base::ThreadChecker thread_checker_;
76
77 // Route ID for corresponding GLSurfaceCapturer in the GPU process.
78 const int32 capturer_route_id_;
79
80 // Weak pointer for registering as a listener for |channel_|.
81 base::WeakPtrFactory<GLSurfaceCapturerHost> weak_this_factory_;
piman 2013/08/28 21:59:44 nit: move this to the end, so that it's cleared be
sheu 2013/08/28 22:20:18 I think the sort order makes sense this way, and s
82
83 // SurfaceEncoder::Client callbacks received over IPC are forwarded to
84 // |client_|. |client_ptr_factory_| is used for calls originating directly
85 // from a SurfaceEncoder interface function, that require an extra PostTask()
86 // back on its own thread to avoid re-entrancy.
87 base::WeakPtrFactory<SurfaceCapturer::Client> client_ptr_factory_;
88 SurfaceCapturer::Client* client_;
89
90 // Unowned reference to the CommandBufferProxyImpl that created us.
91 CommandBufferProxyImpl* impl_;
92
93 // GPU process channel to send messages on.
94 GpuChannelHost* channel_;
95
96 // media::VideoFrames sent to the capturer.
97 // base::IDMap not used here, since that takes pointers, not scoped_refptr.
98 typedef base::SmallMap<std::map<int32, scoped_refptr<media::VideoFrame> > >
99 FrameMap;
100 FrameMap frame_map_;
101
102 // ID serial number for next frame to send to the GPU process.
103 int32 next_frame_id_;
104
105 DISALLOW_COPY_AND_ASSIGN(GLSurfaceCapturerHost);
106 };
107
108 } // namespace content
109
110 #endif // CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698