|
Lines 36-44
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 "GBMDevice.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" |
|
|
44 |
|
| 45 |
#include <fcntl.h> |
| 42 |
#endif |
46 |
#endif |
| 43 |
|
47 |
|
| 44 |
namespace WebCore { |
48 |
namespace WebCore { |
|
Lines 51-56
GraphicsContextGLANGLE::GraphicsContextGLANGLE(GraphicsContextGLAttributes attri
a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp_sec2
|
| 51 |
#endif |
55 |
#endif |
| 52 |
#if USE(NICOSIA) |
56 |
#if USE(NICOSIA) |
| 53 |
m_nicosiaPipe = makeUnique<Nicosia::GCGLANGLEPipe>(*this); |
57 |
m_nicosiaPipe = makeUnique<Nicosia::GCGLANGLEPipe>(*this); |
|
|
58 |
|
| 59 |
auto& gbmDevice = GBMDevice::forCurrentThread(); |
| 60 |
if (auto* device = gbmDevice.device()) { |
| 61 |
m_textureBacking = makeUnique<EGLImageBacking>(device, platformDisplay()); |
| 62 |
m_compositorTextureBacking = makeUnique<EGLImageBacking>(device, platformDisplay()); |
| 63 |
m_intermediateTextureBacking = makeUnique<EGLImageBacking>(device, platformDisplay()); |
| 64 |
} |
| 54 |
#else |
65 |
#else |
| 55 |
m_texmapLayer = makeUnique<TextureMapperGCGLPlatformLayer>(*this); |
66 |
m_texmapLayer = makeUnique<TextureMapperGCGLPlatformLayer>(*this); |
| 56 |
#endif |
67 |
#endif |
|
Lines 112-122
GraphicsContextGLANGLE::GraphicsContextGLANGLE(GraphicsContextGLAttributes attri
a/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp_sec3
|
| 112 |
GL_ClearColor(0, 0, 0, 0); |
123 |
GL_ClearColor(0, 0, 0, 0); |
| 113 |
} |
124 |
} |
| 114 |
|
125 |
|
|
|
126 |
#if USE(NICOSIA) |
| 127 |
GraphicsContextGLANGLE::EGLImageBacking::EGLImageBacking(gbm_device* device, PlatformGraphicsContextGLDisplay display) |
| 128 |
: m_device(device) |
| 129 |
, m_display(display) |
| 130 |
{ |
| 131 |
} |
| 132 |
|
| 133 |
GraphicsContextGLANGLE::EGLImageBacking::~EGLImageBacking() |
| 134 |
{ |
| 135 |
releaseResources(); |
| 136 |
} |
| 137 |
|
| 138 |
uint32_t GraphicsContextGLANGLE::EGLImageBacking::format() const |
| 139 |
{ |
| 140 |
if (m_BO) |
| 141 |
return gbm_bo_get_format(m_BO); |
| 142 |
return 0; |
| 143 |
} |
| 144 |
|
| 145 |
uint32_t GraphicsContextGLANGLE::EGLImageBacking::stride() const |
| 146 |
{ |
| 147 |
if (m_BO) |
| 148 |
return gbm_bo_get_stride(m_BO); |
| 149 |
return 0; |
| 150 |
} |
| 151 |
|
| 152 |
void GraphicsContextGLANGLE::EGLImageBacking::releaseResources() |
| 153 |
{ |
| 154 |
if (m_BO) { |
| 155 |
gbm_bo_destroy(m_BO); |
| 156 |
m_BO = nullptr; |
| 157 |
} |
| 158 |
if (m_image) { |
| 159 |
EGL_DestroyImageKHR(m_display, m_image); |
| 160 |
m_image = EGL_NO_IMAGE; |
| 161 |
} |
| 162 |
if (m_FD >= 0) { |
| 163 |
close(m_FD); |
| 164 |
m_FD = -1; |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
bool GraphicsContextGLANGLE::EGLImageBacking::reset(int width, int height, bool hasAlpha) |
| 169 |
{ |
| 170 |
releaseResources(); |
| 171 |
|
| 172 |
if (!width || !height) |
| 173 |
return false; |
| 174 |
|
| 175 |
m_BO = gbm_bo_create(m_device, width, height, hasAlpha ? GBM_BO_FORMAT_ARGB8888 : GBM_BO_FORMAT_XRGB8888, GBM_BO_USE_RENDERING); |
| 176 |
if (m_BO) { |
| 177 |
m_FD = gbm_bo_get_fd(m_BO); |
| 178 |
if (m_FD >= 0) { |
| 179 |
EGLint imageAttributes[] = { |
| 180 |
EGL_WIDTH, width, |
| 181 |
EGL_HEIGHT, height, |
| 182 |
EGL_LINUX_DRM_FOURCC_EXT, static_cast<EGLint>(gbm_bo_get_format(m_BO)), |
| 183 |
EGL_DMA_BUF_PLANE0_FD_EXT, m_FD, |
| 184 |
EGL_DMA_BUF_PLANE0_PITCH_EXT, static_cast<EGLint>(gbm_bo_get_stride(m_BO)), |
| 185 |
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, |
| 186 |
EGL_NONE |
| 187 |
}; |
| 188 |
m_image = EGL_CreateImageKHR(m_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)nullptr, imageAttributes); |
| 189 |
if (m_image) |
| 190 |
return true; |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
releaseResources(); |
| 195 |
return false; |
| 196 |
} |
| 197 |
#endif |
| 198 |
|
| 115 |
GraphicsContextGLANGLE::~GraphicsContextGLANGLE() |
199 |
GraphicsContextGLANGLE::~GraphicsContextGLANGLE() |
| 116 |
{ |
200 |
{ |
| 117 |
GraphicsContextGLOpenGLManager::sharedManager().removeContext(this); |
201 |
GraphicsContextGLOpenGLManager::sharedManager().removeContext(this); |
| 118 |
bool success = makeContextCurrent(); |
202 |
bool success = makeContextCurrent(); |
| 119 |
ASSERT_UNUSED(success, success); |
203 |
ASSERT_UNUSED(success, success); |
|
|
204 |
|
| 120 |
if (m_texture) |
205 |
if (m_texture) |
| 121 |
GL_DeleteTextures(1, &m_texture); |
206 |
GL_DeleteTextures(1, &m_texture); |
| 122 |
#if USE(COORDINATED_GRAPHICS) |
207 |
#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; |
274 |
GLuint colorFormat = attrs.alpha ? GL_RGBA : GL_RGB; |
| 190 |
GLenum textureTarget = drawingBufferTextureTarget(); |
275 |
GLenum textureTarget = drawingBufferTextureTarget(); |
| 191 |
GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat; |
276 |
GLuint internalColorFormat = textureTarget == GL_TEXTURE_2D ? colorFormat : m_internalColorFormat; |
|
|
277 |
|
| 278 |
#if USE(NICOSIA) |
| 279 |
if (m_textureBacking) |
| 280 |
m_textureBacking->reset(width, height, attrs.alpha); |
| 281 |
if (m_compositorTextureBacking) |
| 282 |
m_compositorTextureBacking->reset(width, height, attrs.alpha); |
| 283 |
if (m_intermediateTextureBacking) |
| 284 |
m_intermediateTextureBacking->reset(width, height, attrs.alpha); |
| 285 |
#endif |
| 286 |
|
| 192 |
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB); |
287 |
ScopedRestoreTextureBinding restoreBinding(drawingBufferTextureTargetQueryForDrawingTarget(textureTarget), textureTarget, textureTarget != TEXTURE_RECTANGLE_ARB); |
| 193 |
#if USE(COORDINATED_GRAPHICS) |
288 |
#if USE(COORDINATED_GRAPHICS) |
| 194 |
if (m_compositorTexture) { |
289 |
if (m_compositorTexture) { |
| 195 |
GL_BindTexture(textureTarget, m_compositorTexture); |
290 |
GL_BindTexture(textureTarget, m_compositorTexture); |
|
|
291 |
#if USE(NICOSIA) |
| 292 |
if (m_compositorTextureBacking && m_compositorTextureBacking->image()) |
| 293 |
GL_EGLImageTargetTexture2DOES(textureTarget, m_compositorTextureBacking->image()); |
| 294 |
else |
| 295 |
#endif |
| 196 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
296 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
| 197 |
GL_BindTexture(textureTarget, m_intermediateTexture); |
297 |
GL_BindTexture(textureTarget, m_intermediateTexture); |
|
|
298 |
#if USE(NICOSIA) |
| 299 |
if (m_intermediateTextureBacking && m_intermediateTextureBacking->image()) |
| 300 |
GL_EGLImageTargetTexture2DOES(textureTarget, m_intermediateTextureBacking->image()); |
| 301 |
else |
| 302 |
#endif |
| 198 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
303 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
| 199 |
} |
304 |
} |
| 200 |
#endif |
305 |
#endif |
| 201 |
GL_BindTexture(textureTarget, m_texture); |
306 |
GL_BindTexture(textureTarget, m_texture); |
|
|
307 |
#if USE(NICOSIA) |
| 308 |
if (m_textureBacking && m_textureBacking->image()) |
| 309 |
GL_EGLImageTargetTexture2DOES(textureTarget, m_textureBacking->image()); |
| 310 |
else |
| 311 |
#endif |
| 202 |
GL_TexImage2D(textureTarget, 0, internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); |
312 |
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); |
313 |
GL_FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureTarget, m_texture, 0); |
|
|
314 |
|
| 204 |
return true; |
315 |
return true; |
| 205 |
} |
316 |
} |
| 206 |
|
317 |
|