Index: content/renderer/pepper/pepper_plugin_instance_impl.h |
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h |
index da461798a5502d85b77b040a6e0bbc80c3ec0cb0..b8077857e7f1c0adbd8d0b7f8f957304e825f645 100644 |
--- a/content/renderer/pepper/pepper_plugin_instance_impl.h |
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.h |
@@ -24,6 +24,7 @@ |
#include "cc/layers/content_layer_client.h" |
#include "cc/layers/layer.h" |
#include "cc/layers/texture_layer_client.h" |
+#include "cc/resources/texture_mailbox.h" |
#include "content/common/content_export.h" |
#include "content/public/renderer/pepper_plugin_instance.h" |
#include "content/public/renderer/plugin_instance_throttler.h" |
@@ -197,9 +198,18 @@ class CONTENT_EXPORT PepperPluginInstanceImpl |
// slow path can also be triggered if there is an overlapping frame. |
void ScrollRect(int dx, int dy, const gfx::Rect& rect); |
- // Commit the backing texture to the screen once the side effects some |
- // rendering up to an offscreen SwapBuffers are visible. |
- void CommitBackingTexture(); |
+ // Commit the texture mailbox to the screen. |
+ void CommitTextureMailbox(const cc::TextureMailbox& texture_mailbox); |
+ |
+ // Passes the committed texture to |texture_layer_| and marks it as in use. |
+ void PassCommittedTextureToTextureLayer(); |
+ |
+ // Callback when the compositor is finished consuming the committed texture. |
+ void FinishedConsumingCommittedTexture( |
+ const cc::TextureMailbox& texture_mailbox, |
+ scoped_refptr<PPB_Graphics3D_Impl> graphics_3d, |
+ const gpu::SyncToken& sync_token, |
+ bool is_lost); |
// Called when the out-of-process plugin implementing this instance crashed. |
void InstanceCrashed(); |
@@ -702,6 +712,28 @@ class CONTENT_EXPORT PepperPluginInstanceImpl |
void ConvertRectToDIP(PP_Rect* rect) const; |
void ConvertDIPToViewport(gfx::Rect* rect) const; |
+ // Each time CommitTextureMailbox() is called, this instance is given |
+ // ownership |
+ // of a cc::TextureMailbox. This instance always needs to hold on to the most |
+ // recently committed cc::TextureMailbox, since UpdateLayer() might require |
+ // it. |
+ // Since it is possible for a cc::TextureMailbox to be passed to |
+ // texture_layer_ more than once, a reference counting mechanism is necessary |
+ // to ensure that a cc::TextureMailbox isn't returned until all copies of it |
+ // have been released by texture_layer_. |
+ // |
+ // This method should be called each time a cc::TextureMailbox is passed to |
+ // |texture_layer_|. It increments an internal reference count. |
+ void IncrementTextureReferenceCount(const cc::TextureMailbox& mailbox); |
+ |
+ // This method should be called each time |texture_layer_| finishes consuming |
+ // a cc::TextureMailbox. It decrements an internal reference count. Returns |
+ // whether the last reference was removed. |
+ bool DecrementTextureReferenceCount(const cc::TextureMailbox& mailbox); |
+ |
+ // Whether a given cc::TextureMailbox is in use by |texture_layer_|. |
+ bool IsTextureInUse(const cc::TextureMailbox& mailbox) const; |
+ |
RenderFrameImpl* render_frame_; |
base::Closure instance_deleted_callback_; |
scoped_refptr<PluginModule> module_; |
@@ -933,6 +965,22 @@ class CONTENT_EXPORT PepperPluginInstanceImpl |
// The text that is currently selected in the plugin. |
base::string16 selected_text_; |
+ // The most recently committed texture. This is kept around in case the layer |
+ // needs to be regenerated. |
+ cc::TextureMailbox committed_texture_; |
+ |
+ // The Graphics3D that produced the most recently committed texture. |
+ scoped_refptr<PPB_Graphics3D_Impl> committed_texture_graphics_3d_; |
+ |
+ gpu::SyncToken committed_texture_consumed_sync_token_; |
+ |
+ // Holds the number of references |texture_layer_| has to any given |
+ // cc::TextureMailbox. |
+ // We expect there to be no more than 10 textures in use at a time. A |
+ // std::vector will have better performance than a std::map. |
+ using TextureMailboxRefCount = std::pair<cc::TextureMailbox, int>; |
+ std::vector<TextureMailboxRefCount> texture_ref_counts_; |
+ |
bool initialized_; |
// We use a weak ptr factory for scheduling DidChangeView events so that we |