OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "cc/layers/solid_color_layer.h" |
| 13 #include "ppapi/host/host_message_context.h" |
| 14 #include "ppapi/host/resource_host.h" |
| 15 #include "ppapi/shared_impl/compositor_layer_data.h" |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class PepperPluginInstanceImpl; |
| 20 class RendererPpapiHost; |
| 21 |
| 22 class PepperCompositorHost : public ppapi::host::ResourceHost { |
| 23 public: |
| 24 PepperCompositorHost(RendererPpapiHost* host, |
| 25 PP_Instance instance, |
| 26 PP_Resource resource); |
| 27 // AssOciates this device with the given plugin instance. You can pass NULL |
| 28 // to clear the existing device. Returns true on success. In this case, a |
| 29 // repaint of the page will also be scheduled. Failure means that the device |
| 30 // is already bound to a different instance, and nothing will happen. |
| 31 bool BindToInstance(PepperPluginInstanceImpl* new_instance); |
| 32 |
| 33 const scoped_refptr<cc::Layer> layer() { return layer_; }; |
| 34 |
| 35 void ViewInitiatedPaint(); |
| 36 void ViewFlushedPaint(); |
| 37 |
| 38 private: |
| 39 virtual ~PepperCompositorHost(); |
| 40 |
| 41 void UpdateLayer(const scoped_refptr<cc::Layer>& layer, |
| 42 const ppapi::CompositorLayerData* pp_layer_old, |
| 43 const ppapi::CompositorLayerData* pp_layer); |
| 44 |
| 45 void ResourceReleased(int32_t id, |
| 46 uint32_t sync_point, |
| 47 bool is_lost); |
| 48 void ImageReleased(int32_t id, |
| 49 scoped_ptr<base::SharedMemory> shared_memory, |
| 50 uint32_t sync_point, |
| 51 bool is_lost); |
| 52 |
| 53 // ResourceMessageHandler overrides: |
| 54 virtual int32_t OnResourceMessageReceived( |
| 55 const IPC::Message& msg, |
| 56 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 57 |
| 58 // ppapi::host::ResourceHost overrides: |
| 59 virtual bool IsCompositorHost() OVERRIDE; |
| 60 |
| 61 // Message handlers: |
| 62 int32_t OnHostMsgCommitLayers( |
| 63 ppapi::host::HostMessageContext* context, |
| 64 const std::vector<ppapi::CompositorLayerData>& layers, |
| 65 bool reset); |
| 66 |
| 67 // Non-owning pointer to the plugin instance this context is currently bound |
| 68 // to, if any. If the context is currently unbound, this will be NULL. |
| 69 PepperPluginInstanceImpl* bound_instance_; |
| 70 |
| 71 // The toplevel cc::Layer. It is the parent of other cc::Layers. |
| 72 scoped_refptr<cc::Layer> layer_; |
| 73 |
| 74 // A list of cc::Layer. It is used for updating layers' properties in |
| 75 // subsequent CommitLayers() calls. |
| 76 std::vector<scoped_refptr<cc::Layer> > cc_layers_; |
| 77 |
| 78 // A list of pepper CompositorLayerData. It is used for comparing layers' |
| 79 // properties with subsequent layers committed by CommitLayers() calls. |
| 80 std::vector<ppapi::CompositorLayerData> pp_layers_; |
| 81 |
| 82 ppapi::host::ReplyMessageContext commit_layers_reply_context_; |
| 83 |
| 84 base::WeakPtrFactory<PepperCompositorHost> weak_factory_; |
| 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(PepperCompositorHost); |
| 87 }; |
| 88 |
| 89 } // namespace content |
| 90 |
| 91 #endif // CONTENT_RENDERER_PEPPER_PEPPER_COMPOSITOR_H_ |
OLD | NEW |