summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsievers@google.com <sievers@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 23:02:55 +0000
committersievers@google.com <sievers@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 23:02:55 +0000
commit7bffe9e1e36489115a3ae4577b2e4f1a1253374b (patch)
tree54f66fd51a598e3b94f430b77e9cc22eff48ead2
parentdc6938a6f60389c30d4db00077627e1a31517e0b (diff)
downloadchromium_src-7bffe9e1e36489115a3ae4577b2e4f1a1253374b.zip
chromium_src-7bffe9e1e36489115a3ae4577b2e4f1a1253374b.tar.gz
chromium_src-7bffe9e1e36489115a3ae4577b2e4f1a1253374b.tar.bz2
[gpu] Remove StreamTexture(Manager) concept from command decoder
Instead add a simple GpuControl interface to attach a GLImage-wrapped SurfaceTexture ref to a texture which will provide the necessary hooks. BUG=282700,309162 R=palmer@chromium.org, piman@chromium.org, reveman@chromium.org Review URL: https://codereview.chromium.org/147463002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247334 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.cc10
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.h1
-rw-r--r--content/common/gpu/gpu_channel.cc7
-rw-r--r--content/common/gpu/gpu_channel.h15
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc18
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h1
-rw-r--r--content/common/gpu/gpu_messages.h5
-rw-r--r--content/common/gpu/stream_texture_android.cc169
-rw-r--r--content/common/gpu/stream_texture_android.h75
-rw-r--r--content/common/gpu/stream_texture_manager_android.cc184
-rw-r--r--content/common/gpu/stream_texture_manager_android.h49
-rw-r--r--content/content_common.gypi4
-rw-r--r--content/renderer/media/android/stream_texture_factory_android_impl.cc3
-rw-r--r--content/renderer/media/android/stream_texture_factory_android_synchronous_impl.cc1
-rw-r--r--gpu/GLES2/gl2chromium_autogen.h2
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py18
-rw-r--r--gpu/command_buffer/client/client_test_helper.h1
-rw-r--r--gpu/command_buffer/client/gles2_c_lib_autogen.h5
-rw-r--r--gpu/command_buffer/client/gles2_cmd_helper_autogen.h17
-rw-r--r--gpu/command_buffer/client/gles2_implementation.cc25
-rw-r--r--gpu/command_buffer/client/gles2_implementation_autogen.h2
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc28
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest_autogen.h12
-rw-r--r--gpu/command_buffer/client/gles2_interface_autogen.h1
-rw-r--r--gpu/command_buffer/client/gles2_interface_stub_autogen.h1
-rw-r--r--gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h2
-rw-r--r--gpu/command_buffer/client/gles2_trace_implementation_autogen.h1
-rw-r--r--gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h5
-rw-r--r--gpu/command_buffer/cmd_buffer_functions.txt1
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_autogen.h84
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_test_autogen.h32
-rw-r--r--gpu/command_buffer/common/gles2_cmd_ids_autogen.h60
-rw-r--r--gpu/command_buffer/common/gpu_control.h4
-rw-r--r--gpu/command_buffer/service/context_group.cc4
-rw-r--r--gpu/command_buffer/service/context_group.h7
-rw-r--r--gpu/command_buffer/service/context_group_unittest.cc2
-rw-r--r--gpu/command_buffer/service/feature_info.cc4
-rw-r--r--gpu/command_buffer/service/feature_info.h1
-rw-r--r--gpu/command_buffer/service/feature_info_unittest.cc8
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc170
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h1
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_mock.h2
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc459
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h4
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc4
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h8
-rw-r--r--gpu/command_buffer/service/gpu_control_service.cc5
-rw-r--r--gpu/command_buffer/service/gpu_control_service.h1
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.cc32
-rw-r--r--gpu/command_buffer/service/in_process_command_buffer.h4
-rw-r--r--gpu/command_buffer/service/stream_texture.h32
-rw-r--r--gpu/command_buffer/service/stream_texture_manager.h36
-rw-r--r--gpu/command_buffer/service/stream_texture_manager_in_process_android.cc130
-rw-r--r--gpu/command_buffer/service/stream_texture_manager_in_process_android.h55
-rw-r--r--gpu/command_buffer/service/stream_texture_manager_mock.cc15
-rw-r--r--gpu/command_buffer/service/stream_texture_manager_mock.h32
-rw-r--r--gpu/command_buffer/service/stream_texture_mock.cc15
-rw-r--r--gpu/command_buffer/service/stream_texture_mock.h28
-rw-r--r--gpu/command_buffer/service/texture_manager.cc23
-rw-r--r--gpu/command_buffer/service/texture_manager.h41
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc35
-rw-r--r--gpu/command_buffer/tests/gl_manager.cc1
-rw-r--r--gpu/command_buffer_service.gypi2
-rw-r--r--gpu/gles2_conform_support/egl/display.cc2
-rw-r--r--gpu/gpu.gyp4
-rw-r--r--ppapi/proxy/ppapi_command_buffer_proxy.cc5
-rw-r--r--ppapi/proxy/ppapi_command_buffer_proxy.h1
67 files changed, 592 insertions, 1424 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc
index 0d31a91..c785dcb 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -448,6 +448,16 @@ void CommandBufferProxyImpl::Echo(const base::Closure& callback) {
echo_tasks_.push(callback);
}
+uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) {
+ if (last_state_.error != gpu::error::kNoError)
+ return 0;
+
+ int32 stream_id = 0;
+ Send(new GpuCommandBufferMsg_CreateStreamTexture(
+ route_id_, texture_id, &stream_id));
+ return stream_id;
+}
+
uint32 CommandBufferProxyImpl::InsertSyncPoint() {
if (last_state_.error != gpu::error::kNoError)
return 0;
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h
index 357b29e..8da5778 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.h
+++ b/content/common/gpu/client/command_buffer_proxy_impl.h
@@ -114,6 +114,7 @@ class CommandBufferProxyImpl
virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats)
OVERRIDE;
virtual void Echo(const base::Closure& callback) OVERRIDE;
+ virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE;
int GetRouteID() const;
bool ProduceFrontBuffer(const gpu::Mailbox& mailbox);
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
index be273f4..f02a69f 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -39,10 +39,6 @@
#include "ipc/ipc_channel_posix.h"
#endif
-#if defined(OS_ANDROID)
-#include "content/common/gpu/stream_texture_manager_android.h"
-#endif
-
namespace content {
namespace {
@@ -458,9 +454,6 @@ GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager,
log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
disallowed_features_.multisampling =
command_line->HasSwitch(switches::kDisableGLMultisampling);
-#if defined(OS_ANDROID)
- stream_texture_manager_.reset(new StreamTextureManagerAndroid(this));
-#endif
}
diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h
index cf8438b..68ca022 100644
--- a/content/common/gpu/gpu_channel.h
+++ b/content/common/gpu/gpu_channel.h
@@ -38,12 +38,6 @@ class ImageManager;
}
}
-#if defined(OS_ANDROID)
-namespace content {
-class StreamTextureManagerAndroid;
-}
-#endif
-
namespace content {
class DevToolsGpuAgent;
class GpuChannelManager;
@@ -149,12 +143,6 @@ class GpuChannel : public IPC::Listener,
void SetPreemptByFlag(
scoped_refptr<gpu::PreemptionFlag> preemption_flag);
-#if defined(OS_ANDROID)
- StreamTextureManagerAndroid* stream_texture_manager() {
- return stream_texture_manager_.get();
- }
-#endif
-
void CacheShader(const std::string& key, const std::string& shader);
void AddFilter(IPC::ChannelProxy::MessageFilter* filter);
@@ -225,9 +213,6 @@ class GpuChannel : public IPC::Listener,
scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
scoped_refptr<gpu::gles2::ImageManager> image_manager_;
-#if defined(OS_ANDROID)
- scoped_ptr<StreamTextureManagerAndroid> stream_texture_manager_;
-#endif
typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap;
StubMap stubs_;
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 7716d62..ad048c6 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -40,7 +40,7 @@
#endif
#if defined(OS_ANDROID)
-#include "content/common/gpu/stream_texture_manager_android.h"
+#include "content/common/gpu/stream_texture_android.h"
#endif
namespace content {
@@ -141,15 +141,10 @@ GpuCommandBufferStub::GpuCommandBufferStub(
if (share_group) {
context_group_ = share_group->context_group_;
} else {
- gpu::StreamTextureManager* stream_texture_manager = NULL;
-#if defined(OS_ANDROID)
- stream_texture_manager = channel_->stream_texture_manager();
-#endif
context_group_ = new gpu::gles2::ContextGroup(
mailbox_manager,
image_manager,
new GpuCommandBufferMemoryTracker(channel),
- stream_texture_manager,
NULL,
true);
}
@@ -228,6 +223,8 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
OnRegisterGpuMemoryBuffer);
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyGpuMemoryBuffer,
OnDestroyGpuMemoryBuffer);
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateStreamTexture,
+ OnCreateStreamTexture)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -575,6 +572,15 @@ void GpuCommandBufferStub::OnSetLatencyInfo(
latency_info_callback_.Run(latency_info);
}
+void GpuCommandBufferStub::OnCreateStreamTexture(uint32 texture_id,
+ int32* stream_id) {
+#if defined(OS_ANDROID)
+ *stream_id = StreamTexture::Create(this, texture_id);
+#else
+ *stream_id = 0;
+#endif
+}
+
void GpuCommandBufferStub::SetLatencyInfoCallback(
const LatencyInfoCallback& callback) {
latency_info_callback_ = callback;
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index 4539f6a..f79062e 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -197,6 +197,7 @@ class GpuCommandBufferStub
void OnCommandProcessed();
void OnParseError();
void OnSetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info);
+ void OnCreateStreamTexture(uint32 texture_id, int32* stream_id);
void ReportState();
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 765210f..4ee0cab 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -669,6 +669,11 @@ IPC_MESSAGE_ROUTED5(GpuCommandBufferMsg_RegisterGpuMemoryBuffer,
IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_DestroyGpuMemoryBuffer,
int32 /* id */)
+// Attaches an external image stream to the client texture.
+IPC_SYNC_MESSAGE_ROUTED1_1(GpuCommandBufferMsg_CreateStreamTexture,
+ uint32, /* client_texture_id */
+ int32 /* stream_id */)
+
//------------------------------------------------------------------------------
// Accelerated Video Decoder Messages
// These messages are sent from Renderer process to GPU process.
diff --git a/content/common/gpu/stream_texture_android.cc b/content/common/gpu/stream_texture_android.cc
new file mode 100644
index 0000000..1d510e6
--- /dev/null
+++ b/content/common/gpu/stream_texture_android.cc
@@ -0,0 +1,169 @@
+// 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 "content/common/gpu/stream_texture_android.h"
+
+#include "base/bind.h"
+#include "content/common/android/surface_texture_peer.h"
+#include "content/common/gpu/gpu_channel.h"
+#include "content/common/gpu/gpu_messages.h"
+#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
+#include "gpu/command_buffer/service/texture_manager.h"
+#include "ui/gfx/size.h"
+
+namespace content {
+
+using gpu::gles2::ContextGroup;
+using gpu::gles2::GLES2Decoder;
+using gpu::gles2::TextureManager;
+using gpu::gles2::TextureRef;
+
+// static
+int32 StreamTexture::Create(
+ GpuCommandBufferStub* owner_stub,
+ uint32 client_texture_id) {
+ GpuChannel* channel = owner_stub->channel();
+ int32 route_id = channel->GenerateRouteID();
+
+ GLES2Decoder* decoder = owner_stub->decoder();
+ TextureManager* texture_manager =
+ decoder->GetContextGroup()->texture_manager();
+ TextureRef* texture = texture_manager->GetTexture(client_texture_id);
+
+ if (texture && (!texture->texture()->target() ||
+ texture->texture()->target() == GL_TEXTURE_EXTERNAL_OES)) {
+
+ // TODO: Ideally a valid image id was returned to the client so that
+ // it could then call glBindTexImage2D() for doing the following.
+ scoped_refptr<gfx::GLImage> gl_image(
+ new StreamTexture(owner_stub, route_id, texture->service_id()));
+ gfx::Size size = gl_image->GetSize();
+ texture_manager->SetTarget(texture, GL_TEXTURE_EXTERNAL_OES);
+ texture_manager->SetLevelInfo(texture,
+ GL_TEXTURE_EXTERNAL_OES,
+ 0,
+ GL_RGBA,
+ size.width(),
+ size.height(),
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ texture_manager->SetLevelImage(
+ texture, GL_TEXTURE_EXTERNAL_OES, 0, gl_image);
+ return route_id;
+ }
+
+ return 0;
+}
+
+StreamTexture::StreamTexture(GpuCommandBufferStub* owner_stub,
+ int32 route_id,
+ uint32 texture_id)
+ : surface_texture_(new gfx::SurfaceTexture(texture_id)),
+ size_(0, 0),
+ has_updated_(false),
+ owner_stub_(owner_stub),
+ route_id_(route_id),
+ has_listener_(false),
+ weak_factory_(this) {
+ owner_stub->AddDestructionObserver(this);
+ memset(current_matrix_, 0, sizeof(current_matrix_));
+ owner_stub->channel()->AddRoute(route_id, this);
+}
+
+StreamTexture::~StreamTexture() {
+ if (owner_stub_) {
+ owner_stub_->RemoveDestructionObserver(this);
+ owner_stub_->channel()->RemoveRoute(route_id_);
+ }
+}
+
+void StreamTexture::OnWillDestroyStub() {
+ owner_stub_->RemoveDestructionObserver(this);
+ owner_stub_->channel()->RemoveRoute(route_id_);
+ owner_stub_ = NULL;
+
+ // If the owner goes away, there is no need to keep the SurfaceTexture around.
+ // The GL texture will keep working regardless with the currently bound frame.
+ surface_texture_ = NULL;
+}
+
+void StreamTexture::Destroy() {
+ NOTREACHED();
+}
+
+void StreamTexture::WillUseTexImage() {
+ if (!owner_stub_)
+ return;
+
+ // TODO(sievers): Update also when used in a different context.
+ // Also see crbug.com/309162.
+ if (surface_texture_.get() &&
+ owner_stub_->decoder()->GetGLContext()->IsCurrent(NULL)) {
+ surface_texture_->UpdateTexImage();
+ }
+
+ if (has_listener_) {
+ float mtx[16];
+ surface_texture_->GetTransformMatrix(mtx);
+
+ // Only query the matrix once we have bound a valid frame.
+ if (has_updated_ && memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) {
+ memcpy(current_matrix_, mtx, sizeof(mtx));
+
+ GpuStreamTextureMsg_MatrixChanged_Params params;
+ memcpy(&params.m00, mtx, sizeof(mtx));
+ owner_stub_->channel()->Send(
+ new GpuStreamTextureMsg_MatrixChanged(route_id_, params));
+ }
+ }
+}
+
+void StreamTexture::OnFrameAvailable() {
+ has_updated_ = true;
+ DCHECK(has_listener_);
+ if (owner_stub_) {
+ owner_stub_->channel()->Send(
+ new GpuStreamTextureMsg_FrameAvailable(route_id_));
+ }
+}
+
+gfx::Size StreamTexture::GetSize() {
+ return size_;
+}
+
+bool StreamTexture::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(StreamTexture, message)
+ IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_StartListening, OnStartListening)
+ IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_EstablishPeer, OnEstablishPeer)
+ IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_SetSize, OnSetSize)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ DCHECK(handled);
+ return handled;
+}
+
+void StreamTexture::OnStartListening() {
+ DCHECK(!has_listener_);
+ has_listener_ = true;
+ surface_texture_->SetFrameAvailableCallback(base::Bind(
+ &StreamTexture::OnFrameAvailable, weak_factory_.GetWeakPtr()));
+}
+
+void StreamTexture::OnEstablishPeer(int32 primary_id, int32 secondary_id) {
+ if (!owner_stub_)
+ return;
+
+ base::ProcessHandle process = owner_stub_->channel()->renderer_pid();
+
+ SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer(
+ process, surface_texture_, primary_id, secondary_id);
+}
+
+} // namespace content
diff --git a/content/common/gpu/stream_texture_android.h b/content/common/gpu/stream_texture_android.h
new file mode 100644
index 0000000..50ab567
--- /dev/null
+++ b/content/common/gpu/stream_texture_android.h
@@ -0,0 +1,75 @@
+// 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.
+
+#ifndef CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_
+#define CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_
+
+#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
+#include "content/common/gpu/gpu_command_buffer_stub.h"
+#include "ipc/ipc_listener.h"
+#include "ui/gl/android/surface_texture.h"
+#include "ui/gl/gl_image.h"
+
+namespace gfx {
+class Size;
+}
+
+namespace content {
+
+class StreamTexture : public gfx::GLImage,
+ public IPC::Listener,
+ public GpuCommandBufferStub::DestructionObserver {
+ public:
+ static int32 Create(GpuCommandBufferStub* owner_stub,
+ uint32 client_texture_id);
+
+ private:
+ StreamTexture(GpuCommandBufferStub* owner_stub,
+ int32 route_id,
+ uint32 texture_id);
+ virtual ~StreamTexture();
+
+ // gfx::GLImage implementation:
+ virtual void Destroy() OVERRIDE;
+ virtual gfx::Size GetSize() OVERRIDE;
+ virtual void WillUseTexImage() OVERRIDE;
+ virtual void DidUseTexImage() OVERRIDE {}
+
+ // GpuCommandBufferStub::DestructionObserver implementation.
+ virtual void OnWillDestroyStub() OVERRIDE;
+
+ // Called when a new frame is available for the SurfaceTexture.
+ void OnFrameAvailable();
+
+ // IPC::Listener implementation:
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // IPC message handlers:
+ void OnStartListening();
+ void OnEstablishPeer(int32 primary_id, int32 secondary_id);
+ void OnSetSize(const gfx::Size& size) { size_ = size; }
+
+ scoped_refptr<gfx::SurfaceTexture> surface_texture_;
+
+ // Current transform matrix of the surface texture.
+ float current_matrix_[16];
+
+ // Current size of the surface texture.
+ gfx::Size size_;
+
+ // Whether the surface texture has been updated.
+ bool has_updated_;
+
+ GpuCommandBufferStub* owner_stub_;
+ int32 route_id_;
+ bool has_listener_;
+
+ base::WeakPtrFactory<StreamTexture> weak_factory_;
+ DISALLOW_COPY_AND_ASSIGN(StreamTexture);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_ANDROID_H_
diff --git a/content/common/gpu/stream_texture_manager_android.cc b/content/common/gpu/stream_texture_manager_android.cc
deleted file mode 100644
index 31557b5..0000000
--- a/content/common/gpu/stream_texture_manager_android.cc
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright (c) 2012 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/stream_texture_manager_android.h"
-
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "content/common/android/surface_texture_peer.h"
-#include "content/common/gpu/gpu_channel.h"
-#include "content/common/gpu/gpu_messages.h"
-#include "gpu/command_buffer/service/stream_texture.h"
-#include "ipc/ipc_listener.h"
-#include "ui/gfx/size.h"
-#include "ui/gl/android/surface_texture.h"
-#include "ui/gl/gl_bindings.h"
-
-namespace content {
-
-namespace {
-
-class StreamTextureImpl : public gpu::StreamTexture,
- public IPC::Listener {
- public:
- StreamTextureImpl(GpuChannel* channel, int service_id, int32 route_id);
- virtual ~StreamTextureImpl();
-
- // gpu::StreamTexture implementation:
- virtual void Update() OVERRIDE;
- virtual gfx::Size GetSize() OVERRIDE;
-
- // IPC::Listener implementation:
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- private:
- // Called when a new frame is available for the SurfaceTexture.
- void OnFrameAvailable();
-
- // IPC message handlers:
- void OnStartListening();
- void OnEstablishPeer(int32 primary_id, int32 secondary_id);
- void OnSetSize(const gfx::Size& size) { size_ = size; }
-
- scoped_refptr<gfx::SurfaceTexture> surface_texture_;
-
- // Current transform matrix of the surface texture.
- float current_matrix_[16];
-
- // Current size of the surface texture.
- gfx::Size size_;
-
- // Whether the surface texture has been updated.
- bool has_updated_;
-
- GpuChannel* channel_;
- int32 route_id_;
- bool has_listener_;
-
- base::WeakPtrFactory<StreamTextureImpl> weak_factory_;
- DISALLOW_COPY_AND_ASSIGN(StreamTextureImpl);
-};
-
-StreamTextureImpl::StreamTextureImpl(GpuChannel* channel,
- int service_id,
- int32 route_id)
- : surface_texture_(new gfx::SurfaceTexture(service_id)),
- size_(0, 0),
- has_updated_(false),
- channel_(channel),
- route_id_(route_id),
- has_listener_(false),
- weak_factory_(this) {
- memset(current_matrix_, 0, sizeof(current_matrix_));
- channel_->AddRoute(route_id, this);
-}
-
-StreamTextureImpl::~StreamTextureImpl() {
- channel_->RemoveRoute(route_id_);
-}
-
-void StreamTextureImpl::Update() {
- surface_texture_->UpdateTexImage();
- if (!has_listener_)
- return;
-
- float mtx[16];
- surface_texture_->GetTransformMatrix(mtx);
-
- // Only query the matrix once we have bound a valid frame.
- if (has_updated_ && memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) {
- memcpy(current_matrix_, mtx, sizeof(mtx));
-
- GpuStreamTextureMsg_MatrixChanged_Params params;
- memcpy(&params.m00, mtx, sizeof(mtx));
- channel_->Send(new GpuStreamTextureMsg_MatrixChanged(route_id_, params));
- }
-}
-
-void StreamTextureImpl::OnFrameAvailable() {
- has_updated_ = true;
- DCHECK(has_listener_);
- channel_->Send(new GpuStreamTextureMsg_FrameAvailable(route_id_));
-}
-
-gfx::Size StreamTextureImpl::GetSize() {
- return size_;
-}
-
-bool StreamTextureImpl::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(StreamTextureImpl, message)
- IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_StartListening, OnStartListening)
- IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_EstablishPeer, OnEstablishPeer)
- IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_SetSize, OnSetSize)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- DCHECK(handled);
- return handled;
-}
-
-void StreamTextureImpl::OnStartListening() {
- DCHECK(!has_listener_);
- has_listener_ = true;
- surface_texture_->SetFrameAvailableCallback(base::Bind(
- &StreamTextureImpl::OnFrameAvailable, weak_factory_.GetWeakPtr()));
-}
-
-void StreamTextureImpl::OnEstablishPeer(int32 primary_id, int32 secondary_id) {
- base::ProcessHandle process = channel_->renderer_pid();
-
- SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer(
- process, surface_texture_, primary_id, secondary_id);
-}
-
-} // anonymous namespace
-
-StreamTextureManagerAndroid::StreamTextureManagerAndroid(
- GpuChannel* channel)
- : channel_(channel) {
-}
-
-StreamTextureManagerAndroid::~StreamTextureManagerAndroid() {
- DCHECK(textures_.size() == textures_from_service_id_.size());
- if (!textures_.IsEmpty())
- LOG(WARNING) << "Undestroyed surface textures while closing GPU channel.";
-}
-
-GLuint StreamTextureManagerAndroid::CreateStreamTexture(uint32 service_id,
- uint32 client_id) {
- // service_id: the actual GL texture name
- // client_id: texture name given to the client in the renderer (unused here)
- // The return value here is what glCreateStreamTextureCHROMIUM() will return
- // to identify the stream (i.e. surface texture).
- int32 route_id = channel_->GenerateRouteID();
- StreamTextureImpl* texture =
- new StreamTextureImpl(channel_, service_id, route_id);
- textures_from_service_id_.AddWithID(texture, service_id);
- textures_.AddWithID(texture, route_id);
- return route_id;
-}
-
-void StreamTextureManagerAndroid::DestroyStreamTexture(uint32 service_id) {
- gpu::StreamTexture* texture = textures_from_service_id_.Lookup(service_id);
- if (texture) {
- textures_from_service_id_.Remove(service_id);
-
- for (TextureMap::Iterator<gpu::StreamTexture> it(&textures_);
- !it.IsAtEnd(); it.Advance()) {
- if (it.GetCurrentValue() == texture) {
- textures_.Remove(it.GetCurrentKey());
- break;
- }
- }
- }
-}
-
-gpu::StreamTexture* StreamTextureManagerAndroid::LookupStreamTexture(
- uint32 service_id) {
- return textures_from_service_id_.Lookup(service_id);
-}
-
-} // namespace content
diff --git a/content/common/gpu/stream_texture_manager_android.h b/content/common/gpu/stream_texture_manager_android.h
deleted file mode 100644
index b9474bb..0000000
--- a/content/common/gpu/stream_texture_manager_android.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2012 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_STREAM_TEXTURE_MANAGER_ANDROID_H_
-#define CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_
-
-#include "base/id_map.h"
-#include "gpu/command_buffer/service/stream_texture.h"
-#include "gpu/command_buffer/service/stream_texture_manager.h"
-
-struct GpuStreamTextureMsg_MatrixChanged_Params;
-
-namespace gfx {
-class Size;
-class SurfaceTexture;
-}
-
-namespace content {
-class GpuChannel;
-
-// Class for managing the stream texture.
-class StreamTextureManagerAndroid : public gpu::StreamTextureManager {
- public:
- StreamTextureManagerAndroid(GpuChannel* channel);
- virtual ~StreamTextureManagerAndroid();
-
- // implement gpu::StreamTextureManager:
- virtual uint32 CreateStreamTexture(uint32 service_id,
- uint32 client_id) OVERRIDE;
- virtual void DestroyStreamTexture(uint32 service_id) OVERRIDE;
- virtual gpu::StreamTexture* LookupStreamTexture(uint32 service_id) OVERRIDE;
-
- private:
- GpuChannel* channel_;
-
- typedef IDMap<gpu::StreamTexture, IDMapOwnPointer> TextureMap;
- TextureMap textures_;
-
- // Map for more convenient lookup.
- typedef IDMap<gpu::StreamTexture, IDMapExternalPointer> TextureServiceIdMap;
- TextureServiceIdMap textures_from_service_id_;
-
- DISALLOW_COPY_AND_ASSIGN(StreamTextureManagerAndroid);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_GPU_STREAM_TEXTURE_MANAGER_ANDROID_H_
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 7ad3e0c..ac20cba 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -246,8 +246,8 @@
'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/stream_texture_manager_android.cc',
- 'common/gpu/stream_texture_manager_android.h',
+ 'common/gpu/stream_texture_android.cc',
+ 'common/gpu/stream_texture_android.h',
'common/gpu/sync_point_manager.cc',
'common/gpu/sync_point_manager.h',
'common/gpu/texture_image_transport_surface.cc',
diff --git a/content/renderer/media/android/stream_texture_factory_android_impl.cc b/content/renderer/media/android/stream_texture_factory_android_impl.cc
index b69d4d6..8febd3f 100644
--- a/content/renderer/media/android/stream_texture_factory_android_impl.cc
+++ b/content/renderer/media/android/stream_texture_factory_android_impl.cc
@@ -124,9 +124,6 @@ unsigned StreamTextureFactoryImpl::CreateStreamTexture(
void StreamTextureFactoryImpl::DestroyStreamTexture(unsigned texture_id) {
gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
- // TODO(sievers): Make the DestroyStreamTexture implicit when the last
- // texture referencing it is lost.
- gl->DestroyStreamTextureCHROMIUM(texture_id);
gl->DeleteTextures(1, &texture_id);
gl->Flush();
}
diff --git a/content/renderer/media/android/stream_texture_factory_android_synchronous_impl.cc b/content/renderer/media/android/stream_texture_factory_android_synchronous_impl.cc
index c19b5c6..0c65e41 100644
--- a/content/renderer/media/android/stream_texture_factory_android_synchronous_impl.cc
+++ b/content/renderer/media/android/stream_texture_factory_android_synchronous_impl.cc
@@ -174,7 +174,6 @@ void StreamTextureFactorySynchronousImpl::DestroyStreamTexture(
unsigned texture_id) {
DCHECK(context_provider_);
GLES2Interface* gl = context_provider_->ContextGL();
- gl->DestroyStreamTextureCHROMIUM(texture_id);
gl->DeleteTextures(1, &texture_id);
gl->Flush();
}
diff --git a/gpu/GLES2/gl2chromium_autogen.h b/gpu/GLES2/gl2chromium_autogen.h
index 968962be..62b22d5 100644
--- a/gpu/GLES2/gl2chromium_autogen.h
+++ b/gpu/GLES2/gl2chromium_autogen.h
@@ -204,8 +204,6 @@
#define glGetProgramInfoCHROMIUM GLES2_GET_FUN(GetProgramInfoCHROMIUM)
#define glCreateStreamTextureCHROMIUM GLES2_GET_FUN( \
CreateStreamTextureCHROMIUM)
-#define glDestroyStreamTextureCHROMIUM GLES2_GET_FUN( \
- DestroyStreamTextureCHROMIUM)
#define glCreateImageCHROMIUM GLES2_GET_FUN(CreateImageCHROMIUM)
#define glDestroyImageCHROMIUM GLES2_GET_FUN(DestroyImageCHROMIUM)
#define glGetImageParameterivCHROMIUM GLES2_GET_FUN( \
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 4c228a1..4eb9c47 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -2233,23 +2233,13 @@ _FUNCTION_INFO = {
'client_test': False,
},
'CreateStreamTextureCHROMIUM': {
- 'type': 'Custom',
- 'cmd_args': 'GLuint client_id, void* result',
- 'result': ['GLuint'],
- 'immediate': False,
- 'impl_func': False,
- 'expectation': False,
- 'extension': True,
- 'chromium': True,
- 'client_test': False,
- },
- 'DestroyStreamTextureCHROMIUM': {
- 'type': 'Custom',
+ 'type': 'HandWritten',
'impl_func': False,
- 'expectation': False,
+ 'gen_cmd': False,
+ 'immediate': False,
'extension': True,
'chromium': True,
- },
+ },
'TexImageIOSurface2DCHROMIUM': {
'decoder_func': 'DoTexImageIOSurface2DCHROMIUM',
'unit_test': False,
diff --git a/gpu/command_buffer/client/client_test_helper.h b/gpu/command_buffer/client/client_test_helper.h
index e071f5a..c6d6e02 100644
--- a/gpu/command_buffer/client/client_test_helper.h
+++ b/gpu/command_buffer/client/client_test_helper.h
@@ -105,6 +105,7 @@ class MockClientGpuControl : public GpuControl {
MOCK_METHOD1(SetSurfaceVisible, void(bool visible));
MOCK_METHOD1(SendManagedMemoryStats,
void(const ManagedMemoryStats& stats));
+ MOCK_METHOD1(CreateStreamTexture, uint32(uint32));
private:
DISALLOW_COPY_AND_ASSIGN(MockClientGpuControl);
diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h
index d2a091f..717604d 100644
--- a/gpu/command_buffer/client/gles2_c_lib_autogen.h
+++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h
@@ -657,9 +657,6 @@ void GLES2GetProgramInfoCHROMIUM(
GLuint GLES2CreateStreamTextureCHROMIUM(GLuint texture) {
return gles2::GetGLContext()->CreateStreamTextureCHROMIUM(texture);
}
-void GLES2DestroyStreamTextureCHROMIUM(GLuint texture) {
- gles2::GetGLContext()->DestroyStreamTextureCHROMIUM(texture);
-}
GLuint GLES2CreateImageCHROMIUM(
GLsizei width, GLsizei height, GLenum internalformat) {
return gles2::GetGLContext()->CreateImageCHROMIUM(
@@ -1070,8 +1067,6 @@ extern const NameToFunc g_gles2_function_table[] = {
glGetProgramInfoCHROMIUM), },
{ "glCreateStreamTextureCHROMIUM", reinterpret_cast<GLES2FunctionPointer>(
glCreateStreamTextureCHROMIUM), },
- { "glDestroyStreamTextureCHROMIUM", reinterpret_cast<GLES2FunctionPointer>(
- glDestroyStreamTextureCHROMIUM), },
{ "glCreateImageCHROMIUM", reinterpret_cast<GLES2FunctionPointer>(
glCreateImageCHROMIUM), },
{ "glDestroyImageCHROMIUM", reinterpret_cast<GLES2FunctionPointer>(
diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
index b4ec2c3..1ff6dc4 100644
--- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
+++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h
@@ -1754,23 +1754,6 @@
}
}
- void CreateStreamTextureCHROMIUM(
- GLuint client_id, uint32 result_shm_id, uint32 result_shm_offset) {
- gles2::cmds::CreateStreamTextureCHROMIUM* c =
- GetCmdSpace<gles2::cmds::CreateStreamTextureCHROMIUM>();
- if (c) {
- c->Init(client_id, result_shm_id, result_shm_offset);
- }
- }
-
- void DestroyStreamTextureCHROMIUM(GLuint texture) {
- gles2::cmds::DestroyStreamTextureCHROMIUM* c =
- GetCmdSpace<gles2::cmds::DestroyStreamTextureCHROMIUM>();
- if (c) {
- c->Init(texture);
- }
- }
-
void GetTranslatedShaderSourceANGLE(GLuint shader, uint32 bucket_id) {
gles2::cmds::GetTranslatedShaderSourceANGLE* c =
GetCmdSpace<gles2::cmds::GetTranslatedShaderSourceANGLE>();
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 93aa3d63..0133311 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -3207,29 +3207,8 @@ GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) {
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] CreateStreamTextureCHROMIUM("
<< texture << ")");
TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM");
- typedef cmds::CreateStreamTextureCHROMIUM::Result Result;
- Result* result = GetResultAs<Result*>();
- if (!result) {
- return GL_ZERO;
- }
- *result = GL_ZERO;
-
- helper_->CreateStreamTextureCHROMIUM(texture,
- GetResultShmId(),
- GetResultShmOffset());
- WaitForCmd();
- GLuint result_value = *result;
- CheckGLError();
- return result_value;
-}
-
-void GLES2Implementation::DestroyStreamTextureCHROMIUM(GLuint texture) {
- GPU_CLIENT_SINGLE_THREAD_CHECK();
- GPU_CLIENT_LOG("[" << GetLogPrefix() << "] DestroyStreamTextureCHROMIUM("
- << texture << ")");
- TRACE_EVENT0("gpu", "GLES2::DestroyStreamTextureCHROMIUM");
- helper_->DestroyStreamTextureCHROMIUM(texture);
- CheckGLError();
+ helper_->CommandBufferHelper::Flush();
+ return gpu_control_->CreateStreamTexture(texture);
}
void GLES2Implementation::PostSubBufferCHROMIUM(
diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h
index bf5c18e..0c54dc3 100644
--- a/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -481,8 +481,6 @@ virtual void GetProgramInfoCHROMIUM(
virtual GLuint CreateStreamTextureCHROMIUM(GLuint texture) OVERRIDE;
-virtual void DestroyStreamTextureCHROMIUM(GLuint texture) OVERRIDE;
-
virtual GLuint CreateImageCHROMIUM(
GLsizei width, GLsizei height, GLenum internalformat) OVERRIDE;
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index dbb9b21..6103309 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -2444,34 +2444,6 @@ TEST_F(GLES2ImplementationStrictSharedTest, BindsNotCached) {
}
}
-TEST_F(GLES2ImplementationTest, CreateStreamTextureCHROMIUM) {
- const GLuint kTextureId = 123;
- const GLuint kResult = 456;
-
- struct Cmds {
- cmds::CreateStreamTextureCHROMIUM create_stream;
- };
-
- ExpectedMemoryInfo result1 =
- GetExpectedResultMemory(
- sizeof(cmds::CreateStreamTextureCHROMIUM::Result));
- ExpectedMemoryInfo result2 =
- GetExpectedResultMemory(sizeof(cmds::GetError::Result));
-
- Cmds expected;
- expected.create_stream.Init(kTextureId, result1.id, result1.offset);
-
- EXPECT_CALL(*command_buffer(), OnFlush())
- .WillOnce(SetMemory(result1.ptr, kResult))
- .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR)))
- .RetiresOnSaturation();
-
- GLuint handle = gl_->CreateStreamTextureCHROMIUM(kTextureId);
- EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
- EXPECT_EQ(handle, kResult);
- EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError());
-}
-
TEST_F(GLES2ImplementationTest, GetString) {
const uint32 kBucketId = GLES2Implementation::kResultBucketId;
const Str7 kString = {"foobar"};
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
index 5913f2b..6cefd1d 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_unittest_autogen.h
@@ -1691,17 +1691,7 @@ TEST_F(GLES2ImplementationTest, ResizeCHROMIUM) {
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
}
// TODO: Implement unit test for GetRequestableExtensionsCHROMIUM
-
-TEST_F(GLES2ImplementationTest, DestroyStreamTextureCHROMIUM) {
- struct Cmds {
- cmds::DestroyStreamTextureCHROMIUM cmd;
- };
- Cmds expected;
- expected.cmd.Init(1);
-
- gl_->DestroyStreamTextureCHROMIUM(1);
- EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
-}
+// TODO: Implement unit test for CreateStreamTextureCHROMIUM
// TODO: Implement unit test for GetTranslatedShaderSourceANGLE
TEST_F(GLES2ImplementationTest, TexImageIOSurface2DCHROMIUM) {
diff --git a/gpu/command_buffer/client/gles2_interface_autogen.h b/gpu/command_buffer/client/gles2_interface_autogen.h
index 16d3996..c7020e3 100644
--- a/gpu/command_buffer/client/gles2_interface_autogen.h
+++ b/gpu/command_buffer/client/gles2_interface_autogen.h
@@ -277,7 +277,6 @@ virtual void GetMultipleIntegervCHROMIUM(
virtual void GetProgramInfoCHROMIUM(
GLuint program, GLsizei bufsize, GLsizei* size, void* info) = 0;
virtual GLuint CreateStreamTextureCHROMIUM(GLuint texture) = 0;
-virtual void DestroyStreamTextureCHROMIUM(GLuint texture) = 0;
virtual GLuint CreateImageCHROMIUM(
GLsizei width, GLsizei height, GLenum internalformat) = 0;
virtual void DestroyImageCHROMIUM(GLuint image_id) = 0;
diff --git a/gpu/command_buffer/client/gles2_interface_stub_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_autogen.h
index d2dee87..45ec0e4 100644
--- a/gpu/command_buffer/client/gles2_interface_stub_autogen.h
+++ b/gpu/command_buffer/client/gles2_interface_stub_autogen.h
@@ -306,7 +306,6 @@ virtual void GetMultipleIntegervCHROMIUM(
virtual void GetProgramInfoCHROMIUM(
GLuint program, GLsizei bufsize, GLsizei* size, void* info) OVERRIDE;
virtual GLuint CreateStreamTextureCHROMIUM(GLuint texture) OVERRIDE;
-virtual void DestroyStreamTextureCHROMIUM(GLuint texture) OVERRIDE;
virtual GLuint CreateImageCHROMIUM(
GLsizei width, GLsizei height, GLenum internalformat) OVERRIDE;
virtual void DestroyImageCHROMIUM(GLuint image_id) OVERRIDE;
diff --git a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
index 3f87538..539ea70 100644
--- a/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
+++ b/gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h
@@ -580,8 +580,6 @@ void GLES2InterfaceStub::GetProgramInfoCHROMIUM(
GLuint GLES2InterfaceStub::CreateStreamTextureCHROMIUM(GLuint /* texture */) {
return 0;
}
-void GLES2InterfaceStub::DestroyStreamTextureCHROMIUM(GLuint /* texture */) {
-}
GLuint GLES2InterfaceStub::CreateImageCHROMIUM(
GLsizei /* width */, GLsizei /* height */, GLenum /* internalformat */) {
return 0;
diff --git a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
index a4b56d6..bd2d9a2 100644
--- a/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_trace_implementation_autogen.h
@@ -306,7 +306,6 @@ virtual void GetMultipleIntegervCHROMIUM(
virtual void GetProgramInfoCHROMIUM(
GLuint program, GLsizei bufsize, GLsizei* size, void* info) OVERRIDE;
virtual GLuint CreateStreamTextureCHROMIUM(GLuint texture) OVERRIDE;
-virtual void DestroyStreamTextureCHROMIUM(GLuint texture) OVERRIDE;
virtual GLuint CreateImageCHROMIUM(
GLsizei width, GLsizei height, GLenum internalformat) OVERRIDE;
virtual void DestroyImageCHROMIUM(GLuint image_id) OVERRIDE;
diff --git a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
index 35776ce..c8a052b 100644
--- a/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
+++ b/gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h
@@ -1073,11 +1073,6 @@ GLuint GLES2TraceImplementation::CreateStreamTextureCHROMIUM(GLuint texture) {
return gl_->CreateStreamTextureCHROMIUM(texture);
}
-void GLES2TraceImplementation::DestroyStreamTextureCHROMIUM(GLuint texture) {
- TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::DestroyStreamTextureCHROMIUM"); // NOLINT
- gl_->DestroyStreamTextureCHROMIUM(texture);
-}
-
GLuint GLES2TraceImplementation::CreateImageCHROMIUM(
GLsizei width, GLsizei height, GLenum internalformat) {
TRACE_EVENT_BINARY_EFFICIENT0("gpu", "GLES2Trace::CreateImageCHROMIUM");
diff --git a/gpu/command_buffer/cmd_buffer_functions.txt b/gpu/command_buffer/cmd_buffer_functions.txt
index eeb4760..0aba02e 100644
--- a/gpu/command_buffer/cmd_buffer_functions.txt
+++ b/gpu/command_buffer/cmd_buffer_functions.txt
@@ -192,7 +192,6 @@ GL_APICALL void GL_APIENTRY glRateLimitOffscreenContextCHROMIUM (void);
GL_APICALL void GL_APIENTRY glGetMultipleIntegervCHROMIUM (const GLenum* pnames, GLuint count, GLint* results, GLsizeiptr size);
GL_APICALL void GL_APIENTRY glGetProgramInfoCHROMIUM (GLidProgram program, GLsizeiNotNegative bufsize, GLsizei* size, void* info);
GL_APICALL GLuint GL_APIENTRY glCreateStreamTextureCHROMIUM (GLuint texture);
-GL_APICALL void GL_APIENTRY glDestroyStreamTextureCHROMIUM (GLuint texture);
GL_APICALL GLuint GL_APIENTRY glCreateImageCHROMIUM (GLsizei width, GLsizei height, GLenum internalformat);
GL_APICALL void GL_APIENTRY glDestroyImageCHROMIUM (GLuint image_id);
GL_APICALL void GL_APIENTRY glGetImageParameterivCHROMIUM (GLuint image_id, GLenum pname, GLint* params);
diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
index a6c741e..34c50c2 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -9504,90 +9504,6 @@ COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM::Result, num_attribs) == 4,
COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM::Result, num_uniforms) == 8,
OffsetOf_GetProgramInfoCHROMIUM_Result_num_uniforms_not_8);
-struct CreateStreamTextureCHROMIUM {
- typedef CreateStreamTextureCHROMIUM ValueType;
- static const CommandId kCmdId = kCreateStreamTextureCHROMIUM;
- static const cmd::ArgFlags kArgFlags = cmd::kFixed;
- static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
-
- typedef GLuint Result;
-
- static uint32 ComputeSize() {
- return static_cast<uint32>(sizeof(ValueType)); // NOLINT
- }
-
- void SetHeader() {
- header.SetCmd<ValueType>();
- }
-
- void Init(
- GLuint _client_id, uint32 _result_shm_id, uint32 _result_shm_offset) {
- SetHeader();
- client_id = _client_id;
- result_shm_id = _result_shm_id;
- result_shm_offset = _result_shm_offset;
- }
-
- void* Set(
- void* cmd, GLuint _client_id, uint32 _result_shm_id,
- uint32 _result_shm_offset) {
- static_cast<ValueType*>(
- cmd)->Init(_client_id, _result_shm_id, _result_shm_offset);
- return NextCmdAddress<ValueType>(cmd);
- }
-
- gpu::CommandHeader header;
- uint32 client_id;
- uint32 result_shm_id;
- uint32 result_shm_offset;
-};
-
-COMPILE_ASSERT(sizeof(CreateStreamTextureCHROMIUM) == 16,
- Sizeof_CreateStreamTextureCHROMIUM_is_not_16);
-COMPILE_ASSERT(offsetof(CreateStreamTextureCHROMIUM, header) == 0,
- OffsetOf_CreateStreamTextureCHROMIUM_header_not_0);
-COMPILE_ASSERT(offsetof(CreateStreamTextureCHROMIUM, client_id) == 4,
- OffsetOf_CreateStreamTextureCHROMIUM_client_id_not_4);
-COMPILE_ASSERT(offsetof(CreateStreamTextureCHROMIUM, result_shm_id) == 8,
- OffsetOf_CreateStreamTextureCHROMIUM_result_shm_id_not_8);
-COMPILE_ASSERT(offsetof(CreateStreamTextureCHROMIUM, result_shm_offset) == 12,
- OffsetOf_CreateStreamTextureCHROMIUM_result_shm_offset_not_12);
-
-struct DestroyStreamTextureCHROMIUM {
- typedef DestroyStreamTextureCHROMIUM ValueType;
- static const CommandId kCmdId = kDestroyStreamTextureCHROMIUM;
- static const cmd::ArgFlags kArgFlags = cmd::kFixed;
- static const uint8 cmd_flags = CMD_FLAG_SET_TRACE_LEVEL(3);
-
- static uint32 ComputeSize() {
- return static_cast<uint32>(sizeof(ValueType)); // NOLINT
- }
-
- void SetHeader() {
- header.SetCmd<ValueType>();
- }
-
- void Init(GLuint _texture) {
- SetHeader();
- texture = _texture;
- }
-
- void* Set(void* cmd, GLuint _texture) {
- static_cast<ValueType*>(cmd)->Init(_texture);
- return NextCmdAddress<ValueType>(cmd);
- }
-
- gpu::CommandHeader header;
- uint32 texture;
-};
-
-COMPILE_ASSERT(sizeof(DestroyStreamTextureCHROMIUM) == 8,
- Sizeof_DestroyStreamTextureCHROMIUM_is_not_8);
-COMPILE_ASSERT(offsetof(DestroyStreamTextureCHROMIUM, header) == 0,
- OffsetOf_DestroyStreamTextureCHROMIUM_header_not_0);
-COMPILE_ASSERT(offsetof(DestroyStreamTextureCHROMIUM, texture) == 4,
- OffsetOf_DestroyStreamTextureCHROMIUM_texture_not_4);
-
struct GetTranslatedShaderSourceANGLE {
typedef GetTranslatedShaderSourceANGLE ValueType;
static const CommandId kCmdId = kGetTranslatedShaderSourceANGLE;
diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
index abdf94e..efb6daf 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -3801,38 +3801,6 @@ TEST_F(GLES2FormatTest, GetProgramInfoCHROMIUM) {
next_cmd, sizeof(cmd));
}
-TEST_F(GLES2FormatTest, CreateStreamTextureCHROMIUM) {
- cmds::CreateStreamTextureCHROMIUM& cmd =
- *GetBufferAs<cmds::CreateStreamTextureCHROMIUM>();
- void* next_cmd = cmd.Set(
- &cmd,
- static_cast<GLuint>(11),
- static_cast<uint32>(12),
- static_cast<uint32>(13));
- EXPECT_EQ(static_cast<uint32>(cmds::CreateStreamTextureCHROMIUM::kCmdId),
- cmd.header.command);
- EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
- EXPECT_EQ(static_cast<GLuint>(11), cmd.client_id);
- EXPECT_EQ(static_cast<uint32>(12), cmd.result_shm_id);
- EXPECT_EQ(static_cast<uint32>(13), cmd.result_shm_offset);
- CheckBytesWrittenMatchesExpectedSize(
- next_cmd, sizeof(cmd));
-}
-
-TEST_F(GLES2FormatTest, DestroyStreamTextureCHROMIUM) {
- cmds::DestroyStreamTextureCHROMIUM& cmd =
- *GetBufferAs<cmds::DestroyStreamTextureCHROMIUM>();
- void* next_cmd = cmd.Set(
- &cmd,
- static_cast<GLuint>(11));
- EXPECT_EQ(static_cast<uint32>(cmds::DestroyStreamTextureCHROMIUM::kCmdId),
- cmd.header.command);
- EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
- EXPECT_EQ(static_cast<GLuint>(11), cmd.texture);
- CheckBytesWrittenMatchesExpectedSize(
- next_cmd, sizeof(cmd));
-}
-
TEST_F(GLES2FormatTest, GetTranslatedShaderSourceANGLE) {
cmds::GetTranslatedShaderSourceANGLE& cmd =
*GetBufferAs<cmds::GetTranslatedShaderSourceANGLE>();
diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
index 27ee6a4..32a4df5 100644
--- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
@@ -214,37 +214,35 @@
OP(RequestExtensionCHROMIUM) /* 457 */ \
OP(GetMultipleIntegervCHROMIUM) /* 458 */ \
OP(GetProgramInfoCHROMIUM) /* 459 */ \
- OP(CreateStreamTextureCHROMIUM) /* 460 */ \
- OP(DestroyStreamTextureCHROMIUM) /* 461 */ \
- OP(GetTranslatedShaderSourceANGLE) /* 462 */ \
- OP(PostSubBufferCHROMIUM) /* 463 */ \
- OP(TexImageIOSurface2DCHROMIUM) /* 464 */ \
- OP(CopyTextureCHROMIUM) /* 465 */ \
- OP(DrawArraysInstancedANGLE) /* 466 */ \
- OP(DrawElementsInstancedANGLE) /* 467 */ \
- OP(VertexAttribDivisorANGLE) /* 468 */ \
- OP(GenMailboxCHROMIUM) /* 469 */ \
- OP(ProduceTextureCHROMIUM) /* 470 */ \
- OP(ProduceTextureCHROMIUMImmediate) /* 471 */ \
- OP(ConsumeTextureCHROMIUM) /* 472 */ \
- OP(ConsumeTextureCHROMIUMImmediate) /* 473 */ \
- OP(BindUniformLocationCHROMIUM) /* 474 */ \
- OP(BindUniformLocationCHROMIUMBucket) /* 475 */ \
- OP(BindTexImage2DCHROMIUM) /* 476 */ \
- OP(ReleaseTexImage2DCHROMIUM) /* 477 */ \
- OP(TraceBeginCHROMIUM) /* 478 */ \
- OP(TraceEndCHROMIUM) /* 479 */ \
- OP(AsyncTexSubImage2DCHROMIUM) /* 480 */ \
- OP(AsyncTexImage2DCHROMIUM) /* 481 */ \
- OP(WaitAsyncTexImage2DCHROMIUM) /* 482 */ \
- OP(DiscardFramebufferEXT) /* 483 */ \
- OP(DiscardFramebufferEXTImmediate) /* 484 */ \
- OP(LoseContextCHROMIUM) /* 485 */ \
- OP(InsertSyncPointCHROMIUM) /* 486 */ \
- OP(WaitSyncPointCHROMIUM) /* 487 */ \
- OP(DrawBuffersEXT) /* 488 */ \
- OP(DrawBuffersEXTImmediate) /* 489 */ \
- OP(DiscardBackbufferCHROMIUM) /* 490 */ \
+ OP(GetTranslatedShaderSourceANGLE) /* 460 */ \
+ OP(PostSubBufferCHROMIUM) /* 461 */ \
+ OP(TexImageIOSurface2DCHROMIUM) /* 462 */ \
+ OP(CopyTextureCHROMIUM) /* 463 */ \
+ OP(DrawArraysInstancedANGLE) /* 464 */ \
+ OP(DrawElementsInstancedANGLE) /* 465 */ \
+ OP(VertexAttribDivisorANGLE) /* 466 */ \
+ OP(GenMailboxCHROMIUM) /* 467 */ \
+ OP(ProduceTextureCHROMIUM) /* 468 */ \
+ OP(ProduceTextureCHROMIUMImmediate) /* 469 */ \
+ OP(ConsumeTextureCHROMIUM) /* 470 */ \
+ OP(ConsumeTextureCHROMIUMImmediate) /* 471 */ \
+ OP(BindUniformLocationCHROMIUM) /* 472 */ \
+ OP(BindUniformLocationCHROMIUMBucket) /* 473 */ \
+ OP(BindTexImage2DCHROMIUM) /* 474 */ \
+ OP(ReleaseTexImage2DCHROMIUM) /* 475 */ \
+ OP(TraceBeginCHROMIUM) /* 476 */ \
+ OP(TraceEndCHROMIUM) /* 477 */ \
+ OP(AsyncTexSubImage2DCHROMIUM) /* 478 */ \
+ OP(AsyncTexImage2DCHROMIUM) /* 479 */ \
+ OP(WaitAsyncTexImage2DCHROMIUM) /* 480 */ \
+ OP(DiscardFramebufferEXT) /* 481 */ \
+ OP(DiscardFramebufferEXTImmediate) /* 482 */ \
+ OP(LoseContextCHROMIUM) /* 483 */ \
+ OP(InsertSyncPointCHROMIUM) /* 484 */ \
+ OP(WaitSyncPointCHROMIUM) /* 485 */ \
+ OP(DrawBuffersEXT) /* 486 */ \
+ OP(DrawBuffersEXTImmediate) /* 487 */ \
+ OP(DiscardBackbufferCHROMIUM) /* 488 */ \
enum CommandId {
kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this.
diff --git a/gpu/command_buffer/common/gpu_control.h b/gpu/command_buffer/common/gpu_control.h
index d971972..448ab1d 100644
--- a/gpu/command_buffer/common/gpu_control.h
+++ b/gpu/command_buffer/common/gpu_control.h
@@ -63,6 +63,10 @@ class GPU_EXPORT GpuControl {
// Invokes the callback once the context has been flushed.
virtual void Echo(const base::Closure& callback) = 0;
+ // Attaches an external stream to the texture given by |texture_id| and
+ // returns a stream identifier.
+ virtual uint32 CreateStreamTexture(uint32 texture_id) = 0;
+
private:
DISALLOW_COPY_AND_ASSIGN(GpuControl);
};
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index 27af0ab..a0c1d39 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -32,13 +32,11 @@ ContextGroup::ContextGroup(
MailboxManager* mailbox_manager,
ImageManager* image_manager,
MemoryTracker* memory_tracker,
- StreamTextureManager* stream_texture_manager,
FeatureInfo* feature_info,
bool bind_generates_resource)
: mailbox_manager_(mailbox_manager ? mailbox_manager : new MailboxManager),
image_manager_(image_manager ? image_manager : new ImageManager),
memory_tracker_(memory_tracker),
- stream_texture_manager_(stream_texture_manager),
enforce_gl_minimums_(CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnforceGLMinimums)),
bind_generates_resource_(bind_generates_resource),
@@ -180,7 +178,6 @@ bool ContextGroup::Initialize(
max_texture_size,
max_cube_map_texture_size));
texture_manager_->set_framebuffer_manager(framebuffer_manager_.get());
- texture_manager_->set_stream_texture_manager(stream_texture_manager_);
const GLint kMinTextureImageUnits = 8;
const GLint kMinVertexTextureImageUnits = 0;
@@ -319,7 +316,6 @@ void ContextGroup::Destroy(GLES2Decoder* decoder, bool have_context) {
}
memory_tracker_ = NULL;
- stream_texture_manager_ = NULL;
}
IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) {
diff --git a/gpu/command_buffer/service/context_group.h b/gpu/command_buffer/service/context_group.h
index 391db1a..bb15270 100644
--- a/gpu/command_buffer/service/context_group.h
+++ b/gpu/command_buffer/service/context_group.h
@@ -21,7 +21,6 @@
namespace gpu {
class IdAllocatorInterface;
-class StreamTextureManager;
class TransferBufferManagerInterface;
namespace gles2 {
@@ -47,7 +46,6 @@ class GPU_EXPORT ContextGroup : public base::RefCounted<ContextGroup> {
MailboxManager* mailbox_manager,
ImageManager* image_manager,
MemoryTracker* memory_tracker,
- StreamTextureManager* stream_texture_manager,
FeatureInfo* feature_info,
bool bind_generates_resource);
@@ -73,10 +71,6 @@ class GPU_EXPORT ContextGroup : public base::RefCounted<ContextGroup> {
return memory_tracker_.get();
}
- StreamTextureManager* stream_texture_manager() const {
- return stream_texture_manager_;
- }
-
bool bind_generates_resource() {
return bind_generates_resource_;
}
@@ -185,7 +179,6 @@ class GPU_EXPORT ContextGroup : public base::RefCounted<ContextGroup> {
scoped_refptr<MailboxManager> mailbox_manager_;
scoped_refptr<ImageManager> image_manager_;
scoped_refptr<MemoryTracker> memory_tracker_;
- StreamTextureManager* stream_texture_manager_;
scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_;
bool enforce_gl_minimums_;
diff --git a/gpu/command_buffer/service/context_group_unittest.cc b/gpu/command_buffer/service/context_group_unittest.cc
index 84f285d..3cce29c 100644
--- a/gpu/command_buffer/service/context_group_unittest.cc
+++ b/gpu/command_buffer/service/context_group_unittest.cc
@@ -39,7 +39,7 @@ class ContextGroupTest : public testing::Test {
::gfx::MockGLInterface::SetGLInterface(gl_.get());
decoder_.reset(new MockGLES2Decoder());
group_ = scoped_refptr<ContextGroup>(
- new ContextGroup(NULL, NULL, NULL, NULL, NULL, true));
+ new ContextGroup(NULL, NULL, NULL, NULL, true));
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index cacc826..573cec4 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -111,7 +111,6 @@ FeatureInfo::FeatureFlags::FeatureFlags()
npot_ok(false),
enable_texture_float_linear(false),
enable_texture_half_float_linear(false),
- chromium_stream_texture(false),
angle_translated_shader_source(false),
angle_pack_reverse_row_order(false),
arb_texture_rectangle(false),
@@ -244,12 +243,9 @@ void FeatureInfo::InitializeFeatures() {
AddExtensionString("GL_CHROMIUM_resize");
AddExtensionString("GL_CHROMIUM_resource_safe");
AddExtensionString("GL_CHROMIUM_strict_attribs");
- AddExtensionString("GL_CHROMIUM_stream_texture");
AddExtensionString("GL_CHROMIUM_texture_mailbox");
AddExtensionString("GL_EXT_debug_marker");
- feature_flags_.chromium_stream_texture = true;
-
// OES_vertex_array_object is emulated if not present natively,
// so the extension string is always exposed.
AddExtensionString("GL_OES_vertex_array_object");
diff --git a/gpu/command_buffer/service/feature_info.h b/gpu/command_buffer/service/feature_info.h
index ca8c03c..81a7f7c 100644
--- a/gpu/command_buffer/service/feature_info.h
+++ b/gpu/command_buffer/service/feature_info.h
@@ -42,7 +42,6 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool npot_ok;
bool enable_texture_float_linear;
bool enable_texture_half_float_linear;
- bool chromium_stream_texture;
bool angle_translated_shader_source;
bool angle_pack_reverse_row_order;
bool arb_texture_rectangle;
diff --git a/gpu/command_buffer/service/feature_info_unittest.cc b/gpu/command_buffer/service/feature_info_unittest.cc
index bf2b816..53d1527 100644
--- a/gpu/command_buffer/service/feature_info_unittest.cc
+++ b/gpu/command_buffer/service/feature_info_unittest.cc
@@ -110,7 +110,6 @@ TEST_F(FeatureInfoTest, Basic) {
EXPECT_FALSE(info_->feature_flags().oes_egl_image_external);
EXPECT_FALSE(info_->feature_flags().oes_depth24);
EXPECT_FALSE(info_->feature_flags().packed_depth24_stencil8);
- EXPECT_FALSE(info_->feature_flags().chromium_stream_texture);
EXPECT_FALSE(info_->feature_flags().angle_translated_shader_source);
EXPECT_FALSE(info_->feature_flags().angle_pack_reverse_row_order);
EXPECT_FALSE(info_->feature_flags().arb_texture_rectangle);
@@ -810,13 +809,6 @@ TEST_F(FeatureInfoTest, InitializeOES_compressed_ETC1_RGB8_texture) {
GL_ETC1_RGB8_OES));
}
-TEST_F(FeatureInfoTest, InitializeCHROMIUM_stream_texture) {
- SetupInitExpectations("GL_CHROMIUM_stream_texture");
- EXPECT_THAT(info_->extensions(),
- HasSubstr("GL_CHROMIUM_stream_texture"));
- EXPECT_TRUE(info_->feature_flags().chromium_stream_texture);
-}
-
TEST_F(FeatureInfoTest, InitializeEXT_occlusion_query_boolean) {
SetupInitExpectations("GL_EXT_occlusion_query_boolean");
EXPECT_THAT(info_->extensions(),
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index d35a8b1..729ab26 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -52,8 +52,6 @@
#include "gpu/command_buffer/service/shader_manager.h"
#include "gpu/command_buffer/service/shader_translator.h"
#include "gpu/command_buffer/service/shader_translator_cache.h"
-#include "gpu/command_buffer/service/stream_texture.h"
-#include "gpu/command_buffer/service/stream_texture_manager.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "gpu/command_buffer/service/vertex_array_manager.h"
#include "gpu/command_buffer/service/vertex_attrib_manager.h"
@@ -723,10 +721,6 @@ class GLES2DecoderImpl : public GLES2Decoder,
return group_->memory_tracker();
}
- StreamTextureManager* stream_texture_manager() const {
- return group_->stream_texture_manager();
- }
-
bool EnsureGPUMemoryAvailable(size_t estimated_size) {
MemoryTracker* tracker = memory_tracker();
if (tracker) {
@@ -1389,10 +1383,6 @@ class GLES2DecoderImpl : public GLES2Decoder,
const char* function_name, GLuint max_vertex_accessed, bool* simulated);
void RestoreStateForAttrib(GLuint attrib);
- // If texture is a stream texture, this will update the stream to the newest
- // buffer and bind the texture implicitly.
- void UpdateStreamTextureIfNeeded(Texture* texture, GLuint texture_unit_index);
-
// If an image is bound to texture, this will call Will/DidUseTexImage
// if needed.
void DoWillUseTexImageIfNeeded(Texture* texture, GLenum textarget);
@@ -3906,12 +3896,6 @@ void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) {
"glBindTexture", "texture bound to more than 1 target.");
return;
}
- if (texture->IsStreamTexture() && target != GL_TEXTURE_EXTERNAL_OES) {
- LOCAL_SET_GL_ERROR(
- GL_INVALID_OPERATION,
- "glBindTexture", "illegal target for stream texture.");
- return;
- }
LogClientServiceForInfo(texture, client_id, "glBindTexture");
if (texture->target() == 0) {
texture_manager()->SetTarget(texture_ref, target);
@@ -5898,19 +5882,6 @@ void GLES2DecoderImpl::PerformanceWarning(
std::string("PERFORMANCE WARNING: ") + msg);
}
-void GLES2DecoderImpl::UpdateStreamTextureIfNeeded(Texture* texture,
- GLuint texture_unit_index) {
- if (texture && texture->IsStreamTexture()) {
- DCHECK(stream_texture_manager());
- StreamTexture* stream_tex =
- stream_texture_manager()->LookupStreamTexture(texture->service_id());
- if (stream_tex) {
- glActiveTexture(GL_TEXTURE0 + texture_unit_index);
- stream_tex->Update();
- }
- }
-}
-
void GLES2DecoderImpl::DoWillUseTexImageIfNeeded(
Texture* texture, GLenum textarget) {
// This might be supported in the future.
@@ -5952,8 +5923,7 @@ void GLES2DecoderImpl::DoDidUseTexImageIfNeeded(
bool GLES2DecoderImpl::PrepareTexturesForRender() {
DCHECK(state_.current_program.get());
if (!texture_manager()->HaveUnrenderableTextures() &&
- !texture_manager()->HaveImages() &&
- !features().oes_egl_image_external) {
+ !texture_manager()->HaveImages()) {
return true;
}
@@ -5987,19 +5957,15 @@ bool GLES2DecoderImpl::PrepareTexturesForRender() {
}
Texture* texture = texture_ref->texture();
- if (textarget == GL_TEXTURE_2D) {
- gfx::GLImage* image = texture->GetLevelImage(textarget, 0);
- if (image && !texture->IsAttachedToFramebuffer()) {
- ScopedGLErrorSuppressor suppressor(
- "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState());
- textures_set = true;
- glActiveTexture(GL_TEXTURE0 + texture_unit_index);
- image->WillUseTexImage();
- continue;
- }
+ gfx::GLImage* image = texture->GetLevelImage(textarget, 0);
+ if (image && !texture->IsAttachedToFramebuffer()) {
+ ScopedGLErrorSuppressor suppressor(
+ "GLES2DecoderImpl::PrepareTexturesForRender", GetErrorState());
+ textures_set = true;
+ glActiveTexture(GL_TEXTURE0 + texture_unit_index);
+ image->WillUseTexImage();
+ continue;
}
-
- UpdateStreamTextureIfNeeded(texture, texture_unit_index);
}
// else: should this be an error?
}
@@ -6033,16 +5999,14 @@ void GLES2DecoderImpl::RestoreStateForTextures() {
}
Texture* texture = texture_ref->texture();
- if (texture_unit.bind_target == GL_TEXTURE_2D) {
- gfx::GLImage* image = texture->GetLevelImage(
- texture_unit.bind_target, 0);
- if (image && !texture->IsAttachedToFramebuffer()) {
- ScopedGLErrorSuppressor suppressor(
- "GLES2DecoderImpl::RestoreStateForTextures", GetErrorState());
- glActiveTexture(GL_TEXTURE0 + texture_unit_index);
- image->DidUseTexImage();
- continue;
- }
+ gfx::GLImage* image =
+ texture->GetLevelImage(texture_unit.bind_target, 0);
+ if (image && !texture->IsAttachedToFramebuffer()) {
+ ScopedGLErrorSuppressor suppressor(
+ "GLES2DecoderImpl::RestoreStateForTextures", GetErrorState());
+ glActiveTexture(GL_TEXTURE0 + texture_unit_index);
+ image->DidUseTexImage();
+ continue;
}
}
}
@@ -9567,86 +9531,6 @@ bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) {
return vao && vao->IsValid() && !vao->IsDeleted();
}
-error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM(
- uint32 immediate_data_size,
- const cmds::CreateStreamTextureCHROMIUM& c) {
- if (!features().chromium_stream_texture) {
- LOCAL_SET_GL_ERROR(
- GL_INVALID_OPERATION,
- "glOpenStreamTextureCHROMIUM", "not supported.");
- return error::kNoError;
- }
-
- uint32 client_id = c.client_id;
- typedef cmds::CreateStreamTextureCHROMIUM::Result Result;
- Result* result = GetSharedMemoryAs<Result*>(
- c.result_shm_id, c.result_shm_offset, sizeof(*result));
-
- if (!result)
- return error::kOutOfBounds;
- *result = GL_ZERO;
- TextureRef* texture_ref = texture_manager()->GetTexture(client_id);
- if (!texture_ref) {
- LOCAL_SET_GL_ERROR(
- GL_INVALID_VALUE,
- "glCreateStreamTextureCHROMIUM", "bad texture id.");
- return error::kNoError;
- }
-
- Texture* texture = texture_ref->texture();
- if (texture->IsStreamTexture()) {
- LOCAL_SET_GL_ERROR(
- GL_INVALID_OPERATION,
- "glCreateStreamTextureCHROMIUM", "is already a stream texture.");
- return error::kNoError;
- }
-
- if (texture->target() && texture->target() != GL_TEXTURE_EXTERNAL_OES) {
- LOCAL_SET_GL_ERROR(
- GL_INVALID_OPERATION,
- "glCreateStreamTextureCHROMIUM",
- "is already bound to incompatible target.");
- return error::kNoError;
- }
-
- if (!stream_texture_manager())
- return error::kInvalidArguments;
-
- GLuint object_id = stream_texture_manager()->CreateStreamTexture(
- texture->service_id(), client_id);
-
- if (object_id) {
- texture_manager()->SetStreamTexture(texture_ref, true);
- } else {
- LOCAL_SET_GL_ERROR(
- GL_OUT_OF_MEMORY,
- "glCreateStreamTextureCHROMIUM", "failed to create platform texture.");
- }
-
- *result = object_id;
- return error::kNoError;
-}
-
-error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM(
- uint32 immediate_data_size,
- const cmds::DestroyStreamTextureCHROMIUM& c) {
- GLuint client_id = c.texture;
- TextureRef* texture_ref = texture_manager()->GetTexture(client_id);
- if (texture_ref && texture_manager()->IsStreamTextureOwner(texture_ref)) {
- if (!stream_texture_manager())
- return error::kInvalidArguments;
-
- stream_texture_manager()->DestroyStreamTexture(texture_ref->service_id());
- texture_manager()->SetStreamTexture(texture_ref, false);
- } else {
- LOCAL_SET_GL_ERROR(
- GL_INVALID_VALUE,
- "glDestroyStreamTextureCHROMIUM", "bad texture id.");
- }
-
- return error::kNoError;
-}
-
#if defined(OS_MACOSX)
void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) {
TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find(
@@ -9829,26 +9713,22 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
int source_width, source_height, dest_width, dest_height;
- if (source_texture->IsStreamTexture()) {
- DCHECK_EQ(source_texture->target(),
- static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES));
- DCHECK(stream_texture_manager());
- StreamTexture* stream_tex =
- stream_texture_manager()->LookupStreamTexture(
- source_texture->service_id());
- if (!stream_tex) {
+ if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
+ gfx::GLImage* image =
+ source_texture->GetLevelImage(source_texture->target(), 0);
+ if (!image) {
LOCAL_SET_GL_ERROR(
- GL_INVALID_VALUE,
- "glCopyTextureChromium", "Stream texture lookup failed");
+ GL_INVALID_OPERATION,
+ "glCopyTextureChromium", "No external image");
return;
}
- gfx::Size size = stream_tex->GetSize();
+ gfx::Size size = image->GetSize();
source_width = size.width();
source_height = size.height();
if (source_width <= 0 || source_height <= 0) {
LOCAL_SET_GL_ERROR(
GL_INVALID_VALUE,
- "glCopyTextureChromium", "invalid streamtexture size");
+ "glCopyTextureChromium", "invalid image size");
return;
}
} else {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index a0a7274..10e63e6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -28,7 +28,6 @@ namespace gpu {
class AsyncPixelTransferDelegate;
class AsyncPixelTransferManager;
-class StreamTextureManager;
struct Mailbox;
namespace gles2 {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
index a945caf..387e272 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
@@ -21,8 +21,6 @@ class GLSurface;
}
namespace gpu {
-class StreamTextureManager;
-
namespace gles2 {
class ContextGroup;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index cb4f822..dcfd228 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -22,8 +22,6 @@
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/mocks.h"
#include "gpu/command_buffer/service/program_manager.h"
-#include "gpu/command_buffer/service/stream_texture_manager_mock.h"
-#include "gpu/command_buffer/service/stream_texture_mock.h"
#include "gpu/command_buffer/service/test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_implementation.h"
@@ -5680,388 +5678,6 @@ TEST_F(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) {
EXPECT_NE(error::kNoError, ExecuteCmd(cmd4));
}
-TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUM) {
- const GLuint kObjectId = 123;
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- EXPECT_CALL(*stream_texture_manager(), CreateStreamTexture(
- kServiceTextureId, client_texture_id_))
- .WillOnce(Return(kObjectId))
- .RetiresOnSaturation();
-
- CreateStreamTextureCHROMIUM cmd;
- CreateStreamTextureCHROMIUM::Result* result =
- static_cast<CreateStreamTextureCHROMIUM::Result*>(shared_memory_address_);
- cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(kObjectId, *result);
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- EXPECT_TRUE(texture_ref != NULL);
- EXPECT_TRUE(texture_ref->texture()->IsStreamTexture());
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-}
-
-TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUMBadId) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- CreateStreamTextureCHROMIUM cmd;
- CreateStreamTextureCHROMIUM::Result* result =
- static_cast<CreateStreamTextureCHROMIUM::Result*>(shared_memory_address_);
- cmd.Init(kNewClientId, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(static_cast<GLuint>(GL_ZERO), *result);
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
-}
-
-TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUMAlreadyBound) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
- DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
-
- CreateStreamTextureCHROMIUM cmd;
- CreateStreamTextureCHROMIUM::Result* result =
- static_cast<CreateStreamTextureCHROMIUM::Result*>(shared_memory_address_);
- cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(static_cast<GLuint>(GL_ZERO), *result);
- EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
-}
-
-TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUMAlreadySet) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- group().texture_manager()->SetStreamTexture(texture_ref, true);
-
- CreateStreamTextureCHROMIUM cmd;
- cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
-
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-}
-
-TEST_F(GLES2DecoderManualInitTest, DrawStreamTextureCHROMIUM) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions
- "opengl es 2.0", // gl version
- true, // has alpha
- true, // has depth
- false, // has stencil
- true, // request alpha
- true, // request depth
- false, // request stencil
- true); // bind generates resource
-
- StrictMock<MockStreamTexture> stream_texture;
-
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- group().texture_manager()->SetStreamTexture(texture_ref, true);
-
- DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
-
- SetupSamplerExternalProgram();
- SetupIndexBuffer();
- AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0);
- SetupExpectationsForApplyingDefaultDirtyState();
- EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref));
-
- InSequence s;
- EXPECT_CALL(*stream_texture_manager(), LookupStreamTexture(kServiceTextureId))
- .WillOnce(Return(&stream_texture))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
- .Times(1)
- .RetiresOnSaturation();
- EXPECT_CALL(stream_texture, Update())
- .Times(1)
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
- .Times(1);
- DrawElements cmd;
- cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
- kValidIndexRangeStart * 2);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
-
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-}
-
-TEST_F(GLES2DecoderManualInitTest, BindStreamTextureCHROMIUMInvalid) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- group().texture_manager()->SetStreamTexture(texture_ref, true);
-
- BindTexture cmd;
- cmd.Init(GL_TEXTURE_2D, client_texture_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
-
- BindTexture cmd2;
- cmd2.Init(GL_TEXTURE_CUBE_MAP, client_texture_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
- EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
-
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-}
-
-TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUM) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- group().texture_manager()->SetStreamTexture(texture_ref, true);
-
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-
- DestroyStreamTextureCHROMIUM cmd;
- cmd.Init(client_texture_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
- EXPECT_FALSE(texture_ref->texture()->IsStreamTexture());
- EXPECT_EQ(0U, texture_ref->texture()->target());
-}
-
-TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMInvalid) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- DestroyStreamTextureCHROMIUM cmd;
- cmd.Init(client_texture_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
-}
-
-TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMBadId) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- DestroyStreamTextureCHROMIUM cmd;
- cmd.Init(GL_ZERO);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
-}
-
-TEST_F(GLES2DecoderManualInitTest, StreamTextureCHROMIUMNullMgr) {
- InitDecoder(
- "", // extensions
- "3.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- CreateStreamTextureCHROMIUM cmd;
- cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd));
- GetGLError(); // ignore internal error
-
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- group().texture_manager()->SetStreamTexture(texture_ref, true);
-
- DestroyStreamTextureCHROMIUM cmd2;
- cmd2.Init(client_texture_id_);
- EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd2));
- GetGLError(); // ignore internal error
-}
-
-TEST_F(GLES2DecoderManualInitTest, ReCreateStreamTextureCHROMIUM) {
- const GLuint kObjectId = 123;
- InitDecoder(
- "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions
- "opengl es 2.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
- EXPECT_CALL(*stream_texture_manager(),
- CreateStreamTexture(kServiceTextureId, client_texture_id_))
- .WillOnce(Return(kObjectId))
- .RetiresOnSaturation();
-
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- group().texture_manager()->SetStreamTexture(texture_ref, true);
-
- DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
-
- DestroyStreamTextureCHROMIUM cmd;
- cmd.Init(client_texture_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
- EXPECT_FALSE(texture_ref->texture()->IsStreamTexture());
-
- CreateStreamTextureCHROMIUM cmd2;
- cmd2.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
- EXPECT_TRUE(texture_ref->texture()->IsStreamTexture());
-
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-}
-
-TEST_F(GLES2DecoderManualInitTest, ProduceAndConsumeStreamTextureCHROMIUM) {
- InitDecoder(
- "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions
- "opengl es 2.0", // gl version
- false, // has alpha
- false, // has depth
- false, // has stencil
- false, // request alpha
- false, // request depth
- false, // request stencil
- true); // bind generates resource
-
- TextureRef* texture_ref = GetTexture(client_texture_id_);
- group().texture_manager()->SetStreamTexture(texture_ref, true);
-
- DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
-
- GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM];
- group().mailbox_manager()->GenerateMailboxName(
- reinterpret_cast<MailboxName*>(mailbox));
-
- memcpy(shared_memory_address_, mailbox, sizeof(mailbox));
-
- EXPECT_EQ(kServiceTextureId, texture_ref->service_id());
-
- ProduceTextureCHROMIUM produce_cmd;
- produce_cmd.Init(
- GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset);
- EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd));
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
-
- // Create new texture for consume.
- EXPECT_CALL(*gl_, GenTextures(_, _))
- .WillOnce(SetArgumentPointee<1>(kNewServiceId))
- .RetiresOnSaturation();
- DoBindTexture(GL_TEXTURE_EXTERNAL_OES, kNewClientId, kNewServiceId);
-
- // Assigns and binds original service size texture ID.
- EXPECT_CALL(*gl_, DeleteTextures(1, _))
- .Times(1)
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-
- // Shared mem got clobbered from GetError() above.
- memcpy(shared_memory_address_, mailbox, sizeof(mailbox));
- ConsumeTextureCHROMIUM consume_cmd;
- consume_cmd.Init(
- GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset);
- EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd));
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
-
- // Service ID is restored.
- EXPECT_EQ(kServiceTextureId, texture_ref->service_id());
-
- EXPECT_CALL(*stream_texture_manager(),
- DestroyStreamTexture(kServiceTextureId))
- .Times(1)
- .RetiresOnSaturation();
-}
-
TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) {
InitDecoder(
"GL_ARB_texture_rectangle", // extensions
@@ -8285,6 +7901,81 @@ TEST_F(GLES2DecoderWithShaderTest, UseTexImage) {
EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd));
}
+TEST_F(GLES2DecoderManualInitTest, DrawWithGLImageExternal) {
+ InitDecoder(
+ "GL_OES_EGL_image_external", // extensions
+ "opengl es 2.0", // gl version
+ true, // has alpha
+ true, // has depth
+ false, // has stencil
+ true, // request alpha
+ true, // request depth
+ false, // request stencil
+ true); // bind generates resource
+
+ TextureRef* texture_ref = GetTexture(client_texture_id_);
+ scoped_refptr<MockGLImage> image(new MockGLImage);
+ group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES);
+ group().texture_manager()->SetLevelInfo(texture_ref,
+ GL_TEXTURE_EXTERNAL_OES,
+ 0,
+ GL_RGBA,
+ 0,
+ 0,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ group().texture_manager()->SetLevelImage(
+ texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image);
+
+ DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+
+ SetupSamplerExternalProgram();
+ SetupIndexBuffer();
+ AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0);
+ SetupExpectationsForApplyingDefaultDirtyState();
+ EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref));
+
+ InSequence s;
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*image, WillUseTexImage())
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
+ .Times(1);
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*image, DidUseTexImage())
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
+ .Times(1)
+ .RetiresOnSaturation();
+ DrawElements cmd;
+ cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
TEST_F(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) {
InitDecoder(
"GL_ARB_texture_rectangle", // extensions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
index 3a648db..a8cc551 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h
@@ -25,10 +25,6 @@
// TODO(gman): GetProgramInfoCHROMIUM
-// TODO(gman): CreateStreamTextureCHROMIUM
-
-// TODO(gman): DestroyStreamTextureCHROMIUM
-
// TODO(gman): GetTranslatedShaderSourceANGLE
// TODO(gman): PostSubBufferCHROMIUM
// TODO(gman): TexImageIOSurface2DCHROMIUM
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 4ee1e78..097d8cd 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -125,9 +125,6 @@ void GLES2DecoderTestBase::InitDecoderWithCommandLine(
// Only create stream texture manager if extension is requested.
std::vector<std::string> list;
base::SplitString(std::string(extensions), ' ', &list);
- if (std::find(list.begin(), list.end(),
- "GL_CHROMIUM_stream_texture") != list.end())
- stream_texture_manager_.reset(new StrictMock<MockStreamTextureManager>);
scoped_refptr<FeatureInfo> feature_info;
if (command_line)
feature_info = new FeatureInfo(*command_line);
@@ -135,7 +132,6 @@ void GLES2DecoderTestBase::InitDecoderWithCommandLine(
NULL,
NULL,
memory_tracker_,
- stream_texture_manager_.get(),
feature_info.get(),
bind_generates_resource));
// These two workarounds are always turned on.
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
index 04066b4..ea19be8 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -16,7 +16,6 @@
#include "gpu/command_buffer/service/query_manager.h"
#include "gpu/command_buffer/service/renderbuffer_manager.h"
#include "gpu/command_buffer/service/shader_manager.h"
-#include "gpu/command_buffer/service/stream_texture_manager_mock.h"
#include "gpu/command_buffer/service/test_helper.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "gpu/command_buffer/service/vertex_array_manager.h"
@@ -140,11 +139,6 @@ class GLES2DecoderTestBase : public testing::Test {
return group_->program_manager();
}
- ::testing::StrictMock<MockStreamTextureManager>*
- stream_texture_manager() const {
- return stream_texture_manager_.get();
- }
-
void DoCreateProgram(GLuint client_id, GLuint service_id);
void DoCreateShader(GLenum shader_type, GLuint client_id, GLuint service_id);
@@ -545,8 +539,6 @@ class GLES2DecoderTestBase : public testing::Test {
void AddExpectationsForVertexAttribManager();
scoped_ptr< ::testing::StrictMock<MockCommandBufferEngine> > engine_;
- scoped_ptr< ::testing::StrictMock<MockStreamTextureManager> >
- stream_texture_manager_;
scoped_refptr<ContextGroup> group_;
};
diff --git a/gpu/command_buffer/service/gpu_control_service.cc b/gpu/command_buffer/service/gpu_control_service.cc
index 7c0eb8c..013c06a 100644
--- a/gpu/command_buffer/service/gpu_control_service.cc
+++ b/gpu/command_buffer/service/gpu_control_service.cc
@@ -105,6 +105,11 @@ void GpuControlService::Echo(const base::Closure& callback) {
NOTREACHED();
}
+uint32 GpuControlService::CreateStreamTexture(uint32 texture_id) {
+ NOTREACHED();
+ return 0;
+}
+
bool GpuControlService::RegisterGpuMemoryBuffer(
int32 id,
gfx::GpuMemoryBufferHandle buffer,
diff --git a/gpu/command_buffer/service/gpu_control_service.h b/gpu/command_buffer/service/gpu_control_service.h
index 3764ad4..9e36f15 100644
--- a/gpu/command_buffer/service/gpu_control_service.h
+++ b/gpu/command_buffer/service/gpu_control_service.h
@@ -49,6 +49,7 @@ class GPU_EXPORT GpuControlService : public GpuControl {
virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats)
OVERRIDE;
virtual void Echo(const base::Closure& callback) OVERRIDE;
+ virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE;
// Register an existing gpu memory buffer and get an ID that can be used
// to identify it in the command buffer.
diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc
index af14778..95e172b 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.cc
+++ b/gpu/command_buffer/service/in_process_command_buffer.cc
@@ -393,11 +393,8 @@ bool InProcessCommandBuffer::InitializeOnGpuThread(
share_group = new gfx::GLShareGroup;
}
- StreamTextureManager* stream_texture_manager = NULL;
#if defined(OS_ANDROID)
- stream_texture_manager = stream_texture_manager_ =
- context_group ? context_group->stream_texture_manager_.get()
- : new StreamTextureManagerInProcess;
+ stream_texture_manager_.reset(new StreamTextureManagerInProcess);
#endif
bool bind_generates_resource = false;
@@ -406,7 +403,6 @@ bool InProcessCommandBuffer::InitializeOnGpuThread(
: new gles2::ContextGroup(NULL,
NULL,
NULL,
- stream_texture_manager,
NULL,
bind_generates_resource)));
@@ -521,6 +517,9 @@ bool InProcessCommandBuffer::DestroyOnGpuThread() {
}
context_ = NULL;
surface_ = NULL;
+#if defined(OS_ANDROID)
+ stream_texture_manager_.reset();
+#endif
g_all_shared_contexts.Pointer()->erase(this);
return true;
@@ -738,6 +737,29 @@ void InProcessCommandBuffer::Echo(const base::Closure& callback) {
QueueTask(WrapCallback(callback));
}
+uint32 InProcessCommandBuffer::CreateStreamTexture(uint32 texture_id) {
+ base::WaitableEvent completion(true, false);
+ uint32 stream_id = 0;
+ base::Callback<uint32(void)> task =
+ base::Bind(&InProcessCommandBuffer::CreateStreamTextureOnGpuThread,
+ base::Unretained(this),
+ texture_id);
+ QueueTask(
+ base::Bind(&RunTaskWithResult<uint32>, task, &stream_id, &completion));
+ completion.Wait();
+ return 0;
+}
+
+uint32 InProcessCommandBuffer::CreateStreamTextureOnGpuThread(
+ uint32 client_texture_id) {
+#if defined(OS_ANDROID)
+ return stream_texture_manager_->CreateStreamTexture(
+ client_texture_id, decoder_->GetContextGroup()->texture_manager());
+#else
+ return 0;
+#endif
+}
+
gpu::error::Error InProcessCommandBuffer::GetLastError() {
CheckSequencedThread();
return last_state_.error;
diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h
index b00f25b..5484f2a 100644
--- a/gpu/command_buffer/service/in_process_command_buffer.h
+++ b/gpu/command_buffer/service/in_process_command_buffer.h
@@ -126,6 +126,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats)
OVERRIDE;
virtual void Echo(const base::Closure& callback) OVERRIDE;
+ virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE;
// The serializer interface to the GPU service (i.e. thread).
class SchedulerClient {
@@ -171,6 +172,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params);
bool DestroyOnGpuThread();
void FlushOnGpuThread(int32 put_offset);
+ uint32 CreateStreamTextureOnGpuThread(uint32 client_texture_id);
bool MakeCurrent();
bool IsContextLost();
base::Closure WrapCallback(const base::Closure& callback);
@@ -212,7 +214,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer,
scoped_ptr<GpuControl> gpu_control_;
#if defined(OS_ANDROID)
- scoped_refptr<StreamTextureManagerInProcess> stream_texture_manager_;
+ scoped_ptr<StreamTextureManagerInProcess> stream_texture_manager_;
#endif
// Only used with explicit scheduling and the gpu thread is the same as
diff --git a/gpu/command_buffer/service/stream_texture.h b/gpu/command_buffer/service/stream_texture.h
deleted file mode 100644
index bcddc82..0000000
--- a/gpu/command_buffer/service/stream_texture.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2011 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 GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_H_
-#define GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_H_
-
-#include "base/basictypes.h"
-#include "ui/gfx/size.h"
-
-namespace gpu {
-
-class StreamTexture {
- public:
- StreamTexture() {
- }
-
- virtual ~StreamTexture() {
- }
-
- virtual void Update() = 0;
-
- // Get the size of the StreamTexture.
- virtual gfx::Size GetSize() = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StreamTexture);
-};
-
-} // namespace gpu
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_H_
diff --git a/gpu/command_buffer/service/stream_texture_manager.h b/gpu/command_buffer/service/stream_texture_manager.h
deleted file mode 100644
index 51119fa..0000000
--- a/gpu/command_buffer/service/stream_texture_manager.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2011 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 GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MANAGER_H_
-#define GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MANAGER_H_
-
-#include "base/basictypes.h"
-
-namespace gpu {
-
-class StreamTexture;
-
-// Interface used by the cmd decoder to create and lookup stream textures.
-class StreamTextureManager {
- public:
- StreamTextureManager() {
- }
-
- virtual ~StreamTextureManager() {
- }
-
- // Returns an identifier for the object, or NULL if not successful.
- virtual uint32 CreateStreamTexture(uint32 service_id, uint32 client_id) = 0;
-
- virtual void DestroyStreamTexture(uint32 service_id) = 0;
-
- virtual StreamTexture* LookupStreamTexture(uint32 service_id) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StreamTextureManager);
-};
-
-} // namespace gpu
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MANAGER_H_
diff --git a/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc b/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc
index 2fd5535..691e7ce 100644
--- a/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc
+++ b/gpu/command_buffer/service/stream_texture_manager_in_process_android.cc
@@ -5,41 +5,63 @@
#include "gpu/command_buffer/service/stream_texture_manager_in_process_android.h"
#include "base/bind.h"
+#include "base/callback.h"
+#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gfx/size.h"
#include "ui/gl/android/surface_texture.h"
#include "ui/gl/gl_bindings.h"
+#include "ui/gl/gl_image.h"
namespace gpu {
-StreamTextureManagerInProcess::StreamTextureImpl::StreamTextureImpl(
- uint32 service_id,
- uint32 stream_id)
- : surface_texture_(new gfx::SurfaceTexture(service_id)),
- stream_id_(stream_id) {}
+namespace {
-StreamTextureManagerInProcess::StreamTextureImpl::~StreamTextureImpl() {}
+// Simply wraps a SurfaceTexture reference as a GLImage.
+class GLImageImpl : public gfx::GLImage {
+ public:
+ GLImageImpl(const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
+ const base::Closure& release_callback);
-void StreamTextureManagerInProcess::StreamTextureImpl::Update() {
- GLint texture_id = 0;
- glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id);
- surface_texture_->UpdateTexImage();
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id);
+ // implement gfx::GLImage
+ virtual void Destroy() OVERRIDE;
+ virtual gfx::Size GetSize() OVERRIDE;
+ virtual void WillUseTexImage() OVERRIDE;
+ virtual void DidUseTexImage() OVERRIDE {}
+
+ private:
+ virtual ~GLImageImpl();
+
+ scoped_refptr<gfx::SurfaceTexture> surface_texture_;
+ base::Closure release_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(GLImageImpl);
+};
+
+GLImageImpl::GLImageImpl(
+ const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
+ const base::Closure& release_callback)
+ : surface_texture_(surface_texture), release_callback_(release_callback) {}
+
+GLImageImpl::~GLImageImpl() {
+ release_callback_.Run();
}
-gfx::Size StreamTextureManagerInProcess::StreamTextureImpl::GetSize() {
- return size_;
+void GLImageImpl::Destroy() {
+ NOTREACHED();
}
-void StreamTextureManagerInProcess::StreamTextureImpl::SetSize(gfx::Size size) {
- size_ = size;
+void GLImageImpl::WillUseTexImage() {
+ surface_texture_->UpdateTexImage();
}
-scoped_refptr<gfx::SurfaceTexture>
-StreamTextureManagerInProcess::StreamTextureImpl::GetSurfaceTexture() {
- return surface_texture_;
+gfx::Size GLImageImpl::GetSize() {
+ return gfx::Size();
}
-StreamTextureManagerInProcess::StreamTextureManagerInProcess() : next_id_(1) {}
+} // anonymous namespace
+
+StreamTextureManagerInProcess::StreamTextureManagerInProcess()
+ : next_id_(1), weak_factory_(this) {}
StreamTextureManagerInProcess::~StreamTextureManagerInProcess() {
if (!textures_.empty()) {
@@ -48,13 +70,47 @@ StreamTextureManagerInProcess::~StreamTextureManagerInProcess() {
}
}
-GLuint StreamTextureManagerInProcess::CreateStreamTexture(uint32 service_id,
- uint32 client_id) {
- base::AutoLock lock(map_lock_);
+GLuint StreamTextureManagerInProcess::CreateStreamTexture(
+ uint32 client_texture_id,
+ gles2::TextureManager* texture_manager) {
+ CalledOnValidThread();
+
+ gles2::TextureRef* texture = texture_manager->GetTexture(client_texture_id);
+
+ if (!texture || (texture->texture()->target() &&
+ texture->texture()->target() != GL_TEXTURE_EXTERNAL_OES)) {
+ return 0;
+ }
+
+ scoped_refptr<gfx::SurfaceTexture> surface_texture(
+ new gfx::SurfaceTexture(texture->service_id()));
+
uint32 stream_id = next_id_++;
- linked_ptr<StreamTextureImpl> texture(
- new StreamTextureImpl(service_id, stream_id));
- textures_[service_id] = texture;
+ base::Closure release_callback =
+ base::Bind(&StreamTextureManagerInProcess::OnReleaseStreamTexture,
+ weak_factory_.GetWeakPtr(), stream_id);
+ scoped_refptr<gfx::GLImage> gl_image(new GLImageImpl(surface_texture,
+ release_callback));
+
+ gfx::Size size = gl_image->GetSize();
+ texture_manager->SetTarget(texture, GL_TEXTURE_EXTERNAL_OES);
+ texture_manager->SetLevelInfo(texture,
+ GL_TEXTURE_EXTERNAL_OES,
+ 0,
+ GL_RGBA,
+ size.width(),
+ size.height(),
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ texture_manager->SetLevelImage(texture, GL_TEXTURE_EXTERNAL_OES, 0, gl_image);
+
+ {
+ base::AutoLock lock(map_lock_);
+ textures_[stream_id] = surface_texture;
+ }
if (next_id_ == 0)
next_id_++;
@@ -62,29 +118,19 @@ GLuint StreamTextureManagerInProcess::CreateStreamTexture(uint32 service_id,
return stream_id;
}
-void StreamTextureManagerInProcess::DestroyStreamTexture(uint32 service_id) {
- base::AutoLock lock(map_lock_);
- textures_.erase(service_id);
-}
-
-gpu::StreamTexture* StreamTextureManagerInProcess::LookupStreamTexture(
- uint32 service_id) {
+void StreamTextureManagerInProcess::OnReleaseStreamTexture(uint32 stream_id) {
+ CalledOnValidThread();
base::AutoLock lock(map_lock_);
- TextureMap::const_iterator it = textures_.find(service_id);
- if (it != textures_.end())
- return it->second.get();
-
- return NULL;
+ textures_.erase(stream_id);
}
+// This can get called from any thread.
scoped_refptr<gfx::SurfaceTexture>
StreamTextureManagerInProcess::GetSurfaceTexture(uint32 stream_id) {
base::AutoLock lock(map_lock_);
- for (TextureMap::iterator it = textures_.begin(); it != textures_.end();
- it++) {
- if (it->second->stream_id() == stream_id)
- return it->second->GetSurfaceTexture();
- }
+ TextureMap::const_iterator it = textures_.find(stream_id);
+ if (it != textures_.end())
+ return it->second;
return NULL;
}
diff --git a/gpu/command_buffer/service/stream_texture_manager_in_process_android.h b/gpu/command_buffer/service/stream_texture_manager_in_process_android.h
index 6753c13..8b507b0 100644
--- a/gpu/command_buffer/service/stream_texture_manager_in_process_android.h
+++ b/gpu/command_buffer/service/stream_texture_manager_in_process_android.h
@@ -7,66 +7,41 @@
#include <map>
-#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
-#include "gpu/command_buffer/service/stream_texture.h"
-#include "gpu/command_buffer/service/stream_texture_manager.h"
+#include "base/threading/non_thread_safe.h"
namespace gfx {
-class Size;
class SurfaceTexture;
}
namespace gpu {
-class StreamTextureManagerInProcess
- : public gpu::StreamTextureManager,
- public base::RefCountedThreadSafe<StreamTextureManagerInProcess> {
+namespace gles2 {
+class TextureManager;
+}
+
+class StreamTextureManagerInProcess : public base::NonThreadSafe {
public:
StreamTextureManagerInProcess();
+ ~StreamTextureManagerInProcess();
- // implement gpu::StreamTextureManager:
- virtual uint32 CreateStreamTexture(uint32 service_id,
- uint32 client_id) OVERRIDE;
- virtual void DestroyStreamTexture(uint32 service_id) OVERRIDE;
- virtual gpu::StreamTexture* LookupStreamTexture(uint32 service_id) OVERRIDE;
+ uint32 CreateStreamTexture(uint32 client_texture_id,
+ gles2::TextureManager* texture_manager);
+ // This method can be called from any thread.
scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(uint32 stream_id);
private:
- class StreamTextureImpl : public gpu::StreamTexture {
- public:
- StreamTextureImpl(uint32 service_id, uint32 stream_id);
- virtual ~StreamTextureImpl();
-
- // implement gpu::StreamTexture
- virtual void Update() OVERRIDE;
- virtual gfx::Size GetSize() OVERRIDE;
-
- void SetSize(gfx::Size size);
-
- scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture();
- uint32 stream_id() { return stream_id_; }
-
- private:
- scoped_refptr<gfx::SurfaceTexture> surface_texture_;
- uint32 stream_id_;
- gfx::Size size_;
+ void OnReleaseStreamTexture(uint32 stream_id);
- DISALLOW_COPY_AND_ASSIGN(StreamTextureImpl);
- };
-
- friend class base::RefCountedThreadSafe<StreamTextureManagerInProcess>;
- virtual ~StreamTextureManagerInProcess();
-
- typedef std::map<uint32, linked_ptr<StreamTextureImpl> > TextureMap;
+ typedef std::map<uint32, scoped_refptr<gfx::SurfaceTexture> > TextureMap;
TextureMap textures_;
-
- uint32 next_id_;
-
base::Lock map_lock_;
+ uint32 next_id_;
+ base::WeakPtrFactory<StreamTextureManagerInProcess> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(StreamTextureManagerInProcess);
};
diff --git a/gpu/command_buffer/service/stream_texture_manager_mock.cc b/gpu/command_buffer/service/stream_texture_manager_mock.cc
deleted file mode 100644
index 75268b8..0000000
--- a/gpu/command_buffer/service/stream_texture_manager_mock.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2011 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 "gpu/command_buffer/service/stream_texture_manager_mock.h"
-
-namespace gpu {
-
-MockStreamTextureManager::MockStreamTextureManager() {
-}
-
-MockStreamTextureManager::~MockStreamTextureManager() {
-}
-
-} // namespace gpu
diff --git a/gpu/command_buffer/service/stream_texture_manager_mock.h b/gpu/command_buffer/service/stream_texture_manager_mock.h
deleted file mode 100644
index 4b744f2..0000000
--- a/gpu/command_buffer/service/stream_texture_manager_mock.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2011 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 GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MANAGER_MOCK_H_
-#define GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MANAGER_MOCK_H_
-
-#include "base/basictypes.h"
-#include "gpu/command_buffer/service/stream_texture_manager.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-namespace gpu {
-
-class StreamTexture;
-
-class MockStreamTextureManager : public StreamTextureManager {
- public:
- MockStreamTextureManager();
- virtual ~MockStreamTextureManager();
-
- MOCK_METHOD2(CreateStreamTexture,
- uint32(uint32 service_id, uint32 client_id));
- MOCK_METHOD1(DestroyStreamTexture, void(uint32 service_id));
- MOCK_METHOD1(LookupStreamTexture, StreamTexture*(uint32 service_id));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockStreamTextureManager);
-};
-
-} // namespace gpu
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MANAGER_MOCK_H_
diff --git a/gpu/command_buffer/service/stream_texture_mock.cc b/gpu/command_buffer/service/stream_texture_mock.cc
deleted file mode 100644
index 742a4f7..0000000
--- a/gpu/command_buffer/service/stream_texture_mock.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2011 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 "gpu/command_buffer/service/stream_texture_mock.h"
-
-namespace gpu {
-
-MockStreamTexture::MockStreamTexture() {
-}
-
-MockStreamTexture::~MockStreamTexture() {
-}
-
-} // namespace gpu
diff --git a/gpu/command_buffer/service/stream_texture_mock.h b/gpu/command_buffer/service/stream_texture_mock.h
deleted file mode 100644
index cd951d2..0000000
--- a/gpu/command_buffer/service/stream_texture_mock.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2011 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 GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MOCK_H_
-#define GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MOCK_H_
-
-#include "base/memory/ref_counted.h"
-#include "gpu/command_buffer/service/stream_texture.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-namespace gpu {
-
-class MockStreamTexture : public StreamTexture {
- public:
- MockStreamTexture();
- virtual ~MockStreamTexture();
-
- MOCK_METHOD0(Update, void());
- MOCK_METHOD0(GetSize, gfx::Size(void));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockStreamTexture);
-};
-
-} // namespace gpu
-
-#endif // GPU_COMMAND_BUFFER_SERVICE_STREAM_TEXTURE_MOCK_H_
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 64ead82..72d3b4c 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -13,7 +13,6 @@
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/memory_tracking.h"
-#include "gpu/command_buffer/service/stream_texture_manager.h"
namespace gpu {
namespace gles2 {
@@ -117,7 +116,6 @@ Texture::Texture(GLuint service_id)
npot_(false),
has_been_bound_(false),
framebuffer_attachment_count_(0),
- stream_texture_(false),
immutable_(false),
has_images_(false),
estimated_size_(0),
@@ -827,8 +825,7 @@ TextureRef::TextureRef(TextureManager* manager,
Texture* texture)
: manager_(manager),
texture_(texture),
- client_id_(client_id),
- is_stream_texture_owner_(false) {
+ client_id_(client_id) {
DCHECK(manager_);
DCHECK(texture_);
texture_->AddTextureRef(this);
@@ -857,7 +854,6 @@ TextureManager::TextureManager(MemoryTracker* memory_tracker,
new MemoryTypeTracker(memory_tracker, MemoryTracker::kUnmanaged)),
feature_info_(feature_info),
framebuffer_manager_(NULL),
- stream_texture_manager_(NULL),
max_texture_size_(max_texture_size),
max_cube_map_texture_size_(max_cube_map_texture_size),
max_levels_(ComputeMipMapCount(GL_TEXTURE_2D,
@@ -1006,19 +1002,6 @@ void TextureManager::SetTarget(TextureRef* ref, GLenum target) {
->SetTarget(feature_info_.get(), target, MaxLevelsForTarget(target));
}
-void TextureManager::SetStreamTexture(TextureRef* ref, bool stream_texture) {
- DCHECK(ref);
- // Only the owner can mark as non-stream texture.
- DCHECK_EQ(stream_texture, !ref->is_stream_texture_owner_);
- ref->texture()->SetStreamTexture(stream_texture);
- ref->set_is_stream_texture_owner(stream_texture);
-}
-
-bool TextureManager::IsStreamTextureOwner(TextureRef* ref) {
- DCHECK(ref);
- return ref->is_stream_texture_owner();
-}
-
void TextureManager::SetLevelCleared(TextureRef* ref,
GLenum target,
GLint level,
@@ -1167,10 +1150,6 @@ void TextureManager::StopTracking(TextureRef* ref) {
OnTextureRefDestroying(ref));
Texture* texture = ref->texture();
- if (ref->is_stream_texture_owner_ && stream_texture_manager_) {
- DCHECK(texture->IsStreamTexture());
- stream_texture_manager_->DestroyStreamTexture(texture->service_id());
- }
--texture_count_;
if (texture->HasImages()) {
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index bd9e3da..b74ef91 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -21,9 +21,6 @@
#include "ui/gl/gl_image.h"
namespace gpu {
-
-class StreamTextureManager;
-
namespace gles2 {
class GLES2Decoder;
@@ -77,7 +74,7 @@ class GPU_EXPORT Texture {
}
bool CanRenderTo() const {
- return !stream_texture_ && target_ != GL_TEXTURE_EXTERNAL_OES;
+ return target_ != GL_TEXTURE_EXTERNAL_OES;
}
// The service side OpenGL id of the texture.
@@ -147,10 +144,6 @@ class GPU_EXPORT Texture {
--framebuffer_attachment_count_;
}
- bool IsStreamTexture() const {
- return stream_texture_;
- }
-
void SetImmutable(bool immutable) {
immutable_ = immutable;
}
@@ -242,11 +235,6 @@ class GPU_EXPORT Texture {
return npot_;
}
- void SetStreamTexture(bool stream_texture) {
- stream_texture_ = stream_texture;
- UpdateCanRenderCondition();
- }
-
// Marks a particular level as cleared or uncleared.
void SetLevelCleared(GLenum target, GLint level, bool cleared);
@@ -379,9 +367,6 @@ class GPU_EXPORT Texture {
// The number of framebuffers this texture is attached to.
int framebuffer_attachment_count_;
- // Whether this is a special streaming texture.
- bool stream_texture_;
-
// Whether the texture is immutable and no further changes to the format
// or dimensions of the texture object can be made.
bool immutable_;
@@ -402,13 +387,6 @@ class GPU_EXPORT Texture {
// with a client id, though it can outlive the client id if it's still bound to
// a FBO or another context when destroyed.
// Multiple TextureRef can point to the same texture with cross-context sharing.
-//
-// Note: for stream textures, the TextureRef that created the stream texture is
-// set as the "owner" of the stream texture, i.e. it will call
-// DestroyStreamTexture on destruction. This is because the StreamTextureManager
-// isn't generally shared between ContextGroups, so ownership can't be at the
-// Texture level. We also can't have multiple StreamTexture on the same service
-// id, so there can be only one owner.
class GPU_EXPORT TextureRef : public base::RefCounted<TextureRef> {
public:
TextureRef(TextureManager* manager, GLuint client_id, Texture* texture);
@@ -429,15 +407,10 @@ class GPU_EXPORT TextureRef : public base::RefCounted<TextureRef> {
const TextureManager* manager() const { return manager_; }
TextureManager* manager() { return manager_; }
void reset_client_id() { client_id_ = 0; }
- void set_is_stream_texture_owner(bool owner) {
- is_stream_texture_owner_ = owner;
- }
- bool is_stream_texture_owner() const { return is_stream_texture_owner_; }
TextureManager* manager_;
Texture* texture_;
GLuint client_id_;
- bool is_stream_texture_owner_;
DISALLOW_COPY_AND_ASSIGN(TextureRef);
};
@@ -504,10 +477,6 @@ class GPU_EXPORT TextureManager {
framebuffer_manager_ = manager;
}
- void set_stream_texture_manager(StreamTextureManager* manager) {
- stream_texture_manager_ = manager;
- }
-
// Init the texture manager.
bool Initialize();
@@ -567,13 +536,6 @@ class GPU_EXPORT TextureManager {
TextureRef* ref,
GLenum target);
- // Marks a texture as a stream texture, and the ref as the stream texture
- // owner.
- void SetStreamTexture(TextureRef* ref, bool stream_texture);
-
- // Whether the TextureRef is the stream texture owner.
- bool IsStreamTextureOwner(TextureRef* ref);
-
// Set the info for a particular level in a TexureInfo.
void SetLevelInfo(
TextureRef* ref,
@@ -782,7 +744,6 @@ class GPU_EXPORT TextureManager {
scoped_refptr<FeatureInfo> feature_info_;
FramebufferManager* framebuffer_manager_;
- StreamTextureManager* stream_texture_manager_;
// Info for each texture in the system.
typedef base::hash_map<GLuint, scoped_refptr<TextureRef> > TextureMap;
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index 6daebe3..002f2f8 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -1805,7 +1805,8 @@ TEST_F(TextureTest, AddToSignature) {
EXPECT_EQ(11u, string_set.size());
}
-class ProduceConsumeTextureTest : public TextureTest {
+class ProduceConsumeTextureTest : public TextureTest,
+ public ::testing::WithParamInterface<GLenum> {
public:
virtual void SetUp() {
TextureTest::SetUpBase(NULL, "GL_OES_EGL_image_external");
@@ -2020,25 +2021,43 @@ TEST_F(ProduceConsumeTextureTest, ProduceConsumeExternal) {
GetLevelInfo(restored_texture.get(), GL_TEXTURE_EXTERNAL_OES, 0));
}
-TEST_F(ProduceConsumeTextureTest, ProduceConsumeStreamTexture) {
- manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_EXTERNAL_OES);
+TEST_P(ProduceConsumeTextureTest, ProduceConsumeTextureWithImage) {
+ GLenum target = GetParam();
+ manager_->SetTarget(texture_ref_.get(), target);
Texture* texture = texture_ref_->texture();
- EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture->target());
- manager_->SetStreamTexture(texture_ref_.get(), true);
+ EXPECT_EQ(static_cast<GLenum>(target), texture->target());
+ scoped_refptr<gfx::GLImage> image(gfx::GLImage::CreateGLImage(0));
+ manager_->SetLevelInfo(texture_ref_.get(),
+ target,
+ 0,
+ GL_RGBA,
+ 0,
+ 0,
+ 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ true);
+ manager_->SetLevelImage(texture_ref_.get(), target, 0, image);
GLuint service_id = texture->service_id();
Texture* produced_texture = Produce(texture_ref_.get());
- EXPECT_TRUE(texture->IsStreamTexture());
GLuint client_id = texture2_->client_id();
manager_->RemoveTexture(client_id);
Consume(client_id, produced_texture);
scoped_refptr<TextureRef> restored_texture = manager_->GetTexture(client_id);
EXPECT_EQ(produced_texture, restored_texture->texture());
- EXPECT_TRUE(restored_texture->texture()->IsStreamTexture());
- EXPECT_TRUE(restored_texture->texture()->IsImmutable());
EXPECT_EQ(service_id, restored_texture->service_id());
+ EXPECT_EQ(image.get(), restored_texture->texture()->GetLevelImage(target, 0));
}
+static const GLenum kTextureTargets[] = {GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL_OES,
+ GL_TEXTURE_RECTANGLE_ARB, };
+
+INSTANTIATE_TEST_CASE_P(Target,
+ ProduceConsumeTextureTest,
+ ::testing::ValuesIn(kTextureTargets));
+
TEST_F(ProduceConsumeTextureTest, ProduceConsumeCube) {
manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_CUBE_MAP);
Texture* texture = texture_ref_->texture();
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index ff2de9c..db0c4c6 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -121,7 +121,6 @@ void GLManager::Initialize(const GLManager::Options& options) {
options.image_manager,
NULL,
NULL,
- NULL,
options.bind_generates_resource);
}
diff --git a/gpu/command_buffer_service.gypi b/gpu/command_buffer_service.gypi
index 6d5b3fd..541c9e2 100644
--- a/gpu/command_buffer_service.gypi
+++ b/gpu/command_buffer_service.gypi
@@ -118,8 +118,6 @@
'command_buffer/service/shader_translator.cc',
'command_buffer/service/shader_translator_cache.h',
'command_buffer/service/shader_translator_cache.cc',
- 'command_buffer/service/stream_texture.h',
- 'command_buffer/service/stream_texture_manager.h',
'command_buffer/service/stream_texture_manager_in_process_android.h',
'command_buffer/service/stream_texture_manager_in_process_android.cc',
'command_buffer/service/texture_manager.h',
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc
index 92d8f71..73fb185 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -114,7 +114,7 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config,
return NULL;
scoped_refptr<gpu::gles2::ContextGroup> group(
- new gpu::gles2::ContextGroup(NULL, NULL, NULL, NULL, NULL, true));
+ new gpu::gles2::ContextGroup(NULL, NULL, NULL, NULL, true));
decoder_.reset(gpu::gles2::GLES2Decoder::Create(group.get()));
if (!decoder_.get())
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index 014c5cd..477e62a 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -235,10 +235,6 @@
'command_buffer/service/program_cache_unittest.cc',
'command_buffer/service/shader_manager_unittest.cc',
'command_buffer/service/shader_translator_unittest.cc',
- 'command_buffer/service/stream_texture_mock.cc',
- 'command_buffer/service/stream_texture_mock.h',
- 'command_buffer/service/stream_texture_manager_mock.cc',
- 'command_buffer/service/stream_texture_manager_mock.h',
'command_buffer/service/test_helper.cc',
'command_buffer/service/test_helper.h',
'command_buffer/service/texture_manager_unittest.cc',
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc
index a6da2107..c2f74e2 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.cc
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc
@@ -143,6 +143,11 @@ void PpapiCommandBufferProxy::Echo(const base::Closure& callback) {
NOTREACHED();
}
+uint32 PpapiCommandBufferProxy::CreateStreamTexture(uint32 texture_id) {
+ NOTREACHED();
+ return 0;
+}
+
gpu::Buffer PpapiCommandBufferProxy::GetTransferBuffer(int32 id) {
if (last_state_.error != gpu::error::kNoError)
return gpu::Buffer();
diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.h b/ppapi/proxy/ppapi_command_buffer_proxy.h
index 16809bd..36d23ea 100644
--- a/ppapi/proxy/ppapi_command_buffer_proxy.h
+++ b/ppapi/proxy/ppapi_command_buffer_proxy.h
@@ -64,6 +64,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer,
virtual void SendManagedMemoryStats(const gpu::ManagedMemoryStats& stats)
OVERRIDE;
virtual void Echo(const base::Closure& callback) OVERRIDE;
+ virtual uint32 CreateStreamTexture(uint32 texture_id) OVERRIDE;
private:
bool Send(IPC::Message* msg);