~linaro-graphics-wg/compiz-core/linaro-gles2

« back to all changes in this revision

Viewing changes to plugins/decor/src/decor.cpp

  • Committer: Alexandros Frantzis
  • Date: 2012-04-19 10:17:26 UTC
  • mfrom: (2753.36.304 trunk)
  • Revision ID: alexandros.frantzis@linaro.org-20120419101726-1vgfi4f4s95uc42q
Sync with lp:compiz-core.

Show diffs side-by-side

added added

removed removed

Lines of Context:
214
214
                         const CompRegion          &region,
215
215
                         unsigned int              mask)
216
216
{
217
 
    const CompRegion *preg = NULL;
218
217
    GLboolean isBlendingEnabled;
219
218
 
220
 
    if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
221
 
                 PAINT_WINDOW_WITH_OFFSET_MASK)))
222
 
        preg = &region;
223
 
    else if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
224
 
        preg = &infiniteRegion;
225
 
    else
226
 
    {
227
 
        tmpRegion = shadowRegion;
228
 
        tmpRegion &= region;
229
 
        preg = &tmpRegion;
230
 
    }
231
 
 
232
 
    /* In case some plugin needs to paint us with an offset region */
233
 
    if (preg->isEmpty ())
234
 
        preg = &region;
235
 
 
236
 
    const CompRegion &reg (*preg);
237
 
 
238
219
    if (wd &&
239
220
        wd->decor->type == WINDOW_DECORATION_TYPE_PIXMAP)
240
221
    {
243
224
        mask |= PAINT_WINDOW_BLEND_MASK;
244
225
 
245
226
        gWindow->vertexBuffer ()->begin ();
 
227
        const CompRegion *preg = NULL;
 
228
 
 
229
        if ((mask & (PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK |
 
230
                 PAINT_WINDOW_WITH_OFFSET_MASK)))
 
231
            preg = &region;
 
232
        else if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
 
233
            preg = &infiniteRegion;
 
234
        else
 
235
        {
 
236
            tmpRegion = mOutputRegion;
 
237
            tmpRegion &= region;
 
238
 
 
239
            if (tmpRegion.isEmpty ())
 
240
                preg = &region;
 
241
            else
 
242
                preg = &shadowRegion;
 
243
        }
 
244
 
 
245
        /* In case some plugin needs to paint us with an offset region */
 
246
        if (preg->isEmpty ())
 
247
            preg = &region;
 
248
 
 
249
        const CompRegion &reg (*preg);
246
250
 
247
251
        for (int i = 0; i < wd->nQuad; i++)
248
252
        {
268
272
        if (!isBlendingEnabled)
269
273
            glDisable (GL_BLEND);
270
274
    }
271
 
    else if (wd && !reg.isEmpty () &&
272
 
             wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)
 
275
    else if (wd && wd->decor->type == WINDOW_DECORATION_TYPE_WINDOW)
273
276
    {
274
277
        GLTexture::MatrixList ml (1);
275
278
 
285
288
        {
286
289
            ml[0] = gWindow->matrices ()[0];
287
290
            gWindow->vertexBuffer ()->begin ();
288
 
            gWindow->glAddGeometry (ml, window->frameRegion (), reg);
 
291
            gWindow->glAddGeometry (ml, window->frameRegion (), region);
289
292
            gWindow->vertexBuffer ()->end ();
290
293
 
291
294
            gWindow->glDrawTexture (gWindow->textures ()[0], transform,
299
302
            {
300
303
                ml[0] = gWindow->matrices ()[i];
301
304
                gWindow->vertexBuffer ()->begin ();
302
 
                gWindow->glAddGeometry (ml, regions[i], reg);
 
305
                gWindow->glAddGeometry (ml, regions[i], region);
303
306
                gWindow->vertexBuffer ()->end ();
304
307
 
305
308
                gWindow->glDrawTexture (gWindow->textures ()[i], transform,
330
333
    pixmap (pixmap),
331
334
    damage (None)
332
335
{
 
336
    if (!bindTexture (pixmap))
 
337
        return;
 
338
 
 
339
    damage = XDamageCreate (screen->dpy (), pixmap,
 
340
                             XDamageReportRawRectangles);
 
341
}
 
342
 
 
343
/*
 
344
 * DecorTexture::~DecorTexture
 
345
 *
 
346
 * Remove damage handle on texture
 
347
 *
 
348
 */
 
349
 
 
350
DecorTexture::~DecorTexture ()
 
351
{
 
352
    if (damage)
 
353
        XDamageDestroy (screen->dpy (), damage);
 
354
}
 
355
 
 
356
/*
 
357
 * DecorTexture::indTexture
 
358
 *
 
359
 * This function actually takes and binds/rebinds the given Pixmap
 
360
 * to a texture (i.e. calls GLTexture::bindPixmapToTexture)
 
361
 *
 
362
 */
 
363
 
 
364
bool
 
365
DecorTexture::bindTexture (Pixmap src)
 
366
{
333
367
    unsigned int width, height, depth, ui;
334
368
    Window       root;
335
369
    int          i;
336
370
 
 
371
    pixmap = src;
 
372
 
337
373
    if (!XGetGeometry (screen->dpy (), pixmap, &root,
338
374
                       &i, &i, &width, &height, &ui, &depth))
339
375
    {
340
 
        status = false;
341
 
        return;
 
376
        status = false;
 
377
        return false;
342
378
    }
343
379
 
 
380
    // Explicitly clear the texture list before binding/rebinding
 
381
    textures.clear ();
 
382
 
344
383
    bindFailed = false;
345
384
    textures = GLTexture::bindPixmapToTexture (pixmap, width, height, depth);
346
385
    if (textures.size () != 1)
347
386
    {
348
387
        bindFailed = true;
349
 
        status = false;
350
 
        return;
 
388
        status = false;
 
389
        return false;
351
390
    }
352
391
 
353
392
    if (!DecorScreen::get (screen)->optionGetMipmap ())
354
393
        textures[0]->setMipmap (false);
355
394
 
356
 
    damage = XDamageCreate (screen->dpy (), pixmap,
357
 
                             XDamageReportRawRectangles);
358
 
}
359
 
 
360
 
/*
361
 
 * DecorTexture::~DecorTexture
362
 
 *
363
 
 * Remove damage handle on texture
364
 
 *
365
 
 */
366
 
 
367
 
DecorTexture::~DecorTexture ()
368
 
{
369
 
    if (damage)
370
 
        XDamageDestroy (screen->dpy (), damage);
 
395
    return true;
371
396
}
372
397
 
373
398
/*
1547
1572
        /* Undecorated windows need to have the
1548
1573
         * input and output frame removed and the
1549
1574
         * frame window geometry reset */
1550
 
        if (decorate)
1551
 
            updateFrame ();
 
1575
        updateFrame ();
1552
1576
 
1553
1577
        memset (&emptyExtents, 0, sizeof (CompWindowExtents));
1554
1578