Exemple #1
0
void GPUFilter::setDimensions(const IntPoint& srcSize, const IntRect& destRect,
        unsigned texMode)
{
    bool bProjectionChanged = false;
    if (destRect != m_DestRect) {
        m_pFBOs.clear();
        for (unsigned i=0; i<m_NumTextures; ++i) {
            FBOPtr pFBO = FBOPtr(new FBO(destRect.size(), m_PFDest, 1, 1, false,
                    m_bMipmap));
            m_pFBOs.push_back(pFBO);
        }
        m_DestRect = destRect;
        bProjectionChanged = true;
    }
    if (m_bStandalone && srcSize != m_SrcSize) {
        m_pSrcTex = GLTexturePtr(new GLTexture(srcSize, m_PFSrc, false, texMode, 
                texMode));
        m_pSrcPBO = PBOPtr(new PBO(srcSize, m_PFSrc, GL_STREAM_DRAW));
        bProjectionChanged = true;
    }
    m_SrcSize = srcSize;
    if (bProjectionChanged) {
        m_pProjection = ImagingProjectionPtr(new ImagingProjection(srcSize, destRect));
    }
}
Exemple #2
0
void GPUBlurFilter::setStdDev(float stdDev)
{
    m_StdDev = stdDev;
    m_pGaussCurveTex = calcBlurKernelTex(m_StdDev, 1, m_bUseFloatKernel);
    setDimensions(getSrcSize(), stdDev);
    IntRect destRect2(IntPoint(0,0), getDestRect().size());
    m_pProjection2 = ImagingProjectionPtr(new ImagingProjection(
            getDestRect().size(), destRect2));
}
Exemple #3
0
void RasterNode::disconnect(bool bKill)
{
    if (m_pSurface) {
        m_pSurface->destroy();
    }
    m_pFBO = MCFBOPtr();
    m_pImagingProjection = ImagingProjectionPtr();
    if (bKill) {
        m_pFXNode = FXNodePtr();
    } else {
        if (m_pFXNode) {
            m_pFXNode->disconnect();
        }
    }
    AreaNode::disconnect(bKill);
}
Exemple #4
0
void RasterNode::setupFX()
{
    if (m_pSurface && m_pSurface->getSize() != IntPoint(-1,-1) && m_pFXNode) {
        m_pFXNode->setSize(m_pSurface->getSize());
        m_pFXNode->connect();
        m_bFXDirty = true;
        if (!m_pFBO || m_pFBO->getSize() != m_pSurface->getSize()) {
            PixelFormat pf = BitmapLoader::get()->getDefaultPixelFormat(true);
#ifdef AVG_ENABLE_EGL
            unsigned wrapMode = GL_CLAMP_TO_EDGE;
#else
            unsigned wrapMode = GL_CLAMP_TO_BORDER;
#endif
            GLContextManager* pCM = GLContextManager::get();
            m_pFBO = pCM->createFBO(IntPoint(m_pSurface->getSize()), pf, 1, 1, false, 
                    false, getMipmap(), wrapMode, wrapMode);
            m_pImagingProjection = ImagingProjectionPtr(new ImagingProjection(
                    m_pSurface->getSize()));
        }
    }
}
Exemple #5
0
GPUChromaKeyFilter::GPUChromaKeyFilter(const IntPoint& size, bool bStandalone)
    : GPUFilter(SHADERID_CHROMAKEY, true, bStandalone, 2),
      m_Color(0, 255, 0),
      m_HTolerance(0.0),
      m_STolerance(0.0),
      m_LTolerance(0.0),
      m_Softness(0.0),
      m_Erosion(0),
      m_SpillThreshold(0.0)
{
    ObjectCounter::get()->incRef(&typeid(*this));

    GLContext::getCurrent()->ensureFullShaders("GPUChromaKeyFilter");

    setDimensions(size);
    OGLShaderPtr pShader = getShader();
    m_pTextureParam = pShader->getParam<int>("u_Texture");
    
    m_pHKeyParam = pShader->getParam<float>("u_HKey");
    m_pHToleranceParam = pShader->getParam<float>("u_HTolerance");
    m_pHSoftToleranceParam = pShader->getParam<float>("u_HSoftTolerance");
    
    m_pSKeyParam = pShader->getParam<float>("u_SKey");
    m_pSToleranceParam = pShader->getParam<float>("u_STolerance");
    m_pSSoftToleranceParam = pShader->getParam<float>("u_SSoftTolerance");
    
    m_pLKeyParam = pShader->getParam<float>("u_LKey");
    m_pLToleranceParam = pShader->getParam<float>("u_LTolerance");
    m_pLSoftToleranceParam = pShader->getParam<float>("u_LSoftTolerance");
    
    m_pSpillThresholdParam = pShader->getParam<float>("u_SpillThreshold");
    m_pIsLastParam = pShader->getParam<int>("u_bIsLast");

    createShader(SHADERID_EROSION);
    pShader = avg::getShader(SHADERID_EROSION);
    m_pErosionTextureParam= pShader->getParam<int>("u_Texture");
    m_pErosionIsLastParam = pShader->getParam<int>("u_bIsLast");
    
    m_pProjection2 = ImagingProjectionPtr(new ImagingProjection(size));
}