|
Lines 23-29
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec1
|
| 23 |
#include "WebGLObject.h" |
23 |
#include "WebGLObject.h" |
| 24 |
#include <cairo/OpenGLShims.h> |
24 |
#include <cairo/OpenGLShims.h> |
| 25 |
#include "CanvasRenderingContext.h" |
25 |
#include "CanvasRenderingContext.h" |
|
|
26 |
#if defined(QT_OPENGL_ES_2) |
| 26 |
#include "Extensions3DQt.h" |
27 |
#include "Extensions3DQt.h" |
|
|
28 |
#else |
| 29 |
#include "Extensions3DOpenGL.h" |
| 30 |
#endif |
| 27 |
#include "GraphicsContext.h" |
31 |
#include "GraphicsContext.h" |
| 28 |
#include "HTMLCanvasElement.h" |
32 |
#include "HTMLCanvasElement.h" |
| 29 |
#include "HostWindow.h" |
33 |
#include "HostWindow.h" |
|
Lines 76-81
public:
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec2
|
| 76 |
|
80 |
|
| 77 |
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); |
81 |
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); |
| 78 |
QRectF boundingRect() const; |
82 |
QRectF boundingRect() const; |
|
|
83 |
void multisampleResolve() const; |
| 79 |
|
84 |
|
| 80 |
GraphicsContext3D* m_context; |
85 |
GraphicsContext3D* m_context; |
| 81 |
HostWindow* m_hostWindow; |
86 |
HostWindow* m_hostWindow; |
|
Lines 109-119
GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D* context,
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec3
|
| 109 |
m_glWidget->setGeometry(0, 0, 0, 0); |
114 |
m_glWidget->setGeometry(0, 0, 0, 0); |
| 110 |
|
115 |
|
| 111 |
m_glWidget->makeCurrent(); |
116 |
m_glWidget->makeCurrent(); |
| 112 |
|
|
|
| 113 |
#if !defined(QT_OPENGL_ES_2) |
| 114 |
glEnable(GL_POINT_SPRITE); |
| 115 |
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
| 116 |
#endif |
| 117 |
} |
117 |
} |
| 118 |
|
118 |
|
| 119 |
GraphicsContext3DInternal::~GraphicsContext3DInternal() |
119 |
GraphicsContext3DInternal::~GraphicsContext3DInternal() |
|
Lines 143-148
static inline quint32 swapBgrToRgb(quint32 pixel)
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec4
|
| 143 |
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) |
143 |
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) |
| 144 |
void GraphicsContext3DInternal::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask) const |
144 |
void GraphicsContext3DInternal::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask) const |
| 145 |
{ |
145 |
{ |
|
|
146 |
if (m_context->m_attrs.antialias) { |
| 147 |
const QGLContext* currentContext = QGLContext::currentContext(); |
| 148 |
const QGLContext* widgetContext = m_glWidget->context(); |
| 149 |
if (currentContext != widgetContext) |
| 150 |
m_glWidget->makeCurrent(); |
| 151 |
multisampleResolve(); |
| 152 |
if (currentContext) { |
| 153 |
if (currentContext != widgetContext) |
| 154 |
const_cast<QGLContext*>(currentContext)->makeCurrent(); |
| 155 |
} else |
| 156 |
m_glWidget->doneCurrent(); |
| 157 |
} |
| 158 |
|
| 146 |
if (textureMapper->isOpenGLBacked()) { |
159 |
if (textureMapper->isOpenGLBacked()) { |
| 147 |
TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper); |
160 |
TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper); |
| 148 |
texmapGL->drawTexture(m_context->m_texture, !m_context->m_attrs.alpha, FloatSize(1, 1), targetRect, matrix, opacity, mask, true /* flip */); |
161 |
texmapGL->drawTexture(m_context->m_texture, !m_context->m_attrs.alpha, FloatSize(1, 1), targetRect, matrix, opacity, mask, true /* flip */); |
|
Lines 205-210
void GraphicsContext3DInternal::paint(QPainter* painter, const QStyleOptionGraph
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec5
|
| 205 |
|
218 |
|
| 206 |
QRectF rect = option ? option->rect : boundingRect(); |
219 |
QRectF rect = option ? option->rect : boundingRect(); |
| 207 |
|
220 |
|
|
|
221 |
m_glWidget->makeCurrent(); |
| 222 |
if (m_context->m_attrs.antialias) |
| 223 |
multisampleResolve(); |
| 224 |
|
| 208 |
// Use direct texture mapping if WebGL canvas has a shared OpenGL context |
225 |
// Use direct texture mapping if WebGL canvas has a shared OpenGL context |
| 209 |
// with browsers OpenGL context. |
226 |
// with browsers OpenGL context. |
| 210 |
QGLWidget* viewportGLWidget = getViewportGLWidget(); |
227 |
QGLWidget* viewportGLWidget = getViewportGLWidget(); |
|
Lines 217-223
void GraphicsContext3DInternal::paint(QPainter* painter, const QStyleOptionGraph
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec6
|
| 217 |
QImage offscreenImage(rect.width(), rect.height(), QImage::Format_ARGB32); |
234 |
QImage offscreenImage(rect.width(), rect.height(), QImage::Format_ARGB32); |
| 218 |
quint32* imagePixels = reinterpret_cast<quint32*>(offscreenImage.bits()); |
235 |
quint32* imagePixels = reinterpret_cast<quint32*>(offscreenImage.bits()); |
| 219 |
|
236 |
|
| 220 |
m_glWidget->makeCurrent(); |
|
|
| 221 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo); |
237 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo); |
| 222 |
glReadPixels(/* x */ 0, /* y */ 0, rect.width(), rect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, imagePixels); |
238 |
glReadPixels(/* x */ 0, /* y */ 0, rect.width(), rect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, imagePixels); |
| 223 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO); |
239 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO); |
|
Lines 249-254
void GraphicsContext3DInternal::paint(QPainter* painter, const QStyleOptionGraph
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec7
|
| 249 |
painter->drawImage(/* x */ 0, /* y */ 0, offscreenImage); |
265 |
painter->drawImage(/* x */ 0, /* y */ 0, offscreenImage); |
| 250 |
} |
266 |
} |
| 251 |
|
267 |
|
|
|
268 |
void GraphicsContext3DInternal::multisampleResolve() const |
| 269 |
{ |
| 270 |
glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_context->m_multisampleFBO); |
| 271 |
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_context->m_fbo); |
| 272 |
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); |
| 273 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO); |
| 274 |
} |
| 275 |
|
| 252 |
PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) |
276 |
PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) |
| 253 |
{ |
277 |
{ |
| 254 |
// This implementation doesn't currently support rendering directly to the HostWindow. |
278 |
// This implementation doesn't currently support rendering directly to the HostWindow. |
|
Lines 280-289
GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec8
|
| 280 |
#if defined(QT_OPENGL_ES_2) |
304 |
#if defined(QT_OPENGL_ES_2) |
| 281 |
m_attrs.stencil = false; |
305 |
m_attrs.stencil = false; |
| 282 |
#else |
306 |
#else |
| 283 |
if (m_attrs.stencil) |
307 |
validateAttributes(); |
| 284 |
m_attrs.depth = true; |
|
|
| 285 |
#endif |
308 |
#endif |
| 286 |
m_attrs.antialias = false; |
|
|
| 287 |
|
309 |
|
| 288 |
if (!m_internal->m_glWidget->isValid()) { |
310 |
if (!m_internal->m_glWidget->isValid()) { |
| 289 |
LOG_ERROR("GraphicsContext3D: QGLWidget initialization failed."); |
311 |
LOG_ERROR("GraphicsContext3D: QGLWidget initialization failed."); |
|
Lines 313-325
GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec9
|
| 313 |
glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); |
335 |
glTexParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); |
| 314 |
glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); |
336 |
glBindTexture(GraphicsContext3D::TEXTURE_2D, 0); |
| 315 |
|
337 |
|
| 316 |
if (m_attrs.depth) |
338 |
// Create a multisample FBO. |
| 317 |
glGenRenderbuffers(/* count */ 1, &m_depthStencilBuffer); |
339 |
if (m_attrs.antialias) { |
| 318 |
|
340 |
glGenFramebuffers(1, &m_multisampleFBO); |
| 319 |
// Bind canvas FBO and set initial clear color to black. |
341 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); |
| 320 |
m_boundFBO = m_fbo; |
342 |
m_boundFBO = m_multisampleFBO; |
| 321 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); |
343 |
glGenRenderbuffers(1, &m_multisampleColorBuffer); |
| 322 |
glClearColor(0.0, 0.0, 0.0, 0.0); |
344 |
if (m_attrs.stencil || m_attrs.depth) |
|
|
345 |
glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer); |
| 346 |
} else { |
| 347 |
// Bind canvas FBO |
| 348 |
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); |
| 349 |
m_boundFBO = m_fbo; |
| 350 |
if (m_attrs.stencil || m_attrs.depth) |
| 351 |
glGenRenderbuffers(1, &m_depthStencilBuffer); |
| 352 |
} |
| 323 |
|
353 |
|
| 324 |
#if !defined(QT_OPENGL_ES_2) |
354 |
#if !defined(QT_OPENGL_ES_2) |
| 325 |
// ANGLE initialization. |
355 |
// ANGLE initialization. |
|
Lines 337-343
GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec10
|
| 337 |
// Always set to 1 for OpenGL ES. |
367 |
// Always set to 1 for OpenGL ES. |
| 338 |
ANGLEResources.MaxDrawBuffers = 1; |
368 |
ANGLEResources.MaxDrawBuffers = 1; |
| 339 |
m_compiler.setResources(ANGLEResources); |
369 |
m_compiler.setResources(ANGLEResources); |
|
|
370 |
|
| 371 |
glEnable(GL_POINT_SPRITE); |
| 372 |
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
| 340 |
#endif |
373 |
#endif |
|
|
374 |
|
| 375 |
glClearColor(0.0, 0.0, 0.0, 0.0); |
| 341 |
} |
376 |
} |
| 342 |
|
377 |
|
| 343 |
GraphicsContext3D::~GraphicsContext3D() |
378 |
GraphicsContext3D::~GraphicsContext3D() |
|
Lines 345-351
GraphicsContext3D::~GraphicsContext3D()
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec11
|
| 345 |
m_internal->m_glWidget->makeCurrent(); |
380 |
m_internal->m_glWidget->makeCurrent(); |
| 346 |
if (m_internal->m_glWidget->isValid()) { |
381 |
if (m_internal->m_glWidget->isValid()) { |
| 347 |
glDeleteTextures(1, &m_texture); |
382 |
glDeleteTextures(1, &m_texture); |
| 348 |
glDeleteRenderbuffers(1, &m_depthStencilBuffer); |
383 |
if (m_attrs.antialias) { |
|
|
384 |
glDeleteRenderbuffers(1, &m_multisampleColorBuffer); |
| 385 |
if (m_attrs.stencil || m_attrs.depth) |
| 386 |
glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer); |
| 387 |
glDeleteFramebuffers(1, &m_multisampleFBO); |
| 388 |
} else if (m_attrs.stencil || m_attrs.depth) |
| 389 |
glDeleteRenderbuffers(1, &m_depthStencilBuffer); |
| 349 |
glDeleteFramebuffers(1, &m_fbo); |
390 |
glDeleteFramebuffers(1, &m_fbo); |
| 350 |
} |
391 |
} |
| 351 |
} |
392 |
} |
|
Lines 1495-1501
bool GraphicsContext3D::layerComposited() const
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec12
|
| 1495 |
{ |
1536 |
{ |
| 1496 |
return m_layerComposited; |
1537 |
return m_layerComposited; |
| 1497 |
} |
1538 |
} |
| 1498 |
#endif |
|
|
| 1499 |
|
1539 |
|
| 1500 |
Extensions3D* GraphicsContext3D::getExtensions() |
1540 |
Extensions3D* GraphicsContext3D::getExtensions() |
| 1501 |
{ |
1541 |
{ |
|
Lines 1503-1508
Extensions3D* GraphicsContext3D::getExtensions()
a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp_sec13
|
| 1503 |
m_extensions = adoptPtr(new Extensions3DQt); |
1543 |
m_extensions = adoptPtr(new Extensions3DQt); |
| 1504 |
return m_extensions.get(); |
1544 |
return m_extensions.get(); |
| 1505 |
} |
1545 |
} |
|
|
1546 |
#endif |
| 1506 |
|
1547 |
|
| 1507 |
bool GraphicsContext3D::getImageData(Image* image, |
1548 |
bool GraphicsContext3D::getImageData(Image* image, |
| 1508 |
GC3Denum format, |
1549 |
GC3Denum format, |