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
1365a76f
Commit
1365a76f
authored
Apr 26, 2022
by
Xaver Hugl
Browse files
manage ColorPipelineStages with unique_ptr
parent
14e7afcb
Pipeline
#168717
passed with stage
in 12 minutes and 47 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/colors/colordevice.cpp
View file @
1365a76f
...
...
@@ -59,9 +59,9 @@ public:
uint
brightness
=
100
;
uint
temperature
=
6500
;
QSharedPointe
r
<
ColorPipelineStage
>
temperatureStage
;
QSharedPointe
r
<
ColorPipelineStage
>
brightnessStage
;
QSharedPointe
r
<
ColorPipelineStage
>
calibrationStage
;
std
::
unique_pt
r
<
ColorPipelineStage
>
temperatureStage
;
std
::
unique_pt
r
<
ColorPipelineStage
>
brightnessStage
;
std
::
unique_pt
r
<
ColorPipelineStage
>
calibrationStage
;
QSharedPointer
<
ColorTransformation
>
transformation
;
};
...
...
@@ -79,7 +79,30 @@ void ColorDevicePrivate::rebuildPipeline()
}
dirtyCurves
=
DirtyToneCurves
();
const
auto
tmp
=
QSharedPointer
<
ColorTransformation
>::
create
(
QVector
{
calibrationStage
,
brightnessStage
,
temperatureStage
});
std
::
vector
<
std
::
unique_ptr
<
ColorPipelineStage
>>
stages
;
if
(
calibrationStage
)
{
if
(
auto
s
=
calibrationStage
->
dup
())
{
stages
.
push_back
(
std
::
move
(
s
));
}
else
{
return
;
}
}
if
(
brightnessStage
)
{
if
(
auto
s
=
brightnessStage
->
dup
())
{
stages
.
push_back
(
std
::
move
(
s
));
}
else
{
return
;
}
}
if
(
temperatureStage
)
{
if
(
auto
s
=
temperatureStage
->
dup
())
{
stages
.
push_back
(
std
::
move
(
s
));
}
else
{
return
;
}
}
const
auto
tmp
=
QSharedPointer
<
ColorTransformation
>::
create
(
std
::
move
(
stages
));
if
(
tmp
->
valid
())
{
transformation
=
tmp
;
}
...
...
@@ -135,7 +158,7 @@ void ColorDevicePrivate::updateTemperatureToneCurves()
// The ownership of the tone curves will be moved to the pipeline stage.
cmsToneCurve
*
toneCurves
[]
=
{
redCurve
.
take
(),
greenCurve
.
take
(),
blueCurve
.
take
()};
temperatureStage
=
QSharedPointer
<
ColorPipelineStage
>
::
create
(
cmsStageAllocToneCurves
(
nullptr
,
3
,
toneCurves
));
temperatureStage
=
std
::
make_unique
<
ColorPipelineStage
>
(
cmsStageAllocToneCurves
(
nullptr
,
3
,
toneCurves
));
if
(
!
temperatureStage
)
{
qCWarning
(
KWIN_CORE
)
<<
"Failed to create the color temperature pipeline stage"
;
}
...
...
@@ -172,7 +195,7 @@ void ColorDevicePrivate::updateBrightnessToneCurves()
// The ownership of the tone curves will be moved to the pipeline stage.
cmsToneCurve
*
toneCurves
[]
=
{
redCurve
.
take
(),
greenCurve
.
take
(),
blueCurve
.
take
()};
brightnessStage
=
QSharedPointer
<
ColorPipelineStage
>
::
create
(
cmsStageAllocToneCurves
(
nullptr
,
3
,
toneCurves
));
brightnessStage
=
std
::
make_unique
<
ColorPipelineStage
>
(
cmsStageAllocToneCurves
(
nullptr
,
3
,
toneCurves
));
if
(
!
brightnessStage
)
{
qCWarning
(
KWIN_CORE
)
<<
"Failed to create the color brightness pipeline stage"
;
}
...
...
@@ -202,7 +225,7 @@ void ColorDevicePrivate::updateCalibrationToneCurves()
cmsDupToneCurve
(
vcgt
[
1
]),
cmsDupToneCurve
(
vcgt
[
2
]),
};
calibrationStage
=
QSharedPointer
<
ColorPipelineStage
>
::
create
(
cmsStageAllocToneCurves
(
nullptr
,
3
,
toneCurves
));
calibrationStage
=
std
::
make_unique
<
ColorPipelineStage
>
(
cmsStageAllocToneCurves
(
nullptr
,
3
,
toneCurves
));
}
cmsCloseProfile
(
handle
);
...
...
src/colors/colorpipelinestage.cpp
View file @
1365a76f
...
...
@@ -27,18 +27,17 @@ ColorPipelineStage::~ColorPipelineStage()
}
}
QSharedPointe
r
<
ColorPipelineStage
>
ColorPipelineStage
::
dup
()
const
std
::
unique_pt
r
<
ColorPipelineStage
>
ColorPipelineStage
::
dup
()
const
{
if
(
m_stage
)
{
auto
dup
=
cmsStageDup
(
m_stage
);
if
(
dup
)
{
return
QSharedPointer
<
ColorPipelineStage
>
::
create
(
dup
);
return
std
::
make_unique
<
ColorPipelineStage
>
(
dup
);
}
else
{
qCWarning
(
KWIN_CORE
)
<<
"Failed to duplicate cmsStage!"
;
}
}
return
nullptr
;
;
}
cmsStage
*
ColorPipelineStage
::
stage
()
const
...
...
src/colors/colorpipelinestage.h
View file @
1365a76f
...
...
@@ -10,7 +10,7 @@
#include
"kwin_export.h"
#include
<
QSharedPointer
>
#include
<
memory
>
typedef
struct
_cmsStage_struct
cmsStage
;
...
...
@@ -23,7 +23,7 @@ public:
ColorPipelineStage
(
cmsStage
*
stage
);
~
ColorPipelineStage
();
QSharedPointe
r
<
ColorPipelineStage
>
dup
()
const
;
std
::
unique_pt
r
<
ColorPipelineStage
>
dup
()
const
;
cmsStage
*
stage
()
const
;
private:
...
...
src/colors/colortransformation.cpp
View file @
1365a76f
...
...
@@ -9,27 +9,20 @@
namespace
KWin
{
ColorTransformation
::
ColorTransformation
(
const
QVector
<
QSharedPointe
r
<
ColorPipelineStage
>>
&
stages
)
ColorTransformation
::
ColorTransformation
(
std
::
vector
<
std
::
unique_pt
r
<
ColorPipelineStage
>>
&
&
stages
)
:
m_pipeline
(
cmsPipelineAlloc
(
nullptr
,
3
,
3
))
,
m_stages
(
std
::
move
(
stages
))
{
if
(
!
m_pipeline
)
{
qCWarning
(
KWIN_CORE
)
<<
"Failed to allocate cmsPipeline!"
;
m_valid
=
false
;
return
;
}
for
(
const
auto
&
stage
:
stages
)
{
if
(
stage
)
{
const
auto
dup
=
stage
->
dup
();
if
(
!
dup
)
{
m_valid
=
false
;
return
;
}
m_stages
<<
dup
;
if
(
!
cmsPipelineInsertStage
(
m_pipeline
,
cmsAT_END
,
dup
->
stage
()))
{
qCWarning
(
KWIN_CORE
)
<<
"Failed to insert cmsPipeline stage!"
;
m_valid
=
false
;
return
;
}
for
(
auto
&
stage
:
m_stages
)
{
if
(
!
cmsPipelineInsertStage
(
m_pipeline
,
cmsAT_END
,
stage
->
stage
()))
{
qCWarning
(
KWIN_CORE
)
<<
"Failed to insert cmsPipeline stage!"
;
m_valid
=
false
;
return
;
}
}
}
...
...
src/colors/colortransformation.h
View file @
1365a76f
...
...
@@ -25,7 +25,7 @@ class ColorPipelineStage;
class
KWIN_EXPORT
ColorTransformation
{
public:
ColorTransformation
(
const
QVector
<
QSharedPointe
r
<
ColorPipelineStage
>>
&
stages
);
ColorTransformation
(
std
::
vector
<
std
::
unique_pt
r
<
ColorPipelineStage
>>
&
&
stages
);
~
ColorTransformation
();
bool
valid
()
const
;
...
...
@@ -34,7 +34,7 @@ public:
private:
cmsPipeline
*
const
m_pipeline
;
QVector
<
QSharedPointe
r
<
ColorPipelineStage
>>
m_stages
;
const
std
::
vector
<
std
::
unique_pt
r
<
ColorPipelineStage
>>
m_stages
;
bool
m_valid
=
true
;
};
...
...
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