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

Unified Diff: content/browser/aura/browser_compositor_output_surface.cc

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 side-by-side diff with in-line comments
Download patch
Index: content/browser/aura/browser_compositor_output_surface.cc
diff --git a/content/browser/aura/browser_compositor_output_surface.cc b/content/browser/aura/browser_compositor_output_surface.cc
index 11fbe0c42a958a99a2f47cf686eadf9e22bb3ff7..83be65e6e1e987d39ec679d60656cbbd3db2c765 100644
--- a/content/browser/aura/browser_compositor_output_surface.cc
+++ b/content/browser/aura/browser_compositor_output_surface.cc
@@ -10,6 +10,7 @@
#include "base/message_loop/message_loop_proxy.h"
#include "base/strings/string_number_conversions.h"
#include "cc/output/compositor_frame.h"
+#include "content/browser/aura/browser_compositor_output_surface_capturer.h"
#include "content/browser/aura/reflector_impl.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "ui/compositor/compositor.h"
@@ -21,7 +22,7 @@ BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
scoped_ptr<WebKit::WebGraphicsContext3D> context,
int surface_id,
IDMap<BrowserCompositorOutputSurface>* output_surface_map,
- base::MessageLoopProxy* compositor_message_loop,
+ const scoped_refptr<base::MessageLoopProxy>& compositor_message_loop,
base::WeakPtr<ui::Compositor> compositor)
: OutputSurface(context.Pass()),
surface_id_(surface_id),
@@ -47,6 +48,10 @@ BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
if (!HasClient())
return;
output_surface_map_->Remove(surface_id_);
+ // Don't delete the actual object; we don't own it.
+ FOR_EACH_OBSERVER(BrowserCompositorOutputSurfaceCapturer,
+ capturer_list_,
+ DoDestroyOnImplThread());
}
bool BrowserCompositorOutputSurface::BindToClient(
@@ -70,14 +75,16 @@ void BrowserCompositorOutputSurface::Reshape(gfx::Size size,
void BrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
DCHECK(frame->gl_frame_data);
- WebGraphicsContext3DCommandBufferImpl* command_buffer =
- static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d());
CommandBufferProxyImpl* command_buffer_proxy =
- command_buffer->GetCommandBufferProxy();
+ GetContext3DCommandBufferImpl()->GetCommandBufferProxy();
DCHECK(command_buffer_proxy);
context3d()->shallowFlushCHROMIUM();
command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
+ FOR_EACH_OBSERVER(BrowserCompositorOutputSurfaceCapturer,
+ capturer_list_,
+ NotifySwapBuffersOnImplThread());
+
if (reflector_.get()) {
if (frame->gl_frame_data->sub_buffer_rect ==
gfx::Rect(frame->gl_frame_data->size))
@@ -105,4 +112,21 @@ void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
reflector_ = reflector;
}
+void BrowserCompositorOutputSurface::AddCapturer(
+ BrowserCompositorOutputSurfaceCapturer* capturer) {
+ DCHECK(CalledOnValidThread());
+ capturer_list_.AddObserver(capturer);
+}
+
+void BrowserCompositorOutputSurface::RemoveCapturer(
+ BrowserCompositorOutputSurfaceCapturer* capturer) {
+ DCHECK(CalledOnValidThread());
+ capturer_list_.RemoveObserver(capturer);
+}
+
+WebGraphicsContext3DCommandBufferImpl*
+BrowserCompositorOutputSurface::GetContext3DCommandBufferImpl() {
+ return static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698