Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: content/renderer/gpu/stream_texture_host_android.cc

Issue 10695181: [Android] Upstream all the IPC communications/handlings for stream texture (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove #pragma once Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 SurfaceTexturePeer::SurfaceTextureTarget type,
57 int32 primary_id, int32 secondary_id) {
58 if (channel_.get()) {
59 channel_->Send(new GpuChannelMsg_EstablishStreamTexture(
60 stream_id_, type,
61 primary_id, secondary_id));
62 }
63 }
64 void StreamTextureHost::OnChannelError() {
65 }
66
67 void StreamTextureHost::OnFrameAvailable() {
68 if (listener_)
69 listener_->OnFrameAvailable();
70 }
71
72 void StreamTextureHost::OnMatrixChanged(
73 const GpuStreamTextureMsg_MatrixChanged_Params& params) {
74 COMPILE_ASSERT(sizeof(params) == sizeof(float) * 16,
75 bad_GpuStreamTextureMsg_MatrixChanged_Params_format);
76 if (listener_)
77 listener_->OnMatrixChanged((const float*)&params);
78 }
79
80 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/stream_texture_host_android.h ('k') | content/renderer/media/stream_texture_factory_impl_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698