OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 WEBKIT_GLUE_PLUGINS_MAC_GPU_PLUGIN_CONTAINER_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_MAC_GPU_PLUGIN_CONTAINER_H_ |
| 7 |
| 8 // The "GPU plugin" is currently implemented as a special kind of |
| 9 // NPAPI plugin to provide high-performance on-screen 3D rendering for |
| 10 // Pepper 3D. |
| 11 // |
| 12 // On Windows and X11 platforms the GPU plugin relies on cross-process |
| 13 // parenting of windows, which is not supported via any public APIs in |
| 14 // the Mac OS X window system. |
| 15 // |
| 16 // To achieve full hardware acceleration we use the new IOSurface APIs |
| 17 // introduced in Mac OS X 10.6. The GPU plugin's process produces an |
| 18 // IOSurface and renders into it using OpenGL. It uses the |
| 19 // IOSurfaceGetID and IOSurfaceLookup APIs to pass a reference to this |
| 20 // surface to the browser process for on-screen rendering. The GPU |
| 21 // plugin essentially looks like a windowless plugin; the browser |
| 22 // process gets all of the mouse events, because the plugin process |
| 23 // does not have an on-screen window. |
| 24 // |
| 25 // This class encapsulates some of the management of these data |
| 26 // structures, in conjunction with the MacGPUPluginContainerManager. |
| 27 |
| 28 #include <CoreFoundation/CoreFoundation.h> |
| 29 #include <OpenGL/OpenGL.h> |
| 30 |
| 31 #include "app/gfx/native_widget_types.h" |
| 32 #include "base/basictypes.h" |
| 33 |
| 34 namespace webkit_glue { |
| 35 struct WebPluginGeometry; |
| 36 } |
| 37 |
| 38 class MacGPUPluginContainerManager; |
| 39 |
| 40 class MacGPUPluginContainer { |
| 41 public: |
| 42 MacGPUPluginContainer(); |
| 43 virtual ~MacGPUPluginContainer(); |
| 44 |
| 45 // Sets the backing store and size of this plugin container. |
| 46 void SetSizeAndBackingStore(int32 width, |
| 47 int32 height, |
| 48 uint64 io_surface_identifier, |
| 49 MacGPUPluginContainerManager* manager); |
| 50 |
| 51 // Tells the plugin container that it has moved relative to the |
| 52 // origin of the window, for example because of a scroll event. |
| 53 void MoveTo(const webkit_glue::WebPluginGeometry& geom); |
| 54 |
| 55 // Draws this plugin's contents, texture mapped onto a quad in the |
| 56 // given OpenGL context. TODO(kbr): figure out and define exactly |
| 57 // how the coordinate system will work out. |
| 58 void Draw(CGLContextObj context); |
| 59 |
| 60 // Enqueue our texture for later deletion. Call this before deleting |
| 61 // this object. |
| 62 void EnqueueTextureForDeletion(MacGPUPluginContainerManager* manager); |
| 63 |
| 64 private: |
| 65 // We currently only have a viable implementation of this class on |
| 66 // Snow Leopard. We need to think about fallback strategies that |
| 67 // will work on Leopard. |
| 68 |
| 69 // The x and y coordinates of the plugin window on the web page. |
| 70 // TODO(kbr): see whether additional clipping information is |
| 71 // necessary. |
| 72 int x_; |
| 73 int y_; |
| 74 |
| 75 void ReleaseIOSurface(); |
| 76 |
| 77 // The IOSurfaceRef, if any, that has been handed from the GPU |
| 78 // plugin process back to the browser process for drawing. |
| 79 // This is held as a CFTypeRef because we can't refer to the |
| 80 // IOSurfaceRef type when building on 10.5. |
| 81 CFTypeRef surface_; |
| 82 |
| 83 // The width and height of the surface. |
| 84 int32 width_; |
| 85 int32 height_; |
| 86 |
| 87 // The "live" OpenGL texture referring to this IOSurfaceRef. Note |
| 88 // that per the CGLTexImageIOSurface2D API we do not need to |
| 89 // explicitly update this texture's contents once created. All we |
| 90 // need to do is ensure it is re-bound before attempting to draw |
| 91 // with it. |
| 92 GLuint texture_; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(MacGPUPluginContainer); |
| 95 }; |
| 96 |
| 97 #endif // WEBKIT_GLUE_PLUGINS_MAC_GPU_PLUGIN_CONTAINER_H_ |
| 98 |
OLD | NEW |