1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/gpu/stream_texture_host_android.h"
7 #include "content/common/gpu/client/gpu_channel_host.h"
8 #include "content/common/gpu/gpu_messages.h"
9 #include "content/renderer/render_thread_impl.h"
10 #include "ipc/ipc_message_macros.h"
14 StreamTextureHost::StreamTextureHost(GpuChannelHost
* channel
)
18 weak_ptr_factory_(this) {
22 StreamTextureHost::~StreamTextureHost() {
23 if (channel_
.get() && stream_id_
)
24 channel_
->RemoveRoute(stream_id_
);
27 bool StreamTextureHost::BindToCurrentThread(int32 stream_id
,
30 if (channel_
.get() && stream_id
&& !stream_id_
) {
31 stream_id_
= stream_id
;
32 channel_
->AddRoute(stream_id
, weak_ptr_factory_
.GetWeakPtr());
33 channel_
->Send(new GpuStreamTextureMsg_StartListening(stream_id
));
40 bool StreamTextureHost::OnMessageReceived(const IPC::Message
& message
) {
42 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost
, message
)
43 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable
,
45 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_MatrixChanged
,
47 IPC_MESSAGE_UNHANDLED(handled
= false)
53 void StreamTextureHost::OnChannelError() {
56 void StreamTextureHost::OnFrameAvailable() {
58 listener_
->OnFrameAvailable();
61 void StreamTextureHost::OnMatrixChanged(
62 const GpuStreamTextureMsg_MatrixChanged_Params
& params
) {
63 static_assert(sizeof(params
) == sizeof(float) * 16,
64 "bad GpuStreamTextureMsg MatrixChanged_Params format");
66 listener_
->OnMatrixChanged((const float*)¶ms
);
69 } // namespace content