Index: content/browser/aura/browser_compositor_output_surface_capturer.h |
diff --git a/content/browser/aura/browser_compositor_output_surface_capturer.h b/content/browser/aura/browser_compositor_output_surface_capturer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..42823417b5d5a56537dda984dc6a332720b6d0b9 |
--- /dev/null |
+++ b/content/browser/aura/browser_compositor_output_surface_capturer.h |
@@ -0,0 +1,80 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <list> |
+ |
+#include "base/id_map.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
+#include "content/common/gpu/surface_capturer.h" |
+#include "ui/gfx/size.h" |
+ |
+namespace base { |
+ |
+class MessageLoopProxy; |
+ |
+} // namespace base |
+ |
+namespace content { |
+ |
+class BrowserCompositorOutputSurface; |
+ |
+// This class implements the SurfaceCapturer interface for capturing from a |
+// BrowserCompositorOutputSurface. It essentially proxies the SurfaceCapturer |
+// between the compositor's impl thread (which BrowserCompositorOutputSurface |
+// runs on) and the compositor's own main thread (presently the UI thread). |
+class BrowserCompositorOutputSurfaceCapturer : public SurfaceCapturer, |
+ public SurfaceCapturer::Client { |
+ public: |
+ BrowserCompositorOutputSurfaceCapturer( |
+ IDMap<BrowserCompositorOutputSurface>* output_surface_map, |
+ int output_surface_id, |
+ SurfaceCapturer::Client* client); |
+ virtual ~BrowserCompositorOutputSurfaceCapturer(); |
+ |
+ // SurfaceCapturer implementation. |
+ virtual void Initialize(media::VideoFrame::Format format) OVERRIDE; |
+ virtual void Capture(const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; |
+ virtual void Destroy() OVERRIDE; |
+ |
+ // SurfaceCapturer::Client implementation. |
+ virtual void NotifyCaptureParameters(const gfx::Size& buffer_size, |
+ const gfx::Rect& visible_rect) OVERRIDE; |
+ virtual void NotifyError(Error error); |
+ |
+ void NotifySwapBuffersOnImplThread(); |
+ void DoDestroyOnImplThread(); |
+ |
+ private: |
+ void DoInitializeOnImplThread(media::VideoFrame::Format format); |
+ void DoCaptureOnImplThread(const scoped_refptr<media::VideoFrame>& frame); |
+ |
+ // Map to look up BrowserCompositorOutputSurfaces from their surface IDs. |
+ // Must outlive |this|. Should only be accessed on |
+ // |compositor_impl_message_loop_proxy_|. |
+ const IDMap<BrowserCompositorOutputSurface>* output_surface_map_; |
+ |
+ // The ID of the surface we will be capturing from. |
+ const int output_surface_id_; |
+ |
+ // Factory for weak pointers back to the SurfaceCapturer::Client, for |
+ // callbacks posted back to |ui_compositor_message_loop_proxy_|. |
+ base::WeakPtrFactory<SurfaceCapturer::Client> client_ptr_factory_; |
+ base::WeakPtr<SurfaceCapturer::Client> client_; |
+ |
+ // The main thread of the ui::Compositor. Presently the Browser process UI |
+ // thread. |
+ scoped_refptr<base::MessageLoopProxy> ui_compositor_message_loop_proxy_; |
+ |
+ // The impl thread of the ui::Compositor. |
+ scoped_refptr<base::MessageLoopProxy> compositor_impl_message_loop_proxy_; |
+ |
+ // The underlying capturer we capture from. |
+ scoped_ptr<SurfaceCapturer> capturer_; |
+ |
+ // A queue of input frames ready to be captured to. |
+ std::list<scoped_refptr<media::VideoFrame> > input_frames_; |
+}; |
+ |
+} // namespace content |