| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_TEXTURE_PROVIDER_H_ |
| 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_TEXTURE_PROVIDER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/synchronization/lock.h" |
| 10 #include "content/common/browser_plugin_info.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "ipc/ipc_forwarding_message_filter.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureP
rovider.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" |
| 15 #include "ui/gfx/size.h" |
| 16 |
| 17 struct BrowserPluginMsg_UpdateRect_Params; |
| 18 |
| 19 class RenderViewImpl; |
| 20 |
| 21 namespace base { |
| 22 class MessageLoopProxy; |
| 23 } |
| 24 |
| 25 namespace content { |
| 26 |
| 27 class BrowserPluginManager; |
| 28 |
| 29 class CONTENT_EXPORT BrowserPluginTextureProvider |
| 30 : public WebKit::WebExternalTextureProvider, |
| 31 public IPC::Sender { |
| 32 public: |
| 33 BrowserPluginTextureProvider(int instance_id, |
| 34 int routing_id, |
| 35 IPC::ChannelProxy* channel_proxy); |
| 36 |
| 37 void Destroy(); |
| 38 |
| 39 void OnMessageReceived(const IPC::Message& message); |
| 40 void OnBuffersSwapped( |
| 41 int instance_id, |
| 42 uint64 surface_id, |
| 43 const BrowserPlugin_SwapInfo& info); |
| 44 void OnSurfaceResize(int instance_id, const gfx::Size& size); |
| 45 |
| 46 // virtual to allow for mocking |
| 47 virtual void Resize(const gfx::Size& size); |
| 48 virtual void SurfaceResize(const gfx::Size& size); |
| 49 virtual void SetDelayedSwap( |
| 50 uint64 surface_id, |
| 51 const BrowserPlugin_SwapInfo& delayed_swap_info); |
| 52 |
| 53 // WebExternalTextureProvider implementation |
| 54 virtual void setTextureProviderClient(Client*); |
| 55 |
| 56 virtual unsigned textureId() const OVERRIDE; |
| 57 virtual bool premultipliedAlpha() const OVERRIDE; |
| 58 virtual bool flipped() const OVERRIDE; |
| 59 virtual WebKit::WebFloatRect uvRect() const OVERRIDE; |
| 60 |
| 61 // IPC::Sender implementation |
| 62 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 63 |
| 64 private: |
| 65 friend class MockBrowserPluginTextureProvider; |
| 66 |
| 67 virtual ~BrowserPluginTextureProvider(); |
| 68 |
| 69 void DestroyImpl(); |
| 70 void ResizeImpl(const gfx::Size& size); |
| 71 |
| 72 void SetUpFilter(); |
| 73 void RemoveFilter(); |
| 74 |
| 75 // Used as the main thread callback to signal that we are attached to a |
| 76 // client |
| 77 static void SignalReady(int instance_id); |
| 78 |
| 79 WebExternalTextureProvider::Client* client_; |
| 80 |
| 81 // The texture ID we are currently providing |
| 82 unsigned texture_id_; |
| 83 |
| 84 scoped_refptr<IPC::ForwardingMessageFilter> filter_; |
| 85 |
| 86 int instance_id_; |
| 87 |
| 88 // If impl_loop_ is 0, we are working only on the main thread |
| 89 scoped_refptr<base::MessageLoopProxy> main_loop_, impl_loop_; |
| 90 |
| 91 // The IPC channel used by the renderer to communicate with the host. |
| 92 // This is allowed to be 0 only in testing, when a derived class should |
| 93 // override SetUpFilter, RemoveFilter, and Send, which are the only members |
| 94 // allowed to use channel_proxy. |
| 95 IPC::ChannelProxy* channel_proxy_; |
| 96 |
| 97 int host_routing_id_; |
| 98 |
| 99 // The size of the next texture update we will receive |
| 100 gfx::Size texture_size_; |
| 101 |
| 102 // The size of the container |
| 103 gfx::Size container_size_; |
| 104 |
| 105 // Information for performing a delayed buffer swap during startup |
| 106 bool has_delayed_swap_; |
| 107 BrowserPlugin_SwapInfo delayed_swap_info_; |
| 108 |
| 109 // This lock is for when we may be updating the impl_loop_ member, which |
| 110 // could trigger a switch between threaded and non-threaded. It is also |
| 111 // used for setting a delayed swap, as that relies on shared state. |
| 112 base::Lock lock_; |
| 113 }; |
| 114 |
| 115 } // namespace content |
| 116 |
| 117 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_WEB_BROWSER_PLUGIN_TEXTURE_PROVIDER_H
_ |
| OLD | NEW |