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
)
15 : route_id_(MSG_ROUTING_NONE
),
19 weak_ptr_factory_(this) {
23 StreamTextureHost::~StreamTextureHost() {
24 if (channel_
.get() && route_id_
!= MSG_ROUTING_NONE
)
25 channel_
->RemoveRoute(route_id_
);
28 bool StreamTextureHost::Initialize(int32 stream_id
) {
29 if (channel_
.get() && stream_id
) {
30 if (channel_
->Send(new GpuChannelMsg_RegisterStreamTextureProxy(
31 stream_id
, &route_id_
))) {
32 stream_id_
= stream_id
;
33 channel_
->AddRoute(route_id_
, weak_ptr_factory_
.GetWeakPtr());
41 bool StreamTextureHost::OnMessageReceived(const IPC::Message
& message
) {
43 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost
, message
)
44 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable
,
46 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_MatrixChanged
,
48 IPC_MESSAGE_UNHANDLED(handled
= false)
54 void StreamTextureHost::EstablishPeer(int32 primary_id
, int32 secondary_id
) {
56 channel_
->Send(new GpuChannelMsg_EstablishStreamTexture(
57 stream_id_
, primary_id
, secondary_id
));
60 void StreamTextureHost::OnChannelError() {
63 void StreamTextureHost::OnFrameAvailable() {
65 listener_
->OnFrameAvailable();
68 void StreamTextureHost::OnMatrixChanged(
69 const GpuStreamTextureMsg_MatrixChanged_Params
& params
) {
70 COMPILE_ASSERT(sizeof(params
) == sizeof(float) * 16,
71 bad_GpuStreamTextureMsg_MatrixChanged_Params_format
);
73 listener_
->OnMatrixChanged((const float*)¶ms
);
76 } // namespace content