Changeset View
Changeset View
Standalone View
Standalone View
plugins/scenes/opengl/scene_opengl.cpp
Show First 20 Lines • Show All 2068 Lines • ▼ Show 20 Line(s) | |||||
2069 | 2069 | | |||
2070 | SceneOpenGLShadow::SceneOpenGLShadow(Toplevel *toplevel) | 2070 | SceneOpenGLShadow::SceneOpenGLShadow(Toplevel *toplevel) | ||
2071 | : Shadow(toplevel) | 2071 | : Shadow(toplevel) | ||
2072 | { | 2072 | { | ||
2073 | } | 2073 | } | ||
2074 | 2074 | | |||
2075 | SceneOpenGLShadow::~SceneOpenGLShadow() | 2075 | SceneOpenGLShadow::~SceneOpenGLShadow() | ||
2076 | { | 2076 | { | ||
2077 | if (effects) { | 2077 | Scene *scene = Compositor::self()->scene(); | ||
2078 | effects->makeOpenGLContextCurrent(); | 2078 | if (scene) { | ||
2079 | scene->makeOpenGLContextCurrent(); | ||||
2079 | DecorationShadowTextureCache::instance().unregister(this); | 2080 | DecorationShadowTextureCache::instance().unregister(this); | ||
2080 | m_texture.reset(); | 2081 | m_texture.reset(); | ||
2081 | } | 2082 | } | ||
2082 | } | 2083 | } | ||
2083 | 2084 | | |||
2084 | static inline void distributeHorizontally(QRectF &leftRect, QRectF &rightRect) | 2085 | static inline void distributeHorizontally(QRectF &leftRect, QRectF &rightRect) | ||
2085 | { | 2086 | { | ||
2086 | if (leftRect.right() > rightRect.left()) { | 2087 | if (leftRect.right() > rightRect.left()) { | ||
▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Line(s) | 2320 | if (leftRect.isValid()) { | |||
2329 | m_shadowQuads.append(leftQuad); | 2330 | m_shadowQuads.append(leftQuad); | ||
2330 | } | 2331 | } | ||
2331 | } | 2332 | } | ||
2332 | 2333 | | |||
2333 | bool SceneOpenGLShadow::prepareBackend() | 2334 | bool SceneOpenGLShadow::prepareBackend() | ||
2334 | { | 2335 | { | ||
2335 | if (hasDecorationShadow()) { | 2336 | if (hasDecorationShadow()) { | ||
2336 | // simplifies a lot by going directly to | 2337 | // simplifies a lot by going directly to | ||
2337 | effects->makeOpenGLContextCurrent(); | 2338 | Scene *scene = Compositor::self()->scene(); | ||
2339 | scene->makeOpenGLContextCurrent(); | ||||
2338 | m_texture = DecorationShadowTextureCache::instance().getTexture(this); | 2340 | m_texture = DecorationShadowTextureCache::instance().getTexture(this); | ||
2339 | 2341 | | |||
2340 | return true; | 2342 | return true; | ||
2341 | } | 2343 | } | ||
2342 | const QSize top(shadowPixmap(ShadowElementTop).size()); | 2344 | const QSize top(shadowPixmap(ShadowElementTop).size()); | ||
2343 | const QSize topRight(shadowPixmap(ShadowElementTopRight).size()); | 2345 | const QSize topRight(shadowPixmap(ShadowElementTopRight).size()); | ||
2344 | const QSize right(shadowPixmap(ShadowElementRight).size()); | 2346 | const QSize right(shadowPixmap(ShadowElementRight).size()); | ||
2345 | const QSize bottom(shadowPixmap(ShadowElementBottom).size()); | 2347 | const QSize bottom(shadowPixmap(ShadowElementBottom).size()); | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 2391 | for (ptrdiff_t y = 0; alphaOnly && y < image.height(); y++) { | |||
2398 | } | 2400 | } | ||
2399 | } | 2401 | } | ||
2400 | 2402 | | |||
2401 | if (alphaOnly) { | 2403 | if (alphaOnly) { | ||
2402 | image = alphaImage; | 2404 | image = alphaImage; | ||
2403 | } | 2405 | } | ||
2404 | } | 2406 | } | ||
2405 | 2407 | | |||
2406 | effects->makeOpenGLContextCurrent(); | 2408 | Scene *scene = Compositor::self()->scene(); | ||
2409 | scene->makeOpenGLContextCurrent(); | ||||
2407 | m_texture = QSharedPointer<GLTexture>::create(image); | 2410 | m_texture = QSharedPointer<GLTexture>::create(image); | ||
2408 | 2411 | | |||
2409 | if (m_texture->internalFormat() == GL_R8) { | 2412 | if (m_texture->internalFormat() == GL_R8) { | ||
2410 | // Swizzle red to alpha and all other channels to zero | 2413 | // Swizzle red to alpha and all other channels to zero | ||
2411 | m_texture->bind(); | 2414 | m_texture->bind(); | ||
2412 | m_texture->setSwizzle(GL_ZERO, GL_ZERO, GL_ZERO, GL_RED); | 2415 | m_texture->setSwizzle(GL_ZERO, GL_ZERO, GL_ZERO, GL_RED); | ||
2413 | } | 2416 | } | ||
2414 | 2417 | | |||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |