X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fcanvas.C;h=aabe440de3c470bfd47a1865e0dfc732c7893a29;hp=b2bd838ddb01d94c81b535e1e8a6c517cc87766a;hb=7b25542808937e46959c104a706b75f04b1215be;hpb=2ba7e9962ea989863e152373e96a09b00a0b4eb8 diff --git a/cinelerra-5.1/cinelerra/canvas.C b/cinelerra-5.1/cinelerra/canvas.C index b2bd838d..aabe440d 100644 --- a/cinelerra-5.1/cinelerra/canvas.C +++ b/cinelerra-5.1/cinelerra/canvas.C @@ -1,7 +1,7 @@ /* * CINELERRA - * Copyright (C) 2008 Adam Williams + * Copyright (C) 2008-2017 Adam Williams * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,8 @@ #include "mwindowgui.h" #include "mutex.h" #include "mwindow.h" +#include "playback3d.h" +#include "videodevice.h" #include "vframe.h" @@ -330,8 +332,8 @@ void Canvas::get_transfers(EDL *edl, float &canvas_x1, float &canvas_y1, float &canvas_x2, float &canvas_y2, int canvas_w, int canvas_h) { -// printf("Canvas::get_transfers %d %d\n", canvas_w, -// canvas_h); +//printf("Canvas::get_transfers %d canvas_w=%d canvas_h=%d\n", +// __LINE__, canvas_w, canvas_h); // automatic canvas size detection if(canvas_w < 0) canvas_w = get_canvas()->get_w(); if(canvas_h < 0) canvas_h = get_canvas()->get_h(); @@ -428,6 +430,11 @@ void Canvas::get_transfers(EDL *edl, { out_h = (int)(out_w / edl->get_aspect_ratio() + 0.5); canvas_y1 = canvas_h / 2 - out_h / 2; +// printf("Canvas::get_transfers %d canvas_h=%d out_h=%f canvas_y1=%f\n", +// __LINE__, +// canvas_h, +// out_h, +// canvas_y1); } canvas_x2 = canvas_x1 + out_w; canvas_y2 = canvas_y1 + out_h; @@ -457,7 +464,8 @@ void Canvas::get_transfers(EDL *edl, canvas_y1 = MAX(0, canvas_y1); canvas_x2 = MAX(canvas_x1, canvas_x2); canvas_y2 = MAX(canvas_y1, canvas_y2); -// printf("Canvas::get_transfers 2 %f,%f %f,%f -> %f,%f %f,%f\n", +// printf("Canvas::get_transfers %d %f,%f %f,%f -> %f,%f %f,%f\n", +// __LINE__, // output_x1, // output_y1, // output_x2, @@ -838,19 +846,53 @@ int Canvas::keypress_event(BC_WindowBase *caller) return 1; } +void Canvas::update_refresh(VideoDevice *device, VFrame *output_frame) +{ + int best_color_model = output_frame->get_color_model(); + int use_opengl = + device->out_config->driver == PLAYBACK_X11_GL && + output_frame->get_opengl_state() == VFrame::SCREEN; +// OpenGL does YUV->RGB in the compositing step + if( use_opengl ) + best_color_model = BC_RGB888; + if( refresh_frame && + (refresh_frame->get_w() != device->out_w || + refresh_frame->get_h() != device->out_h || + refresh_frame->get_color_model() != best_color_model ) ) { +// x11 direct render uses BC_BGR8888, use tranfer_from to remap + delete refresh_frame; refresh_frame = 0; + } + if( !refresh_frame ) { + refresh_frame = + new VFrame(device->out_w, device->out_h, best_color_model); + } + if( use_opengl ) { + get_canvas()->unlock_window(); + unlock_canvas(); + mwindow->playback_3d->copy_from(this, refresh_frame, output_frame, 0); + lock_canvas(" Canvas::output_refresh"); + get_canvas()->lock_window(" Canvas::output_refresh"); + } + else + refresh_frame->transfer_from(output_frame); +} - - - - - - +void Canvas::clear(int flush) +{ + if( refresh_frame ) + refresh_frame->clear_frame(); + BC_WindowBase *wdw = get_canvas(); + if( !wdw ) return; + wdw->set_bg_color(BLACK); + wdw->clear_box(0,0, wdw->get_w(), wdw->get_h()); + wdw->flash(flush); +}