Chromium Code Reviews| Index: content/renderer/pepper/pepper_compositor_host.h |
| diff --git a/content/renderer/pepper/pepper_audio_input_host.h b/content/renderer/pepper/pepper_compositor_host.h |
| similarity index 17% |
| copy from content/renderer/pepper/pepper_audio_input_host.h |
| copy to content/renderer/pepper/pepper_compositor_host.h |
| index 40f98b0db7f590960527193a9b3cda204ac10a5a..981fd0ed028b7e65e6c516aa547df15fcfa912ea 100644 |
| --- a/content/renderer/pepper/pepper_audio_input_host.h |
| +++ b/content/renderer/pepper/pepper_compositor_host.h |
| @@ -1,81 +1,97 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
| -#define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
| +#ifndef CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_ |
| +#define CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_ |
| -#include <string> |
| - |
| -#include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "base/memory/shared_memory.h" |
| -#include "base/sync_socket.h" |
| -#include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" |
| -#include "ipc/ipc_platform_file.h" |
| -#include "ppapi/c/ppb_audio_config.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "ppapi/host/host_message_context.h" |
| #include "ppapi/host/resource_host.h" |
| +#include "ppapi/shared_impl/compositor_layer_data.h" |
| + |
| +namespace base { |
| +class SharedMemory; |
| +} // namespace base |
| + |
| +namespace cc { |
| +class Layer; |
| +} // namespace cc |
| namespace content { |
| -class PepperPlatformAudioInput; |
| -class RendererPpapiHostImpl; |
| -class PepperAudioInputHost : public ppapi::host::ResourceHost { |
| +class PepperPluginInstanceImpl; |
| +class RendererPpapiHost; |
| + |
| +class PepperCompositorHost : public ppapi::host::ResourceHost { |
| public: |
| - PepperAudioInputHost(RendererPpapiHostImpl* host, |
| + PepperCompositorHost(RendererPpapiHost* host, |
| PP_Instance instance, |
| PP_Resource resource); |
| - virtual ~PepperAudioInputHost(); |
| + // Associates this device with the given plugin instance. You can pass NULL |
| + // to clear the existing device. Returns true on success. In this case, a |
| + // repaint of the page will also be scheduled. Failure means that the device |
| + // is already bound to a different instance, and nothing will happen. |
| + bool BindToInstance(PepperPluginInstanceImpl* new_instance); |
| - virtual int32_t OnResourceMessageReceived( |
| - const IPC::Message& msg, |
| - ppapi::host::HostMessageContext* context) OVERRIDE; |
| + const scoped_refptr<cc::Layer> layer() { return layer_; }; |
| - // Called when the stream is created. |
| - void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
| - size_t shared_memory_size, |
| - base::SyncSocket::Handle socket); |
| - void StreamCreationFailed(); |
| + void ViewInitiatedPaint(); |
| + void ViewFlushedPaint(); |
| private: |
| - int32_t OnOpen(ppapi::host::HostMessageContext* context, |
| - const std::string& device_id, |
| - PP_AudioSampleRate sample_rate, |
| - uint32_t sample_frame_count); |
| - int32_t OnStartOrStop(ppapi::host::HostMessageContext* context, bool capture); |
| - int32_t OnClose(ppapi::host::HostMessageContext* context); |
| + virtual ~PepperCompositorHost(); |
| + |
| + void UpdateLayer(const scoped_refptr<cc::Layer>& layer, |
| + const ppapi::CompositorLayerData* pp_layer_old, |
| + const ppapi::CompositorLayerData* pp_layer); |
| + |
| + void ResourceReleased(int32_t id, |
| + uint32_t sync_point, |
| + bool is_lost); |
| + void ImageReleased(int32_t id, |
| + const scoped_ptr<base::SharedMemory>& shared_memory, |
| + uint32_t sync_point, |
| + bool is_lost); |
| + |
| + // ResourceMessageHandler overrides: |
| + virtual int32_t OnResourceMessageReceived( |
| + const IPC::Message& msg, |
| + ppapi::host::HostMessageContext* context) OVERRIDE; |
| - void OnOpenComplete(int32_t result, |
| - base::SharedMemoryHandle shared_memory_handle, |
| - size_t shared_memory_size, |
| - base::SyncSocket::Handle socket_handle); |
| + // ppapi::host::ResourceHost overrides: |
| + virtual bool IsCompositorHost() OVERRIDE; |
| - int32_t GetRemoteHandles( |
| - const base::SyncSocket& socket, |
| - const base::SharedMemory& shared_memory, |
| - IPC::PlatformFileForTransit* remote_socket_handle, |
| - base::SharedMemoryHandle* remote_shared_memory_handle); |
| + // Message handlers: |
| + int32_t OnHostMsgCommitLayers( |
| + ppapi::host::HostMessageContext* context, |
| + const std::vector<ppapi::CompositorLayerData>& layers, |
| + bool reset); |
| - void Close(); |
| + // Non-owning pointer to the plugin instance this context is currently bound |
| + // to, if any. If the context is currently unbound, this will be NULL. |
| + PepperPluginInstanceImpl* bound_instance_; |
| - void SendOpenReply(int32_t result); |
| + // The toplevel cc::Layer. It is the parent of other cc::Layers. |
| + scoped_refptr<cc::Layer> layer_; |
| - // Non-owning pointer. |
| - RendererPpapiHostImpl* renderer_ppapi_host_; |
| + // A list of cc::Layer. It is used for updating layers' properties in |
| + // subsequent CommitLayers() calls. |
| + std::vector<scoped_refptr<cc::Layer> > cc_layers_; |
| - ppapi::host::ReplyMessageContext open_context_; |
| + // A list of pepper CompositorLayerData. It is used for comparing layers' |
| + // properties with subsequent layers committed by CommitLayers() calls. |
| + 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.
|
| - // Audio input object that we delegate audio IPC through. |
| - // We don't own this pointer but are responsible for calling Shutdown on it. |
| - PepperPlatformAudioInput* audio_input_; |
| + ppapi::host::ReplyMessageContext commit_layers_reply_context_; |
| - PepperDeviceEnumerationHostHelper enumeration_helper_; |
| + base::WeakPtrFactory<PepperCompositorHost> weak_factory_; |
| - DISALLOW_COPY_AND_ASSIGN(PepperAudioInputHost); |
| + DISALLOW_COPY_AND_ASSIGN(PepperCompositorHost); |
| }; |
| } // namespace content |
| -#endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_INPUT_HOST_H_ |
| +#endif // CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_ |