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

Side by Side Diff: content/renderer/pepper/pepper_compositor_host.h

Issue 298023004: [PPAPI] Compositor API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor_api_def_new
Patch Set: Fix review issue Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ 6 #define CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_
7 7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/shared_memory.h" 10 #include "base/memory/weak_ptr.h"
14 #include "base/sync_socket.h"
15 #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h"
16 #include "ipc/ipc_platform_file.h"
17 #include "ppapi/c/ppb_audio_config.h"
18 #include "ppapi/host/host_message_context.h" 11 #include "ppapi/host/host_message_context.h"
19 #include "ppapi/host/resource_host.h" 12 #include "ppapi/host/resource_host.h"
13 #include "ppapi/shared_impl/compositor_layer_data.h"
14
15 namespace base {
16 class SharedMemory;
17 } // namespace base
18
19 namespace cc {
20 class Layer;
21 } // namespace cc
20 22
21 namespace content { 23 namespace content {
22 class PepperPlatformAudioInput;
23 class RendererPpapiHostImpl;
24 24
25 class PepperAudioInputHost : public ppapi::host::ResourceHost { 25 class PepperPluginInstanceImpl;
26 class RendererPpapiHost;
27
28 class PepperCompositorHost : public ppapi::host::ResourceHost {
26 public: 29 public:
27 PepperAudioInputHost(RendererPpapiHostImpl* host, 30 PepperCompositorHost(RendererPpapiHost* host,
28 PP_Instance instance, 31 PP_Instance instance,
29 PP_Resource resource); 32 PP_Resource resource);
30 virtual ~PepperAudioInputHost(); 33 // Associates this device with the given plugin instance. You can pass NULL
34 // to clear the existing device. Returns true on success. In this case, a
35 // repaint of the page will also be scheduled. Failure means that the device
36 // is already bound to a different instance, and nothing will happen.
37 bool BindToInstance(PepperPluginInstanceImpl* new_instance);
31 38
39 const scoped_refptr<cc::Layer> layer() { return layer_; };
40
41 void ViewInitiatedPaint();
42 void ViewFlushedPaint();
43
44 private:
45 virtual ~PepperCompositorHost();
46
47 void UpdateLayer(const scoped_refptr<cc::Layer>& layer,
48 const ppapi::CompositorLayerData* pp_layer_old,
49 const ppapi::CompositorLayerData* pp_layer);
50
51 void ResourceReleased(int32_t id,
52 uint32_t sync_point,
53 bool is_lost);
54 void ImageReleased(int32_t id,
55 const scoped_ptr<base::SharedMemory>& shared_memory,
56 uint32_t sync_point,
57 bool is_lost);
58
59 // ResourceMessageHandler overrides:
32 virtual int32_t OnResourceMessageReceived( 60 virtual int32_t OnResourceMessageReceived(
33 const IPC::Message& msg, 61 const IPC::Message& msg,
34 ppapi::host::HostMessageContext* context) OVERRIDE; 62 ppapi::host::HostMessageContext* context) OVERRIDE;
35 63
36 // Called when the stream is created. 64 // ppapi::host::ResourceHost overrides:
37 void StreamCreated(base::SharedMemoryHandle shared_memory_handle, 65 virtual bool IsCompositorHost() OVERRIDE;
38 size_t shared_memory_size,
39 base::SyncSocket::Handle socket);
40 void StreamCreationFailed();
41 66
42 private: 67 // Message handlers:
43 int32_t OnOpen(ppapi::host::HostMessageContext* context, 68 int32_t OnHostMsgCommitLayers(
44 const std::string& device_id, 69 ppapi::host::HostMessageContext* context,
45 PP_AudioSampleRate sample_rate, 70 const std::vector<ppapi::CompositorLayerData>& layers,
46 uint32_t sample_frame_count); 71 bool reset);
47 int32_t OnStartOrStop(ppapi::host::HostMessageContext* context, bool capture);
48 int32_t OnClose(ppapi::host::HostMessageContext* context);
49 72
50 void OnOpenComplete(int32_t result, 73 // Non-owning pointer to the plugin instance this context is currently bound
51 base::SharedMemoryHandle shared_memory_handle, 74 // to, if any. If the context is currently unbound, this will be NULL.
52 size_t shared_memory_size, 75 PepperPluginInstanceImpl* bound_instance_;
53 base::SyncSocket::Handle socket_handle);
54 76
55 int32_t GetRemoteHandles( 77 // The toplevel cc::Layer. It is the parent of other cc::Layers.
56 const base::SyncSocket& socket, 78 scoped_refptr<cc::Layer> layer_;
57 const base::SharedMemory& shared_memory,
58 IPC::PlatformFileForTransit* remote_socket_handle,
59 base::SharedMemoryHandle* remote_shared_memory_handle);
60 79
61 void Close(); 80 // A list of cc::Layer. It is used for updating layers' properties in
81 // subsequent CommitLayers() calls.
82 std::vector<scoped_refptr<cc::Layer> > cc_layers_;
62 83
63 void SendOpenReply(int32_t result); 84 // A list of pepper CompositorLayerData. It is used for comparing layers'
85 // properties with subsequent layers committed by CommitLayers() calls.
86 std::vector<ppapi::CompositorLayerData> pp_layers_;
piman 2014/06/04 13:19:43 Can we use an array of structures? The intent is t
Peng 2014/06/05 00:50:38 Done.
64 87
65 // Non-owning pointer. 88 ppapi::host::ReplyMessageContext commit_layers_reply_context_;
66 RendererPpapiHostImpl* renderer_ppapi_host_;
67 89
68 ppapi::host::ReplyMessageContext open_context_; 90 base::WeakPtrFactory<PepperCompositorHost> weak_factory_;
69 91
70 // Audio input object that we delegate audio IPC through. 92 DISALLOW_COPY_AND_ASSIGN(PepperCompositorHost);
71 // We don't own this pointer but are responsible for calling Shutdown on it.
72 PepperPlatformAudioInput* audio_input_;
73
74 PepperDeviceEnumerationHostHelper enumeration_helper_;
75
76 DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost);
77 }; 93 };
78 94
79 } // namespace content 95 } // namespace content
80 96
81 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ 97 #endif // CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698