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

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

Issue 1943513002: [Reland 1] Pepper takes ownership of a mailbox before passing it to the texture layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from sunnyps and piman. Created 4 years, 7 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 (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"
27 #include "content/common/content_export.h" 28 #include "content/common/content_export.h"
28 #include "content/public/renderer/pepper_plugin_instance.h" 29 #include "content/public/renderer/pepper_plugin_instance.h"
29 #include "content/public/renderer/plugin_instance_throttler.h" 30 #include "content/public/renderer/plugin_instance_throttler.h"
30 #include "content/public/renderer/render_frame.h" 31 #include "content/public/renderer/render_frame.h"
31 #include "content/public/renderer/render_frame_observer.h" 32 #include "content/public/renderer/render_frame_observer.h"
32 #include "content/renderer/mouse_lock_dispatcher.h" 33 #include "content/renderer/mouse_lock_dispatcher.h"
33 #include "gin/handle.h" 34 #include "gin/handle.h"
34 #include "ppapi/c/dev/pp_cursor_type_dev.h" 35 #include "ppapi/c/dev/pp_cursor_type_dev.h"
35 #include "ppapi/c/dev/ppp_printing_dev.h" 36 #include "ppapi/c/dev/ppp_printing_dev.h"
36 #include "ppapi/c/dev/ppp_text_input_dev.h" 37 #include "ppapi/c/dev/ppp_text_input_dev.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // relative to the top-left of the plugin. This does nothing if the plugin 191 // relative to the top-left of the plugin. This does nothing if the plugin
191 // has not yet been positioned. You can supply an empty gfx::Rect() to 192 // has not yet been positioned. You can supply an empty gfx::Rect() to
192 // invalidate the entire plugin. 193 // invalidate the entire plugin.
193 void InvalidateRect(const gfx::Rect& rect); 194 void InvalidateRect(const gfx::Rect& rect);
194 195
195 // Schedules a scroll of the plugin. This uses optimized scrolling only for 196 // Schedules a scroll of the plugin. This uses optimized scrolling only for
196 // full-frame plugins, as otherwise there could be other elements on top. The 197 // full-frame plugins, as otherwise there could be other elements on top. The
197 // slow path can also be triggered if there is an overlapping frame. 198 // slow path can also be triggered if there is an overlapping frame.
198 void ScrollRect(int dx, int dy, const gfx::Rect& rect); 199 void ScrollRect(int dx, int dy, const gfx::Rect& rect);
199 200
200 // Commit the backing texture to the screen once the side effects some 201 // Commit the texture mailbox to the screen.
201 // rendering up to an offscreen SwapBuffers are visible. 202 void CommitTextureMailbox(const cc::TextureMailbox& texture_mailbox);
202 void CommitBackingTexture(); 203
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 const gpu::SyncToken& sync_token,
211 bool is_lost);
203 212
204 // Called when the out-of-process plugin implementing this instance crashed. 213 // Called when the out-of-process plugin implementing this instance crashed.
205 void InstanceCrashed(); 214 void InstanceCrashed();
206 215
207 // PPB_Instance and PPB_Instance_Private implementation. 216 // PPB_Instance and PPB_Instance_Private implementation.
208 bool full_frame() const { return full_frame_; } 217 bool full_frame() const { return full_frame_; }
209 const ppapi::ViewData& view_data() const { return view_data_; } 218 const ppapi::ViewData& view_data() const { return view_data_; }
210 219
211 // PPP_Instance and PPP_Instance_Private. 220 // PPP_Instance and PPP_Instance_Private.
212 bool Initialize(const std::vector<std::string>& arg_names, 221 bool Initialize(const std::vector<std::string>& arg_names,
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 void DidDataFromWebURLResponse(const blink::WebURLResponse& response, 704 void DidDataFromWebURLResponse(const blink::WebURLResponse& response,
696 int pending_host_id, 705 int pending_host_id,
697 const ppapi::URLResponseInfoData& data); 706 const ppapi::URLResponseInfoData& data);
698 707
699 void RecordFlashJavaScriptUse(); 708 void RecordFlashJavaScriptUse();
700 709
701 // Converts the PP_Rect between DIP and Viewport. 710 // Converts the PP_Rect between DIP and Viewport.
702 void ConvertRectToDIP(PP_Rect* rect) const; 711 void ConvertRectToDIP(PP_Rect* rect) const;
703 void ConvertDIPToViewport(gfx::Rect* rect) const; 712 void ConvertDIPToViewport(gfx::Rect* rect) const;
704 713
714 // Each time CommitTextureMailbox() is called, this instance is given
715 // ownership
716 // of a cc::TextureMailbox. This instance always needs to hold on to the most
717 // recently committed cc::TextureMailbox, since UpdateLayer() might require
718 // it.
719 // Since it is possible for a cc::TextureMailbox to be passed to
720 // texture_layer_ more than once, a reference counting mechanism is necessary
721 // to ensure that a cc::TextureMailbox isn't returned until all copies of it
722 // have been released by texture_layer_.
723 //
724 // This method should be called each time a cc::TextureMailbox is passed to
725 // |texture_layer_|. It increments an internal reference count.
726 void IncrementTextureReferenceCount(const cc::TextureMailbox& mailbox);
727
728 // This method should be called each time |texture_layer_| finishes consuming
729 // a cc::TextureMailbox. It decrements an internal reference count. Returns
730 // whether the last reference was removed.
731 bool DecrementTextureReferenceCount(const cc::TextureMailbox& mailbox);
732
733 // Whether a given cc::TextureMailbox is in use by |texture_layer_|.
734 bool IsTextureInUse(const cc::TextureMailbox& mailbox) const;
735
705 RenderFrameImpl* render_frame_; 736 RenderFrameImpl* render_frame_;
706 base::Closure instance_deleted_callback_; 737 base::Closure instance_deleted_callback_;
707 scoped_refptr<PluginModule> module_; 738 scoped_refptr<PluginModule> module_;
708 std::unique_ptr<ppapi::PPP_Instance_Combined> instance_interface_; 739 std::unique_ptr<ppapi::PPP_Instance_Combined> instance_interface_;
709 // If this is the NaCl plugin, we create a new module when we switch to the 740 // If this is the NaCl plugin, we create a new module when we switch to the
710 // IPC-based PPAPI proxy. Store the original module and instance interface 741 // IPC-based PPAPI proxy. Store the original module and instance interface
711 // so we can shut down properly. 742 // so we can shut down properly.
712 scoped_refptr<PluginModule> original_module_; 743 scoped_refptr<PluginModule> original_module_;
713 std::unique_ptr<ppapi::PPP_Instance_Combined> original_instance_interface_; 744 std::unique_ptr<ppapi::PPP_Instance_Combined> original_instance_interface_;
714 745
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 // Isolate in which this Instance was created when interacting with v8. 957 // Isolate in which this Instance was created when interacting with v8.
927 v8::Isolate* isolate_; 958 v8::Isolate* isolate_;
928 959
929 std::unique_ptr<MouseLockDispatcher::LockTarget> lock_target_; 960 std::unique_ptr<MouseLockDispatcher::LockTarget> lock_target_;
930 961
931 bool is_deleted_; 962 bool is_deleted_;
932 963
933 // The text that is currently selected in the plugin. 964 // The text that is currently selected in the plugin.
934 base::string16 selected_text_; 965 base::string16 selected_text_;
935 966
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 gpu::SyncToken committed_texture_consumed_sync_token_;
972
973 // Holds the number of references |texture_layer_| has to any given
974 // cc::TextureMailbox.
975 // We expect there to be no more than 10 textures in use at a time. A
976 // std::vector will have better performance than a std::map.
977 using TextureMailboxRefCount = std::pair<cc::TextureMailbox, int>;
978 std::vector<TextureMailboxRefCount> texture_ref_counts_;
979
936 bool initialized_; 980 bool initialized_;
937 981
938 // We use a weak ptr factory for scheduling DidChangeView events so that we 982 // We use a weak ptr factory for scheduling DidChangeView events so that we
939 // can tell whether updates are pending and consolidate them. When there's 983 // can tell whether updates are pending and consolidate them. When there's
940 // already a weak ptr pending (HasWeakPtrs is true), code should update the 984 // already a weak ptr pending (HasWeakPtrs is true), code should update the
941 // view_data_ but not send updates. This also allows us to cancel scheduled 985 // view_data_ but not send updates. This also allows us to cancel scheduled
942 // view change events. 986 // view change events.
943 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_; 987 base::WeakPtrFactory<PepperPluginInstanceImpl> view_change_weak_ptr_factory_;
944 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_; 988 base::WeakPtrFactory<PepperPluginInstanceImpl> weak_factory_;
945 989
946 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl); 990 DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceImpl);
947 }; 991 };
948 992
949 } // namespace content 993 } // namespace content
950 994
951 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_ 995 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_IMPL_H_
OLDNEW
« no previous file with comments | « components/mus/public/interfaces/command_buffer.mojom ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698