|
Lines 28-34
Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec1
|
| 28 |
|
28 |
|
| 29 |
#if USE(ACCELERATED_COMPOSITING) |
29 |
#if USE(ACCELERATED_COMPOSITING) |
| 30 |
|
30 |
|
|
|
31 |
#if USE(GLX) |
| 31 |
#include "GLXWindowResources.h" |
32 |
#include "GLXWindowResources.h" |
|
|
33 |
#endif |
| 32 |
|
34 |
|
| 33 |
namespace WebCore { |
35 |
namespace WebCore { |
| 34 |
|
36 |
|
|
Lines 37-62
PlatformSharedResources* SharedX11Resources::m_staticSharedResource = 0;
Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec2
|
| 37 |
X11OffScreenWindow::X11OffScreenWindow() |
39 |
X11OffScreenWindow::X11OffScreenWindow() |
| 38 |
: GLPlatformSurface() |
40 |
: GLPlatformSurface() |
| 39 |
, m_sharedResources(0) |
41 |
, m_sharedResources(0) |
|
|
42 |
, m_configVisualInfo(0) |
| 40 |
{ |
43 |
{ |
| 41 |
m_sharedResources = PlatformSharedResources::create(); |
44 |
m_sharedResources = PlatformSharedResources::create(); |
| 42 |
|
45 |
|
| 43 |
if (!m_sharedResources) |
46 |
if (!m_sharedResources) |
| 44 |
return; |
47 |
return; |
| 45 |
|
48 |
|
| 46 |
m_sharedDisplay = m_sharedResources->nativeDisplay(); |
49 |
m_sharedDisplay = m_sharedResources->x11Display(); |
| 47 |
} |
50 |
} |
| 48 |
|
51 |
|
| 49 |
X11OffScreenWindow::~X11OffScreenWindow() |
52 |
X11OffScreenWindow::~X11OffScreenWindow() |
| 50 |
{ |
53 |
{ |
|
|
54 |
if (m_configVisualInfo) { |
| 55 |
XFree(m_configVisualInfo); |
| 56 |
m_configVisualInfo = 0; |
| 57 |
} |
| 51 |
} |
58 |
} |
| 52 |
|
59 |
|
| 53 |
void X11OffScreenWindow::setGeometry(const IntRect& newRect) |
60 |
void X11OffScreenWindow::reSizeWindow(const IntRect& newRect, PlatformBufferHandle windowId) |
| 54 |
{ |
61 |
{ |
| 55 |
GLPlatformSurface::setGeometry(newRect); |
62 |
XResizeWindow(m_sharedResources->x11Display(), windowId, newRect.width(), newRect.height()); |
| 56 |
XResizeWindow(m_sharedResources->x11Display(), m_bufferHandle, newRect.width(), newRect.height()); |
|
|
| 57 |
} |
63 |
} |
| 58 |
|
64 |
|
| 59 |
void X11OffScreenWindow::createOffscreenWindow() |
65 |
void X11OffScreenWindow::createOffscreenWindow(PlatformBufferHandle* handleId) |
| 60 |
{ |
66 |
{ |
| 61 |
if (!m_sharedResources) |
67 |
if (!m_sharedResources) |
| 62 |
return; |
68 |
return; |
|
Lines 65-78
void X11OffScreenWindow::createOffscreenWindow()
Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec3
|
| 65 |
if (!display) |
71 |
if (!display) |
| 66 |
return; |
72 |
return; |
| 67 |
|
73 |
|
| 68 |
PlatformSurfaceConfig config = m_sharedResources->surfaceContextConfig(); |
74 |
#if USE(GLX) |
| 69 |
|
|
|
| 70 |
if (!config) { |
| 71 |
LOG_ERROR("Failed to retrieve a valid configiration."); |
| 72 |
return; |
| 73 |
} |
| 74 |
|
| 75 |
XVisualInfo* visInfo = m_sharedResources->visualInfo(); |
75 |
XVisualInfo* visInfo = m_sharedResources->visualInfo(); |
|
|
76 |
#else |
| 77 |
XVisualInfo* visInfo = m_configVisualInfo; |
| 78 |
#endif |
| 76 |
|
79 |
|
| 77 |
if (!visInfo) { |
80 |
if (!visInfo) { |
| 78 |
LOG_ERROR("Failed to find valid XVisual"); |
81 |
LOG_ERROR("Failed to find valid XVisual"); |
|
Lines 88-111
void X11OffScreenWindow::createOffscreenWindow()
Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec4
|
| 88 |
attribute.background_pixel = WhitePixel(display, 0); |
91 |
attribute.background_pixel = WhitePixel(display, 0); |
| 89 |
attribute.border_pixel = BlackPixel(display, 0); |
92 |
attribute.border_pixel = BlackPixel(display, 0); |
| 90 |
attribute.colormap = cmap; |
93 |
attribute.colormap = cmap; |
| 91 |
m_bufferHandle = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute); |
94 |
PlatformBufferHandle tempHandleId; |
|
|
95 |
tempHandleId = XCreateWindow(display, xWindow, 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute); |
| 92 |
|
96 |
|
| 93 |
if (!m_bufferHandle) { |
97 |
if (!tempHandleId) { |
| 94 |
LOG_ERROR("Failed to create offscreen window"); |
98 |
LOG_ERROR("Failed to create offscreen window"); |
| 95 |
return; |
99 |
return; |
| 96 |
} |
100 |
} |
| 97 |
|
101 |
|
| 98 |
XSetWindowBackgroundPixmap(display, m_bufferHandle, 0); |
102 |
XSetWindowBackgroundPixmap(display, tempHandleId, 0); |
| 99 |
XCompositeRedirectWindow(display, m_bufferHandle, CompositeRedirectManual); |
103 |
XCompositeRedirectWindow(display, tempHandleId, CompositeRedirectManual); |
|
|
104 |
*handleId = tempHandleId; |
| 105 |
m_bufferHandle = tempHandleId; |
| 100 |
|
106 |
|
| 101 |
if (m_sharedResources->isXRenderExtensionSupported()) |
107 |
if (m_sharedResources->isXRenderExtensionSupported()) |
| 102 |
XMapWindow(display, m_bufferHandle); |
108 |
XMapWindow(display, tempHandleId); |
| 103 |
|
109 |
|
| 104 |
} |
110 |
} |
| 105 |
|
111 |
|
| 106 |
void X11OffScreenWindow::destroyWindow() |
112 |
void X11OffScreenWindow::destroyWindow(PlatformBufferHandle windowId) |
| 107 |
{ |
113 |
{ |
| 108 |
if (!m_bufferHandle) |
114 |
if (!windowId) |
| 109 |
return; |
115 |
return; |
| 110 |
|
116 |
|
| 111 |
GLPlatformSurface::destroy(); |
117 |
GLPlatformSurface::destroy(); |
|
Lines 113-121
void X11OffScreenWindow::destroyWindow()
Source/WebCore/platform/graphics/surfaces/glx/X11WindowResources.cpp_sec5
|
| 113 |
if (!display) |
119 |
if (!display) |
| 114 |
return; |
120 |
return; |
| 115 |
|
121 |
|
| 116 |
XDestroyWindow(display, m_bufferHandle); |
122 |
XDestroyWindow(display, windowId); |
| 117 |
m_bufferHandle = 0; |
123 |
} |
|
|
124 |
|
| 125 |
Display* X11OffScreenWindow::nativeSharedDisplay() |
| 126 |
{ |
| 127 |
return m_sharedResources->x11Display(); |
| 128 |
} |
| 129 |
|
| 130 |
#if USE(EGL) |
| 131 |
bool X11OffScreenWindow::setVisualId(const EGLint id) |
| 132 |
{ |
| 133 |
VisualID visualId = static_cast<VisualID>(id); |
| 134 |
|
| 135 |
if (!visualId) |
| 136 |
return false; |
| 137 |
|
| 138 |
// EGL has suggested a visual id, so get the rest of the visual info for that id. |
| 139 |
XVisualInfo visualInfoTemplate; |
| 140 |
memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); |
| 141 |
visualInfoTemplate.visualid = visualId; |
| 142 |
|
| 143 |
XVisualInfo* chosenVisualInfo; |
| 144 |
int matchingCount = 0; |
| 145 |
chosenVisualInfo = XGetVisualInfo(m_sharedResources->x11Display(), VisualIDMask, &visualInfoTemplate, &matchingCount); |
| 146 |
if (chosenVisualInfo) { |
| 147 |
#if USE(GRAPHICS_SURFACE) |
| 148 |
if (m_sharedResources->isXRenderExtensionSupported()) { |
| 149 |
XRenderPictFormat* format = XRenderFindVisualFormat(m_sharedResources->x11Display(), chosenVisualInfo->visual); |
| 150 |
if (format && format->direct.alphaMask > 0) { |
| 151 |
m_configVisualInfo = chosenVisualInfo; |
| 152 |
return true; |
| 153 |
} |
| 154 |
} |
| 155 |
#endif |
| 156 |
if (chosenVisualInfo->depth == 32) { |
| 157 |
m_configVisualInfo = chosenVisualInfo; |
| 158 |
return true; |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
if (!m_configVisualInfo) { |
| 163 |
memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); |
| 164 |
XVisualInfo* matchingVisuals; |
| 165 |
int matchingCount = 0; |
| 166 |
|
| 167 |
visualInfoTemplate.depth = chosenVisualInfo->depth; |
| 168 |
matchingVisuals = XGetVisualInfo(m_sharedResources->x11Display(), VisualDepthMask, &visualInfoTemplate, &matchingCount); |
| 169 |
|
| 170 |
if (matchingVisuals) { |
| 171 |
m_configVisualInfo = &matchingVisuals[0]; |
| 172 |
XFree(matchingVisuals); |
| 173 |
return true; |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
if (!m_configVisualInfo) |
| 178 |
LOG_ERROR("Failed to retrieve XVisual Info.\n"); |
| 179 |
|
| 180 |
return false; |
| 118 |
} |
181 |
} |
|
|
182 |
#endif |
| 119 |
|
183 |
|
| 120 |
} |
184 |
} |
| 121 |
|
185 |
|