Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laszlo Agocs
qtrhi
Commits
28730ead
Commit
28730ead
authored
Jan 09, 2019
by
Laszlo Agocs
Browse files
multiwindow examples: handle zero size
parent
ccb04e70
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/rhi/multiwindow/multiwindow.cpp
View file @
28730ead
...
...
@@ -363,12 +363,13 @@ void Window::exposeEvent(QExposeEvent *)
render
();
}
// stop pushing frames when not exposed (o
n some platforms this is essential, optional on others
)
if
(
!
isExposed
()
&&
m_running
)
// stop pushing frames when not exposed (o
r size is 0
)
if
(
(
!
isExposed
()
||
(
m_hasSwapChain
&&
m_sc
->
surfacePixelSize
().
isEmpty
()))
&&
m_running
)
m_notExposed
=
true
;
// continue when exposed again
if
(
isExposed
()
&&
m_running
&&
m_notExposed
)
{
// continue when exposed again and the surface has a valid size.
// note that the surface size can be (0, 0) even though size() reports a valid one...
if
(
isExposed
()
&&
m_running
&&
m_notExposed
&&
!
m_sc
->
surfacePixelSize
().
isEmpty
())
{
m_notExposed
=
false
;
m_newlyExposed
=
true
;
render
();
...
...
examples/rhi/multiwindow_threaded/multiwindow_threaded.cpp
View file @
28730ead
...
...
@@ -566,21 +566,41 @@ void Renderer::render(bool newlyExposed, bool wakeBeforePresent)
m_proj
.
translate
(
0
,
0
,
-
4
);
};
if
(
newlyExposed
||
m_sc
->
currentPixelSize
()
!=
m_sc
->
surfacePixelSize
())
auto
wakeUpIfNeeded
=
[
wakeBeforePresent
,
this
]
{
// make sure the main/gui thread is not blocked when issuing the Present (or equivalent)
if
(
wakeBeforePresent
)
{
thread
->
cond
.
wakeOne
();
thread
->
mutex
.
unlock
();
}
};
const
QSize
surfaceSize
=
m_sc
->
surfacePixelSize
();
if
(
surfaceSize
.
isEmpty
())
{
wakeUpIfNeeded
();
return
;
}
if
(
newlyExposed
||
m_sc
->
currentPixelSize
()
!=
surfaceSize
)
buildOrResizeSwapChain
();
if
(
!
m_hasSwapChain
)
if
(
!
m_hasSwapChain
)
{
wakeUpIfNeeded
();
return
;
}
QRhi
::
FrameOpResult
result
=
r
->
beginFrame
(
m_sc
);
if
(
result
==
QRhi
::
FrameOpSwapChainOutOfDate
)
{
buildOrResizeSwapChain
();
if
(
!
m_hasSwapChain
)
if
(
!
m_hasSwapChain
)
{
wakeUpIfNeeded
();
return
;
}
result
=
r
->
beginFrame
(
m_sc
);
}
if
(
result
!=
QRhi
::
FrameOpSuccess
)
if
(
result
!=
QRhi
::
FrameOpSuccess
)
{
wakeUpIfNeeded
();
return
;
}
QRhiCommandBuffer
*
cb
=
m_sc
->
currentFrameCommandBuffer
();
const
QSize
outputSize
=
m_sc
->
currentPixelSize
();
...
...
@@ -610,11 +630,7 @@ void Renderer::render(bool newlyExposed, bool wakeBeforePresent)
cb
->
endPass
();
// make sure the main/gui thread is not blocked when issuing the Present (or equivalent)
if
(
wakeBeforePresent
)
{
thread
->
cond
.
wakeOne
();
thread
->
mutex
.
unlock
();
}
wakeUpIfNeeded
();
r
->
endFrame
(
m_sc
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment