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_PLUGIN_WEBPLUGIN_PROXY_H_ | 5 #ifndef CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
6 #define CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 6 #define CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
14 #endif | 14 #endif |
15 #include "base/memory/scoped_handle.h" | 15 #include "base/memory/scoped_handle.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
20 #include "content/child/npapi/webplugin.h" | 20 #include "content/child/npapi/webplugin.h" |
21 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
22 #include "ipc/ipc_sender.h" | 22 #include "ipc/ipc_sender.h" |
23 #include "skia/ext/refptr.h" | 23 #include "skia/ext/refptr.h" |
24 #include "third_party/skia/include/core/SkCanvas.h" | 24 #include "third_party/skia/include/core/SkCanvas.h" |
25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
26 #if defined(USE_X11) | |
27 #include "ui/base/x/x11_util.h" | |
28 #endif | |
29 #include "ui/gl/gpu_preference.h" | 26 #include "ui/gl/gpu_preference.h" |
30 #include "ui/surface/transport_dib.h" | 27 #include "ui/surface/transport_dib.h" |
31 | 28 |
32 struct PluginMsg_FetchURL_Params; | 29 struct PluginMsg_FetchURL_Params; |
33 | 30 |
34 namespace content { | 31 namespace content { |
35 class PluginChannel; | 32 class PluginChannel; |
36 class WebPluginDelegateImpl; | 33 class WebPluginDelegateImpl; |
37 | 34 |
38 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
164 void CreateCanvasFromHandle(const TransportDIB::Handle& dib_handle, | 161 void CreateCanvasFromHandle(const TransportDIB::Handle& dib_handle, |
165 const gfx::Rect& window_rect, | 162 const gfx::Rect& window_rect, |
166 skia::RefPtr<SkCanvas>* canvas); | 163 skia::RefPtr<SkCanvas>* canvas); |
167 #elif defined(OS_MACOSX) | 164 #elif defined(OS_MACOSX) |
168 static void CreateDIBAndCGContextFromHandle( | 165 static void CreateDIBAndCGContextFromHandle( |
169 const TransportDIB::Handle& dib_handle, | 166 const TransportDIB::Handle& dib_handle, |
170 const gfx::Rect& window_rect, | 167 const gfx::Rect& window_rect, |
171 scoped_ptr<TransportDIB>* dib_out, | 168 scoped_ptr<TransportDIB>* dib_out, |
172 base::ScopedCFTypeRef<CGContextRef>* cg_context_out); | 169 base::ScopedCFTypeRef<CGContextRef>* cg_context_out); |
173 #elif defined(USE_X11) | |
174 static void CreateDIBAndCanvasFromHandle( | |
175 const TransportDIB::Handle& dib_handle, | |
176 const gfx::Rect& window_rect, | |
177 scoped_refptr<SharedTransportDIB>* dib_out, | |
178 skia::RefPtr<SkCanvas>* canvas); | |
179 | |
180 static void CreateShmPixmapFromDIB( | |
181 TransportDIB* dib, | |
182 const gfx::Rect& window_rect, | |
183 XID* pixmap_out); | |
184 #endif | 170 #endif |
185 | 171 |
186 // Updates the shared memory sections where windowless plugins paint. | 172 // Updates the shared memory sections where windowless plugins paint. |
187 void SetWindowlessBuffers(const TransportDIB::Handle& windowless_buffer0, | 173 void SetWindowlessBuffers(const TransportDIB::Handle& windowless_buffer0, |
188 const TransportDIB::Handle& windowless_buffer1, | 174 const TransportDIB::Handle& windowless_buffer1, |
189 const gfx::Rect& window_rect); | 175 const gfx::Rect& window_rect); |
190 | 176 |
191 #if defined(OS_MACOSX) | 177 #if defined(OS_MACOSX) |
192 CGContextRef windowless_context() const { | 178 CGContextRef windowless_context() const { |
193 return windowless_contexts_[windowless_buffer_index_].get(); | 179 return windowless_contexts_[windowless_buffer_index_].get(); |
194 } | 180 } |
195 #else | 181 #else |
196 skia::RefPtr<SkCanvas> windowless_canvas() const { | 182 skia::RefPtr<SkCanvas> windowless_canvas() const { |
197 return windowless_canvases_[windowless_buffer_index_]; | 183 return windowless_canvases_[windowless_buffer_index_]; |
198 } | 184 } |
199 | |
200 #if defined(USE_X11) | |
201 XID windowless_shm_pixmap() const { | |
202 return windowless_shm_pixmaps_[windowless_buffer_index_]; | |
203 } | |
204 #endif | |
205 | |
206 #endif | 185 #endif |
207 | 186 |
208 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; | 187 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; |
209 ResourceClientMap resource_clients_; | 188 ResourceClientMap resource_clients_; |
210 | 189 |
211 scoped_refptr<PluginChannel> channel_; | 190 scoped_refptr<PluginChannel> channel_; |
212 int route_id_; | 191 int route_id_; |
213 NPObject* window_npobject_; | 192 NPObject* window_npobject_; |
214 NPObject* plugin_element_; | 193 NPObject* plugin_element_; |
215 WebPluginDelegateImpl* delegate_; | 194 WebPluginDelegateImpl* delegate_; |
216 gfx::Rect damaged_rect_; | 195 gfx::Rect damaged_rect_; |
217 bool waiting_for_paint_; | 196 bool waiting_for_paint_; |
218 // The url of the main frame hosting the plugin. | 197 // The url of the main frame hosting the plugin. |
219 GURL page_url_; | 198 GURL page_url_; |
220 | 199 |
221 // Variables used for desynchronized windowless plugin painting. See note in | 200 // Variables used for desynchronized windowless plugin painting. See note in |
222 // webplugin_delegate_proxy.h for how this works. The two sets of windowless_* | 201 // webplugin_delegate_proxy.h for how this works. The two sets of windowless_* |
223 // fields are for the front-buffer and back-buffer of a buffer flipping system | 202 // fields are for the front-buffer and back-buffer of a buffer flipping system |
224 // and windowless_buffer_index_ identifies which set we are using as the | 203 // and windowless_buffer_index_ identifies which set we are using as the |
225 // back-buffer at any given time. | 204 // back-buffer at any given time. |
226 int windowless_buffer_index_; | 205 int windowless_buffer_index_; |
227 #if defined(OS_MACOSX) | 206 #if defined(OS_MACOSX) |
228 scoped_ptr<TransportDIB> windowless_dibs_[2]; | 207 scoped_ptr<TransportDIB> windowless_dibs_[2]; |
229 base::ScopedCFTypeRef<CGContextRef> windowless_contexts_[2]; | 208 base::ScopedCFTypeRef<CGContextRef> windowless_contexts_[2]; |
230 scoped_ptr<WebPluginAcceleratedSurfaceProxy> accelerated_surface_; | 209 scoped_ptr<WebPluginAcceleratedSurfaceProxy> accelerated_surface_; |
231 #else | 210 #else |
232 skia::RefPtr<SkCanvas> windowless_canvases_[2]; | 211 skia::RefPtr<SkCanvas> windowless_canvases_[2]; |
233 | |
234 #if defined(USE_X11) | |
235 scoped_refptr<SharedTransportDIB> windowless_dibs_[2]; | |
236 // If we can use SHM pixmaps for windowless plugin painting or not. | |
237 bool use_shm_pixmap_; | |
238 // The SHM pixmaps for windowless plugin painting. | |
239 XID windowless_shm_pixmaps_[2]; | |
240 #endif | |
241 | |
242 #endif | 212 #endif |
243 | 213 |
244 // Contains the routing id of the host render view. | 214 // Contains the routing id of the host render view. |
245 int host_render_view_routing_id_; | 215 int host_render_view_routing_id_; |
246 | 216 |
247 base::WeakPtrFactory<WebPluginProxy> weak_factory_; | 217 base::WeakPtrFactory<WebPluginProxy> weak_factory_; |
248 }; | 218 }; |
249 | 219 |
250 } // namespace content | 220 } // namespace content |
251 | 221 |
252 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 222 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
OLD | NEW |