summaryrefslogtreecommitdiffstats
path: root/src/core/delegated_frame_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/delegated_frame_node.cpp')
-rw-r--r--src/core/delegated_frame_node.cpp76
1 files changed, 28 insertions, 48 deletions
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index be0858310..12d429770 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -59,7 +59,8 @@
#include "base/threading/thread_task_runner_handle.h"
#include "cc/base/math_util.h"
#include "cc/output/bsp_tree.h"
-#include "cc/output/delegated_frame_data.h"
+#include "cc/output/compositor_frame.h"
+#include "cc/output/compositor_frame_metadata.h"
#include "cc/quads/debug_border_draw_quad.h"
#include "cc/quads/draw_quad.h"
#include "cc/quads/render_pass_draw_quad.h"
@@ -70,7 +71,7 @@
#include "cc/quads/yuv_video_draw_quad.h"
#include "cc/resources/returned_resource.h"
#include "cc/resources/transferable_resource.h"
-#include "content/common/host_shared_bitmap_manager.h"
+#include "components/viz/display_compositor/host_shared_bitmap_manager.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_fence.h"
@@ -83,13 +84,8 @@
#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>
@@ -211,7 +207,6 @@ protected:
QVector<QSGNode*> *m_sceneGraphNodes;
};
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
class DelegatedNodeTreeUpdater : public DelegatedNodeTreeHandler
{
public:
@@ -243,8 +238,11 @@ public:
QSGNode *) override
{
QSGTextureNode *textureNode = static_cast<QSGTextureNode*>(*m_nodeIterator++);
- if (textureNode->texture() != texture)
+ if (textureNode->texture() != texture) {
textureNode->setTexture(texture);
+ // @TODO: This is a workaround for funky rendering, figure out why this is needed.
+ textureNode->markDirty(QSGTextureNode::DirtyGeometry);
+ }
if (textureNode->textureCoordinatesTransform() != texCoordTransForm)
textureNode->setTextureCoordinatesTransform(texCoordTransForm);
if (textureNode->rect() != rect)
@@ -258,15 +256,17 @@ public:
QSGTexture::Filtering filtering, QSGNode *) override
{
QSGTextureNode *textureNode = static_cast<QSGTextureNode*>(*m_nodeIterator++);
-
+ if (textureNode->texture() != texture) {
+ textureNode->setTexture(texture);
+ // @TODO: This is a workaround for funky rendering, figure out why this is needed.
+ textureNode->markDirty(QSGTextureNode::DirtyGeometry);
+ }
if (textureNode->rect() != rect)
textureNode->setRect(rect);
if (textureNode->sourceRect() != sourceRect)
textureNode->setSourceRect(sourceRect);
if (textureNode->filtering() != filtering)
textureNode->setFiltering(filtering);
- if (textureNode->texture() != texture)
- textureNode->setTexture(texture);
}
void setupSolidColorNode(const QRect &rect, const QColor &color, QSGNode *) override
{
@@ -306,7 +306,6 @@ public:
private:
QVector<QSGNode*>::iterator m_nodeIterator;
};
-#endif
class DelegatedNodeTreeCreator : public DelegatedNodeTreeHandler
{
@@ -437,9 +436,9 @@ private:
};
-static inline QSharedPointer<QSGLayer> findRenderPassLayer(const cc::RenderPassId &id, const QVector<QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > > &list)
+static inline QSharedPointer<QSGLayer> findRenderPassLayer(const int &id, const QVector<QPair<int, QSharedPointer<QSGLayer> > > &list)
{
- typedef QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > Pair;
+ typedef QPair<int, QSharedPointer<QSGLayer> > Pair;
Q_FOREACH (const Pair &pair, list)
if (pair.first == id)
return pair.second;
@@ -660,7 +659,7 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R
if (!texture) {
if (m_resource.is_software) {
Q_ASSERT(apiDelegate);
- std::unique_ptr<cc::SharedBitmap> sharedBitmap = content::HostSharedBitmapManager::current()->GetSharedBitmapFromId(m_resource.size, m_resource.mailbox_holder.mailbox);
+ std::unique_ptr<cc::SharedBitmap> sharedBitmap = viz::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
@@ -755,7 +754,7 @@ void DelegatedFrameNode::preprocess()
fetchAndSyncMailboxes(mailboxesToFetch);
// Then render any intermediate RenderPass in order.
- typedef QPair<cc::RenderPassId, QSharedPointer<QSGLayer> > Pair;
+ typedef QPair<int, QSharedPointer<QSGLayer> > Pair;
Q_FOREACH (const Pair &pair, m_sgObjects.renderPassLayers) {
// The layer is non-live, request a one-time update here.
pair.second->scheduleUpdate();
@@ -793,8 +792,8 @@ static bool areSharedQuadStatesEqual(const cc::SharedQuadState *layerState,
// Compares if the frame data that we got from the Chromium Compositor is
// *structurally* equivalent to the one of the previous frame.
// If it is, we will just reuse and update the old nodes where necessary.
-static bool areRenderPassStructuresEqual(cc::DelegatedFrameData *frameData,
- cc::DelegatedFrameData *previousFrameData)
+static bool areRenderPassStructuresEqual(cc::CompositorFrame *frameData,
+ cc::CompositorFrame *previousFrameData)
{
if (!previousFrameData)
return false;
@@ -842,8 +841,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
RenderWidgetHostViewQtDelegate *apiDelegate)
{
m_chromiumCompositorData = chromiumCompositorData;
- cc::DelegatedFrameData* frameData = m_chromiumCompositorData->frameData.get();
- if (!frameData)
+ cc::CompositorFrame* frameData = &m_chromiumCompositorData->frameData;
+ if (frameData->render_pass_list.empty())
return;
// DelegatedFrameNode is a transform node only for the purpose of
@@ -876,15 +875,10 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
// We first compare if the render passes from the previous frame data are structurally
// equivalent to the render passes in the current frame data. If they are, we are going
// to reuse the old nodes. Otherwise, we will delete the old nodes and build a new tree.
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
- cc::DelegatedFrameData *previousFrameData = m_chromiumCompositorData->previousFrameData.get();
+ cc::CompositorFrame *previousFrameData = &m_chromiumCompositorData->previousFrameData;
const bool buildNewTree = !areRenderPassStructuresEqual(frameData, previousFrameData) || m_sceneGraphNodes.empty();
-#else
- // No updates possible with old scenegraph nodes
- const bool buildNewTree = true;
-#endif
- m_chromiumCompositorData->previousFrameData = nullptr;
+ m_chromiumCompositorData->previousFrameData = cc::CompositorFrame();
SGObjects previousSGObjects;
QVector<QSharedPointer<QSGTexture> > textureStrongRefs;
if (buildNewTree) {
@@ -896,13 +890,11 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
delete oldChain;
m_sceneGraphNodes.clear();
nodeHandler.reset(new DelegatedNodeTreeCreator(&m_sceneGraphNodes, apiDelegate));
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
} else {
// Save the texture strong refs so they only go out of scope when the method returns and
// the new vector of texture strong refs has been filled.
qSwap(m_sgObjects.textureStrongRefs, textureStrongRefs);
nodeHandler.reset(new DelegatedNodeTreeUpdater(&m_sceneGraphNodes));
-#endif
}
// The RenderPasses list is actually a tree where a parent RenderPass is connected
// to its dependencies through a RenderPassId reference in one or more RenderPassQuads.
@@ -933,7 +925,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
}
QSharedPointer<QSGRootNode> rootNode(new QSGRootNode);
rpLayer->setItem(rootNode.data());
- m_sgObjects.renderPassLayers.append(QPair<cc::RenderPassId,
+ m_sgObjects.renderPassLayers.append(QPair<int,
QSharedPointer<QSGLayer> >(pass->id, rpLayer));
m_sgObjects.renderPassRootNodes.append(rootNode);
renderPassParent = rootNode.data();
@@ -1250,27 +1242,15 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
QMutexLocker lock(&m_mutex);
gpu::SyncPointManager *syncPointManager = sync_point_manager();
- if (!m_syncPointClient)
- m_syncPointClient = syncPointManager->CreateSyncPointClientWaiter();
base::MessageLoop *gpuMessageLoop = gpu_message_loop();
Q_ASSERT(m_numPendingSyncPoints == 0);
m_numPendingSyncPoints = mailboxesToFetch.count();
- auto it = mailboxesToFetch.constBegin();
- auto end = mailboxesToFetch.constEnd();
- for (; it != end; ++it) {
- MailboxTexture *mailboxTexture = *it;
+ for (MailboxTexture *mailboxTexture : qAsConst(mailboxesToFetch)) {
gpu::SyncToken &syncToken = mailboxTexture->mailboxHolder().sync_token;
- if (syncToken.HasData()) {
- scoped_refptr<gpu::SyncPointClientState> release_state =
- syncPointManager->GetSyncPointClientState(syncToken.namespace_id(), syncToken.command_buffer_id());
- if (release_state && !release_state->IsFenceSyncReleased(syncToken.release_count())) {
- m_syncPointClient->WaitOutOfOrderNonThreadSafe(
- release_state.get(), syncToken.release_count(),
- gpuMessageLoop->task_runner(), base::Bind(&DelegatedFrameNode::pullTexture, this, mailboxTexture));
- continue;
- }
- }
- gpuMessageLoop->task_runner()->PostTask(FROM_HERE, base::Bind(&DelegatedFrameNode::pullTexture, this, mailboxTexture));
+ const auto task = base::Bind(&DelegatedFrameNode::pullTexture, this, mailboxTexture);
+ if (syncPointManager->WaitOutOfOrderNonThreadSafe(syncToken, gpuMessageLoop->task_runner(), task))
+ continue;
+ gpuMessageLoop->task_runner()->PostTask(FROM_HERE, task);
}
m_mailboxesFetchedWaitCond.wait(&m_mutex);