Ejemplo n.º 1
0
void VisualisationContainer::Init() {
  setWindowTitle(tr("Clementine Visualization"));
  setWindowIcon(QIcon(":/icon.png"));

  // Set up the graphics view
  setScene(vis_);
  setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
  setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setFrameStyle(QFrame::NoFrame);

  // Add the overlay
  overlay_proxy_ = scene()->addWidget(overlay_);
  connect(overlay_, SIGNAL(OpacityChanged(qreal)), SLOT(ChangeOverlayOpacity(qreal)));
  connect(overlay_, SIGNAL(ShowPopupMenu(QPoint)), SLOT(ShowPopupMenu(QPoint)));
  ChangeOverlayOpacity(0.0);

  vis_->SetTextureSize(size_);
  SizeChanged();

  // Selector
  selector_->SetVisualisation(vis_);

  // Settings menu
  menu_->addAction(IconLoader::Load("view-fullscreen"), tr("Toggle fullscreen"),
                   this, SLOT(ToggleFullscreen()));

  QMenu* fps_menu = menu_->addMenu(tr("Framerate"));
  QSignalMapper* fps_mapper = new QSignalMapper(this);
  QActionGroup* fps_group = new QActionGroup(this);
  AddMenuItem(tr("Low (15 fps)"), 15, fps_, fps_group, fps_mapper);
  AddMenuItem(tr("Medium (25 fps)"), 25, fps_, fps_group, fps_mapper);
  AddMenuItem(tr("High (35 fps)"), 35, fps_, fps_group, fps_mapper);
  AddMenuItem(tr("Super high (60 fps)"), 60, fps_, fps_group, fps_mapper);
  fps_menu->addActions(fps_group->actions());
  connect(fps_mapper, SIGNAL(mapped(int)), SLOT(SetFps(int)));

  QMenu* quality_menu = menu_->addMenu(tr("Quality"));
  QSignalMapper* quality_mapper = new QSignalMapper(this);
  QActionGroup* quality_group = new QActionGroup(this);
  AddMenuItem(tr("Low (256x256)"), 256, size_, quality_group, quality_mapper);
  AddMenuItem(tr("Medium (512x512)"), 512, size_, quality_group, quality_mapper);
  AddMenuItem(tr("High (1024x1024)"), 1024, size_, quality_group, quality_mapper);
  quality_menu->addActions(quality_group->actions());
  connect(quality_mapper, SIGNAL(mapped(int)), SLOT(SetQuality(int)));

  menu_->addAction(tr("Select visualizations..."), selector_, SLOT(show()));

  menu_->addSeparator();
  menu_->addAction(IconLoader::Load("application-exit"), tr("Close visualization"),
                   this, SLOT(hide()));
}
void CHuiFxVg10BlurFilter::DrawEffect(CHuiFxEngine& aEngine, VGImage aTargetImage, VGImage aSourceImage, TInt aWidth, TInt aHeight, TBool /*aHasSurface*/)
    {
    const VGfloat blur_x = clamp(iBlurX, EPSILON, 128.0f);
    const VGfloat blur_y = clamp(iBlurY, EPSILON, 128.0f);
    const VGfloat opacity = clamp(iOpacity, 0.0f, 1.0f);
    
    if(opacity < 1.0f - EPSILON)    // slow path --- take opacity into account
        {
//        const VGint width = vgGetParameteri(aSourceImage, VG_IMAGE_WIDTH);
//        const VGint height = vgGetParameteri(aSourceImage, VG_IMAGE_HEIGHT);
        const VGint width = aWidth;
        const VGint height = aHeight;
    
        CHuiFxRenderbuffer* auxBuffer = aEngine.AcquireRenderbuffer(TSize(width, height));
        if (!auxBuffer)
            {
            return;  // not enough memory --- filter not completed successfully
            }
        auxBuffer->BindAsTexture(ERenderbufferUsageReadWrite);
        
        VGImage auxImage = reinterpret_cast<CHuiFxVg10RenderbufferBase*>(auxBuffer)->Image();
        
        vgGaussianBlur(auxImage, aSourceImage, blur_x, blur_y, VG_TILE_PAD);
    
        if(OpacityChanged())
            {
            UpdateAlphaLUT();
            }
        vgLookup(aTargetImage, auxImage, iColorLUT, iColorLUT, iColorLUT, iAlphaLUT, VG_TRUE, VG_FALSE);
        auxBuffer->UnbindAsTexture();
        aEngine.ReleaseRenderbuffer(auxBuffer);
    }    
    else    // fast path --- the blur, just blur and nothing but the blur.
        {
        vgGaussianBlur(aTargetImage, aSourceImage, blur_x, blur_y, VG_TILE_PAD);   
        }
    }