Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / gpu / stream_texture_host_android.h
blob871cb63e045b0fa3fcb817b168782ebbc6df7890
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 #ifndef CONTENT_RENDERER_GPU_STREAM_TEXTURE_HOST_ANDROID_H_
6 #define CONTENT_RENDERER_GPU_STREAM_TEXTURE_HOST_ANDROID_H_
8 #include "base/memory/weak_ptr.h"
9 #include "content/common/android/surface_texture_peer.h"
10 #include "ipc/ipc_listener.h"
11 #include "ipc/ipc_message.h"
13 namespace gfx {
14 class Size;
17 struct GpuStreamTextureMsg_MatrixChanged_Params;
19 namespace content {
20 class GpuChannelHost;
22 // Class for handling all the IPC messages between the GPU process and
23 // StreamTextureProxy.
24 class StreamTextureHost : public IPC::Listener {
25 public:
26 explicit StreamTextureHost(GpuChannelHost* channel);
27 ~StreamTextureHost() override;
29 // Listener class that is listening to the stream texture updates. It is
30 // implemented by StreamTextureProxyImpl.
31 class Listener {
32 public:
33 virtual void OnFrameAvailable() = 0;
34 virtual void OnMatrixChanged(const float mtx[16]) = 0;
35 virtual ~Listener() {}
38 bool BindToCurrentThread(int32 stream_id, Listener* listener);
40 // IPC::Channel::Listener implementation:
41 bool OnMessageReceived(const IPC::Message& message) override;
42 void OnChannelError() override;
44 private:
45 // Message handlers:
46 void OnFrameAvailable();
47 void OnMatrixChanged(const GpuStreamTextureMsg_MatrixChanged_Params& param);
49 int stream_id_;
50 Listener* listener_;
51 scoped_refptr<GpuChannelHost> channel_;
52 base::WeakPtrFactory<StreamTextureHost> weak_ptr_factory_;
54 DISALLOW_IMPLICIT_CONSTRUCTORS(StreamTextureHost);
57 } // namespace content
59 #endif // CONTENT_RENDERER_GPU_STREAM_TEXTURE_HOST_ANDROID_H_