Delay creation of EffectFrames till needed
Creating an EffectFrame requires I/O which takes on my system during testing between 10 and 40 msec. Also it needs a little bit of memory. This changes moves out the creation of EffectFrames at Effect load till the Effect actually needs the EffectFrame. E.g. if a user does not filter in PresentWindows there is no need to ever create it. BoxSwitch effect is ignored as it should be dropped for 4.9. REVIEW: 104815
This commit is contained in:
parent
8489ede9aa
commit
d05d55b140
5 changed files with 29 additions and 15 deletions
|
@ -57,7 +57,7 @@ CoverSwitchEffect::CoverSwitchEffect()
|
|||
, scaleFactor(0.0)
|
||||
, direction(Left)
|
||||
, selected_window(0)
|
||||
, captionFrame(effects->effectFrame(EffectFrameStyled))
|
||||
, captionFrame(NULL)
|
||||
, primaryTabBox(false)
|
||||
, secondaryTabBox(false)
|
||||
{
|
||||
|
@ -66,8 +66,6 @@ CoverSwitchEffect::CoverSwitchEffect()
|
|||
// Caption frame
|
||||
captionFont.setBold(true);
|
||||
captionFont.setPointSize(captionFont.pointSize() * 2);
|
||||
captionFrame->setFont(captionFont);
|
||||
captionFrame->enableCrossFade(true);
|
||||
|
||||
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/coverswitch-reflection.glsl");
|
||||
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
||||
|
@ -576,6 +574,11 @@ void CoverSwitchEffect::slotTabBoxAdded(int mode)
|
|||
area.height() * 0.9f + area.y(),
|
||||
area.width() * 0.5f,
|
||||
QFontMetrics(captionFont).height());
|
||||
if (!captionFrame) {
|
||||
captionFrame = effects->effectFrame(EffectFrameStyled);
|
||||
captionFrame->setFont(captionFont);
|
||||
captionFrame->enableCrossFade(true);
|
||||
}
|
||||
captionFrame->setGeometry(frameRect);
|
||||
captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height()));
|
||||
// And initial contents
|
||||
|
|
|
@ -60,7 +60,7 @@ CubeEffect::CubeEffect()
|
|||
, cubeOpacity(1.0)
|
||||
, opacityDesktopOnly(true)
|
||||
, displayDesktopName(false)
|
||||
, desktopNameFrame(effects->effectFrame(EffectFrameStyled))
|
||||
, desktopNameFrame(NULL)
|
||||
, reflection(true)
|
||||
, rotating(false)
|
||||
, desktopChangedWhileRotating(false)
|
||||
|
@ -97,7 +97,6 @@ CubeEffect::CubeEffect()
|
|||
{
|
||||
desktopNameFont.setBold(true);
|
||||
desktopNameFont.setPointSize(14);
|
||||
desktopNameFrame->setFont(desktopNameFont);
|
||||
|
||||
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/cube-reflection.glsl");
|
||||
m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader);
|
||||
|
@ -592,6 +591,10 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|||
QRect screenRect = effects->clientArea(ScreenArea, activeScreen, frontDesktop);
|
||||
QRect frameRect = QRect(screenRect.width() * 0.33f + screenRect.x(), screenRect.height() * 0.95f + screenRect.y(),
|
||||
screenRect.width() * 0.34f, QFontMetrics(desktopNameFont).height());
|
||||
if (!desktopNameFrame) {
|
||||
desktopNameFrame = effects->effectFrame(EffectFrameStyled);
|
||||
desktopNameFrame->setFont(desktopNameFont);
|
||||
}
|
||||
desktopNameFrame->setGeometry(frameRect);
|
||||
desktopNameFrame->setText(effects->desktopName(frontDesktop));
|
||||
desktopNameFrame->render(region, opacity);
|
||||
|
|
|
@ -47,15 +47,13 @@ FlipSwitchEffect::FlipSwitchEffect()
|
|||
, m_stop(false)
|
||||
, m_animation(false)
|
||||
, m_hasKeyboardGrab(false)
|
||||
, m_captionFrame(effects->effectFrame(EffectFrameStyled))
|
||||
, m_captionFrame(NULL)
|
||||
{
|
||||
reconfigure(ReconfigureAll);
|
||||
|
||||
// Caption frame
|
||||
m_captionFont.setBold(true);
|
||||
m_captionFont.setPointSize(m_captionFont.pointSize() * 2);
|
||||
m_captionFrame->setFont(m_captionFont);
|
||||
m_captionFrame->enableCrossFade(true);
|
||||
|
||||
KActionCollection* actionCollection = new KActionCollection(this);
|
||||
KAction* a = (KAction*)actionCollection->addAction("FlipSwitchCurrent");
|
||||
|
@ -660,6 +658,11 @@ void FlipSwitchEffect::setActive(bool activate, FlipSwitchMode mode)
|
|||
m_screenArea.height() * 0.1f + m_screenArea.y() - QFontMetrics(m_captionFont).height(),
|
||||
m_screenArea.width() * 0.5f,
|
||||
QFontMetrics(m_captionFont).height());
|
||||
if (!m_captionFrame) {
|
||||
m_captionFrame = effects->effectFrame(EffectFrameStyled);
|
||||
m_captionFrame->setFont(m_captionFont);
|
||||
m_captionFrame->enableCrossFade(true);
|
||||
}
|
||||
m_captionFrame->setGeometry(frameRect);
|
||||
m_captionFrame->setIconSize(QSize(frameRect.height(), frameRect.height()));
|
||||
updateCaption();
|
||||
|
|
|
@ -28,8 +28,8 @@ KWIN_EFFECT(outline, OutlineEffect)
|
|||
OutlineEffect::OutlineEffect()
|
||||
: Effect()
|
||||
, m_active(false)
|
||||
, m_outline(NULL)
|
||||
{
|
||||
m_outline = effects->effectFrame(EffectFrameNone);
|
||||
connect(effects, SIGNAL(showOutline(QRect)), SLOT(slotShowOutline(QRect)));
|
||||
connect(effects, SIGNAL(hideOutline()), SLOT(slotHideOutline()));
|
||||
}
|
||||
|
@ -70,6 +70,9 @@ void OutlineEffect::slotShowOutline(const QRect& geometry)
|
|||
}
|
||||
m_active = true;
|
||||
m_geometry = geometry;
|
||||
if (!m_outline) {
|
||||
m_outline = effects->effectFrame(EffectFrameNone);
|
||||
}
|
||||
m_outline->setGeometry(geometry);
|
||||
m_outline->setSelection(geometry);
|
||||
effects->addRepaint(geometry);
|
||||
|
|
|
@ -61,7 +61,7 @@ PresentWindowsEffect::PresentWindowsEffect()
|
|||
, m_mode(ModeCurrentDesktop)
|
||||
, m_managerWindow(NULL)
|
||||
, m_highlightedWindow(NULL)
|
||||
, m_filterFrame(effects->effectFrame(EffectFrameStyled, false))
|
||||
, m_filterFrame(NULL)
|
||||
, m_closeView(NULL)
|
||||
, m_dragInProgress(false)
|
||||
, m_dragWindow(NULL)
|
||||
|
@ -78,11 +78,6 @@ PresentWindowsEffect::PresentWindowsEffect()
|
|||
XChangeProperty(display(), rootWindow(), m_atomDesktop, m_atomDesktop, 8, PropModeReplace, &dummy, 1);
|
||||
XChangeProperty(display(), rootWindow(), m_atomWindows, m_atomWindows, 8, PropModeReplace, &dummy, 1);
|
||||
|
||||
QFont font;
|
||||
font.setPointSize(font.pointSize() * 2);
|
||||
font.setBold(true);
|
||||
m_filterFrame->setFont(font);
|
||||
|
||||
KActionCollection* actionCollection = new KActionCollection(this);
|
||||
KAction* a = (KAction*)actionCollection->addAction("Expose");
|
||||
a->setText(i18n("Toggle Present Windows (Current desktop)"));
|
||||
|
@ -1635,6 +1630,13 @@ void PresentWindowsEffect::setActive(bool active, bool closingTab)
|
|||
void PresentWindowsEffect::updateFilterFrame()
|
||||
{
|
||||
QRect area = effects->clientArea(ScreenArea, effects->activeScreen(), effects->currentDesktop());
|
||||
if (!m_filterFrame){
|
||||
m_filterFrame = effects->effectFrame(EffectFrameStyled, false);
|
||||
QFont font;
|
||||
font.setPointSize(font.pointSize() * 2);
|
||||
font.setBold(true);
|
||||
m_filterFrame->setFont(font);
|
||||
}
|
||||
m_filterFrame->setPosition(QPoint(area.x() + area.width() / 2, area.y() + area.height() / 2));
|
||||
m_filterFrame->setText(i18n("Filter:\n%1", m_windowFilter));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue