alphamodifier: move to unique ptrs
less refcounting, move by rvalue.
This commit is contained in:
parent
f5af40afce
commit
37be9a8959
2 changed files with 7 additions and 7 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
#include "alpha-modifier-v1.hpp"
|
#include "alpha-modifier-v1.hpp"
|
||||||
#include "core/Compositor.hpp"
|
#include "core/Compositor.hpp"
|
||||||
|
|
||||||
CAlphaModifier::CAlphaModifier(SP<CWpAlphaModifierSurfaceV1> resource, SP<CWLSurfaceResource> surface) : m_surface(surface) {
|
CAlphaModifier::CAlphaModifier(UP<CWpAlphaModifierSurfaceV1>&& resource, SP<CWLSurfaceResource> surface) : m_surface(surface) {
|
||||||
setResource(std::move(resource));
|
setResource(std::move(resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ bool CAlphaModifier::good() {
|
||||||
return m_resource->resource();
|
return m_resource->resource();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAlphaModifier::setResource(SP<CWpAlphaModifierSurfaceV1> resource) {
|
void CAlphaModifier::setResource(UP<CWpAlphaModifierSurfaceV1>&& resource) {
|
||||||
m_resource = std::move(resource);
|
m_resource = std::move(resource);
|
||||||
|
|
||||||
if UNLIKELY (!m_resource->resource())
|
if UNLIKELY (!m_resource->resource())
|
||||||
|
|
@ -89,11 +89,11 @@ void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id
|
||||||
manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present");
|
manager->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
iter->second->setResource(makeShared<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id));
|
iter->second->setResource(makeUnique<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id));
|
||||||
alphaModifier = iter->second.get();
|
alphaModifier = iter->second.get();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alphaModifier = m_alphaModifiers.emplace(surface, makeUnique<CAlphaModifier>(makeShared<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id), surface))
|
alphaModifier = m_alphaModifiers.emplace(surface, makeUnique<CAlphaModifier>(makeUnique<CWpAlphaModifierSurfaceV1>(manager->client(), manager->version(), id), surface))
|
||||||
.first->second.get();
|
.first->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,13 @@ class CAlphaModifierProtocol;
|
||||||
|
|
||||||
class CAlphaModifier {
|
class CAlphaModifier {
|
||||||
public:
|
public:
|
||||||
CAlphaModifier(SP<CWpAlphaModifierSurfaceV1> resource_, SP<CWLSurfaceResource> surface);
|
CAlphaModifier(UP<CWpAlphaModifierSurfaceV1>&& resource_, SP<CWLSurfaceResource> surface);
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
void setResource(SP<CWpAlphaModifierSurfaceV1> resource);
|
void setResource(UP<CWpAlphaModifierSurfaceV1>&& resource);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SP<CWpAlphaModifierSurfaceV1> m_resource;
|
UP<CWpAlphaModifierSurfaceV1> m_resource;
|
||||||
WP<CWLSurfaceResource> m_surface;
|
WP<CWLSurfaceResource> m_surface;
|
||||||
float m_alpha = 1.0;
|
float m_alpha = 1.0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue