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_ACCELERATED_SURFACE_CONTAINER_H_ | |
6 #define WEBKIT_GLUE_PLUGINS_MAC_ACCELERATED_SURFACE_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 MacAcceleratedSurfaceContainerManager. | |
27 | |
28 #include <CoreFoundation/CoreFoundation.h> | |
29 #include <OpenGL/OpenGL.h> | |
30 | |
31 #include "app/gfx/native_widget_types.h" | |
32 #include "app/surface/transport_dib.h" | |
33 #include "base/basictypes.h" | |
34 #include "base/scoped_ptr.h" | |
35 #include "base/gfx/rect.h" | |
36 | |
37 namespace webkit_glue { | |
38 struct WebPluginGeometry; | |
39 } | |
40 | |
41 class MacAcceleratedSurfaceContainerManager; | |
42 | |
43 class MacAcceleratedSurfaceContainer { | |
44 public: | |
45 MacAcceleratedSurfaceContainer(); | |
46 virtual ~MacAcceleratedSurfaceContainer(); | |
47 | |
48 // Sets the backing store and size of this accelerated surface container. | |
49 // There are two versions: the IOSurface version is used on systems where the | |
50 // IOSurface API is supported (Mac OS X 10.6 and later); the TransportDIB is | |
51 // used on Mac OS X 10.5 and earlier. | |
52 void SetSizeAndIOSurface(int32 width, | |
53 int32 height, | |
54 uint64 io_surface_identifier, | |
55 MacAcceleratedSurfaceContainerManager* manager); | |
56 void SetSizeAndTransportDIB(int32 width, | |
57 int32 height, | |
58 TransportDIB::Handle transport_dib, | |
59 MacAcceleratedSurfaceContainerManager* manager); | |
60 | |
61 // Tells the accelerated surface container that it has moved relative to the | |
62 // origin of the window, for example because of a scroll event. | |
63 void MoveTo(const webkit_glue::WebPluginGeometry& geom); | |
64 | |
65 // Draws this accelerated surface's contents, texture mapped onto a quad in | |
66 // the given OpenGL context. TODO(kbr): figure out and define exactly how the | |
67 // coordinate system will work out. | |
68 void Draw(CGLContextObj context); | |
69 | |
70 // Enqueue our texture for later deletion. Call this before deleting | |
71 // this object. | |
72 void EnqueueTextureForDeletion(MacAcceleratedSurfaceContainerManager* manager)
; | |
73 | |
74 private: | |
75 // The x and y coordinates of the plugin window on the web page. | |
76 int x_; | |
77 int y_; | |
78 | |
79 void ReleaseIOSurface(); | |
80 | |
81 // The IOSurfaceRef, if any, that has been handed from the GPU | |
82 // plugin process back to the browser process for drawing. | |
83 // This is held as a CFTypeRef because we can't refer to the | |
84 // IOSurfaceRef type when building on 10.5. | |
85 CFTypeRef surface_; | |
86 | |
87 // The TransportDIB which is used in pre-10.6 systems where the IOSurface | |
88 // API is not supported. This is a weak reference to the actual TransportDIB | |
89 // whic is owned by the GPU process. | |
90 scoped_ptr<TransportDIB> transport_dib_; | |
91 | |
92 // The width and height of the surface. | |
93 int32 width_; | |
94 int32 height_; | |
95 | |
96 // The clip rectangle, relative to the (x_, y_) origin. | |
97 gfx::Rect clipRect_; | |
98 | |
99 // The "live" OpenGL texture referring to this IOSurfaceRef. Note | |
100 // that per the CGLTexImageIOSurface2D API we do not need to | |
101 // explicitly update this texture's contents once created. All we | |
102 // need to do is ensure it is re-bound before attempting to draw | |
103 // with it. | |
104 GLuint texture_; | |
105 | |
106 DISALLOW_COPY_AND_ASSIGN(MacAcceleratedSurfaceContainer); | |
107 }; | |
108 | |
109 #endif // WEBKIT_GLUE_PLUGINS_MAC_ACCELERATED_SURFACE_CONTAINER_H_ | |
110 | |
OLD | NEW |