Ejemplo n.º 1
0
void Profiler::BeginFrame()
{
    // End the previous frame if any
    EndFrame();
    
    BeginBlock("RunFrame");
}
Ejemplo n.º 2
0
STDMETHODIMP AitEncoder::Initialize(IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{
    HRESULT result = E_INVALIDARG;

    if (pIStream)
    {
        result = S_OK;

        stream = pIStream;

        if (SUCCEEDED(result))
        {
            result = VerifyFactory();
        }

        // Remember the position of the header for later reference
        if (SUCCEEDED(result))
        {
            LARGE_INTEGER zero = { 0 };
            result = stream->Seek(zero, STREAM_SEEK_CUR, &headerPos);
        }

        // Write the header with a placeholder for the number of frames
        if (SUCCEEDED(result))
        {
            BeginBlock(stream, "AIT", 0xFFFFFFFF);            
            OutputValue(stream, (UINT)0);
            result = EndBlock(stream);
        }
    }    
    return result;
}
Ejemplo n.º 3
0
static HRESULT OutputBitmapPalette(IStream *stream, UINT frameNum, IWICPalette *palette)
{
    HRESULT result = E_INVALIDARG;

    if (stream && palette)
    {
        UINT colorCount = 0;
        WICColor *colors = NULL;

        result = S_OK;

        if (SUCCEEDED(result))
        {
            result = palette->GetColorCount(&colorCount);
        }

        if (colorCount > 0)
        {

            if (SUCCEEDED(result))
            {
                colors = new WICColor[colorCount];

                if (NULL == colors)
                {
                    result = E_OUTOFMEMORY;
                }
            }

            if (SUCCEEDED(result))
            {
                UINT cActualColors = 0;
                result = palette->GetColors(colorCount, colors, &cActualColors);
            }

            if (SUCCEEDED(result))
            {
                BeginBlock(stream, "PAL", frameNum);
                OutputValue(stream, colorCount);
                OutputValues(stream, colors, colorCount);
                result = EndBlock(stream);
            }

            if (colors)
            {
                delete[] colors;
            }
        }
    }

    return result;
}
Ejemplo n.º 4
0
static HRESULT OutputColorContext(IStream *stream, UINT frameNum, UINT colorContextCount, IWICColorContext **colorContext)
{
    HRESULT result = E_INVALIDARG;
    if (stream && colorContext)
    {
        BeginBlock(stream, "COL", frameNum);
        for(int i = 0; i < colorContextCount; i++)
        {
            UINT numBytes = 0;
            BYTE *bytes = NULL;
    
            result = S_OK;

            if (SUCCEEDED(result))
            {
                result = colorContext[i]->GetProfileBytes(0, NULL, &numBytes);
            }

            if (numBytes > 0)
            {
                if (SUCCEEDED(result))
                {
                    bytes = new BYTE[numBytes];
    
                    if (NULL == bytes)
                    {
                        result = E_OUTOFMEMORY;
                    }
                }

                if (SUCCEEDED(result))
                {
                    result = colorContext[i]->GetProfileBytes(numBytes, bytes, &numBytes);
                }

                if (SUCCEEDED(result))
                {                    
                    OutputValue(stream, numBytes);
                    OutputValues(stream, bytes, numBytes);                    
                }

                if (bytes)
                {
                    delete[] bytes;
                }
            }
       }
       result = EndBlock(stream);
    }
    return result;
}
Ejemplo n.º 5
0
static HRESULT OutputBitmapSource(IStream *stream, LPCSTR name, UINT frameNum,
                                  double dpiX, double dpiY,
                                  IWICBitmapSource *source)
{
    HRESULT result = E_INVALIDARG;

    if (stream && source)
    {
        UINT width = 0, height = 0;
        UINT stride = 0;
        WICPixelFormatGUID pixelFormat;
        BYTE *pixels = NULL;

        result = S_OK;

        // Retrieve the dimensions of the source
        if (SUCCEEDED(result))
        {
            result = source->GetSize(&width, &height);
        }

        // Optionally retrieve the resolution
        if (SUCCEEDED(result) && (dpiX == 0 || dpiY == 0))
        {
            result = source->GetResolution(&dpiX, &dpiY);
        }

        // Get the pixel format
        if (SUCCEEDED(result))
        {
            result = source->GetPixelFormat(&pixelFormat);
        }

        // Get the stride
        if (SUCCEEDED(result))
        {
            stride = GetScanlineStride(width, pixelFormat);

            if (stride < 1)
            {
                result = E_UNEXPECTED;
            }
        }

        // Allocate the pixels
        if (SUCCEEDED(result))
        {
            pixels = new BYTE[stride * height];

            if (NULL == pixels)
            {
                result = E_OUTOFMEMORY;
            }
        }

        // Get the pixels
        if (SUCCEEDED(result))
        {
            WICRect rct;
            rct.X = 0;
            rct.Y = 0;
            rct.Width = width;
            rct.Height = height;

            result = source->CopyPixels(&rct, stride, stride * height, pixels);
        }

        // Output everything
        if (SUCCEEDED(result))
        {
            BeginBlock(stream, name, frameNum);
            OutputValue(stream, width);
            OutputValue(stream, height);
            OutputValue(stream, dpiX);
            OutputValue(stream, dpiY);
            OutputValue(stream, stride);
            OutputValue(stream, pixelFormat);
            OutputValues(stream, pixels, stride*height);
            result = EndBlock(stream);
        }

        if (pixels)
        {
            delete[] pixels;
        }
    }

    return result;
}
Ejemplo n.º 6
0
void Context::Composite()
{
    //printf( "composite()\n");
    auto& targ = gfxtarget;
    int mww = targ.GetW();
    int mwh = targ.GetH();
    int wd2 = mww/2;
    int hd2 = mwh/2;
    int bufw = fbo_left->miW;
    int bufh = fbo_left->miH;
    //printf( "bufw<%d> mainwin_w<%d>\n", bufw, mww);
    using fxp_t = const lev2::FxShaderParam*;

    static auto fxi = targ.FXI();
    static auto gbi = targ.GBI();
    static auto txi = targ.TXI();

    using vtx_t = lev2::SVtxV12C4T16;

    static lev2::DynamicVertexBuffer<vtx_t> gvbuf( 1<<20 );

    const float kbound = 1.0;

    auto ltexture = fbo_left->GetTexture();
    auto rtexture = fbo_right->GetTexture();
    lev2::RenderContextInstData rcid;

    //////////////
    // LEFT
    //////////////
    {
        lev2::VtxWriter<vtx_t> vwriter;
        vwriter.Lock(&targ,&gvbuf,6);
            vwriter.RefInc() = vtx_t(-kbound,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+0,-kbound,0, 1,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+0,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-kbound,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+0,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-kbound,+kbound,0, 0,1, 0xffffffff);
        vwriter.UnLock(&targ);
        fxi->BeginBlock(fx_distort,rcid);
            fxi->BindPass(fx_distort,0);
                fxi->BindParamMatrix( fx_distort,par_mvp,fmtx4());
                fxi->BindParamFloat2( fx_distort, par_fbosiz, float(bufw), float(bufh) );
                fxi->BindParamFloat2( fx_distort, par_cbufsiz, float(mww), float(mwh) );
                fxi->BindParamFloat2( fx_distort, par_llctr, gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rlctr, 1.0f-gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_lsctr, gScrCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rsctr, 1.0f-gScrCenter, 0.5f );
                fxi->BindParamFloat( fx_distort, par_chromab, chromab );
                fxi->BindParamCTex( fx_distort,par_texms,ltexture);
                fxi->CommitParams();
                gbi->DrawPrimitiveEML(vwriter,lev2::EPRIM_TRIANGLES);
            fxi->EndPass(fx_distort);
        fxi->EndBlock(fx_distort);
    }
    //////////////
    // RIGHT
    //////////////
    {
        lev2::VtxWriter<vtx_t> vwriter;
        vwriter.Lock(&targ,&gvbuf,6);
            vwriter.RefInc() = vtx_t(-0,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+kbound,-kbound,0, 1,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+kbound,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-0,-kbound,0, 0,0, 0xffffffff);
            vwriter.RefInc() = vtx_t(+kbound,+kbound,0, 1,1, 0xffffffff);
            vwriter.RefInc() = vtx_t(-0,+kbound,0, 0,1, 0xffffffff);
        vwriter.UnLock(&targ);
        fxi->BeginBlock(fx_distort,rcid);
            fxi->BindPass(fx_distort,0);
                fxi->BindParamMatrix( fx_distort,par_mvp,fmtx4());
                fxi->BindParamFloat2( fx_distort, par_fbosiz, float(bufw), float(bufh) );
                fxi->BindParamFloat2( fx_distort, par_cbufsiz, float(mww), float(mwh) );
                fxi->BindParamFloat2( fx_distort, par_llctr, gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rlctr, 1.0f-gLensCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_lsctr, gScrCenter, 0.5f );
                fxi->BindParamFloat2( fx_distort, par_rsctr, 1.0f-gScrCenter, 0.5f );
                fxi->BindParamFloat( fx_distort, par_chromab, chromab );
                fxi->BindParamCTex( fx_distort,par_texms,rtexture);
                fxi->CommitParams();
                gbi->DrawPrimitiveEML(vwriter,lev2::EPRIM_TRIANGLES);
            fxi->EndPass(fx_distort);
        fxi->EndBlock(fx_distort);
    }

}