~unity-team/unity/trunk

« back to all changes in this revision

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

  • Committer: Daniel van Vugt
  • Date: 2012-09-13 10:56:42 UTC
  • mfrom: (2684 unity)
  • mto: This revision was merged to the branch mainline in revision 2698.
  • Revision ID: daniel.van.vugt@canonical.com-20120913105642-9on2ald55h54j1zn
Merge latest lp:unity and fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
420
420
/* Collect textures */
421
421
void
422
422
UnityDialogWindow::glDrawTexture(GLTexture*          texture,
423
 
#ifdef USE_MODERN_COMPIZ_GL
424
423
                                 const GLMatrix            &transform,
425
424
                                 const GLWindowPaintAttrib &attrib,
426
 
#else
427
 
                                 GLFragment::Attrib& fa,
428
 
#endif
429
425
                                 unsigned int       mask)
430
426
{
431
427
  unity::PaintInfoCollector::Active ()->processTexture (texture);
448
444
          collectedMinVertices.size () == collectedMatrixLists.size ());
449
445
}
450
446
 
451
 
void
 
447
bool
452
448
unity::GeometryCollection::addGeometryForWindow (CompWindow *w, const CompRegion &paintRegion)
453
449
{
454
450
  /* We can reset the window geometry since it will be
455
451
   * re-added later */
456
 
#ifdef USE_MODERN_COMPIZ_GL
457
452
  GLWindow::get (w)->vertexBuffer()->begin();
458
 
#else
459
 
  GLWindow::get (w)->geometry().reset();
460
 
#endif
461
453
 
462
454
  for (unsigned int i = 0; i < collectedMatrixLists.size (); i++)
463
455
  {
472
464
    GLWindow::get (w)->glAddGeometry(matl, reg, paintRegion, min, max);
473
465
  }
474
466
 
475
 
#ifdef USE_MODERN_COMPIZ_GL
476
 
  GLWindow::get (w)->vertexBuffer()->end();
477
 
#endif
 
467
  return GLWindow::get (w)->vertexBuffer()->end();
478
468
}
479
469
 
480
470
void
511
501
 
512
502
void
513
503
unity::TexGeometryCollection::addGeometriesAndDrawTextureForWindow(CompWindow *w,
514
 
#ifdef USE_MODERN_COMPIZ_GL
515
504
                                                                   const GLMatrix &transform,
516
 
#endif
517
505
                                                                   unsigned int mask)
518
506
{
519
507
  if (mTexture && mGeometries.status ())
524
512
    if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
525
513
      paintRegion = infiniteRegion;
526
514
 
527
 
    mGeometries.addGeometryForWindow (w, paintRegion);
528
 
 
529
 
#ifdef USE_MODERN_COMPIZ_GL
530
 
    UnityDialogScreen *uds = UnityDialogScreen::get (screen);
531
 
    GLWindowPaintAttrib attrib (gWindow->lastPaintAttrib());
532
 
    unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
533
 
    /* Texture rendering set-up */
534
 
//    uds->gScreen->setTexEnvMode(GL_MODULATE);
535
 
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
536
 
    /* Draw the dim texture with all of it's modified
537
 
     * geometry glory */
538
 
    gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
539
 
    gWindow->glDrawTexture(mTexture, transform, attrib, mask
540
 
                                              | PAINT_WINDOW_BLEND_MASK
541
 
                                              | PAINT_WINDOW_TRANSLUCENT_MASK
542
 
                                              | PAINT_WINDOW_TRANSFORMED_MASK);
543
 
    gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
544
 
    /* Texture rendering tear-down */
545
 
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
546
 
    uds->gScreen->setTexEnvMode(GL_REPLACE);
547
 
#else
548
 
    if (gWindow->geometry().vertices)
 
515
    if (mGeometries.addGeometryForWindow (w, paintRegion))
549
516
    {
550
 
        UnityDialogScreen *uds = UnityDialogScreen::get (screen);
551
 
        GLFragment::Attrib fa (gWindow->lastPaintAttrib());
552
 
        unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
553
 
        /* Texture rendering set-up */
554
 
        uds->gScreen->setTexEnvMode(GL_MODULATE);
555
 
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
556
 
        /* Draw the dim texture with all of it's modified
557
 
           * geometry glory */
558
 
        gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
559
 
        gWindow->glDrawTexture(mTexture, fa, mask | PAINT_WINDOW_BLEND_MASK
560
 
                               | PAINT_WINDOW_TRANSLUCENT_MASK |
561
 
                               PAINT_WINDOW_TRANSFORMED_MASK);
562
 
        gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
563
 
        /* Texture rendering tear-down */
564
 
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
565
 
        uds->gScreen->setTexEnvMode(GL_REPLACE);
 
517
      UnityDialogScreen *uds = UnityDialogScreen::get (screen);
 
518
      GLWindowPaintAttrib attrib (gWindow->lastPaintAttrib());
 
519
      unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
 
520
      /* Texture rendering set-up */
 
521
      glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
522
      /* Draw the dim texture with all of it's modified
 
523
       * geometry glory */
 
524
      gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
 
525
      gWindow->glDrawTexture(mTexture, transform, attrib, mask
 
526
                                                | PAINT_WINDOW_BLEND_MASK
 
527
                                                | PAINT_WINDOW_TRANSLUCENT_MASK
 
528
                                                | PAINT_WINDOW_TRANSFORMED_MASK);
 
529
      gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
 
530
      /* Texture rendering tear-down */
 
531
      glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
532
      uds->gScreen->setTexEnvMode(GL_REPLACE);
566
533
    }
567
 
#endif
568
534
  }
569
535
}
570
536
 
619
585
 
620
586
void
621
587
unity::PaintInfoCollector::drawGeometriesForWindow(CompWindow *w,
622
 
#ifdef USE_MODERN_COMPIZ_GL
623
588
                                                   const GLMatrix &transform,
624
 
#endif
625
589
                                                   unsigned int pm)
626
590
{
627
591
  for (unity::TexGeometryCollection &tcg : mCollection)
628
 
#if USE_MODERN_COMPIZ_GL
629
592
    tcg.addGeometriesAndDrawTextureForWindow (w, transform, pm);
630
 
#else
631
 
    tcg.addGeometriesAndDrawTextureForWindow (w, pm);
632
 
#endif
633
593
}
634
594
 
635
595
unity::PaintInfoCollector * unity::PaintInfoCollector::active_collector = NULL;
644
604
 
645
605
bool
646
606
UnityDialogWindow::glDraw(const GLMatrix& transform,
647
 
#ifdef USE_MODERN_COMPIZ_GL
648
607
                          const GLWindowPaintAttrib& attrib,
649
 
#else
650
 
                          GLFragment::Attrib& fragment,
651
 
#endif
652
608
                          const CompRegion& region,
653
609
                          unsigned int mask)
654
610
{
660
616
  /* Draw the window on the bottom, we will be drawing the
661
617
   * dim render on top */
662
618
  bool status = gWindow->glDraw(transform,
663
 
#ifdef USE_MODERN_COMPIZ_GL
664
619
                                attrib,
665
 
#else
666
 
                                fragment,
667
 
#endif
668
620
                                region, mask);
669
621
 
670
622
  UNITY_DIALOG_SCREEN(screen);
673
625
  {
674
626
    GLTexture::MatrixList matl;
675
627
    GLTexture::Matrix     mat = tex->matrix();
676
 
#ifdef USE_MODERN_COMPIZ_GL
677
628
    GLWindowPaintAttrib   wAttrib(attrib);
678
 
#endif
679
629
 
680
630
    /* We can reset the window geometry since it will be
681
631
     * re-added later */
682
 
#ifdef USE_MODERN_COMPIZ_GL
683
632
    gWindow->vertexBuffer()->begin();
684
 
#else
685
 
    gWindow->geometry().reset();
686
 
#endif
687
633
 
688
634
    /* Scale the dim render by the ratio of dim size
689
635
     * to window size */
704
650
     * dim (so we get a nice render for things like
705
651
     * wobbly etc etc */
706
652
    gWindow->glAddGeometry(matl, reg, paintRegion);
707
 
#ifdef USE_MODERN_COMPIZ_GL
708
 
    gWindow->vertexBuffer()->end();
709
 
#endif
710
 
 
711
 
#ifdef USE_MODERN_COMPIZ_GL
712
 
    unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
713
 
    wAttrib.opacity = mShadeProgress;
714
 
    /* Texture rendering set-up */
715
 
//    uds->gScreen->setTexEnvMode(GL_MODULATE);
716
 
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
717
 
    /* Draw the dim texture with all of it's modified
718
 
     * geometry glory */
719
 
    gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
720
 
    gWindow->glDrawTexture(tex, transform, attrib, mask
721
 
                                              | PAINT_WINDOW_BLEND_MASK
722
 
                                              | PAINT_WINDOW_TRANSLUCENT_MASK
723
 
                                              | PAINT_WINDOW_TRANSFORMED_MASK);
724
 
    gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
725
 
    /* Texture rendering tear-down */
726
 
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
727
 
    uds->gScreen->setTexEnvMode(GL_REPLACE);
728
 
#else
729
 
    /* Did it succeed? */
730
 
    if (gWindow->geometry().vertices)
 
653
    if (gWindow->vertexBuffer()->end())
731
654
    {
732
655
      unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex();
733
 
      fragment.setOpacity(mShadeProgress);
 
656
      wAttrib.opacity = mShadeProgress;
734
657
      /* Texture rendering set-up */
735
 
      uds->gScreen->setTexEnvMode(GL_MODULATE);
 
658
      //    uds->gScreen->setTexEnvMode(GL_MODULATE);
736
659
      glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
737
660
      /* Draw the dim texture with all of it's modified
738
661
       * geometry glory */
739
662
      gWindow->glDrawTextureSetCurrentIndex(MAXSHORT);
740
 
      gWindow->glDrawTexture(tex, fragment, mask | PAINT_WINDOW_BLEND_MASK
741
 
                             | PAINT_WINDOW_TRANSLUCENT_MASK |
742
 
                             PAINT_WINDOW_TRANSFORMED_MASK);
 
663
      gWindow->glDrawTexture(tex, transform, attrib, mask
 
664
                                                | PAINT_WINDOW_BLEND_MASK
 
665
                                                | PAINT_WINDOW_TRANSLUCENT_MASK
 
666
                                                | PAINT_WINDOW_TRANSFORMED_MASK);
743
667
      gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex);
744
668
      /* Texture rendering tear-down */
745
669
      glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
746
670
      uds->gScreen->setTexEnvMode(GL_REPLACE);
747
671
    }
748
 
#endif
749
672
  }
750
673
 
751
674
  for (CompWindow* w : mTransients)
759
682
 
760
683
      pc.collect();
761
684
      pc.drawGeometriesForWindow (window,
762
 
#ifdef USE_MODERN_COMPIZ_GL
763
685
                                  transform,
764
 
#endif
765
686
                                  mask);
766
687
    }
767
688
  }