diff options
Diffstat (limited to 'src/core/delegated_frame_node.cpp')
-rw-r--r-- | src/core/delegated_frame_node.cpp | 82 |
1 files changed, 39 insertions, 43 deletions
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index 8d0b8166a..3d147226d 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -59,7 +59,6 @@ #include "cc/output/delegated_frame_data.h" #include "cc/quads/debug_border_draw_quad.h" #include "cc/quads/draw_quad.h" -#include "cc/quads/io_surface_draw_quad.h" #include "cc/quads/render_pass_draw_quad.h" #include "cc/quads/solid_color_draw_quad.h" #include "cc/quads/stream_video_draw_quad.h" @@ -73,11 +72,18 @@ #include <QOpenGLContext> #include <QOpenGLFunctions> -#include <QSGSimpleRectNode> -#include <QSGSimpleTextureNode> +#include <QSGFlatColorMaterial> #include <QSGTexture> #include <private/qsgadaptationlayer_p.h> +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) +#include <QSGImageNode> +#include <QSGRectangleNode> +#else +#include <QSGSimpleRectNode> +#include <QSGSimpleTextureNode> +#endif + #if !defined(QT_NO_EGL) #include <EGL/egl.h> #include <EGL/eglext.h> @@ -196,22 +202,22 @@ static QSGNode *buildLayerChain(QSGNode *chainParent, const cc::SharedQuadState return layerChain; } -static void waitChromiumSync(gfx::TransferableFence *sync) +static void waitChromiumSync(gl::TransferableFence *sync) { // Chromium uses its own GL bindings and stores in in thread local storage. // For that reason, let chromium_gpu_helper.cpp contain the producing code that will run in the Chromium // GPU thread, and put the sync consuming code here that will run in the QtQuick SG or GUI thread. switch (sync->type) { - case gfx::TransferableFence::NoSync: + case gl::TransferableFence::NoSync: break; - case gfx::TransferableFence::EglSync: + case gl::TransferableFence::EglSync: #ifdef EGL_KHR_reusable_sync { static bool resolved = false; static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR = 0; if (!resolved) { - if (gfx::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) { + if (gl::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) { QOpenGLContext *context = QOpenGLContext::currentContext(); eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)context->getProcAddress("eglClientWaitSyncKHR"); } @@ -224,7 +230,7 @@ static void waitChromiumSync(gfx::TransferableFence *sync) } #endif break; - case gfx::TransferableFence::ArbSync: + case gl::TransferableFence::ArbSync: typedef void (QOPENGLF_APIENTRYP WaitSyncPtr)(GLsync sync, GLbitfield flags, GLuint64 timeout); static WaitSyncPtr glWaitSync_ = 0; if (!glWaitSync_) { @@ -237,22 +243,22 @@ static void waitChromiumSync(gfx::TransferableFence *sync) } } -static void deleteChromiumSync(gfx::TransferableFence *sync) +static void deleteChromiumSync(gl::TransferableFence *sync) { // Chromium uses its own GL bindings and stores in in thread local storage. // For that reason, let chromium_gpu_helper.cpp contain the producing code that will run in the Chromium // GPU thread, and put the sync consuming code here that will run in the QtQuick SG or GUI thread. switch (sync->type) { - case gfx::TransferableFence::NoSync: + case gl::TransferableFence::NoSync: break; - case gfx::TransferableFence::EglSync: + case gl::TransferableFence::EglSync: #ifdef EGL_KHR_reusable_sync { static bool resolved = false; static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR = 0; if (!resolved) { - if (gfx::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) { + if (gl::GLSurfaceQt::HasEGLExtension("EGL_KHR_fence_sync")) { QOpenGLContext *context = QOpenGLContext::currentContext(); eglDestroySyncKHR = (PFNEGLDESTROYSYNCKHRPROC)context->getProcAddress("eglDestroySyncKHR"); } @@ -267,7 +273,7 @@ static void deleteChromiumSync(gfx::TransferableFence *sync) } #endif break; - case gfx::TransferableFence::ArbSync: + case gl::TransferableFence::ArbSync: typedef void (QOPENGLF_APIENTRYP DeleteSyncPtr)(GLsync sync); static DeleteSyncPtr glDeleteSync_ = 0; if (!glDeleteSync_) { @@ -368,7 +374,7 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R if (!texture) { if (m_resource.is_software) { Q_ASSERT(apiDelegate); - scoped_ptr<cc::SharedBitmap> sharedBitmap = content::HostSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox); + std::unique_ptr<cc::SharedBitmap> sharedBitmap = content::HostSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox); // QSG interprets QImage::hasAlphaChannel meaning that a node should enable blending // to draw it but Chromium keeps this information in the quads. // The input format is currently always Format_ARGB32_Premultiplied, so assume that all @@ -576,8 +582,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, if (!layer) continue; - // Only QSGImageNode currently supports QSGLayer textures. - QSGImageNode *imageNode = apiDelegate->createImageNode(); + // Only QSGInternalImageNode currently supports QSGLayer textures. + QSGInternalImageNode *imageNode = apiDelegate->createImageNode(); imageNode->setTargetRect(toQt(quad->rect)); imageNode->setInnerTargetRect(toQt(quad->rect)); imageNode->setTexture(layer); @@ -588,8 +594,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, const cc::TextureDrawQuad *tquad = cc::TextureDrawQuad::MaterialCast(quad); ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates); - QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode; - textureNode->setTextureCoordinatesTransform(tquad->y_flipped ? QSGSimpleTextureNode::MirrorVertically : QSGSimpleTextureNode::NoTransform); + QSGTextureNode *textureNode = apiDelegate->createTextureNode(); + textureNode->setTextureCoordinatesTransform(tquad->y_flipped ? QSGTextureNode::MirrorVertically : QSGTextureNode::NoTransform); textureNode->setRect(toQt(quad->rect)); textureNode->setFiltering(resource->transferableResource().filter == GL_LINEAR ? QSGTexture::Linear : QSGTexture::Nearest); textureNode->setTexture(initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate)); @@ -597,7 +603,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, break; } case cc::DrawQuad::SOLID_COLOR: { const cc::SolidColorDrawQuad *scquad = cc::SolidColorDrawQuad::MaterialCast(quad); - QSGSimpleRectNode *rectangleNode = new QSGSimpleRectNode; + QSGRectangleNode *rectangleNode = apiDelegate->createRectangleNode(); // Qt only supports MSAA and this flag shouldn't be needed. // If we ever want to use QSGRectangleNode::setAntialiasing for this we should @@ -636,7 +642,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, const cc::TileDrawQuad *tquad = cc::TileDrawQuad::MaterialCast(quad); ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates); - QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode; + QSGTextureNode *textureNode = apiDelegate->createTextureNode(); textureNode->setRect(toQt(quad->rect)); textureNode->setSourceRect(toQt(tquad->tex_coord_rect)); textureNode->setFiltering(resource->transferableResource().filter == GL_LINEAR ? QSGTexture::Linear : QSGTexture::Nearest); @@ -658,13 +664,16 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, initAndHoldTexture(uResource, quad->ShouldDrawWithBlending()), initAndHoldTexture(vResource, quad->ShouldDrawWithBlending()), aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending()) : 0, - toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect), - toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), toQt(vquad->color_space)); + toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect), + toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), + toQt(vquad->color_space), + vquad->resource_multiplier, vquad->resource_offset); videoNode->setRect(toQt(quad->rect)); currentLayerChain->appendChildNode(videoNode); break; + } #ifdef GL_OES_EGL_image_external - } case cc::DrawQuad::STREAM_VIDEO_CONTENT: { + case cc::DrawQuad::STREAM_VIDEO_CONTENT: { const cc::StreamVideoDrawQuad *squad = cc::StreamVideoDrawQuad::MaterialCast(quad); ResourceHolder *resource = findAndHoldResource(squad->resource_id(), resourceCandidates); MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending())); @@ -675,23 +684,10 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, svideoNode->setTextureMatrix(toQt(squad->matrix.matrix())); currentLayerChain->appendChildNode(svideoNode); break; -#endif - } - case cc::DrawQuad::IO_SURFACE_CONTENT: { - const cc::IOSurfaceDrawQuad *ioquad = cc::IOSurfaceDrawQuad::MaterialCast(quad); - ResourceHolder *resource = findAndHoldResource(ioquad->io_surface_resource_id(), resourceCandidates); - MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending())); - texture->setTarget(GL_TEXTURE_RECTANGLE); - - bool flip = ioquad->orientation != cc::IOSurfaceDrawQuad::FLIPPED; - StreamVideoNode *svideoNode = new StreamVideoNode(texture, flip, RectangleTarget); - QMatrix4x4 matrix; - matrix.scale(ioquad->io_surface_size.width(), ioquad->io_surface_size.height()); - svideoNode->setRect(toQt(ioquad->rect)); - svideoNode->setTextureMatrix(matrix); - currentLayerChain->appendChildNode(svideoNode); - break; } +#endif + case cc::DrawQuad::SURFACE_CONTENT: + Q_UNREACHABLE(); default: qWarning("Unimplemented quad material: %d", quad->material); } @@ -727,7 +723,7 @@ QSGTexture *DelegatedFrameNode::initAndHoldTexture(ResourceHolder *resource, boo void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxesToFetch) { - QList<gfx::TransferableFence> transferredFences; + QList<gl::TransferableFence> transferredFences; { QMutexLocker lock(&m_mutex); @@ -759,7 +755,7 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe m_textureFences.swap(transferredFences); } - Q_FOREACH (gfx::TransferableFence sync, transferredFences) { + Q_FOREACH (gl::TransferableFence sync, transferredFences) { // We need to wait on the fences on the Qt current context, and // can therefore not use GLFence routines that uses a different // concept of current context. @@ -832,9 +828,9 @@ void DelegatedFrameNode::pullTexture(DelegatedFrameNode *frameNode, MailboxTextu if (syncToken.HasData()) mailboxManager->PullTextureUpdates(syncToken); texture->fetchTexture(mailboxManager); - if (!!gfx::GLContext::GetCurrent() && gfx::GLFence::IsSupported()) { + if (!!gl::GLContext::GetCurrent() && gl::GLFence::IsSupported()) { // Create a fence on the Chromium GPU-thread and context - gfx::GLFence *fence = gfx::GLFence::Create(); + gl::GLFence *fence = gl::GLFence::Create(); // But transfer it to something generic since we need to read it using Qt's OpenGL. frameNode->m_textureFences.append(fence->Transfer()); delete fence; |