|
Lines 36-42
a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp_sec1
|
| 36 |
#include "PixelBuffer.h" |
36 |
#include "PixelBuffer.h" |
| 37 |
|
37 |
|
| 38 |
#if USE(NICOSIA) |
38 |
#if USE(NICOSIA) |
|
|
39 |
#include <fcntl.h> |
| 39 |
#include "NicosiaGCGLANGLEPipe.h" |
40 |
#include "NicosiaGCGLANGLEPipe.h" |
|
|
41 |
#include "gbm.h" |
| 40 |
#else |
42 |
#else |
| 41 |
#include "TextureMapperGCGLPlatformLayer.h" |
43 |
#include "TextureMapperGCGLPlatformLayer.h" |
| 42 |
#endif |
44 |
#endif |
|
Lines 51-56
GraphicsContextGLANGLE::GraphicsContextGLANGLE(GraphicsContextGLAttributes attri
a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp_sec2
|
| 51 |
#endif |
53 |
#endif |
| 52 |
#if USE(NICOSIA) |
54 |
#if USE(NICOSIA) |
| 53 |
m_nicosiaPipe = makeUnique<Nicosia::GCGLANGLEPipe>(*this); |
55 |
m_nicosiaPipe = makeUnique<Nicosia::GCGLANGLEPipe>(*this); |
|
|
56 |
|
| 57 |
int fd; |
| 58 |
char deviceName[30]; |
| 59 |
for (int i = 128; i < 192; ++i) { |
| 60 |
snprintf(deviceName, sizeof(deviceName), "/dev/dri/renderD%d", i); |
| 61 |
fd = open(deviceName, O_RDWR | O_CLOEXEC); |
| 62 |
if (fd >= 0) { |
| 63 |
m_device = gbm_create_device(fd); |
| 64 |
if (m_device) |
| 65 |
break; |
| 66 |
close(fd); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
if (m_device) { |
| 71 |
m_textureBacking = makeUnique<EGLImageBacking>(m_device, platformDisplay()); |
| 72 |
m_compositorTextureBacking = makeUnique<EGLImageBacking>(m_device, platformDisplay()); |
| 73 |
m_intermediateTextureBacking = makeUnique<EGLImageBacking>(m_device, platformDisplay()); |
| 74 |
} |
| 54 |
#else |
75 |
#else |
| 55 |
m_texmapLayer = makeUnique<TextureMapperGCGLPlatformLayer>(*this); |
76 |
m_texmapLayer = makeUnique<TextureMapperGCGLPlatformLayer>(*this); |
| 56 |
#endif |
77 |
#endif |
|
Lines 112-122
GraphicsContextGLANGLE::GraphicsContextGLANGLE(GraphicsContextGLAttributes attri
a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp_sec3
|
| 112 |
GL_ClearColor(0, 0, 0, 0); |
133 |
GL_ClearColor(0, 0, 0, 0); |
| 113 |
} |
134 |
} |
| 114 |
|
135 |
|
|
|
136 |
#if USE(NICOSIA) |
| 137 |
GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking(gbm_device* device, PlatformGraphicsContextGLDisplay display) |
| 138 |
: m_device(device) |
| 139 |
, m_display(display) |
| 140 |
{ |
| 141 |
} |
| 142 |
|
| 143 |
GraphicsContextGLANGLE::EGLImageBacking::~EGLImageBacking() |
| 144 |
{ |
| 145 |
releaseResources(); |
| 146 |
} |
| 147 |
|
| 148 |
uint32_t GraphicsContextGLANGLE::EGLImageBacking::format() const |
| 149 |
{ |
| 150 |
if (m_BO) |
| 151 |
return gbm_bo_get_format(m_BO); |
| 152 |
return 0; |
| 153 |
} |
| 154 |
|
| 155 |
uint32_t GraphicsContextGLANGLE::EGLImageBacking::stride() const |
| 156 |
{ |
| 157 |
if (m_BO) |
| 158 |
return gbm_bo_get_stride(m_BO); |
| 159 |
return 0; |
| 160 |
} |
| 161 |
|
| 162 |
void GraphicsContextGLANGLE::EGLImageBacking::releaseResources() |
| 163 |
{ |
| 164 |
if (m_BO) { |
| 165 |
gbm_bo_destroy(m_BO); |
| 166 |
m_BO = nullptr; |
| 167 |
} |
| 168 |
if (m_image) { |
| 169 |
EGL_DestroyImageKHR(m_display, m_image); |
| 170 |
m_image = EGL_NO_IMAGE; |
| 171 |
} |
| 172 |
if (m_FD >= 0) { |
| 173 |
close(m_FD); |
| 174 |
m_FD = -1; |
| 175 |
} |
| 176 |
} |
| 177 |
|
| 178 |
bool GraphicsContextGLANGLE::EGLImageBacking::reset(int width, int height, bool hasAlpha) |
| 179 |
{ |
| 180 |
releaseResources(); |
| 181 |
|
| 182 |
if (!width || !height) |
| 183 |
return false; |
| 184 |
|
| 185 |
m_BO = gbm_bo_create(m_device, width, height, hasAlpha ? GBM_BO_FORMAT_ARGB8888 : GBM_BO_FORMAT_XRGB8888, GBM_BO_USE_RENDERING); |
| 186 |
if (m_BO) { |
| 187 |
m_FD = gbm_bo_get_fd(m_BO); |
| 188 |
if (m_FD >= 0) { |
| 189 |
EGLint imageAttributes[] = { |
| 190 |
EGL_WIDTH, width, |
| 191 |
EGL_HEIGHT, height, |
| 192 |
EGL_LINUX_DRM_FOURCC_EXT, static_cast<EGLint>(gbm_bo_get_format(m_BO)), |
| 193 |
EGL_DMA_BUF_PLANE0_FD_EXT, m_FD, |
| 194 |
EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<EGLint>(gbm_bo_get_stride(m_BO)), |
| 195 |
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, |
| 196 |
EGL_NONE |
| 197 |
}; |
| 198 |
m_image = EGL_CreateImageKHR(m_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)nullptr, imageAttributes); |
| 199 |
if (m_image) |
| 200 |
return true; |
| 201 |
} |
| 202 |
} |
| 203 |
|
| 204 |
releaseResources(); |
| 205 |
return false; |
| 206 |
} |
| 207 |
#endif |
| 208 |
|
| 115 |
GraphicsContextGLANGLE::~GraphicsContextGLANGLE() |
209 |
GraphicsContextGLANGLE::~GraphicsContextGLANGLE() |
| 116 |
{ |
210 |
{ |
| 117 |
GraphicsContextGLOpenGLManager::sharedManager().removeContext(this); |
211 |
GraphicsContextGLOpenGLManager::sharedManager().removeContext(this); |
| 118 |
bool success = makeContextCurrent(); |
212 |
bool success = makeContextCurrent(); |
| 119 |
ASSERT_UNUSED(success, success); |
213 |
ASSERT_UNUSED(success, success); |
|
|
214 |
|
| 215 |
#if USE(NICOSIA) |
| 216 |
if (m_device) |
| 217 |
gbm_device_destroy(m_device); |
| 218 |
#endif |
| 219 |
|
| 120 |
if (m_texture) |
220 |
if (m_texture) |
| 121 |
GL_DeleteTextures(1, &m_texture); |
221 |
GL_DeleteTextures(1, &m_texture); |
| 122 |
#if USE(COORDINATED_GRAPHICS) |
222 |
#if USE(COORDINATED_GRAPHICS) |
|
Lines 189-206
bool GraphicsContextGLANGLE::reshapeDisplayBufferBacking()
a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp_sec4
|
| 189 |
GLuint colorFormat = attrs.alpha ? GL_RGBA : GL_RGB; |
289 |
GLuint colorFormat = attrs.alpha ? GL_RGBA : GL_RGB; |
| 190 |
GLenum textureTarget = drawingBufferTextureTarget(); |
290 |
GLenum textureTarget = drawingBufferTextureTarget(); |
| 191 |
GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat; |
291 |
GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat; |
|
|
292 |
|
| 293 |
#if USE(NICOSIA) |
| 294 |
if (m_device) { |
| 295 |
ASSERT(m_textureBacking && m_compositorTextureBacking && m_intermediateTextureBacking); |
| 296 |
m_textureBacking->reset(width, height, attrs.alpha); |
| 297 |
m_compositorTextureBacking->reset(width, height, attrs.alpha); |
| 298 |
m_intermediateTextureBacking->reset(width, height, attrs.alpha); |
| 299 |
} |
| 300 |
#endif |
| 301 |
|
| 192 |
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB); |
302 |
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB); |
| 193 |
#if USE(COORDINATED_GRAPHICS) |
303 |
#if USE(COORDINATED_GRAPHICS) |
| 194 |
if (m_compositorTexture) { |
304 |
if (m_compositorTexture) { |
| 195 |
GL_BindTexture(textureTarget, m_compositorTexture); |
305 |
GL_BindTexture(textureTarget, m_compositorTexture); |
|
|
306 |
#if USE(NICOSIA) |
| 307 |
if (m_compositorTextureBacking && m_compositorTextureBacking->image()) |
| 308 |
GL_EGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_compositorTextureBacking->image()); |
| 309 |
else |
| 310 |
#endif |
| 196 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
311 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
| 197 |
GL_BindTexture(textureTarget, m_intermediateTexture); |
312 |
GL_BindTexture(textureTarget, m_intermediateTexture); |
|
|
313 |
#if USE(NICOSIA) |
| 314 |
if (m_intermediateTextureBacking && m_intermediateTextureBacking->image()) |
| 315 |
GL_EGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_intermediateTextureBacking->image()); |
| 316 |
else |
| 317 |
#endif |
| 198 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
318 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
| 199 |
} |
319 |
} |
| 200 |
#endif |
320 |
#endif |
| 201 |
GL_BindTexture(textureTarget, m_texture); |
321 |
GL_BindTexture(textureTarget, m_texture); |
|
|
322 |
#if USE(NICOSIA) |
| 323 |
if (m_textureBacking && m_textureBacking->image()) |
| 324 |
GL_EGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_textureBacking->image()); |
| 325 |
else |
| 326 |
#endif |
| 202 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
327 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
| 203 |
GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, m_texture, 0); |
328 |
GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, m_texture, 0); |
|
|
329 |
|
| 204 |
return true; |
330 |
return true; |
| 205 |
} |
331 |
} |
| 206 |
|
332 |
|