Changeset 92615 in webkit
- Timestamp:
- Aug 8, 2011 11:42:21 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92611 r92615 1 2011-08-08 Andrew Wason <rectalogic@rectalogic.com> 2 3 [Qt] Implement WebGL antialiasing (part 3) 4 https://bugs.webkit.org/show_bug.cgi?id=64879 5 6 Reviewed by Noam Rosenthal. 7 8 Existing WebGL layout tests cover this. 9 10 Implement WebGL antialiasing for Qt desktop. 11 Existing code in GraphicsContext3DOpenGL.cpp manages the 12 multisample FBO. GraphicsContext3DQt.cpp creates it and blits 13 it to the regular FBO when painting. 14 Requires adoption of Extensions3DOpenGL to be fully functional. 15 16 * platform/graphics/qt/GraphicsContext3DQt.cpp: 17 (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): 18 (WebCore::GraphicsContext3DInternal::paintToTextureMapper): 19 (WebCore::GraphicsContext3DInternal::paint): 20 (WebCore::GraphicsContext3DInternal::multisampleResolve): 21 (WebCore::GraphicsContext3D::GraphicsContext3D): 22 (WebCore::GraphicsContext3D::~GraphicsContext3D): 23 1 24 2011-08-08 Anders Carlsson <andersca@apple.com> 2 25 -
trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
r92596 r92615 81 81 void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); 82 82 QRectF boundingRect() const; 83 void blitMultisampleFramebuffer() const; 84 void blitMultisampleFramebufferAndRestoreContext() const; 83 85 84 86 GraphicsContext3D* m_context; … … 114 116 115 117 m_glWidget->makeCurrent(); 116 117 #if !defined(QT_OPENGL_ES_2)118 glEnable(GL_POINT_SPRITE);119 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);120 #endif121 118 } 122 119 … … 148 145 void GraphicsContext3DInternal::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask) const 149 146 { 147 blitMultisampleFramebufferAndRestoreContext(); 148 150 149 if (textureMapper->isOpenGLBacked()) { 151 150 TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper); … … 210 209 QRectF rect = option ? option->rect : boundingRect(); 211 210 211 m_glWidget->makeCurrent(); 212 blitMultisampleFramebuffer(); 213 212 214 // Use direct texture mapping if WebGL canvas has a shared OpenGL context 213 215 // with browsers OpenGL context. … … 222 224 quint32* imagePixels = reinterpret_cast<quint32*>(offscreenImage.bits()); 223 225 224 m_glWidget->makeCurrent();225 226 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo); 226 227 glReadPixels(/* x */ 0, /* y */ 0, rect.width(), rect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, imagePixels); … … 252 253 253 254 painter->drawImage(/* x */ 0, /* y */ 0, offscreenImage); 255 } 256 257 void GraphicsContext3DInternal::blitMultisampleFramebuffer() const 258 { 259 if (!m_context->m_attrs.antialias) 260 return; 261 glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_context->m_multisampleFBO); 262 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_context->m_fbo); 263 glBlitFramebuffer(0, 0, m_context->m_currentWidth, m_context->m_currentHeight, 0, 0, m_context->m_currentWidth, m_context->m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); 264 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO); 265 } 266 267 void GraphicsContext3DInternal::blitMultisampleFramebufferAndRestoreContext() const 268 { 269 if (!m_context->m_attrs.antialias) 270 return; 271 272 const QGLContext* currentContext = QGLContext::currentContext(); 273 const QGLContext* widgetContext = m_glWidget->context(); 274 if (currentContext != widgetContext) 275 m_glWidget->makeCurrent(); 276 blitMultisampleFramebuffer(); 277 if (currentContext) { 278 if (currentContext != widgetContext) 279 const_cast<QGLContext*>(currentContext)->makeCurrent(); 280 } else 281 m_glWidget->doneCurrent(); 254 282 } 255 283 … … 285 313 m_attrs.stencil = false; 286 314 #else 287 if (m_attrs.stencil) 288 m_attrs.depth = true; 289 #endif 290 m_attrs.antialias = false; 315 validateAttributes(); 316 #endif 291 317 292 318 if (!m_internal->m_glWidget->isValid()) { … … 318 344 glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); 319 345 320 if (m_attrs.depth) 321 glGenRenderbuffers(/* count */ 1, &m_depthStencilBuffer); 322 323 // Bind canvas FBO and set initial clear color to black. 324 m_boundFBO = m_fbo; 325 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); 326 glClearColor(0.0, 0.0, 0.0, 0.0); 346 // Create a multisample FBO. 347 if (m_attrs.antialias) { 348 glGenFramebuffers(1, &m_multisampleFBO); 349 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); 350 m_boundFBO = m_multisampleFBO; 351 glGenRenderbuffers(1, &m_multisampleColorBuffer); 352 if (m_attrs.stencil || m_attrs.depth) 353 glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer); 354 } else { 355 // Bind canvas FBO. 356 glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); 357 m_boundFBO = m_fbo; 358 if (m_attrs.stencil || m_attrs.depth) 359 glGenRenderbuffers(1, &m_depthStencilBuffer); 360 } 327 361 328 362 #if !defined(QT_OPENGL_ES_2) … … 342 376 ANGLEResources.MaxDrawBuffers = 1; 343 377 m_compiler.setResources(ANGLEResources); 344 #endif 378 379 glEnable(GL_POINT_SPRITE); 380 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 381 #endif 382 383 glClearColor(0.0, 0.0, 0.0, 0.0); 345 384 } 346 385 … … 348 387 { 349 388 m_internal->m_glWidget->makeCurrent(); 350 if (m_internal->m_glWidget->isValid()) { 351 glDeleteTextures(1, &m_texture); 389 if (!m_internal->m_glWidget->isValid()) 390 return; 391 glDeleteTextures(1, &m_texture); 392 glDeleteFramebuffers(1, &m_fbo); 393 if (m_attrs.antialias) { 394 glDeleteRenderbuffers(1, &m_multisampleColorBuffer); 395 glDeleteFramebuffers(1, &m_multisampleFBO); 396 if (m_attrs.stencil || m_attrs.depth) 397 glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer); 398 } else if (m_attrs.stencil || m_attrs.depth) 352 399 glDeleteRenderbuffers(1, &m_depthStencilBuffer); 353 glDeleteFramebuffers(1, &m_fbo);354 }355 400 } 356 401
Note: See TracChangeset
for help on using the changeset viewer.