Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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. | |
| 4 | |
| 5 #include "content/renderer/gpu/stream_texture_host_android.h" | |
| 6 | |
| 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" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 StreamTextureHost::StreamTextureHost(GpuChannelHost* channel) | |
| 15 : route_id_(MSG_ROUTING_NONE), | |
| 16 stream_id_(0), | |
| 17 listener_(NULL), | |
| 18 channel_(channel), | |
| 19 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | |
| 20 DCHECK(channel); | |
| 21 } | |
| 22 | |
| 23 StreamTextureHost::~StreamTextureHost() { | |
| 24 if (channel_.get() && route_id_ != MSG_ROUTING_NONE) | |
| 25 channel_->RemoveRoute(route_id_); | |
| 26 } | |
| 27 | |
| 28 bool StreamTextureHost::Initialize( | |
| 29 int stream_id, const gfx::Size& initial_size) { | |
| 30 if (channel_.get() && stream_id) { | |
| 31 if (channel_->Send(new GpuChannelMsg_RegisterStreamTextureProxy( | |
| 32 stream_id, initial_size, &route_id_))) { | |
| 33 stream_id_ = stream_id; | |
| 34 channel_->AddRoute(route_id_, weak_ptr_factory_.GetWeakPtr()); | |
| 35 } | |
| 36 return true; | |
| 37 } | |
| 38 | |
| 39 return false; | |
| 40 } | |
| 41 | |
| 42 bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) { | |
| 43 bool handled = true; | |
| 44 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message) | |
| 45 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable, | |
| 46 OnFrameAvailable); | |
| 47 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_MatrixChanged, | |
| 48 OnMatrixChanged); | |
| 49 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 50 IPC_END_MESSAGE_MAP() | |
| 51 DCHECK(handled); | |
| 52 return handled; | |
| 53 } | |
| 54 | |
| 55 void StreamTextureHost::EstablishPeer( | |
| 56 content::SurfaceTexturePeer::SurfaceTextureTarget type, | |
| 57 int32 primary_id, int32 secondary_id) { | |
| 58 if (channel_.get()) | |
|
apatrick_chromium
2012/07/12 23:51:31
braces for multiline if body.
qinmin
2012/07/13 00:41:33
Done.
| |
| 59 channel_->Send(new GpuChannelMsg_EstablishStreamTexture( | |
| 60 stream_id_, type, | |
| 61 primary_id, secondary_id)); | |
| 62 } | |
| 63 void StreamTextureHost::OnChannelError() { | |
| 64 } | |
| 65 | |
| 66 void StreamTextureHost::OnFrameAvailable() { | |
| 67 if (listener_) | |
| 68 listener_->OnFrameAvailable(); | |
| 69 } | |
| 70 | |
| 71 void StreamTextureHost::OnMatrixChanged( | |
| 72 const GpuStreamTextureMsg_MatrixChanged_Params& params) { | |
| 73 COMPILE_ASSERT(sizeof(params) == sizeof(float) * 16, | |
| 74 bad_GpuStreamTextureMsg_MatrixChanged_Params_format); | |
| 75 if (listener_) | |
| 76 listener_->OnMatrixChanged((const float*)¶ms); | |
| 77 } | |
| 78 | |
| 79 } // namespace content | |
| OLD | NEW |