~compiz-team/compiz/0.9.12

« back to all changes in this revision

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

MergeĀ GLESĀ support

Show diffs side-by-side

added added

removed removed

Lines of Context:
183
183
}
184
184
 
185
185
void
186
 
ShiftScreen::drawWindowTitle ()
 
186
ShiftScreen::drawWindowTitle (const GLMatrix &transform)
187
187
{
188
188
    float width, height, border = 10.0f;
189
189
    CompRect oe;
225
225
        return;
226
226
    }
227
227
 
228
 
    text.draw (floor (x), floor (y), 1.0f);
 
228
    text.draw (transform, floor (x), floor (y), 1.0f);
229
229
}
230
230
 
231
231
bool
272
272
 
273
273
        if (scaled && !gWindow->textures ().empty ())
274
274
        {
275
 
            GLFragment::Attrib fragment (attrib);
 
275
            GLWindowPaintAttrib wAttrib (attrib);
276
276
            GLMatrix wTransform = transform;
277
277
            ShiftSlot      *slot = ss->mActiveSlot->slot;
278
278
 
302
302
            /*if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
303
303
                return false;*/
304
304
 
305
 
            fragment.setOpacity ((float)fragment.getOpacity () * sopacity);
306
 
            fragment.setBrightness ((float)fragment.getBrightness () *
307
 
                                    ss->mReflectBrightness);
 
305
            wAttrib.opacity = (float)wAttrib.opacity * sopacity;
 
306
            wAttrib.brightness = (float)wAttrib.brightness *
 
307
                                    ss->mReflectBrightness;
308
308
 
309
 
            if (window->alpha () || fragment.getOpacity () != OPAQUE)
 
309
            if (window->alpha () || wAttrib.opacity != OPAQUE)
310
310
                mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
311
311
 
312
312
            wTransform.translate (sx, sy, sz);
327
327
            wTransform.translate (-window->x () - (window->width () / 2),
328
328
                                  -window->y () - (window->height () / 2), 0.0f);
329
329
 
330
 
            glPushMatrix ();
331
 
            glLoadMatrixf (wTransform.getMatrix ());
332
 
 
333
 
            gWindow->glDraw (wTransform, fragment, region,
 
330
            gWindow->glDraw (wTransform, wAttrib, region,
334
331
                              mask | PAINT_WINDOW_TRANSFORMED_MASK);
335
 
 
336
 
            glPopMatrix ();
337
332
        }
338
333
 
339
334
        if (scaled && ((ss->optionGetOverlayIcon () != ShiftOptions::OverlayIconNone) ||
418
413
 
419
414
                iconReg = CompRegion (0, 0, icon->width (), icon->height ());
420
415
 
421
 
                gWindow->geometry ().reset ();
 
416
                gWindow->vertexBuffer ()->begin ();
422
417
 
423
418
                matl.push_back (icon->matrix ());
424
419
 
425
420
                gWindow->glAddGeometry (matl, iconReg, iconReg);
426
421
 
427
 
                if (gWindow->geometry ().vCount)
 
422
                if (gWindow->vertexBuffer ()->end ())
428
423
                {
429
 
                    GLFragment::Attrib  fragment (sAttrib);
 
424
                    GLWindowPaintAttrib wAttrib (sAttrib);
430
425
                    GLMatrix            wTransform (transform);
431
426
 
432
427
                    if (gWindow->textures ().empty ())
433
428
                        sAttrib.opacity = gWindow->paintAttrib ().opacity;
434
429
 
435
 
                    fragment = GLFragment::Attrib (sAttrib);
 
430
                    wAttrib = GLWindowPaintAttrib (sAttrib);
436
431
 
437
 
                    fragment.setOpacity  ((float)fragment.getOpacity () * sopacity);
438
 
                    fragment.setBrightness ((float)fragment.getBrightness () *
439
 
                                            ss->mReflectBrightness);
 
432
                    wAttrib.opacity = (float)wAttrib.opacity * sopacity;
 
433
                    wAttrib.brightness = (float)wAttrib.brightness *
 
434
                                         ss->mReflectBrightness;
440
435
 
441
436
                    wTransform.translate (sx, sy, sz);
442
437
 
443
438
                    wTransform.translate (window->x () +
444
439
                                     (window->width ()  * sscale / 2),
445
440
                                     window->y () +
446
 
                                     (window->height ()  * sscale / 2.0), 0.0f);
 
441
                                            (window->height ()  * sscale / 2.0),
 
442
                                          0.0f);
447
443
 
448
444
                    wTransform.scale (ss->mOutput->width (),
449
 
                                      -ss->mOutput->height (), 1.0f);
 
445
                                      -ss->mOutput->height (),
 
446
                                      1.0f);
450
447
 
451
448
                    wTransform.rotate (srot, 0.0, 1.0, 0.0);
452
449
 
453
450
                    wTransform.scale (1.0f  / ss->mOutput->width (),
454
 
                                 -1.0f / ss->mOutput->height (), 1.0f);
 
451
                                      -1.0f / ss->mOutput->height (),
 
452
                                      1.0f);
455
453
 
456
 
                    wTransform.translate (x -
457
 
                                          (window->width () * sscale / 2), y -
458
 
                                          (window->height () * sscale / 2.0), 0.0f);
 
454
                    wTransform.translate (x - (window->width () * sscale / 2),
 
455
                                          y - (window->height () * sscale / 2.0),
 
456
                                          0.0f);
459
457
                    wTransform.scale (scale, scale, 1.0f);
460
458
 
461
 
                    glPushMatrix ();
462
 
                    glLoadMatrixf (wTransform.getMatrix ());
463
 
 
464
 
                    gWindow->glDrawTexture (icon, fragment, mask);
465
 
 
466
 
                    glPopMatrix ();
 
459
                    gWindow->glDrawTexture (icon, wTransform, wAttrib, mask);
467
460
                }
468
461
            }
469
462
        }
470
 
 
471
463
    }
472
464
    else
473
465
    {
1153
1145
 
1154
1146
        sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
1155
1147
 
1156
 
        GLdouble clip[4] = { 0.0, -1.0, 0.0, 0.0};
1157
 
 
1158
 
        clip[3] = ((oy1 + (oy2 - oy1) / 2)) + (maxThumbHeight / 2.0);
1159
 
 
1160
1148
        /* Reflection drawing */
1161
1149
 
1162
1150
        if (optionGetReflection ())
1163
1151
        {
1164
1152
            GLMatrix       rTransform = sTransform;
 
1153
            GLMatrix        r2Transform;
 
1154
            GLushort        colorData[4];
 
1155
            GLfloat         vertexData[12];
1165
1156
            int            cull, cullInv;
 
1157
            GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
 
1158
 
1166
1159
            glGetIntegerv (GL_CULL_FACE_MODE, &cull);
1167
1160
            cullInv = (cull == GL_BACK)? GL_FRONT : GL_BACK;
1168
1161
 
1169
 
            rTransform.translate (0.0, oy1 + oy2 + maxThumbHeight,
1170
 
                             0.0);
 
1162
            rTransform.translate (0.0, oy1 + oy2 + maxThumbHeight, 0.0);
1171
1163
            rTransform.scale (1.0, -1.0, 1.0);
1172
1164
 
1173
 
            glPushMatrix ();
1174
 
            glLoadMatrixf (rTransform.getMatrix ());
1175
 
 
1176
1165
            glCullFace (cullInv);
1177
1166
 
1178
1167
            if (optionGetMipmaps ())
1179
1168
                gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR);
1180
1169
 
1181
 
 
1182
 
            if (mAnim == 1.0)
1183
 
            {
1184
 
                glClipPlane (GL_CLIP_PLANE0, clip);
1185
 
                glEnable (GL_CLIP_PLANE0);
1186
 
            }
1187
 
 
1188
1170
            mReflectActive = true;
1189
1171
            mReflectBrightness = optionGetIntensity ();
1190
1172
            for (i = 0; i < mNSlots; i++)
1200
1182
                }
1201
1183
            }
1202
1184
 
1203
 
            glDisable (GL_CLIP_PLANE0);
1204
1185
            glCullFace (cull);
1205
 
 
1206
 
            glLoadIdentity();
1207
 
            glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA);
1208
 
 
1209
1186
            glEnable(GL_BLEND);
1210
1187
            glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1211
 
 
1212
 
            glBegin (GL_QUADS);
1213
 
            glColor4f (0.0, 0.0, 0.0, 0.0);
1214
 
            glVertex2f (0.5, 0.0);
1215
 
            glVertex2f (-0.5, 0.0);
1216
 
            glColor4f (0.0, 0.0, 0.0,
1217
 
                       MIN (1.0, 1.0 - optionGetIntensity ()) * 2.0 *
1218
 
                       mAnim);
1219
 
            glVertex2f (-0.5, -0.5);
1220
 
            glVertex2f (0.5, -0.5);
1221
 
            glEnd();
 
1188
            r2Transform.translate (0.0, 0.0, -DEFAULT_Z_CAMERA);
 
1189
 
 
1190
            streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
1191
 
 
1192
            colorData[0] = 0;
 
1193
            colorData[1] = 0;
 
1194
            colorData[2] = 0;
 
1195
            colorData[3] = 0;
 
1196
            streamingBuffer->addColors (1, colorData);
 
1197
            streamingBuffer->addColors (1, colorData);
 
1198
 
 
1199
            colorData[3] = MIN (1.0,
 
1200
                                1.0 - optionGetIntensity ()) * 2.0 * mAnim;
 
1201
            streamingBuffer->addColors (1, colorData);
 
1202
            streamingBuffer->addColors (1, colorData);
 
1203
 
 
1204
            vertexData[0]  = 0.5;
 
1205
            vertexData[1]  = 0;
 
1206
            vertexData[2]  = 0;
 
1207
            vertexData[3]  = -0.5;
 
1208
            vertexData[4]  = 0;
 
1209
            vertexData[5]  = 0;
 
1210
            vertexData[6]  = 0.5;
 
1211
            vertexData[7]  = -0.5;
 
1212
            vertexData[8]  = 0;
 
1213
            vertexData[9]  = -0.5;
 
1214
            vertexData[10] = -0.5;
 
1215
            vertexData[11] = 0;
 
1216
 
 
1217
            streamingBuffer->addVertices (4, vertexData);
 
1218
 
 
1219
            streamingBuffer->end ();
 
1220
            streamingBuffer->render (r2Transform);
1222
1221
 
1223
1222
            if (optionGetGroundSize () > 0.0)
1224
1223
            {
1225
 
                unsigned short color[4];
1226
 
                glBegin (GL_QUADS);
1227
 
                color[0] = optionGetGroundColor1 ()[0];
1228
 
                color[1] = optionGetGroundColor1 ()[1];
1229
 
                color[2] = optionGetGroundColor1 ()[2];
1230
 
                color[3] = (float)optionGetGroundColor1 ()[3] * mAnim;
1231
 
                glColor4usv (color);
1232
 
                glVertex2f (-0.5, -0.5);
1233
 
                glVertex2f (0.5, -0.5);
1234
 
                color[0] = optionGetGroundColor2 ()[0];
1235
 
                color[1] = optionGetGroundColor2 ()[1];
1236
 
                color[2] = optionGetGroundColor2 ()[2];
1237
 
                color[3] = (float)optionGetGroundColor2 ()[3] * mAnim;
1238
 
                glColor4usv (color);
1239
 
                glVertex2f (0.5, -0.5 + optionGetGroundSize ());
1240
 
                glVertex2f (-0.5, -0.5 + optionGetGroundSize ());
1241
 
                glEnd();
 
1224
                streamingBuffer->begin (GL_TRIANGLE_STRIP);
 
1225
 
 
1226
                colorData[0] = optionGetGroundColor1 ()[0];
 
1227
                colorData[1] = optionGetGroundColor1 ()[1];
 
1228
                colorData[2] = optionGetGroundColor1 ()[2];
 
1229
                colorData[3] = (float)optionGetGroundColor1 ()[3] * mAnim;
 
1230
                streamingBuffer->addColors (1, colorData);
 
1231
                streamingBuffer->addColors (1, colorData);
 
1232
 
 
1233
                colorData[3] = (float)optionGetGroundColor2 ()[3] * mAnim;
 
1234
                streamingBuffer->addColors (1, colorData);
 
1235
                streamingBuffer->addColors (1, colorData);
 
1236
 
 
1237
                vertexData[0]  = -0.5;
 
1238
                vertexData[1]  = -0.5;
 
1239
                vertexData[2]  = 0;
 
1240
                vertexData[3]  = 0.5;
 
1241
                vertexData[4]  = -0.5;
 
1242
                vertexData[5]  = 0;
 
1243
                vertexData[6]  = -0.5;
 
1244
                vertexData[7]  = -0.5 + optionGetGroundSize ();
 
1245
                vertexData[8]  = 0;
 
1246
                vertexData[9]  = 0.5;
 
1247
                vertexData[10] = -0.5 + optionGetGroundSize ();
 
1248
                vertexData[11] = 0;
 
1249
 
 
1250
                streamingBuffer->addVertices (4, vertexData);
 
1251
 
 
1252
                streamingBuffer->end ();
 
1253
                streamingBuffer->render (r2Transform);
1242
1254
            }
1243
1255
 
1244
1256
            glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1245
1257
            glDisable(GL_BLEND);
1246
 
            glColor4f (1.0, 1.0, 1.0, 1.0);
1247
 
            glPopMatrix ();
1248
1258
        }
1249
1259
 
1250
1260
        /* Drawing normal windows */
1251
1261
 
1252
 
        glPushMatrix ();
1253
 
        glLoadMatrixf (sTransform.getMatrix ());
1254
 
 
1255
 
        if (optionGetReflection () && mAnim == 1.0)
1256
 
        {
1257
 
            glClipPlane (GL_CLIP_PLANE0, clip);
1258
 
            glEnable (GL_CLIP_PLANE0);
1259
 
        }
1260
 
 
1261
1262
        mReflectBrightness = 1.0;
1262
1263
        mReflectActive     = false;
1263
1264
 
1274
1275
            }
1275
1276
        }
1276
1277
 
1277
 
        glDisable (GL_CLIP_PLANE0);
1278
 
 
1279
1278
        mActiveSlot = NULL;
1280
1279
 
1281
1280
        gScreen->setTextureFilter (oldFilter);
1282
1281
 
1283
1282
        if (textAvailable && (mState != ShiftStateIn))
1284
 
            drawWindowTitle ();
 
1283
            drawWindowTitle (sTransform);
1285
1284
 
1286
1285
        if (mState == ShiftStateIn || mState == ShiftStateOut)
1287
1286
        {
1316
1315
 
1317
1316
            mPaintingAbove = false;
1318
1317
        }
1319
 
 
1320
 
        glPopMatrix ();
1321
1318
    }
1322
1319
 
1323
1320
    return status;