Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KWin
Commits
39884136
Commit
39884136
authored
Apr 24, 2021
by
Vlad Zahorodnii
Browse files
Move viewport state into a struct
It makes it more clear what state belongs to the wp_viewport extension.
parent
86d39af6
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/wayland/surface_interface.cpp
View file @
39884136
...
...
@@ -472,10 +472,10 @@ QMatrix4x4 SurfaceInterfacePrivate::buildSurfaceToBufferMatrix(const SurfaceStat
break
;
}
if
(
state
->
sourceGeometry
.
isValid
())
{
surfaceToBufferMatrix
.
translate
(
state
->
sourceGeometry
.
x
(),
state
->
sourceGeometry
.
y
());
surfaceToBufferMatrix
.
scale
(
state
->
sourceGeometry
.
width
()
/
state
->
size
.
width
(),
state
->
sourceGeometry
.
height
()
/
state
->
size
.
height
());
if
(
state
->
viewport
.
sourceGeometry
.
isValid
())
{
surfaceToBufferMatrix
.
translate
(
state
->
viewport
.
sourceGeometry
.
x
(),
state
->
viewport
.
sourceGeometry
.
y
());
surfaceToBufferMatrix
.
scale
(
state
->
viewport
.
sourceGeometry
.
width
()
/
state
->
size
.
width
(),
state
->
viewport
.
sourceGeometry
.
height
()
/
state
->
size
.
height
());
}
return
surfaceToBufferMatrix
;
...
...
@@ -518,13 +518,13 @@ void SurfaceInterfacePrivate::swapStates(SurfaceState *source, SurfaceState *tar
target
->
bufferDamage
=
source
->
bufferDamage
;
target
->
bufferIsSet
=
source
->
bufferIsSet
;
}
if
(
source
->
sourceGeometryIsSet
)
{
target
->
sourceGeometry
=
source
->
sourceGeometry
;
target
->
sourceGeometryIsSet
=
true
;
if
(
source
->
viewport
.
sourceGeometryIsSet
)
{
target
->
viewport
.
sourceGeometry
=
source
->
viewport
.
sourceGeometry
;
target
->
viewport
.
sourceGeometryIsSet
=
true
;
}
if
(
source
->
destinationSizeIsSet
)
{
target
->
destinationSize
=
source
->
destinationSize
;
target
->
destinationSizeIsSet
=
true
;
if
(
source
->
viewport
.
destinationSizeIsSet
)
{
target
->
viewport
.
destinationSize
=
source
->
viewport
.
destinationSize
;
target
->
viewport
.
destinationSizeIsSet
=
true
;
}
if
(
childrenChanged
)
{
target
->
childrenChanged
=
source
->
childrenChanged
;
...
...
@@ -582,10 +582,10 @@ void SurfaceInterfacePrivate::swapStates(SurfaceState *source, SurfaceState *tar
// TODO: Refactor the state management code because it gets more clumsy.
if
(
target
->
buffer
)
{
bufferSize
=
target
->
buffer
->
size
();
if
(
target
->
destinationSize
.
isValid
())
{
target
->
size
=
target
->
destinationSize
;
}
else
if
(
target
->
sourceGeometry
.
isValid
())
{
target
->
size
=
target
->
sourceGeometry
.
size
().
toSize
();
if
(
target
->
viewport
.
destinationSize
.
isValid
())
{
target
->
size
=
target
->
viewport
.
destinationSize
;
}
else
if
(
target
->
viewport
.
sourceGeometry
.
isValid
())
{
target
->
size
=
target
->
viewport
.
sourceGeometry
.
size
().
toSize
();
}
else
{
target
->
size
=
target
->
buffer
->
size
()
/
target
->
bufferScale
;
switch
(
target
->
bufferTransform
)
{
...
...
src/wayland/surface_interface_p.h
View file @
39884136
...
...
@@ -40,11 +40,7 @@ struct SurfaceState
QRegion
bufferDamage
=
QRegion
();
QRegion
opaque
=
QRegion
();
QRegion
input
=
infiniteRegion
();
QRectF
sourceGeometry
=
QRectF
();
QSize
destinationSize
=
QSize
();
QSize
size
=
QSize
();
bool
sourceGeometryIsSet
=
false
;
bool
destinationSizeIsSet
=
false
;
bool
inputIsSet
=
false
;
bool
opaqueIsSet
=
false
;
bool
bufferIsSet
=
false
;
...
...
@@ -66,6 +62,13 @@ struct SurfaceState
QPointer
<
BlurInterface
>
blur
;
QPointer
<
ContrastInterface
>
contrast
;
QPointer
<
SlideInterface
>
slide
;
struct
{
QRectF
sourceGeometry
=
QRectF
();
QSize
destinationSize
=
QSize
();
bool
sourceGeometryIsSet
=
false
;
bool
destinationSizeIsSet
=
false
;
}
viewport
;
};
class
SurfaceInterfacePrivate
:
public
QtWaylandServer
::
wl_surface
...
...
src/wayland/viewporter_interface.cpp
View file @
39884136
...
...
@@ -74,10 +74,10 @@ void ViewportInterface::wp_viewport_destroy(Resource *resource)
{
if
(
surface
)
{
SurfaceInterfacePrivate
*
surfacePrivate
=
SurfaceInterfacePrivate
::
get
(
surface
);
surfacePrivate
->
pending
.
sourceGeometry
=
QRectF
();
surfacePrivate
->
pending
.
sourceGeometryIsSet
=
true
;
surfacePrivate
->
pending
.
destinationSize
=
QSize
();
surfacePrivate
->
pending
.
destinationSizeIsSet
=
true
;
surfacePrivate
->
pending
.
viewport
.
sourceGeometry
=
QRectF
();
surfacePrivate
->
pending
.
viewport
.
sourceGeometryIsSet
=
true
;
surfacePrivate
->
pending
.
viewport
.
destinationSize
=
QSize
();
surfacePrivate
->
pending
.
viewport
.
destinationSizeIsSet
=
true
;
}
wl_resource_destroy
(
resource
->
handle
);
...
...
@@ -98,8 +98,8 @@ void ViewportInterface::wp_viewport_set_source(Resource *resource, wl_fixed_t x_
if
(
x
==
-
1
&&
y
==
-
1
&&
width
==
-
1
&&
height
==
-
1
)
{
SurfaceInterfacePrivate
*
surfacePrivate
=
SurfaceInterfacePrivate
::
get
(
surface
);
surfacePrivate
->
pending
.
sourceGeometry
=
QRectF
();
surfacePrivate
->
pending
.
sourceGeometryIsSet
=
true
;
surfacePrivate
->
pending
.
viewport
.
sourceGeometry
=
QRectF
();
surfacePrivate
->
pending
.
viewport
.
sourceGeometryIsSet
=
true
;
return
;
}
...
...
@@ -109,8 +109,8 @@ void ViewportInterface::wp_viewport_set_source(Resource *resource, wl_fixed_t x_
}
SurfaceInterfacePrivate
*
surfacePrivate
=
SurfaceInterfacePrivate
::
get
(
surface
);
surfacePrivate
->
pending
.
sourceGeometry
=
QRectF
(
x
,
y
,
width
,
height
);
surfacePrivate
->
pending
.
sourceGeometryIsSet
=
true
;
surfacePrivate
->
pending
.
viewport
.
sourceGeometry
=
QRectF
(
x
,
y
,
width
,
height
);
surfacePrivate
->
pending
.
viewport
.
sourceGeometryIsSet
=
true
;
}
void
ViewportInterface
::
wp_viewport_set_destination
(
Resource
*
resource
,
int32_t
width
,
int32_t
height
)
...
...
@@ -123,8 +123,8 @@ void ViewportInterface::wp_viewport_set_destination(Resource *resource, int32_t
if
(
width
==
-
1
&&
height
==
-
1
)
{
SurfaceInterfacePrivate
*
surfacePrivate
=
SurfaceInterfacePrivate
::
get
(
surface
);
surfacePrivate
->
pending
.
destinationSize
=
QSize
();
surfacePrivate
->
pending
.
destinationSizeIsSet
=
true
;
surfacePrivate
->
pending
.
viewport
.
destinationSize
=
QSize
();
surfacePrivate
->
pending
.
viewport
.
destinationSizeIsSet
=
true
;
return
;
}
...
...
@@ -134,8 +134,8 @@ void ViewportInterface::wp_viewport_set_destination(Resource *resource, int32_t
}
SurfaceInterfacePrivate
*
surfacePrivate
=
SurfaceInterfacePrivate
::
get
(
surface
);
surfacePrivate
->
pending
.
destinationSize
=
QSize
(
width
,
height
);
surfacePrivate
->
pending
.
destinationSizeIsSet
=
true
;
surfacePrivate
->
pending
.
viewport
.
destinationSize
=
QSize
(
width
,
height
);
surfacePrivate
->
pending
.
viewport
.
destinationSizeIsSet
=
true
;
}
ViewporterInterface
::
ViewporterInterface
(
Display
*
display
,
QObject
*
parent
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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