| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_PLUGIN_INSTANCE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "cc/layers/content_layer_client.h" | 24 #include "cc/layers/content_layer_client.h" |
| 25 #include "cc/layers/layer.h" | 25 #include "cc/layers/layer.h" |
| 26 #include "cc/layers/texture_layer_client.h" | 26 #include "cc/layers/texture_layer_client.h" |
| 27 #include "cc/resources/texture_mailbox.h" | |
| 28 #include "content/common/content_export.h" | 27 #include "content/common/content_export.h" |
| 29 #include "content/public/renderer/pepper_plugin_instance.h" | 28 #include "content/public/renderer/pepper_plugin_instance.h" |
| 30 #include "content/public/renderer/plugin_instance_throttler.h" | 29 #include "content/public/renderer/plugin_instance_throttler.h" |
| 31 #include "content/public/renderer/render_frame.h" | 30 #include "content/public/renderer/render_frame.h" |
| 32 #include "content/public/renderer/render_frame_observer.h" | 31 #include "content/public/renderer/render_frame_observer.h" |
| 33 #include "content/renderer/mouse_lock_dispatcher.h" | 32 #include "content/renderer/mouse_lock_dispatcher.h" |
| 34 #include "gin/handle.h" | 33 #include "gin/handle.h" |
| 35 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 34 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
| 36 #include "ppapi/c/dev/ppp_printing_dev.h" | 35 #include "ppapi/c/dev/ppp_printing_dev.h" |
| 37 #include "ppapi/c/dev/ppp_text_input_dev.h" | 36 #include "ppapi/c/dev/ppp_text_input_dev.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // relative to the top-left of the plugin. This does nothing if the plugin | 190 // relative to the top-left of the plugin. This does nothing if the plugin |
| 192 // has not yet been positioned. You can supply an empty gfx::Rect() to | 191 // has not yet been positioned. You can supply an empty gfx::Rect() to |
| 193 // invalidate the entire plugin. | 192 // invalidate the entire plugin. |
| 194 void InvalidateRect(const gfx::Rect& rect); | 193 void InvalidateRect(const gfx::Rect& rect); |
| 195 | 194 |
| 196 // Schedules a scroll of the plugin. This uses optimized scrolling only for | 195 // Schedules a scroll of the plugin. This uses optimized scrolling only for |
| 197 // full-frame plugins, as otherwise there could be other elements on top. The | 196 // full-frame plugins, as otherwise there could be other elements on top. The |
| 198 // slow path can also be triggered if there is an overlapping frame. | 197 // slow path can also be triggered if there is an overlapping frame. |
| 199 void ScrollRect(int dx, int dy, const gfx::Rect& rect); | 198 void ScrollRect(int dx, int dy, const gfx::Rect& rect); |
| 200 | 199 |
| 201 // Commit the texture mailbox to the screen. | 200 // Commit the backing texture to the screen once the side effects some |
| 202 void CommitTextureMailbox(const cc::TextureMailbox& texture_mailbox); | 201 // rendering up to an offscreen SwapBuffers are visible. |
| 203 | 202 void CommitBackingTexture(); |
| 204 // Passes the committed texture to |texture_layer_| and marks it as in use. | |
| 205 void PassCommittedTextureToTextureLayer(); | |
| 206 | |
| 207 // Callback when the compositor is finished consuming the committed texture. | |
| 208 void FinishedConsumingCommittedTexture( | |
| 209 const cc::TextureMailbox& texture_mailbox, | |
| 210 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d, | |
| 211 const gpu::SyncToken& sync_token, | |
| 212 bool is_lost); | |
| 213 | 203 |
| 214 // Called when the out-of-process plugin implementing this instance crashed. | 204 // Called when the out-of-process plugin implementing this instance crashed. |
| 215 void InstanceCrashed(); | 205 void InstanceCrashed(); |
| 216 | 206 |
| 217 // PPB_Instance and PPB_Instance_Private implementation. | 207 // PPB_Instance and PPB_Instance_Private implementation. |
| 218 bool full_frame() const { return full_frame_; } | 208 bool full_frame() const { return full_frame_; } |
| 219 const ppapi::ViewData& view_data() const { return view_data_; } | 209 const ppapi::ViewData& view_data() const { return view_data_; } |
| 220 | 210 |
| 221 // PPP_Instance and PPP_Instance_Private. | 211 // PPP_Instance and PPP_Instance_Private. |
| 222 bool Initialize(const std::vector<std::string>& arg_names, | 212 bool Initialize(const std::vector<std::string>& arg_names, |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 void DidDataFromWebURLResponse(const blink::WebURLResponse& response, | 695 void DidDataFromWebURLResponse(const blink::WebURLResponse& response, |
| 706 int pending_host_id, | 696 int pending_host_id, |
| 707 const ppapi::URLResponseInfoData& data); | 697 const ppapi::URLResponseInfoData& data); |
| 708 | 698 |
| 709 void RecordFlashJavaScriptUse(); | 699 void RecordFlashJavaScriptUse(); |
| 710 | 700 |
| 711 // Converts the PP_Rect between DIP and Viewport. | 701 // Converts the PP_Rect between DIP and Viewport. |
| 712 void ConvertRectToDIP(PP_Rect* rect) const; | 702 void ConvertRectToDIP(PP_Rect* rect) const; |
| 713 void ConvertDIPToViewport(gfx::Rect* rect) const; | 703 void ConvertDIPToViewport(gfx::Rect* rect) const; |
| 714 | 704 |
| 715 // Each time CommitTextureMailbox() is called, this instance is given | |
| 716 // ownership | |
| 717 // of a cc::TextureMailbox. This instance always needs to hold on to the most | |
| 718 // recently committed cc::TextureMailbox, since UpdateLayer() might require | |
| 719 // it. | |
| 720 // Since it is possible for a cc::TextureMailbox to be passed to | |
| 721 // texture_layer_ more than once, a reference counting mechanism is necessary | |
| 722 // to ensure that a cc::TextureMailbox isn't returned until all copies of it | |
| 723 // have been released by texture_layer_. | |
| 724 // | |
| 725 // This method should be called each time a cc::TextureMailbox is passed to | |
| 726 // |texture_layer_|. It increments an internal reference count. | |
| 727 void IncrementTextureReferenceCount(const cc::TextureMailbox& mailbox); | |
| 728 | |
| 729 // This method should be called each time |texture_layer_| finishes consuming | |
| 730 // a cc::TextureMailbox. It decrements an internal reference count. Returns | |
| 731 // whether the last reference was removed. | |
| 732 bool DecrementTextureReferenceCount(const cc::TextureMailbox& mailbox); | |
| 733 | |
| 734 // Whether a given cc::TextureMailbox is in use by |texture_layer_|. | |
| 735 bool IsTextureInUse(const cc::TextureMailbox& mailbox) const; | |
| 736 | |
| 737 RenderFrameImpl* render_frame_; | 705 RenderFrameImpl* render_frame_; |
| 738 scoped_refptr<PluginModule> module_; | 706 scoped_refptr<PluginModule> module_; |
| 739 std::unique_ptr<ppapi::PPP_Instance_Combined> instance_interface_; | 707 std::unique_ptr<ppapi::PPP_Instance_Combined> instance_interface_; |
| 740 // If this is the NaCl plugin, we create a new module when we switch to the | 708 // If this is the NaCl plugin, we create a new module when we switch to the |
| 741 // IPC-based PPAPI proxy. Store the original module and instance interface | 709 // IPC-based PPAPI proxy. Store the original module and instance interface |
| 742 // so we can shut down properly. | 710 // so we can shut down properly. |
| 743 scoped_refptr<PluginModule> original_module_; | 711 scoped_refptr<PluginModule> original_module_; |
| 744 std::unique_ptr<ppapi::PPP_Instance_Combined> original_instance_interface_; | 712 std::unique_ptr<ppapi::PPP_Instance_Combined> original_instance_interface_; |
| 745 | 713 |
| 746 PP_Instance pp_instance_; | 714 PP_Instance pp_instance_; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 // Isolate in which this Instance was created when interacting with v8. | 925 // Isolate in which this Instance was created when interacting with v8. |
| 958 v8::Isolate* isolate_; | 926 v8::Isolate* isolate_; |
| 959 | 927 |
| 960 std::unique_ptr<MouseLockDispatcher::LockTarget> lock_target_; | 928 std::unique_ptr<MouseLockDispatcher::LockTarget> lock_target_; |
| 961 | 929 |
| 962 bool is_deleted_; | 930 bool is_deleted_; |
| 963 | 931 |
| 964 // The text that is currently selected in the plugin. | 932 // The text that is currently selected in the plugin. |
| 965 base::string16 selected_text_; | 933 base::string16 selected_text_; |
| 966 | 934 |
| 967 // The most recently committed texture. This is kept around in case the layer | |
| 968 // needs to be regenerated. | |
| 969 cc::TextureMailbox committed_texture_; | |
| 970 | |
| 971 // The Graphics3D that produced the most recently committed texture. | |
| 972 scoped_refptr<PPB_Graphics3D_Impl> committed_texture_graphics_3d_; | |
| 973 | |
| 974 gpu::SyncToken committed_texture_consumed_sync_token_; | |
| 975 | |
| 976 // Holds the number of references |texture_layer_| has to any given | |
| 977 // cc::TextureMailbox. | |
| 978 // We expect there to be no more than 10 textures in use at a time. A | |
| 979 // std::vector will have better performance than a std::map. | |
| 980 using TextureMailboxRefCount = std::pair<cc::TextureMailbox, int>; | |
| 981 std::vector<TextureMailboxRefCount> texture_ref_counts_; | |
| 982 | |
| 983 bool initialized_; | 935 bool initialized_; |
| 984 | 936 |
| 985 // We use a weak ptr factory for scheduling DidChangeView events so that we | 937 // We use a weak ptr factory for scheduling DidChangeView events so that we |
| 986 // can tell whether updates are pending and consolidate them. When there's | 938 // can tell whether updates are pending and consolidate them. When there's |
| 987 // already a weak ptr pending (HasWeakPtrs is true), code should update the | 939 // already a weak ptr pending (HasWeakPtrs is true), code should update the |
| 988 // view_data_ but not send updates. This also allows us to cancel scheduled | 940 // view_data_ but not send updates. This also allows us to cancel scheduled |
| 989 // view change events. | 941 // view change events. |
| 990 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; | 942 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; |
| 991 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; | 943 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; |
| 992 | 944 |
| 993 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); | 945 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); |
| 994 }; | 946 }; |
| 995 | 947 |
| 996 } // namespace content | 948 } // namespace content |
| 997 | 949 |
| 998 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ | 950 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ |
| OLD | NEW |