Changeset View
Changeset View
Standalone View
Standalone View
effects/screenedge/screenedgeeffect.cpp
Show First 20 Lines • Show All 227 Lines • ▼ Show 20 Line(s) | 224 | if (effects->isOpenGLCompositing()) { | |||
---|---|---|---|---|---|
228 | } else { | 228 | } else { | ||
229 | glow->texture.reset(createEdgeGlow<GLTexture>(border, geometry.size())); | 229 | glow->texture.reset(createEdgeGlow<GLTexture>(border, geometry.size())); | ||
230 | } | 230 | } | ||
231 | if (!glow->texture.isNull()) { | 231 | if (!glow->texture.isNull()) { | ||
232 | glow->texture->setWrapMode(GL_CLAMP_TO_EDGE); | 232 | glow->texture->setWrapMode(GL_CLAMP_TO_EDGE); | ||
233 | } | 233 | } | ||
234 | if (glow->texture.isNull()) { | 234 | if (glow->texture.isNull()) { | ||
235 | delete glow; | 235 | delete glow; | ||
236 | return NULL; | 236 | return nullptr; | ||
237 | } | 237 | } | ||
238 | } else if (effects->compositingType() == XRenderCompositing) { | 238 | } else if (effects->compositingType() == XRenderCompositing) { | ||
239 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | 239 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | ||
240 | if (border == ElectricTopLeft || border == ElectricTopRight || border == ElectricBottomRight || border == ElectricBottomLeft) { | 240 | if (border == ElectricTopLeft || border == ElectricTopRight || border == ElectricBottomRight || border == ElectricBottomLeft) { | ||
241 | glow->pictureSize = cornerGlowSize(border); | 241 | glow->pictureSize = cornerGlowSize(border); | ||
242 | glow->picture.reset(createCornerGlow<XRenderPicture>(border)); | 242 | glow->picture.reset(createCornerGlow<XRenderPicture>(border)); | ||
243 | } else { | 243 | } else { | ||
244 | glow->pictureSize = geometry.size(); | 244 | glow->pictureSize = geometry.size(); | ||
245 | glow->picture.reset(createEdgeGlow<XRenderPicture>(border, geometry.size())); | 245 | glow->picture.reset(createEdgeGlow<XRenderPicture>(border, geometry.size())); | ||
246 | } | 246 | } | ||
247 | if (glow->picture.isNull()) { | 247 | if (glow->picture.isNull()) { | ||
248 | delete glow; | 248 | delete glow; | ||
249 | return NULL; | 249 | return nullptr; | ||
250 | } | 250 | } | ||
251 | #endif | 251 | #endif | ||
252 | } else if (effects->compositingType() == QPainterCompositing) { | 252 | } else if (effects->compositingType() == QPainterCompositing) { | ||
253 | if (border == ElectricTopLeft || border == ElectricTopRight || border == ElectricBottomRight || border == ElectricBottomLeft) { | 253 | if (border == ElectricTopLeft || border == ElectricTopRight || border == ElectricBottomRight || border == ElectricBottomLeft) { | ||
254 | glow->image.reset(createCornerGlow<QImage>(border)); | 254 | glow->image.reset(createCornerGlow<QImage>(border)); | ||
255 | glow->pictureSize = cornerGlowSize(border); | 255 | glow->pictureSize = cornerGlowSize(border); | ||
256 | } else { | 256 | } else { | ||
257 | glow->image.reset(createEdgeGlow<QImage>(border, geometry.size())); | 257 | glow->image.reset(createEdgeGlow<QImage>(border, geometry.size())); | ||
258 | glow->pictureSize = geometry.size(); | 258 | glow->pictureSize = geometry.size(); | ||
259 | } | 259 | } | ||
260 | if (glow->image.isNull()) { | 260 | if (glow->image.isNull()) { | ||
261 | delete glow; | 261 | delete glow; | ||
262 | return NULL; | 262 | return nullptr; | ||
263 | } | 263 | } | ||
264 | } | 264 | } | ||
265 | 265 | | |||
266 | return glow; | 266 | return glow; | ||
267 | } | 267 | } | ||
268 | 268 | | |||
269 | template <typename T> | 269 | template <typename T> | ||
270 | T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border) | 270 | T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border) | ||
271 | { | 271 | { | ||
272 | ensureGlowSvg(); | 272 | ensureGlowSvg(); | ||
273 | 273 | | |||
274 | switch (border) { | 274 | switch (border) { | ||
275 | case ElectricTopLeft: | 275 | case ElectricTopLeft: | ||
276 | return new T(m_glow->pixmap(QStringLiteral("bottomright")).toImage()); | 276 | return new T(m_glow->pixmap(QStringLiteral("bottomright")).toImage()); | ||
277 | case ElectricTopRight: | 277 | case ElectricTopRight: | ||
278 | return new T(m_glow->pixmap(QStringLiteral("bottomleft")).toImage()); | 278 | return new T(m_glow->pixmap(QStringLiteral("bottomleft")).toImage()); | ||
279 | case ElectricBottomRight: | 279 | case ElectricBottomRight: | ||
280 | return new T(m_glow->pixmap(QStringLiteral("topleft")).toImage()); | 280 | return new T(m_glow->pixmap(QStringLiteral("topleft")).toImage()); | ||
281 | case ElectricBottomLeft: | 281 | case ElectricBottomLeft: | ||
282 | return new T(m_glow->pixmap(QStringLiteral("topright")).toImage()); | 282 | return new T(m_glow->pixmap(QStringLiteral("topright")).toImage()); | ||
283 | default: | 283 | default: | ||
284 | return NULL; | 284 | return nullptr; | ||
285 | } | 285 | } | ||
286 | } | 286 | } | ||
287 | 287 | | |||
288 | QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) | 288 | QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) | ||
289 | { | 289 | { | ||
290 | ensureGlowSvg(); | 290 | ensureGlowSvg(); | ||
291 | 291 | | |||
292 | switch (border) { | 292 | switch (border) { | ||
Show All 38 Lines | 327 | case ElectricLeft: | |||
331 | break; | 331 | break; | ||
332 | case ElectricRight: | 332 | case ElectricRight: | ||
333 | l = m_glow->pixmap(QStringLiteral("topleft")); | 333 | l = m_glow->pixmap(QStringLiteral("topleft")); | ||
334 | r = m_glow->pixmap(QStringLiteral("bottomleft")); | 334 | r = m_glow->pixmap(QStringLiteral("bottomleft")); | ||
335 | c = m_glow->pixmap(QStringLiteral("left")); | 335 | c = m_glow->pixmap(QStringLiteral("left")); | ||
336 | pixmapPosition = QPoint(size.width() - c.width(), 0); | 336 | pixmapPosition = QPoint(size.width() - c.width(), 0); | ||
337 | break; | 337 | break; | ||
338 | default: | 338 | default: | ||
339 | return NULL; | 339 | return nullptr; | ||
340 | } | 340 | } | ||
341 | QPixmap image(size); | 341 | QPixmap image(size); | ||
342 | image.fill(Qt::transparent); | 342 | image.fill(Qt::transparent); | ||
343 | QPainter p; | 343 | QPainter p; | ||
344 | p.begin(&image); | 344 | p.begin(&image); | ||
345 | if (border == ElectricBottom || border == ElectricTop) { | 345 | if (border == ElectricBottom || border == ElectricTop) { | ||
346 | p.drawPixmap(pixmapPosition, l); | 346 | p.drawPixmap(pixmapPosition, l); | ||
347 | const QRect cRect(l.width(), pixmapPosition.y(), size.width() - l.width() - r.width(), c.height()); | 347 | const QRect cRect(l.width(), pixmapPosition.y(), size.width() - l.width() - r.width(), c.height()); | ||
Show All 26 Lines |