1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtQuick module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qsgd3d12context_p.h"
41 #include "qsgd3d12rendercontext_p.h"
42 #include "qsgd3d12internalrectanglenode_p.h"
43 #include "qsgd3d12internalimagenode_p.h"
44 #include "qsgd3d12glyphnode_p.h"
45 #include "qsgd3d12layer_p.h"
46 #include "qsgd3d12shadereffectnode_p.h"
47 #include "qsgd3d12painternode_p.h"
48 #include "qsgd3d12publicnodes_p.h"
49 #include "qsgd3d12spritenode_p.h"
50 #include <QtQuick/qquickwindow.h>
51 
52 QT_BEGIN_NAMESPACE
53 
createRenderContext()54 QSGRenderContext *QSGD3D12Context::createRenderContext()
55 {
56     return new QSGD3D12RenderContext(this);
57 }
58 
createInternalRectangleNode()59 QSGInternalRectangleNode *QSGD3D12Context::createInternalRectangleNode()
60 {
61     return new QSGD3D12InternalRectangleNode;
62 }
63 
createInternalImageNode(QSGRenderContext * renderContext)64 QSGInternalImageNode *QSGD3D12Context::createInternalImageNode(QSGRenderContext *renderContext)
65 {
66     Q_UNUSED(renderContext);
67     return new QSGD3D12InternalImageNode;
68 }
69 
createPainterNode(QQuickPaintedItem * item)70 QSGPainterNode *QSGD3D12Context::createPainterNode(QQuickPaintedItem *item)
71 {
72     return new QSGD3D12PainterNode(item);
73 }
74 
createGlyphNode(QSGRenderContext * renderContext,bool preferNativeGlyphNode)75 QSGGlyphNode *QSGD3D12Context::createGlyphNode(QSGRenderContext *renderContext, bool preferNativeGlyphNode)
76 {
77     Q_UNUSED(preferNativeGlyphNode);
78     // ### distance field text rendering is not supported atm
79 
80     QSGD3D12RenderContext *rc = static_cast<QSGD3D12RenderContext *>(renderContext);
81     return new QSGD3D12GlyphNode(rc);
82 }
83 
createLayer(QSGRenderContext * renderContext)84 QSGLayer *QSGD3D12Context::createLayer(QSGRenderContext *renderContext)
85 {
86     QSGD3D12RenderContext *rc = static_cast<QSGD3D12RenderContext *>(renderContext);
87     return new QSGD3D12Layer(rc);
88 }
89 
createGuiThreadShaderEffectManager()90 QSGGuiThreadShaderEffectManager *QSGD3D12Context::createGuiThreadShaderEffectManager()
91 {
92     return new QSGD3D12GuiThreadShaderEffectManager;
93 }
94 
createShaderEffectNode(QSGRenderContext * renderContext,QSGGuiThreadShaderEffectManager * mgr)95 QSGShaderEffectNode *QSGD3D12Context::createShaderEffectNode(QSGRenderContext *renderContext,
96                                                              QSGGuiThreadShaderEffectManager *mgr)
97 {
98     QSGD3D12RenderContext *rc = static_cast<QSGD3D12RenderContext *>(renderContext);
99     QSGD3D12GuiThreadShaderEffectManager *dmgr = static_cast<QSGD3D12GuiThreadShaderEffectManager *>(mgr);
100     return new QSGD3D12ShaderEffectNode(rc, dmgr);
101 }
102 
minimumFBOSize() const103 QSize QSGD3D12Context::minimumFBOSize() const
104 {
105     return QSize(16, 16);
106 }
107 
defaultSurfaceFormat() const108 QSurfaceFormat QSGD3D12Context::defaultSurfaceFormat() const
109 {
110     QSurfaceFormat format = QSurfaceFormat::defaultFormat();
111 
112     if (QQuickWindow::hasDefaultAlphaBuffer())
113         format.setAlphaBufferSize(8);
114 
115     return format;
116 }
117 
rendererInterface(QSGRenderContext * renderContext)118 QSGRendererInterface *QSGD3D12Context::rendererInterface(QSGRenderContext *renderContext)
119 {
120     return static_cast<QSGD3D12RenderContext *>(renderContext);
121 }
122 
createRectangleNode()123 QSGRectangleNode *QSGD3D12Context::createRectangleNode()
124 {
125     return new QSGD3D12RectangleNode;
126 }
127 
createImageNode()128 QSGImageNode *QSGD3D12Context::createImageNode()
129 {
130     return new QSGD3D12ImageNode;
131 }
132 
createNinePatchNode()133 QSGNinePatchNode *QSGD3D12Context::createNinePatchNode()
134 {
135     return new QSGD3D12NinePatchNode;
136 }
137 
createSpriteNode()138 QSGSpriteNode *QSGD3D12Context::createSpriteNode()
139 {
140     return new QSGD3D12SpriteNode;
141 }
142 
143 QT_END_NAMESPACE
144