summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.cc20
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.h6
-rw-r--r--content/common/gpu/client/gl_surface_capturer_host.cc196
-rw-r--r--content/common/gpu/client/gl_surface_capturer_host.h107
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc15
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h2
-rw-r--r--content/common/gpu/gpu_messages.h46
-rw-r--r--content/common/gpu/media/gl_surface_capturer.cc186
-rw-r--r--content/common/gpu/media/gl_surface_capturer.h88
-rw-r--r--content/common/gpu/surface_capturer.cc11
-rw-r--r--content/common/gpu/surface_capturer.h100
-rw-r--r--content/content_common.gypi10
12 files changed, 2 insertions, 785 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc
index 1ac9403..94abbe1 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -10,7 +10,6 @@
#include "base/memory/shared_memory.h"
#include "base/stl_util.h"
#include "content/common/child_process_messages.h"
-#include "content/common/gpu/client/gl_surface_capturer_host.h"
#include "content/common/gpu/client/gpu_channel_host.h"
#include "content/common/gpu/client/gpu_video_decode_accelerator_host.h"
#include "content/common/gpu/gpu_memory_allocation.h"
@@ -512,25 +511,6 @@ CommandBufferProxyImpl::CreateVideoDecoder(
return vda.Pass();
}
-scoped_ptr<SurfaceCapturer> CommandBufferProxyImpl::CreateSurfaceCapturer(
- SurfaceCapturer::Client* client) {
- int capturer_route_id;
- scoped_ptr<SurfaceCapturer> capturer;
- if (!Send(new GpuCommandBufferMsg_CreateSurfaceCapturer(
- route_id_, &capturer_route_id))) {
- LOG(ERROR) << "Send(GpuCommandBufferMsg_CreateSurfaceCapturer) failed";
- return capturer.Pass();
- }
-
- if (capturer_route_id < 0) {
- DLOG(ERROR) << "Failed create surface capturer";
- return capturer.Pass();
- }
-
- capturer.reset(new GLSurfaceCapturerHost(capturer_route_id, client, this));
- return capturer.Pass();
-}
-
gpu::error::Error CommandBufferProxyImpl::GetLastError() {
return last_state_.error;
}
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h
index 430ea8f..c891483 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.h
+++ b/content/common/gpu/client/command_buffer_proxy_impl.h
@@ -17,7 +17,6 @@
#include "base/observer_list.h"
#include "content/common/gpu/gpu_memory_allocation.h"
#include "content/common/gpu/gpu_memory_allocation.h"
-#include "content/common/gpu/surface_capturer.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/common/command_buffer_shared.h"
#include "gpu/command_buffer/common/gpu_control.h"
@@ -71,11 +70,6 @@ class CommandBufferProxyImpl
media::VideoCodecProfile profile,
media::VideoDecodeAccelerator::Client* client);
- // Send an IPC message to create a SurfaceCapturer. Returns NULL on failure
- // to create the SurfaceCapturer.
- scoped_ptr<SurfaceCapturer> CreateSurfaceCapturer(
- SurfaceCapturer::Client* client);
-
// IPC::Listener implementation:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
diff --git a/content/common/gpu/client/gl_surface_capturer_host.cc b/content/common/gpu/client/gl_surface_capturer_host.cc
deleted file mode 100644
index c34fcfb..0000000
--- a/content/common/gpu/client/gl_surface_capturer_host.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright 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 "content/common/gpu/client/gl_surface_capturer_host.h"
-
-#include "content/common/gpu/client/gpu_channel_host.h"
-#include "content/common/gpu/gpu_messages.h"
-#include "ipc/ipc_message_macros.h"
-
-namespace content {
-
-namespace {
-
-enum {
- kNumCaptureBuffers = 2,
- kMaxCaptureSize = 4096,
-};
-
-} // anonymous namespace
-
-GLSurfaceCapturerHost::GLSurfaceCapturerHost(int32 capturer_route_id,
- SurfaceCapturer::Client* client,
- CommandBufferProxyImpl* impl)
- : thread_checker_(),
- capturer_route_id_(capturer_route_id),
- weak_this_factory_(this),
- client_(client),
- impl_(impl),
- channel_(impl_->channel()),
- next_frame_id_(0) {
- DCHECK(thread_checker_.CalledOnValidThread());
- channel_->AddRoute(capturer_route_id_, weak_this_factory_.GetWeakPtr());
- impl_->AddDeletionObserver(this);
-}
-
-void GLSurfaceCapturerHost::OnChannelError() {
- DLOG(ERROR) << "OnChannelError()";
- DCHECK(thread_checker_.CalledOnValidThread());
- OnNotifyError(kPlatformFailureError);
- if (channel_) {
- weak_this_factory_.InvalidateWeakPtrs();
- channel_->RemoveRoute(capturer_route_id_);
- channel_ = NULL;
- }
-}
-
-bool GLSurfaceCapturerHost::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(GLSurfaceCapturerHost, message)
- IPC_MESSAGE_HANDLER(SurfaceCapturerHostMsg_NotifyCaptureParameters,
- OnNotifyCaptureParameters)
- IPC_MESSAGE_HANDLER(SurfaceCapturerHostMsg_NotifyCopyCaptureDone,
- OnNotifyCopyCaptureDone)
- IPC_MESSAGE_HANDLER(SurfaceCapturerHostMsg_NotifyError, OnNotifyError)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void GLSurfaceCapturerHost::Initialize(media::VideoFrame::Format format) {
- DCHECK(thread_checker_.CalledOnValidThread());
- Send(new SurfaceCapturerMsg_Initialize(capturer_route_id_, format));
-}
-
-void GLSurfaceCapturerHost::TryCapture() {
- DCHECK(thread_checker_.CalledOnValidThread());
- Send(new SurfaceCapturerMsg_TryCapture(capturer_route_id_));
-}
-
-void GLSurfaceCapturerHost::CopyCaptureToVideoFrame(
- const scoped_refptr<media::VideoFrame>& frame) {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (!channel_)
- return;
- if (!base::SharedMemory::IsHandleValid(frame->shared_memory_handle())) {
- DLOG(ERROR) << "CopyCaptureToVideoFrame(): cannot capture to frame not "
- "backed by shared memory";
- OnNotifyError(kPlatformFailureError);
- return;
- }
- base::SharedMemoryHandle handle =
- channel_->ShareToGpuProcess(frame->shared_memory_handle());
- if (!base::SharedMemory::IsHandleValid(frame->shared_memory_handle())) {
- DLOG(ERROR) << "CopyCaptureToVideoFrame(): failed to duplicate buffer "
- "handle for GPU process";
- OnNotifyError(kPlatformFailureError);
- return;
- }
-
- const size_t plane_count = media::VideoFrame::NumPlanes(frame->format());
- size_t frame_size = 0;
- for (size_t i = 0; i < plane_count; ++i) {
- DCHECK_EQ(reinterpret_cast<void*>(frame->data(i)),
- reinterpret_cast<void*>((frame->data(0) + frame_size)))
- << "plane=" << i;
- frame_size += frame->stride(i) * frame->rows(i);
- }
-
- Send(new SurfaceCapturerMsg_CopyCaptureToVideoFrame(
- capturer_route_id_, next_frame_id_, handle, frame_size));
- frame_map_[next_frame_id_] = frame;
- next_frame_id_ = (next_frame_id_ + 1) & 0x3FFFFFFF;
-}
-
-void GLSurfaceCapturerHost::Destroy() {
- DCHECK(thread_checker_.CalledOnValidThread());
- client_ = NULL;
- Send(new SurfaceCapturerMsg_Destroy(capturer_route_id_));
- delete this;
-}
-
-void GLSurfaceCapturerHost::OnWillDeleteImpl() {
- DCHECK(thread_checker_.CalledOnValidThread());
- impl_ = NULL;
- OnChannelError();
-}
-
-GLSurfaceCapturerHost::~GLSurfaceCapturerHost() {
- DCHECK(thread_checker_.CalledOnValidThread());
- weak_this_factory_.InvalidateWeakPtrs();
- if (channel_)
- channel_->RemoveRoute(capturer_route_id_);
- if (impl_)
- impl_->RemoveDeletionObserver(this);
-}
-
-void GLSurfaceCapturerHost::NotifyError(Error error) {
- DCHECK(thread_checker_.CalledOnValidThread());
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(&GLSurfaceCapturerHost::OnNotifyError,
- weak_this_factory_.GetWeakPtr(),
- error));
-}
-
-void GLSurfaceCapturerHost::OnNotifyCaptureParameters(
- const gfx::Size& buffer_size,
- const gfx::Rect& visible_rect) {
- DVLOG(2) << "OnNotifyCaptureParameters(): "
- "buffer_size=" << buffer_size.ToString()
- << ", visible_rect=" << visible_rect.ToString();
- DCHECK(thread_checker_.CalledOnValidThread());
- if (buffer_size.width() < 1 || buffer_size.width() > kMaxCaptureSize ||
- buffer_size.height() < 1 || buffer_size.height() > kMaxCaptureSize ||
- visible_rect.x() < 0 || visible_rect.x() > kMaxCaptureSize - 1 ||
- visible_rect.y() < 0 || visible_rect.y() > kMaxCaptureSize - 1 ||
- visible_rect.width() < 1 || visible_rect.width() > kMaxCaptureSize ||
- visible_rect.height() < 1 || visible_rect.height() > kMaxCaptureSize) {
- DLOG(ERROR) << "OnNotifyCaptureParameters(): parameters out of bounds: "
- "buffer_size=" << buffer_size.ToString()
- << ", visible_rect=" << visible_rect.ToString();
- OnNotifyError(kPlatformFailureError);
- return;
- }
- if (client_)
- client_->NotifyCaptureParameters(buffer_size, visible_rect);
-}
-
-void GLSurfaceCapturerHost::OnNotifyCopyCaptureDone(int32 frame_id) {
- DVLOG(3) << "OnNotifyCopyCaptureDone(): frame_id=" << frame_id;
- DCHECK(thread_checker_.CalledOnValidThread());
- FrameMap::iterator iter = frame_map_.find(frame_id);
- if (iter == frame_map_.end()) {
- DLOG(ERROR) << "OnNotifyCopyCaptureDone(): invalid frame_id=" << frame_id;
- OnNotifyError(kPlatformFailureError);
- return;
- }
- if (client_)
- client_->NotifyCopyCaptureDone(iter->second);
- frame_map_.erase(iter);
-}
-
-void GLSurfaceCapturerHost::OnNotifyError(Error error) {
- DVLOG(2) << "OnNotifyError(): error=" << error;
- DCHECK(thread_checker_.CalledOnValidThread());
- if (client_) {
- client_->NotifyError(error);
- client_ = NULL;
- }
-}
-
-void GLSurfaceCapturerHost::Send(IPC::Message* message) {
- DCHECK(thread_checker_.CalledOnValidThread());
- uint32 type = message->type();
- if (!channel_) {
- DLOG(ERROR) << "Send(): no channel";
- delete message;
- NotifyError(kPlatformFailureError);
- } else if (!channel_->Send(message)) {
- DLOG(ERROR) << "Send(): failed: message->type()=" << type;
- NotifyError(kPlatformFailureError);
- }
-}
-
-} // namespace content
diff --git a/content/common/gpu/client/gl_surface_capturer_host.h b/content/common/gpu/client/gl_surface_capturer_host.h
deleted file mode 100644
index d90afcd..0000000
--- a/content/common/gpu/client/gl_surface_capturer_host.h
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 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.
-
-#ifndef CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_
-#define CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_
-
-#include "base/containers/small_map.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/thread_checker.h"
-#include "content/common/gpu/client/command_buffer_proxy_impl.h"
-#include "content/common/gpu/surface_capturer.h"
-#include "ipc/ipc_listener.h"
-
-namespace gfx {
-
-class Rect;
-class Size;
-
-} // namespace gfx
-
-namespace media {
-
-class VideoFrame;
-
-} // namespace media
-
-namespace content {
-
-class GpuChannelHost;
-
-// This class is the browser-side host for the SurfaceCapturer in the GPU
-// process, coordinated over IPC.
-class GLSurfaceCapturerHost : public IPC::Listener,
- public SurfaceCapturer,
- public CommandBufferProxyImpl::DeletionObserver {
- public:
- // |client| is expected to outlive this object. We are registered as a
- // DeletionObserver with |impl|, so it will notify us when it is about to
- // be destroyed.
- GLSurfaceCapturerHost(int32 capturer_route_id,
- SurfaceCapturer::Client* client,
- CommandBufferProxyImpl* impl);
-
- // IPC::Listener implementation.
- virtual void OnChannelError() OVERRIDE;
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- // SurfaceCapturer implementation.
- virtual void Initialize(media::VideoFrame::Format format) OVERRIDE;
- virtual void TryCapture() OVERRIDE;
- virtual void CopyCaptureToVideoFrame(
- const scoped_refptr<media::VideoFrame>& frame) OVERRIDE;
- virtual void Destroy() OVERRIDE;
-
- // CommandBufferProxyImpl::DeletionObserver implementation.
- virtual void OnWillDeleteImpl() OVERRIDE;
-
- private:
- virtual ~GLSurfaceCapturerHost();
-
- // Notify |client_| when an error has occured. Used when notifying from
- // within a media::VideoEncodeAccelerator entry point, to avoid re-entrancy.
- void NotifyError(Error error);
-
- // IPC handlers, proxying SurfaceCapturer::Client for the GPU process.
- void OnNotifyCaptureParameters(const gfx::Size& buffer_size,
- const gfx::Rect& visible_rect);
- void OnNotifyCopyCaptureDone(int32 frame_id);
- void OnNotifyError(Error error);
-
- void Send(IPC::Message* message);
-
- const base::ThreadChecker thread_checker_;
-
- // Route ID for corresponding GLSurfaceCapturer in the GPU process.
- const int32 capturer_route_id_;
-
- // Weak pointer for registering as a listener for |channel_|.
- base::WeakPtrFactory<GLSurfaceCapturerHost> weak_this_factory_;
-
- // SurfaceEncoder::Client callbacks received over IPC are forwarded to
- // |client_|.
- SurfaceCapturer::Client* client_;
-
- // Unowned reference to the CommandBufferProxyImpl that created us.
- CommandBufferProxyImpl* impl_;
-
- // GPU process channel to send messages on.
- GpuChannelHost* channel_;
-
- // media::VideoFrames sent to the capturer.
- // base::IDMap not used here, since that takes pointers, not scoped_refptr.
- typedef base::SmallMap<std::map<int32, scoped_refptr<media::VideoFrame> > >
- FrameMap;
- FrameMap frame_map_;
-
- // ID serial number for next frame to send to the GPU process.
- int32 next_frame_id_;
-
- DISALLOW_COPY_AND_ASSIGN(GLSurfaceCapturerHost);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index da3fb0e..05792bf 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -18,7 +18,6 @@
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/gpu_watchdog.h"
#include "content/common/gpu/image_transport_surface.h"
-#include "content/common/gpu/media/gl_surface_capturer.h"
#include "content/common/gpu/media/gpu_video_decode_accelerator.h"
#include "content/common/gpu/sync_point_manager.h"
#include "content/public/common/content_client.h"
@@ -207,8 +206,6 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
OnGetTransferBuffer);
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder,
OnCreateVideoDecoder)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateSurfaceCapturer,
- OnCreateSurfaceCapturer)
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetSurfaceVisible,
OnSetSurfaceVisible)
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DiscardBackbuffer,
@@ -727,18 +724,6 @@ void GpuCommandBufferStub::OnCreateVideoDecoder(
// self-delete during destruction of this stub.
}
-void GpuCommandBufferStub::OnCreateSurfaceCapturer(
- IPC::Message* reply_message) {
- TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateSurfaceCapturer");
- int capturer_route_id = channel_->GenerateRouteID();
- new GLSurfaceCapturer(capturer_route_id, this);
- // The capturer is registered as a DestructionObserver of this stub and will
- // self-delete during destruction of this stub.
- GpuCommandBufferMsg_CreateSurfaceCapturer::WriteReplyParams(
- reply_message, capturer_route_id);
- Send(reply_message);
-}
-
void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) {
TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSetSurfaceVisible");
if (memory_manager_client_state_)
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index 7414b26..47c532b 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -166,8 +166,6 @@ class GpuCommandBufferStub
media::VideoCodecProfile profile,
IPC::Message* reply_message);
- void OnCreateSurfaceCapturer(IPC::Message* reply_message);
-
void OnSetSurfaceVisible(bool visible);
void OnDiscardBackbuffer();
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index a64afdc..124815b 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -14,7 +14,6 @@
#include "content/common/gpu/gpu_memory_uma_stats.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
#include "content/common/gpu/gpu_rendering_stats.h"
-#include "content/common/gpu/surface_capturer.h"
#include "content/public/common/common_param_traits.h"
#include "content/public/common/gpu_memory_stats.h"
#include "gpu/command_buffer/common/command_buffer.h"
@@ -226,8 +225,6 @@ IPC_ENUM_TRAITS(media::VideoFrame::Format)
IPC_ENUM_TRAITS(media::VideoEncodeAccelerator::Error)
-IPC_ENUM_TRAITS(content::SurfaceCapturer::Error)
-
//------------------------------------------------------------------------------
// GPU Messages
// These are messages from the browser to the GPU process.
@@ -576,12 +573,6 @@ IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_CreateVideoDecoder,
media::VideoCodecProfile /* profile */,
int /* route_id */)
-// Create and initialize a surface capturer, returning its new route_id.
-// Created capturers should be freed with SurfaceCapturerMsg_Destroy when no
-// longer needed.
-IPC_SYNC_MESSAGE_ROUTED0_1(GpuCommandBufferMsg_CreateSurfaceCapturer,
- int /* route_id */)
-
// Tells the proxy that there was an error and the command buffer had to be
// destroyed for some reason.
IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_Destroyed,
@@ -773,40 +764,3 @@ IPC_MESSAGE_ROUTED3(AcceleratedVideoEncoderHostMsg_BitstreamBufferReady,
// Report error condition.
IPC_MESSAGE_ROUTED1(AcceleratedVideoEncoderHostMsg_NotifyError,
media::VideoEncodeAccelerator::Error /* error */)
-
-//------------------------------------------------------------------------------
-// Gpu Surface Capturer Messages
-// These messages are sent from the Browser process to the GPU process.
-
-// Initialize the capturer.
-IPC_MESSAGE_ROUTED1(SurfaceCapturerMsg_Initialize,
- media::VideoFrame::Format /* format */)
-
-// Attempt to start a capture.
-IPC_MESSAGE_ROUTED0(SurfaceCapturerMsg_TryCapture)
-
-// Copy captured contents to a video frame.
-IPC_MESSAGE_ROUTED3(SurfaceCapturerMsg_CopyCaptureToVideoFrame,
- int32 /* buffer_id */,
- base::SharedMemoryHandle /* buffer_shm */,
- uint32 /* buffer_size */)
-
-// Destroy the capturer.
-IPC_MESSAGE_ROUTED0(SurfaceCapturerMsg_Destroy)
-
-//------------------------------------------------------------------------------
-// Gpu Surface Capturer Host Messages
-// These messages are sent from GPU process to Browser process.
-
-// Report the capture output parameters to the Browser process.
-IPC_MESSAGE_ROUTED2(SurfaceCapturerHostMsg_NotifyCaptureParameters,
- gfx::Size /* buffer_size */,
- gfx::Rect /* visible_rect */)
-
-// Report successful copy of a capture of a surface.
-IPC_MESSAGE_ROUTED1(SurfaceCapturerHostMsg_NotifyCopyCaptureDone,
- int32 /* frame_id */)
-
-// Report error.
-IPC_MESSAGE_ROUTED1(SurfaceCapturerHostMsg_NotifyError,
- content::SurfaceCapturer::Error /* error */)
diff --git a/content/common/gpu/media/gl_surface_capturer.cc b/content/common/gpu/media/gl_surface_capturer.cc
deleted file mode 100644
index 5f76eda..0000000
--- a/content/common/gpu/media/gl_surface_capturer.cc
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright 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 "content/common/gpu/media/gl_surface_capturer.h"
-
-#include "base/message_loop/message_loop_proxy.h"
-#include "content/common/gpu/gpu_channel.h"
-#include "content/common/gpu/gpu_messages.h"
-#include "ipc/ipc_message_macros.h"
-
-namespace content {
-
-namespace {
-
-enum {
- kMaxCaptureSize = 4096,
-};
-
-} // anonymous namespace
-
-GLSurfaceCapturer::GLSurfaceCapturer(int32 route_id, GpuCommandBufferStub* stub)
- : thread_checker_(),
- route_id_(route_id),
- stub_(stub),
- output_format_(media::VideoFrame::INVALID) {
- DCHECK(thread_checker_.CalledOnValidThread());
- stub_->AddDestructionObserver(this);
- stub_->channel()->AddRoute(route_id_, this);
-}
-
-GLSurfaceCapturer::~GLSurfaceCapturer() {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (surface_capturer_)
- surface_capturer_.release()->Destroy();
-
- stub_->channel()->RemoveRoute(route_id_);
- stub_->RemoveDestructionObserver(this);
-}
-
-bool GLSurfaceCapturer::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(GLSurfaceCapturer, message)
- IPC_MESSAGE_HANDLER(SurfaceCapturerMsg_Initialize, OnInitialize)
- IPC_MESSAGE_HANDLER(SurfaceCapturerMsg_TryCapture, OnTryCapture)
- IPC_MESSAGE_HANDLER(SurfaceCapturerMsg_CopyCaptureToVideoFrame,
- OnCopyCaptureToVideoFrame)
- IPC_MESSAGE_HANDLER(SurfaceCapturerMsg_Destroy, OnDestroy)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void GLSurfaceCapturer::NotifyCaptureParameters(const gfx::Size& buffer_size,
- const gfx::Rect& visible_rect) {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (buffer_size.width() < 1 || buffer_size.width() > kMaxCaptureSize ||
- buffer_size.height() < 1 || buffer_size.height() > kMaxCaptureSize ||
- visible_rect.x() < 0 || visible_rect.x() > kMaxCaptureSize - 1 ||
- visible_rect.y() < 0 || visible_rect.y() > kMaxCaptureSize - 1 ||
- visible_rect.width() < 1 || visible_rect.width() > kMaxCaptureSize ||
- visible_rect.height() < 1 || visible_rect.height() > kMaxCaptureSize) {
- DLOG(ERROR) << "NotifyCaptureParameters(): parameters out of bounds: "
- "buffer_size=" << buffer_size.ToString()
- << ", visible_rect=" << visible_rect.ToString();
- NotifyError(SurfaceCapturer::kInvalidArgumentError);
- return;
- }
- output_buffer_size_ = buffer_size;
- output_visible_rect_ = visible_rect;
- Send(new SurfaceCapturerHostMsg_NotifyCaptureParameters(
- route_id_, buffer_size, visible_rect));
-}
-
-void GLSurfaceCapturer::NotifyCopyCaptureDone(
- const scoped_refptr<media::VideoFrame>& frame) {
- DCHECK(thread_checker_.CalledOnValidThread());
- FrameIdMap::iterator iter = frame_id_map_.find(frame);
- if (iter == frame_id_map_.end()) {
- DLOG(ERROR) << "NotifyCopyCaptureDone(): invalid frame";
- NotifyError(SurfaceCapturer::kInvalidArgumentError);
- return;
- }
- Send(new SurfaceCapturerHostMsg_NotifyCopyCaptureDone(route_id_,
- iter->second));
- frame_id_map_.erase(iter);
-}
-
-void GLSurfaceCapturer::NotifyError(SurfaceCapturer::Error error) {
- DCHECK(thread_checker_.CalledOnValidThread());
- Send(new SurfaceCapturerHostMsg_NotifyError(route_id_, error));
-}
-
-void GLSurfaceCapturer::OnWillDestroyStub() {
- DCHECK(thread_checker_.CalledOnValidThread());
- delete this;
-}
-
-void GLSurfaceCapturer::OnInitialize(media::VideoFrame::Format format) {
- DVLOG(2) << "OnInitialize(): format=" << format;
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(!surface_capturer_);
-
- // TODO(sheu): actually create a surface capturer.
-
- if (!surface_capturer_) {
- NOTIMPLEMENTED() << "OnInitialize(): GL surface capturing not available";
- NotifyError(SurfaceCapturer::kPlatformFailureError);
- return;
- }
-
- output_format_ = format;
- surface_capturer_->Initialize(output_format_);
-}
-
-void GLSurfaceCapturer::OnTryCapture() {
- DVLOG(3) << "OnTryCapture()";
- DCHECK(thread_checker_.CalledOnValidThread());
- if (!surface_capturer_)
- return;
- surface_capturer_->TryCapture();
-}
-
-static void DeleteShm(scoped_ptr<base::SharedMemory> shm) {
- // Just let shm fall out of scope.
-}
-
-void GLSurfaceCapturer::OnCopyCaptureToVideoFrame(
- int32 frame_id,
- base::SharedMemoryHandle buffer_shm,
- uint32_t buffer_size) {
- DVLOG(3) << "OnCopyCaptureToVideoFrame(): frame_id=" << frame_id
- << ", buffer_size=" << buffer_size;
- DCHECK(thread_checker_.CalledOnValidThread());
- if (!surface_capturer_)
- return;
- if (frame_id < 0) {
- DLOG(ERROR) << "OnCopyCaptureToVideoFrame(): invalid frame_id=" << frame_id;
- NotifyError(SurfaceCapturer::kPlatformFailureError);
- return;
- }
-
- scoped_ptr<base::SharedMemory> shm(new base::SharedMemory(buffer_shm, false));
- if (!shm->Map(buffer_size)) {
- DLOG(ERROR) << "OnCopyCaptureToVideoFrame(): could not map "
- "frame_id=" << frame_id;
- NotifyError(SurfaceCapturer::kPlatformFailureError);
- return;
- }
- scoped_refptr<media::VideoFrame> frame =
- media::VideoFrame::WrapExternalSharedMemory(
- output_format_,
- output_buffer_size_,
- output_visible_rect_,
- output_visible_rect_.size(),
- reinterpret_cast<uint8*>(shm->memory()),
- buffer_size,
- buffer_shm,
- base::TimeDelta(),
- base::Bind(&DeleteShm, base::Passed(&shm)));
- if (!frame) {
- DLOG(ERROR) << "OnCopyCaptureToVideoFrame(): could not create frame for"
- "frame_id=" << frame_id;
- NotifyError(SurfaceCapturer::kPlatformFailureError);
- return;
- }
- frame_id_map_[frame] = frame_id;
- surface_capturer_->CopyCaptureToVideoFrame(frame);
-}
-
-void GLSurfaceCapturer::OnDestroy() {
- DVLOG(2) << "OnDestroy()";
- DCHECK(thread_checker_.CalledOnValidThread());
- delete this;
-}
-
-void GLSurfaceCapturer::Send(IPC::Message* message) {
- DCHECK(thread_checker_.CalledOnValidThread());
- uint32 type = message->type();
- if (!stub_->channel()->Send(message)) {
- DLOG(ERROR) << "Send(): send failed: message->type()=" << type;
- NotifyError(SurfaceCapturer::kPlatformFailureError);
- }
-}
-
-} // namespace content
diff --git a/content/common/gpu/media/gl_surface_capturer.h b/content/common/gpu/media/gl_surface_capturer.h
deleted file mode 100644
index d40ae99..0000000
--- a/content/common/gpu/media/gl_surface_capturer.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 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.
-
-#ifndef CONTENT_COMMON_GPU_MEDIA_GL_SURFACE_CAPTURER_H_
-#define CONTENT_COMMON_GPU_MEDIA_GL_SURFACE_CAPTURER_H_
-
-#include "base/callback.h"
-#include "base/containers/small_map.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/threading/thread_checker.h"
-#include "content/common/gpu/gpu_command_buffer_stub.h"
-#include "content/common/gpu/surface_capturer.h"
-#include "ipc/ipc_listener.h"
-#include "ipc/ipc_sender.h"
-
-namespace gfx {
-
-class Size;
-class Rect;
-
-} // namespace gfx
-
-namespace content {
-
-class GpuChannelHost;
-
-// This class implements the GPU process side of a SurfaceCapturer,
-// communicating over IPC with a GLSurfaceCapturerHost on the browser process.
-class GLSurfaceCapturer : public IPC::Listener,
- public SurfaceCapturer::Client,
- public GpuCommandBufferStub::DestructionObserver {
- public:
- GLSurfaceCapturer(int32 route_id, GpuCommandBufferStub* stub);
- virtual ~GLSurfaceCapturer();
-
- // IPC::Listener implementation.
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- // SurfaceCapturer::Client implementation.
- virtual void NotifyCaptureParameters(const gfx::Size& buffer_size,
- const gfx::Rect& visible_rect) OVERRIDE;
- virtual void NotifyCopyCaptureDone(
- const scoped_refptr<media::VideoFrame>& frame) OVERRIDE;
- virtual void NotifyError(SurfaceCapturer::Error error) OVERRIDE;
-
- // GpuCommandBufferStub::DestructionObserver implementation.
- virtual void OnWillDestroyStub() OVERRIDE;
-
- private:
- // Handlers for IPC messages.
- void OnInitialize(media::VideoFrame::Format format);
- void OnCopyCaptureToVideoFrame(int32 frame_id,
- base::SharedMemoryHandle buffer_shm,
- uint32 buffer_size);
- void OnTryCapture();
- void OnDestroy();
-
- void Send(IPC::Message* message);
-
- const base::ThreadChecker thread_checker_;
-
- // Route ID assigned by the GpuCommandBufferStub.
- const int32 route_id_;
-
- // The GpuCommandBufferStub this instance belongs to, as an unowned pointer
- // since |stub_| will own (and outlive) this.
- GpuCommandBufferStub* const stub_;
-
- // media::VideoFrames received from the host side.
- typedef base::SmallMap<std::map<scoped_refptr<media::VideoFrame>, int32> >
- FrameIdMap;
- FrameIdMap frame_id_map_;
-
- // The underlying capturer we delegate to.
- scoped_ptr<SurfaceCapturer> surface_capturer_;
-
- // The capture output parameters that the capturer informs us of.
- media::VideoFrame::Format output_format_;
- gfx::Size output_buffer_size_;
- gfx::Rect output_visible_rect_;
-
- DISALLOW_COPY_AND_ASSIGN(GLSurfaceCapturer);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_MEDIA_GL_SURFACE_CAPTURER_H_
diff --git a/content/common/gpu/surface_capturer.cc b/content/common/gpu/surface_capturer.cc
deleted file mode 100644
index ce02b4d..0000000
--- a/content/common/gpu/surface_capturer.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 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 "content/common/gpu/surface_capturer.h"
-
-namespace content {
-
-SurfaceCapturer::~SurfaceCapturer() {}
-
-} // namespace content
diff --git a/content/common/gpu/surface_capturer.h b/content/common/gpu/surface_capturer.h
deleted file mode 100644
index 77bfe5a..0000000
--- a/content/common/gpu/surface_capturer.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 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.
-
-#ifndef CONTENT_COMMON_GPU_SURFACE_CAPTURER_H_
-#define CONTENT_COMMON_GPU_SURFACE_CAPTURER_H_
-
-#include "content/common/content_export.h"
-#include "media/base/video_frame.h"
-
-namespace gfx {
-
-class Size;
-class Rect;
-
-} // namespace ui
-
-namespace content {
-
-// Surface capturer interface. This interface is implemented by classes
-// that perform image capturing from the backbuffer.
-class CONTENT_EXPORT SurfaceCapturer {
- public:
- enum Error {
- // Invalid argument was passed to an API method.
- kInvalidArgumentError,
- // A failure occurred at the GPU process or one of its dependencies.
- // Examples of such failures include GPU hardware failures, GPU driver
- // failures, GPU library failures, GPU process programming errors, and so
- // on.
- kPlatformFailureError,
- };
-
- class CONTENT_EXPORT Client {
- public:
- // Callback to notify client of parameters of the backbuffer capture. Every
- // time the Client receives this callback, subsequent media::VideoFrames
- // passed to CopyCaptureToVideoFrame() should mind the new parameters.
- // Parameters:
- // |buffer_size| is the required logical size (in pixels) of the buffer
- // to capture to (corresponds to |frame->coded_size()| in
- // CopyCaptureToVideoFrame().
- // |visible_rect| is the visible subrect of the actual screen capture
- // contents in the buffer to capture to (corresponds to
- // |frame->visible_rect()| in CopyCaptureToVideoFrame().
- virtual void NotifyCaptureParameters(const gfx::Size& buffer_size,
- const gfx::Rect& visible_rect) = 0;
-
- // Callback to notify client that CopyCaptureToVideoFrame() has been
- // completed for |frame|. After this call, the capturer will drop all its
- // outstanding references to |frame|.
- // Parameters:
- // |frame| is the completed copied captured frame.
- virtual void NotifyCopyCaptureDone(
- const scoped_refptr<media::VideoFrame>& frame) = 0;
-
- // Error notification callback.
- // Parameters:
- // |error| is the error to report.
- virtual void NotifyError(Error error) = 0;
-
- protected:
- // Clients are not owned by Capturer instances and should not be deleted
- // through these pointers.
- virtual ~Client() {}
- };
-
- // Initialize the capturer to a specific configuration.
- // Parameters:
- // |format| is the format to capture to (corresponds to |frame->format()| in
- // CopyCaptureToVideoFrame()). The NotifyCaptureParameters() callback is
- // made to the Client on success; on failure, a NotifyError() callback is
- // performed.
- virtual void Initialize(media::VideoFrame::Format format) = 0;
-
- // Attempt to capture a single frame. This call is advisory to note to the
- // SurfaceCapturer that capture should be attempted at this time; success is
- // not guaranteed. The most recent captured frame is cached internally, and
- // its contents returned every time CopyCaptureToVideoFrame() is called.
- virtual void TryCapture() = 0;
-
- // Copy the most recent captured contents to |frame|.
- // Parameters:
- // |frame| is the media::VideoFrame to fill with captured contents.
- virtual void CopyCaptureToVideoFrame(
- const scoped_refptr<media::VideoFrame>& frame) = 0;
-
- // Destroys the capturer; all pending inputs and outputs are dropped
- // immediately and the component is freed. This call may asynchronously free
- // system resources, but its client-visible effects are synchronous. After
- // this method returns no more callbacks will be made on the client. Deletes
- // |this| unconditionally, so make sure to drop all pointers to it!
- virtual void Destroy() = 0;
-
- virtual ~SurfaceCapturer();
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_SURFACE_CAPTURER_H_
diff --git a/content/content_common.gypi b/content/content_common.gypi
index cb3b2c5..18edca34 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -188,8 +188,6 @@
'common/gpu/client/gl_helper.h',
'common/gpu/client/gl_helper_scaling.cc',
'common/gpu/client/gl_helper_scaling.h',
- 'common/gpu/client/gl_surface_capturer_host.cc',
- 'common/gpu/client/gl_surface_capturer_host.h',
'common/gpu/client/gpu_channel_host.cc',
'common/gpu/client/gpu_channel_host.h',
'common/gpu/client/gpu_video_decode_accelerator_host.cc',
@@ -226,22 +224,18 @@
'common/gpu/image_transport_surface_linux.cc',
'common/gpu/image_transport_surface_mac.cc',
'common/gpu/image_transport_surface_win.cc',
- 'common/gpu/media/gl_surface_capturer.cc',
- 'common/gpu/media/gl_surface_capturer.h',
'common/gpu/media/gpu_video_decode_accelerator.cc',
'common/gpu/media/gpu_video_decode_accelerator.h',
'common/gpu/media/gpu_video_encode_accelerator.cc',
'common/gpu/media/gpu_video_encode_accelerator.h',
- 'common/gpu/media/video_decode_accelerator_impl.cc',
- 'common/gpu/media/video_decode_accelerator_impl.h',
'common/gpu/media/h264_bit_reader.cc',
'common/gpu/media/h264_bit_reader.h',
'common/gpu/media/h264_parser.cc',
'common/gpu/media/h264_parser.h',
+ 'common/gpu/media/video_decode_accelerator_impl.cc',
+ 'common/gpu/media/video_decode_accelerator_impl.h',
'common/gpu/stream_texture_manager_android.cc',
'common/gpu/stream_texture_manager_android.h',
- 'common/gpu/surface_capturer.cc',
- 'common/gpu/surface_capturer.h',
'common/gpu/sync_point_manager.cc',
'common/gpu/sync_point_manager.h',
'common/gpu/texture_image_transport_surface.cc',