Changeset 81298 in webkit
- Timestamp:
- Mar 16, 2011 5:16:12 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r81295 r81298 1 2011-03-16 Jarkko Sakkinen <jarkko.j.sakkinen@gmail.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] WebGL content not shown when accelerated compositing is enabled 6 https://bugs.webkit.org/show_bug.cgi?id=56339 7 8 Removed all previously implemented WebGL code from GraphicsLayerQt 9 because API has changed. GraphicsContext3D provides PlatformLayer 10 that is added as a child of GraphicsLayer and is therefore painted 11 through QGraphicsView pipeline. 12 13 * platform/graphics/GraphicsContext3D.h: 14 * platform/graphics/qt/GraphicsContext3DQt.cpp: 15 (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): 16 (WebCore::GraphicsContext3DInternal::paint): 17 (WebCore::GraphicsContext3DInternal::boundingRect): 18 (WebCore::GraphicsContext3D::platformLayer): 19 (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas): 20 (WebCore::GraphicsContext3D::reshape): 21 * platform/graphics/qt/GraphicsLayerQt.cpp: 22 (WebCore::GraphicsLayerQtImpl::GraphicsLayerQtImpl): 23 (WebCore::GraphicsLayerQtImpl::paint): 24 (WebCore::GraphicsLayerQtImpl::flushChanges): 25 (WebCore::GraphicsLayerQt::setContentsToCanvas): 26 * platform/graphics/qt/GraphicsLayerQt.h: 27 1 28 2011-03-16 Ryosuke Niwa <rniwa@webkit.org> 2 29 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r81213 r81298 462 462 Platform3DObject platformTexture() const; 463 463 #if USE(ACCELERATED_COMPOSITING) 464 PlatformLayer* platformLayer() const { return 0; }464 PlatformLayer* platformLayer() const; 465 465 #endif 466 466 #else … … 761 761 762 762 #if PLATFORM(QT) 763 void paint(QPainter* painter, const QRect& rect) const;764 763 bool paintsIntoCanvasBuffer() const { return true; } 765 764 #elif PLATFORM(CHROMIUM) -
trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
r81213 r81298 28 28 #include "HostWindow.h" 29 29 #include "ImageBuffer.h" 30 #include "ImageData.h" 30 31 #include "NotImplemented.h" 31 #include "QWebPageClient.h" 32 #include "PageClientQt.h" 33 #include "qwebpage.h" 32 34 #include <QAbstractScrollArea> 35 #include <QGraphicsObject> 33 36 #include <QGLContext> 37 #include <QStyleOptionGraphicsItem> 34 38 #include <wtf/UnusedParam.h> 35 39 #include <wtf/text/CString.h> … … 146 150 typedef void (APIENTRY* glVertexAttribPointerType) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*); 147 151 148 class GraphicsContext3DInternal {152 class GraphicsContext3DInternal : public QGraphicsObject { 149 153 public: 150 154 GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow); … … 153 157 bool isContextValid() { return m_contextValid; } 154 158 QGLWidget* getOwnerGLWidget(QWebPageClient* webPageClient); 159 void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); 160 QRectF boundingRect() const; 155 161 156 162 glActiveTextureType activeTexture; … … 248 254 HostWindow* m_hostWindow; 249 255 QGLWidget* m_glWidget; 256 QGLWidget* m_ownerGLWidget; 257 QRectF m_boundingRect; 250 258 GLuint m_texture; 251 259 GLuint m_mainFbo; … … 282 290 , m_hostWindow(hostWindow) 283 291 , m_glWidget(0) 292 , m_ownerGLWidget(0) 284 293 , m_texture(0) 285 294 , m_mainFbo(0) … … 288 297 , m_contextValid(true) 289 298 { 290 QWebPageClient* webPageClient = hostWindow->platformPageClient(); 291 QGLWidget* ownerGLWidget = getOwnerGLWidget(webPageClient); 292 293 if (ownerGLWidget) 294 m_glWidget = new QGLWidget(0, ownerGLWidget); 299 PageClientQWidget* webPageClient 300 = static_cast<PageClientQWidget*>(hostWindow->platformPageClient()); 301 302 #if USE(ACCELERATED_COMPOSITING) 303 if (webPageClient->page->settings()->testAttribute(QWebSettings::AcceleratedCompositingEnabled)) { 304 QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget()); 305 if (scrollArea) 306 m_ownerGLWidget = qobject_cast<QGLWidget*>(scrollArea->viewport()); 307 } 308 #endif 309 310 if (m_ownerGLWidget) 311 m_glWidget = new QGLWidget(0, m_ownerGLWidget); 295 312 else { 296 313 QGLFormat format; … … 455 472 } 456 473 457 QGLWidget* GraphicsContext3DInternal::getOwnerGLWidget(QWebPageClient* webPageClient) 458 { 459 QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget()); 460 461 if (scrollArea) 462 return qobject_cast<QGLWidget*>(scrollArea->viewport()); 463 464 return 0; 474 void GraphicsContext3DInternal::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) 475 { 476 Q_UNUSED(widget); 477 478 QRectF rect = option ? option->rect : boundingRect(); 479 480 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) 481 // Use direct texture mapping if WebGL canvas has a shared OpenGL context 482 // with browsers OpenGL context. 483 if (m_ownerGLWidget) { 484 m_ownerGLWidget->drawTexture(rect, m_texture); 485 return; 486 } 487 #endif 488 489 // Alternatively read pixels to a memory buffer. 490 m_glWidget->makeCurrent(); 491 bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_mainFbo); 492 glReadPixels(/* x */ 0, /* y */ 0, rect.width(), rect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, m_pixels.bits()); 493 painter->drawImage(/* x */ 0, /* y */ 0, m_pixels.rgbSwapped().transformed(QMatrix().rotate(180))); 494 bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_currentFbo); 495 } 496 497 QRectF GraphicsContext3DInternal::boundingRect() const 498 { 499 return m_boundingRect; 465 500 } 466 501 … … 512 547 } 513 548 549 PlatformLayer* GraphicsContext3D::platformLayer() const 550 { 551 return m_internal.get(); 552 } 553 514 554 void GraphicsContext3D::makeContextCurrent() 515 555 { … … 523 563 ImageBuffer* imageBuffer = canvas->buffer(); 524 564 QPainter* painter = imageBuffer->context()->platformContext(); 525 paint(painter, QRect(QPoint(0, 0), QSize(m_currentWidth, m_currentHeight)));565 m_internal->paint(painter, 0, 0); 526 566 } 527 567 … … 531 571 // support. 532 572 return 0; 533 }534 535 void GraphicsContext3D::paint(QPainter* painter, const QRect& rect) const536 {537 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)538 QWebPageClient* webPageClient = m_internal->m_hostWindow->platformPageClient();539 QGLWidget* ownerGLWidget = m_internal->getOwnerGLWidget(webPageClient);540 if (ownerGLWidget) {541 ownerGLWidget->drawTexture(rect, m_internal->m_texture);542 return;543 }544 #endif545 m_internal->m_glWidget->makeCurrent();546 m_internal->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_internal->m_mainFbo);547 glReadPixels(/* x */ 0, /* y */ 0, m_currentWidth, m_currentHeight, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, m_internal->m_pixels.bits());548 painter->drawImage(/* x */ 0, /* y */ 0, m_internal->m_pixels.rgbSwapped().transformed(QMatrix().rotate(180)));549 m_internal->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_internal->m_currentFbo);550 573 } 551 574 … … 558 581 m_currentHeight = height; 559 582 583 m_internal->m_boundingRect = QRectF(QPointF(0, 0), QSizeF(width, height)); 560 584 m_internal->m_pixels = QImage(m_currentWidth, m_currentHeight, QImage::Format_ARGB32); 561 585 -
trunk/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp
r79595 r81298 311 311 } m_state; 312 312 313 #if ENABLE(WEBGL)314 const GraphicsContext3D* m_gc3D;315 #endif316 317 313 #ifndef QT_NO_ANIMATION 318 314 friend class AnimationQtBase; … … 340 336 #if ENABLE(TILED_BACKING_STORE) 341 337 , m_tiledBackingStore(0) 342 #endif343 #if ENABLE(WEBGL)344 , m_gc3D(0)345 338 #endif 346 339 { … … 666 659 // we don't need to paint anything: we have a QGraphicsItem from the media element 667 660 break; 668 #if ENABLE(WEBGL)669 case Canvas3DContentType:670 m_gc3D->paint(painter, option->rect);671 break;672 #endif673 661 } 674 662 } … … 809 797 setFlag(ItemHasNoContents, !m_layer->drawsContent()); 810 798 break; 811 812 #if ENABLE(WEBGL)813 case Canvas3DContentType:814 if (m_pendingContent.contentType != m_currentContent.contentType)815 update();816 817 setCacheMode(NoCache);818 setFlag(ItemHasNoContents, false);819 break;820 #endif821 799 } 822 800 } … … 1269 1247 } 1270 1248 1271 #if ENABLE(WEBGL)1272 void GraphicsLayerQt::setContentsToGraphicsContext3D(const GraphicsContext3D* ctx)1273 {1274 if (ctx == m_impl->m_gc3D)1275 return;1276 1277 m_impl->m_pendingContent.contentType = GraphicsLayerQtImpl::Canvas3DContentType;1278 m_impl->m_gc3D = ctx;1279 m_impl->notifyChange(GraphicsLayerQtImpl::ContentChange);1280 }1281 1282 void GraphicsLayerQt::setGraphicsContext3DNeedsDisplay()1283 {1284 setNeedsDisplay();1285 }1286 #endif1287 1288 1249 void GraphicsLayerQt::setContentsToMedia(PlatformLayer* media) 1289 1250 { … … 1296 1257 m_impl->notifyChange(GraphicsLayerQtImpl::ContentChange); 1297 1258 GraphicsLayer::setContentsToMedia(media); 1259 } 1260 1261 void GraphicsLayerQt::setContentsToCanvas(PlatformLayer* canvas) 1262 { 1263 setContentsToMedia(canvas); 1298 1264 } 1299 1265 -
trunk/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.h
r76600 r81298 21 21 #define GraphicsLayerQt_h 22 22 23 #if ENABLE(WEBGL)24 #include "GraphicsContext3D.h"25 #endif26 23 #include "GraphicsLayer.h" 27 24 #include "GraphicsLayerClient.h" … … 79 76 virtual void setContentsNeedsDisplay(); 80 77 virtual void setContentsToMedia(PlatformLayer*); 78 virtual void setContentsToCanvas(PlatformLayer*); 81 79 virtual void setContentsBackgroundColor(const Color&); 82 #if ENABLE(WEBGL)83 virtual void setContentsToGraphicsContext3D(const GraphicsContext3D*);84 virtual void setGraphicsContext3DNeedsDisplay();85 #endif86 80 virtual void setContentsOrientation(CompositingCoordinatesOrientation orientation); 87 81 virtual void distributeOpacity(float);
Note: See TracChangeset
for help on using the changeset viewer.