Commit e144748c authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Add some const &

Summary:
Won't make things go much faster since everything that was
being passed by value is refcounted but still const & is a bit faster
than refcounting

For shared pointers instead of adding const & we move them into the
destination variable saving some cpu usage but at the same time making
clear the pointer is being stored by not being const &

Reviewers: zzag

Reviewed By: zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25022
parent 92197242
......@@ -124,7 +124,7 @@ public:
return 0;
}
void doneOpenGLContextCurrent() override {}
void drawWindow(KWin::EffectWindow *, int, QRegion, KWin::WindowPaintData &) override {}
void drawWindow(KWin::EffectWindow *, int, const QRegion &, KWin::WindowPaintData &) override {}
KWin::EffectFrame *effectFrame(KWin::EffectFrameStyle, bool, const QPoint &, Qt::Alignment) const override {
return nullptr;
}
......@@ -173,9 +173,9 @@ public:
bool optionRollOverDesktops() const override {
return false;
}
void paintEffectFrame(KWin::EffectFrame *, QRegion, double, double) override {}
void paintScreen(int, QRegion, KWin::ScreenPaintData &) override {}
void paintWindow(KWin::EffectWindow *, int, QRegion, KWin::WindowPaintData &) override {}
void paintEffectFrame(KWin::EffectFrame *, const QRegion &, double, double) override {}
void paintScreen(int, const QRegion &, KWin::ScreenPaintData &) override {}
void paintWindow(KWin::EffectWindow *, int, const QRegion &, KWin::WindowPaintData &) override {}
void postPaintScreen() override {}
void postPaintWindow(KWin::EffectWindow *) override {}
void prePaintScreen(KWin::ScreenPrePaintData &, int) override {}
......
......@@ -397,7 +397,7 @@ void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time)
// no special final code
}
void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& data)
void EffectsHandlerImpl::paintScreen(int mask, const QRegion &region, ScreenPaintData& data)
{
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
(*m_currentPaintScreenIterator++)->paintScreen(mask, region, data);
......@@ -440,7 +440,7 @@ void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& dat
// no special final code
}
void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, const QRegion &region, WindowPaintData& data)
{
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
(*m_currentPaintWindowIterator++)->paintWindow(w, mask, region, data);
......@@ -449,7 +449,7 @@ void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region,
m_scene->finalPaintWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
}
void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, const QRegion &region, double opacity, double frameOpacity)
{
if (m_currentPaintEffectFrameIterator != m_activeEffects.constEnd()) {
(*m_currentPaintEffectFrameIterator++)->paintEffectFrame(frame, region, opacity, frameOpacity);
......@@ -477,7 +477,7 @@ Effect *EffectsHandlerImpl::provides(Effect::Feature ef)
return nullptr;
}
void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, const QRegion &region, WindowPaintData& data)
{
if (m_currentDrawWindowIterator != m_activeEffects.constEnd()) {
(*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data);
......@@ -2280,7 +2280,7 @@ void EffectFrameImpl::plasmaThemeChanged()
free();
}
void EffectFrameImpl::render(QRegion region, double opacity, double frameOpacity)
void EffectFrameImpl::render(const QRegion &region, double opacity, double frameOpacity)
{
if (m_geometry.isEmpty()) {
return; // Nothing to display
......
......@@ -74,20 +74,20 @@ public:
EffectsHandlerImpl(Compositor *compositor, Scene *scene);
~EffectsHandlerImpl() override;
void prePaintScreen(ScreenPrePaintData& data, int time) override;
void paintScreen(int mask, QRegion region, ScreenPaintData& data) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData& data) override;
/**
* Special hook to perform a paintScreen but just with the windows on @p desktop.
*/
void paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData& data);
void postPaintScreen() override;
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
void paintWindow(EffectWindow* w, int mask, const QRegion &region, WindowPaintData& data) override;
void postPaintWindow(EffectWindow* w) override;
void paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity) override;
void paintEffectFrame(EffectFrame* frame, const QRegion &region, double opacity, double frameOpacity) override;
Effect *provides(Effect::Feature ef);
void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
void drawWindow(EffectWindow* w, int mask, const QRegion &region, WindowPaintData& data) override;
void buildQuads(EffectWindow* w, WindowQuadList& quadList) override;
......@@ -541,7 +541,7 @@ public:
~EffectFrameImpl() override;
void free() override;
void render(QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override;
void render(const QRegion &region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override;
Qt::Alignment alignment() const override;
void setAlignment(Qt::Alignment alignment) override;
const QFont& font() const override;
......
......@@ -431,7 +431,7 @@ bool ContrastEffect::shouldContrast(const EffectWindow *w, int mask, const Windo
return true;
}
void ContrastEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
void ContrastEffect::drawWindow(EffectWindow *w, int mask, const QRegion &region, WindowPaintData &data)
{
const QRect screen = GLRenderTarget::virtualScreenGeometry();
if (shouldContrast(w, mask, data)) {
......@@ -467,7 +467,7 @@ void ContrastEffect::drawWindow(EffectWindow *w, int mask, QRegion region, Windo
effects->drawWindow(w, mask, region, data);
}
void ContrastEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity)
void ContrastEffect::paintEffectFrame(EffectFrame *frame, const QRegion &region, double opacity, double frameOpacity)
{
//FIXME: this is a no-op for now, it should figure out the right contrast, intensity, saturation
effects->paintEffectFrame(frame, region, opacity, frameOpacity);
......
......@@ -55,8 +55,8 @@ public:
void reconfigure(ReconfigureFlags flags) override;
void prePaintScreen(ScreenPrePaintData &data, int time) override;
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override;
void drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
void paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity) override;
void drawWindow(EffectWindow *w, int mask, const QRegion &region, WindowPaintData &data) override;
void paintEffectFrame(EffectFrame *frame, const QRegion &region, double opacity, double frameOpacity) override;
bool provides(Feature feature) override;
......
......@@ -580,7 +580,7 @@ bool BlurEffect::shouldBlur(const EffectWindow *w, int mask, const WindowPaintDa
return true;
}
void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
void BlurEffect::drawWindow(EffectWindow *w, int mask, const QRegion &region, WindowPaintData &data)
{
const QRect screen = GLRenderTarget::virtualScreenGeometry();
if (shouldBlur(w, mask, data)) {
......@@ -616,7 +616,7 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, QRegion region, WindowPai
effects->drawWindow(w, mask, region, data);
}
void BlurEffect::paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity)
void BlurEffect::paintEffectFrame(EffectFrame *frame, const QRegion &region, double opacity, double frameOpacity)
{
const QRect screen = effects->virtualScreenGeometry();
bool valid = m_renderTargetsValid && m_shader && m_shader->isValid();
......
......@@ -58,8 +58,8 @@ public:
void reconfigure(ReconfigureFlags flags) override;
void prePaintScreen(ScreenPrePaintData &data, int time) override;
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
void drawWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
void paintEffectFrame(EffectFrame *frame, QRegion region, double opacity, double frameOpacity) override;
void drawWindow(EffectWindow *w, int mask, const QRegion &region, WindowPaintData &data) override;
void paintEffectFrame(EffectFrame *frame, const QRegion &region, double opacity, double frameOpacity) override;
bool provides(Feature feature) override;
......
......@@ -61,7 +61,7 @@ ColorPickerEffect::ColorPickerEffect()
ColorPickerEffect::~ColorPickerEffect() = default;
void ColorPickerEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data)
void ColorPickerEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &data)
{
m_cachedOutputGeometry = data.outputGeometry();
effects->paintScreen(mask, region, data);
......
......@@ -37,7 +37,7 @@ class ColorPickerEffect : public Effect, protected QDBusContext
public:
ColorPickerEffect();
~ColorPickerEffect() override;
void paintScreen(int mask, QRegion region, ScreenPaintData &data) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData &data) override;
void postPaintScreen() override;
bool isActive() const override;
......
......@@ -129,7 +129,7 @@ void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time)
effects->prePaintScreen(data, time);
}
void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
void CoverSwitchEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
......
......@@ -54,7 +54,7 @@ public:
void reconfigure(ReconfigureFlags) override;
void prePaintScreen(ScreenPrePaintData &data, int time) override;
void paintScreen(int mask, QRegion region, ScreenPaintData &data) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData &data) override;
void postPaintScreen() override;
void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
void windowInputMouseEvent(QEvent *e) override;
......
......@@ -397,7 +397,7 @@ void CubeEffect::prePaintScreen(ScreenPrePaintData& data, int time)
effects->prePaintScreen(data, time);
}
void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
void CubeEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData& data)
{
if (activated) {
QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
......
......@@ -59,7 +59,7 @@ public:
~CubeEffect() override;
void reconfigure(ReconfigureFlags) override;
void prePaintScreen(ScreenPrePaintData& data, int time) override;
void paintScreen(int mask, QRegion region, ScreenPaintData& data) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData& data) override;
void postPaintScreen() override;
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
......
......@@ -87,7 +87,7 @@ void CubeSlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
effects->prePaintScreen(data, time);
}
void CubeSlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
void CubeSlideEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData& data)
{
if (isActive()) {
glEnable(GL_CULL_FACE);
......
......@@ -43,7 +43,7 @@ public:
~CubeSlideEffect() override;
void reconfigure(ReconfigureFlags) override;
void prePaintScreen(ScreenPrePaintData& data, int time) override;
void paintScreen(int mask, QRegion region, ScreenPaintData& data) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData& data) override;
void postPaintScreen() override;
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
......
......@@ -181,7 +181,7 @@ void DesktopGridEffect::prePaintScreen(ScreenPrePaintData& data, int time)
effects->prePaintScreen(data, time);
}
void DesktopGridEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
void DesktopGridEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData& data)
{
if (timeline.currentValue() == 0 && !isUsingPresentWindows()) {
effects->paintScreen(mask, region, data);
......
......@@ -70,7 +70,7 @@ public:
~DesktopGridEffect() override;
void reconfigure(ReconfigureFlags) override;
void prePaintScreen(ScreenPrePaintData& data, int time) override;
void paintScreen(int mask, QRegion region, ScreenPaintData& data) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData& data) override;
void postPaintScreen() override;
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
......
......@@ -120,7 +120,7 @@ void FlipSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time)
effects->prePaintScreen(data, time);
}
void FlipSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
void FlipSwitchEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if (m_active) {
......
......@@ -47,7 +47,7 @@ public:
void reconfigure(ReconfigureFlags) override;
void prePaintScreen(ScreenPrePaintData& data, int time) override;
void paintScreen(int mask, QRegion region, ScreenPaintData& data) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData& data) override;
void postPaintScreen() override;
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override;
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
......
......@@ -82,7 +82,7 @@ bool InvertEffect::loadData()
return true;
}
void InvertEffect::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
void InvertEffect::drawWindow(EffectWindow* w, int mask, const QRegion &region, WindowPaintData& data)
{
// Load if we haven't already
if (m_valid && !m_inited)
......@@ -103,7 +103,7 @@ void InvertEffect::drawWindow(EffectWindow* w, int mask, QRegion region, WindowP
}
}
void InvertEffect::paintEffectFrame(KWin::EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
void InvertEffect::paintEffectFrame(KWin::EffectFrame* frame, const QRegion &region, double opacity, double frameOpacity)
{
if (m_valid && m_allWindows) {
frame->setShader(m_shader);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment