Beispiel #1
0
int pipeline_container_run (LVAVSPipelineContainer *container, VisVideo *video, VisAudio *audio)
{
    int i, s = 0;
    VisListEntry *le = NULL;
    LVAVSPipelineElement *element;
    VisBuffer pcmbuf1;
    VisBuffer pcmbuf2;
    VisBuffer spmbuf1;
    VisBuffer spmbuf2;
    VisBuffer tmp;
    int *fbout;
    int *framebuffer;
    LVAVSPipeline *pipeline = LVAVS_PIPELINE_ELEMENT(container)->pipeline;
    int w = video->width, h = video->height;

    if(video->width != pipeline->dummy_vid->width || video->height != pipeline->dummy_vid->height || video->depth != pipeline->dummy_vid->depth) {

        if(pipeline->dummy_vid)
            visual_object_unref(VISUAL_OBJECT(pipeline->dummy_vid));

        if(pipeline->last_vid)
            visual_object_unref(VISUAL_OBJECT(pipeline->last_vid));
    
        pipeline->dummy_vid = visual_video_scale_depth_new(video, video->width, video->height, video->depth, VISUAL_VIDEO_COMPOSITE_TYPE_SRC);

        pipeline->last_vid = visual_video_scale_depth_new(video, video->width, video->height, video->depth, VISUAL_VIDEO_COMPOSITE_TYPE_SRC);
        
        for(i = 0; i < 16; i++) {
            VisVideo *vid = pipeline->buffers[i];
            if(vid)
                visual_object_unref(VISUAL_OBJECT(vid));
            vid = visual_video_scale_depth_new(video, video->width, video->height, video->depth, VISUAL_VIDEO_COMPOSITE_TYPE_NONE);
            pipeline->buffers[i] = vid;
        }
    }

    visual_video_blit_overlay(video, pipeline->last_vid, 0, 0, 0.5);
      
    fbout = visual_video_get_pixels(video);
    framebuffer = visual_video_get_pixels(pipeline->dummy_vid);

    int is_preinit = pipeline->isBeat;//(pipeline->isBeat&0x80000000);

/*    if(pipeline->isBeat && beat_render)
    fake_enabled = beat_render_frames;
*/
    s = render_now(container, video, audio, s);

    if(!is_preinit)
    {
        int x = video->width * video->height;
        int *tfb=framebuffer;
        int *o = fbout;
        int use_blendin=blendin(pipeline->blendmode);
        if(use_blendin == 10 && pipeline->use_inblendval >= 255)
            use_blendin=1;

        switch (use_blendin)
        {
            case 1:
                visual_mem_copy(o, tfb, w*h*sizeof(int));
            break;
            case 2:
                mmx_avgblend_block(o,tfb,x);
            break;
            case 3:
                while(x--)
                {
                    *o=BLEND_MAX(*o, *tfb++);
                    o++;
                }
            break;
            case 4:
            //mmx_addblend_block(pipeline->blendtable, o, tfb, x);
            break;
            case 5:
                while(x--)
                {
                    *o=BLEND_SUB(*o,*tfb++);
                    o++;
                }
            break;
            case 6:
                while(x--)
                {
                    *o=BLEND_SUB(*tfb++, *o);
                    o++;
                }
            break;
            case 7:
            {
                int y=h/2;
                while(x-- > 0)
                {
                    visual_mem_copy(o,tfb,w*sizeof(int));
                    tfb+=w*2;
                    o+=w*2;
                }
            break;
            }
            case 8:
            {
                int r = 0;
                int y = h;
                while(y-- > 0)
                {
                    int *out, *in;
                    int x=w/2;
                    out=o+r;
                    in=tfb+r;
                    r^=1;
                    while(x-- > 0)
                    {
                        *out=*in;
                        out+=2;
                        in+=2;
                    }
                    o+=w;
                    tfb+=w;
                }
            break;
            }
            case 9:
                while(x--)
                {
                    *o=*o^*tfb++;
                    o++;
                }
            break;
            case 10:
                mmx_adjblend_block(pipeline->blendtable,o,tfb,o,x,pipeline->use_inblendval);
            break;
            case 11:
                mmx_mulblend_block(pipeline->blendtable, o,tfb,x);
            break;
            case 13:
                while(x--)
                {
                    *o=BLEND_MIN(*o,*tfb++);
                    o++;
                }
            break;
            case 12:
    /*
                                    {
                                            int *buf=(int*)getGlobalBuffer(w,h,bufferin,0);
                                            if (!buf) break;
                                            while (x--)
                                            {
                                                    *o=BLEND_ADJ(*tfb++,*o, depthof(*buf, ininvert));
                                                    o++;
                                                    buf++;
                                            }
                                    }
    */
            break;
            default:
            break;
        }
    }
    int x;
    int line_blend_mode_save=pipeline->blendmode;
    //if(!is_preinit) pipeline->blendmode = 0;

    s = render_now(container, video, audio, s);
    //if(!is_preinit) pipeline->blendmode = line_blend_mode_save;

    if(!is_preinit)
    {
        if(s) visual_mem_copy(framebuffer, fbout, w*h*sizeof(int));

        int *tfb=s?fbout:framebuffer;
        int *o=framebuffer;
        x=w*h;
        int use_blendout=blendout(pipeline->blendmode);
        int use_outblendval = 100;
        if(use_blendout == 10 && use_outblendval >= 255)
            use_blendout=1;
        switch(use_blendout)
        {
            case 1:
                visual_mem_copy(o,tfb,x*sizeof(int));
            break;
            case 2:
                mmx_avgblend_block(o,tfb,x);
            break;
            case 3:
                while(x--)
                {
                    *o=BLEND_MAX(*o, *tfb++);
                    o++;
                }
            break;
            case 4:
                mmx_addblend_block(o, tfb, x);
            break;
            case 5:
                while(x--)
                {
                    *o = BLEND_SUB(*o, *tfb++);
                    o++;
                }
            break;
            case 6:
                while(x--)
                {
                    *o=BLEND_SUB(*tfb++, *o);
                    o++;
                }
            break;
            case 7:
            {
                int y=h/2;
                while(y-- > 0)
                {
                    visual_mem_copy(o, tfb, w*sizeof(int));
                    tfb+=w*2;
                    o+=w*2;
                }
            }
            break;
            case 8:
            {
                int r = 0;
                int y = h;
                while(y-- > 0)
                {
                    int *out, *in;
                    int x=w/2;
                    out=o+r;
                    in=tfb+r;
                    r^=1;
                    while(x-- > 0)
                    {
                        *out=*in;
                        out+=2;
                        in+=2;
                    }
                    o+=w;
                    tfb+=2;
                }
            }
            case 9:
                while(x--)
                {
                    *o=*o^*tfb++;
                    o++;
                }
            break;
            case 10:
                mmx_adjblend_block(pipeline->blendtable,o, tfb, o, x, use_outblendval);
            break;
            case 11:
                mmx_mulblend_block(pipeline->blendtable, o, tfb, x);
            break;
            case 13:
                while(x--)
                {
                    *o=BLEND_MIN(*o, *tfb++);
                    o++;
                }
            break;
            case 12:
            {
                //uint32_t *buf = buffer[bufferout]
            }
            break;
            default:
            break;
        }
    } 

    // Save state for next frame.
    visual_video_blit_overlay(pipeline->last_vid, video, 0, 0, 0);
    return VISUAL_OK;
}
Beispiel #2
0
	bool sdl_renderer::process_events()
	{
		bool handledEvents = false;
		SDL_Event event;
		auto lastRenderTime = neolib::thread::program_elapsed_ms();
		while (SDL_PollEvent(&event))
		{
			handledEvents = true;
			switch (event.type)
			{
			case SDL_WINDOWEVENT:
				{
					SDL_Window* window = SDL_GetWindowFromID(event.window.windowID);
					if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
						static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
				}
				break;
			case SDL_MOUSEMOTION:
				{
					SDL_Window* window = SDL_GetWindowFromID(event.motion.windowID);
					if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
						static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
				}
				break;
			case SDL_MOUSEBUTTONDOWN:
				{
					SDL_Window* window = SDL_GetWindowFromID(event.button.windowID);
					if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
						static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
				}
				break;
			case SDL_MOUSEBUTTONUP:
				{
					SDL_Window* window = SDL_GetWindowFromID(event.button.windowID);
					if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
						static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
				}
				break;
			case SDL_MOUSEWHEEL:
				{
					SDL_Window* window = SDL_GetWindowFromID(event.wheel.windowID);
					if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
						static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
				}
				break;
			case SDL_KEYDOWN:
				{
					if (!iKeyboard.grabber().key_pressed(
						static_cast<scan_code_e>(event.key.keysym.scancode),
						static_cast<key_code_e>(event.key.keysym.sym),
						static_cast<key_modifiers_e>(event.key.keysym.mod)))
					{
						iKeyboard.key_pressed.trigger(
							static_cast<scan_code_e>(event.key.keysym.scancode),
							static_cast<key_code_e>(event.key.keysym.sym),
							static_cast<key_modifiers_e>(event.key.keysym.mod));
						SDL_Window* window = SDL_GetWindowFromID(event.key.windowID);
						if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
							static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
					}
				}
				break;
			case SDL_KEYUP:
				{
					if (!iKeyboard.grabber().key_released(
						static_cast<scan_code_e>(event.key.keysym.scancode),
						static_cast<key_code_e>(event.key.keysym.sym),
						static_cast<key_modifiers_e>(event.key.keysym.mod)))
					{
						iKeyboard.key_released.trigger(
							static_cast<scan_code_e>(event.key.keysym.scancode),
							static_cast<key_code_e>(event.key.keysym.sym),
							static_cast<key_modifiers_e>(event.key.keysym.mod));
						SDL_Window* window = SDL_GetWindowFromID(event.key.windowID);
						if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
							static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
					}
				}
				break;
			case SDL_TEXTEDITING:
				{
					SDL_Window* window = SDL_GetWindowFromID(event.edit.windowID);
					if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
						static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
				}
				break;
			case SDL_TEXTINPUT:
				{
					if (!iKeyboard.grabber().text_input(event.text.text))
					{
						SDL_Window* window = SDL_GetWindowFromID(event.text.windowID);
						if (window != NULL && app::instance().surface_manager().is_surface_attached(window))
							static_cast<sdl_window&>(app::instance().surface_manager().attached_surface(window).native_surface()).process_event(event);
					}
				}
				break;
			default:
				break;
			}
			if (neolib::thread::program_elapsed_ms() - lastRenderTime > 10)
			{
				lastRenderTime = neolib::thread::program_elapsed_ms();
				render_now();
			}
		}
		return handledEvents;
	}