4 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "automation.h"
30 #include "bcsignals.h"
33 #include "bccmodels.h"
38 #include "edlsession.h"
40 #include "filesystem.h"
41 #include "floatauto.h"
42 #include "floatautos.h"
43 #include "framecache.h"
44 #include "indexfile.h"
46 #include "localsession.h"
48 #include "mwindowgui.h"
49 #include "preferences.h"
50 #include "renderengine.h"
51 #include "resourcethread.h"
52 #include "resourcepixmap.h"
55 #include "timelinepane.h"
57 #include "trackcanvas.h"
58 #include "transportque.h"
61 #include "wavecache.h"
64 ResourcePixmap::ResourcePixmap(MWindow *mwindow,
70 : BC_Pixmap(gui, w, h)
74 this->mwindow = mwindow;
76 this->pane_number = pane_number;
77 startsource = edit->startsource;
78 data_type = edit->track->data_type;
80 source_framerate = edit->asset->frame_rate;
81 source_samplerate = edit->asset->sample_rate;
84 if( edit->nested_edl ) {
85 source_framerate = edit->nested_edl->session->frame_rate;
86 source_samplerate = edit->nested_edl->session->sample_rate;
89 project_framerate = edit->edl->session->frame_rate;
90 project_samplerate = edit->edl->session->sample_rate;
91 edit_id = edit->id; pixmap_w = w; pixmap_h = h;
94 ResourcePixmap::~ResourcePixmap()
99 void ResourcePixmap::reset()
111 void ResourcePixmap::resize(int w, int h)
113 int new_w = (w > get_w()) ? w : get_w();
114 int new_h = (h > get_h()) ? h : get_h();
116 BC_Pixmap::resize(new_w, new_h);
119 void ResourcePixmap::update_settings(Edit *edit,
120 int64_t edit_x, int64_t edit_w,
121 int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h)
123 this->edit_id = edit->id;
124 this->edit_x = edit_x;
125 this->pixmap_x = pixmap_x;
126 this->pixmap_w = pixmap_w;
127 this->pixmap_h = pixmap_h;
129 startsource = edit->startsource;
131 source_framerate = edit->asset->frame_rate;
133 if( edit->nested_edl )
134 source_framerate = edit->nested_edl->session->frame_rate;
136 source_samplerate = edit->asset->sample_rate;
137 else if( edit->nested_edl )
138 source_samplerate = edit->nested_edl->session->sample_rate;
140 project_framerate = edit->edl->session->frame_rate;
141 project_samplerate = edit->edl->session->sample_rate;
142 zoom_sample = mwindow->edl->local_session->zoom_sample;
143 zoom_track = mwindow->edl->local_session->zoom_track;
144 zoom_y = mwindow->edl->local_session->zoom_y;
147 void ResourcePixmap::draw_data(TrackCanvas *canvas,
148 Edit *edit, int64_t edit_x, int64_t edit_w,
149 int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h,
150 int mode, int indexes_only)
152 // Get new areas to fill in relative to pixmap
153 // Area to redraw relative to pixmap
157 // Ignore if called by resourcethread.
158 // if( mode == IGNORE_THREAD ) return;
161 if( edit->track->show_titles() )
162 y += mwindow->theme->get_image("title_bg_data")->get_h();
164 // If want indexes only & index can't be drawn, don't do anything.
166 int64_t index_zoom = 0;
167 Indexable *indexable = 0;
168 if( edit->asset ) indexable = edit->asset;
169 if( edit->nested_edl ) indexable = edit->nested_edl;
170 if( indexable && indexes_only ) {
171 IndexFile indexfile(mwindow, indexable);
172 if( !indexfile.open_index() ) {
173 index_zoom = indexable->index_state->index_zoom;
174 indexfile.close_index();
178 if( data_type == TRACK_AUDIO ) {
179 double asset_over_session = (double)indexable->get_sample_rate() /
180 mwindow->edl->session->sample_rate;
181 if( index_zoom <= mwindow->edl->local_session->zoom_sample *
191 /* Incremental drawing is not possible with resource thread */
194 refresh_w = pixmap_w;
196 // Draw background image
197 if( refresh_w > 0 ) {
198 int x1 = refresh_x, x2 = x1 + refresh_w;
199 int y1 = y, y2 = y1 + mwindow->edl->local_session->zoom_track;
200 int color = mwindow->get_title_color(edit);
201 mwindow->theme->draw_resource_bg(canvas, this, color,
202 edit_x, edit_w, pixmap_x, x1,y1, x2,y2);
204 //printf("ResourcePixmap::draw_data 70\n");
207 // Draw media which already exists
208 Track *track = edit->track;
210 switch( track->data_type )
213 draw_audio_resource(canvas,
214 edit, refresh_x, refresh_w);
218 draw_video_resource(canvas, edit, edit_x, edit_w,
219 pixmap_x, pixmap_w, refresh_x, refresh_w,
224 draw_subttl_resource(canvas, edit,
225 refresh_x, refresh_w);
233 VFrame *ResourcePixmap::change_title_color(VFrame *title_bg, int color)
235 int colormodel = title_bg->get_color_model();
236 int bpp = BC_CModels::calculate_pixelsize(colormodel);
237 int tw = title_bg->get_w(), tw1 = tw-1, th = title_bg->get_h();
238 VFrame *title_bar = new VFrame(tw, th, colormodel);
239 uint8_t **bar_rows = title_bar->get_rows();
240 const uint8_t gap_grey = 0x4a;
241 union { unsigned rgba; struct { uint8_t r,g,b,a; }; } c;
242 c.r = color>>16; c.g = color>>8; c.b = color>>0; c.a = 0xff;
243 if( BC_CModels::has_alpha(colormodel) && // fast path
244 BC_CModels::calculate_pixelsize(colormodel) == sizeof(unsigned) ) {
245 const unsigned gap_rgba = (0xff<<24) |
246 (gap_grey<<16) | (gap_grey<<8) | (gap_grey<<0);
248 unsigned *bp = (unsigned *)bar_rows[0];
249 for( int i=tw; --i>=0; ) *bp++ = gap_rgba;
251 for( int y=1; y<th; ++y ) {
252 unsigned *bp = (unsigned *)bar_rows[y];
253 if( tw > 0 ) *bp++ = gap_rgba;
254 for( int i=tw1; --i>0; ++bp ) *bp = c.rgba;
255 if( tw > 1 ) *bp = gap_rgba;
260 uint8_t *cp = bar_rows[0];
261 for( int x=0; x<tw; ++x ) {
262 cp[0] = cp[1] = cp[2] = gap_grey;
263 if( bpp > 3 ) cp[3] = 0xff;
267 for( int y=1; y<th; ++y ) {
268 uint8_t *cp = bar_rows[y];
270 cp[0] = cp[1] = cp[2] = gap_grey;
271 if( bpp > 3 ) cp[3] = 0xff;
274 for( int x=1; x<tw1; ++x ) {
275 cp[0] = c.r; cp[1] = c.g; cp[2] = c.b;
276 if( bpp > 3 ) cp[3] = 0xff;
280 cp[0] = cp[1] = cp[2] = gap_grey;
281 if( bpp > 3 ) cp[3] = 0xff;
288 VFrame *ResourcePixmap::change_picon_alpha(VFrame *picon_frame, int alpha)
290 uint8_t **picon_rows = picon_frame->get_rows();
291 int pw = picon_frame->get_w(), ph = picon_frame->get_h();
292 int color_model = picon_frame->get_color_model();
293 int bpp = BC_CModels::calculate_pixelsize(color_model);
294 VFrame *frame = new VFrame(pw, ph, BC_RGBA8888);
295 uint8_t **rows = frame->get_rows();
296 if( BC_CModels::has_alpha(color_model) && // fast path
297 BC_CModels::calculate_pixelsize(color_model) == sizeof(unsigned) ) {
298 unsigned a = alpha << 24;
299 for( int y=0; y<ph; ++y ) {
300 unsigned *bp = (unsigned *)picon_rows[y];
301 unsigned *rp = (unsigned *)rows[y];
302 for( int i=pw; --i>=0; ++bp,++rp ) *rp = (*bp & 0xffffff) | a;
306 for( int y=0; y<ph; ++y ) {
307 uint8_t *bp = picon_rows[y], *rp = rows[y];
308 for( int x=0; x<pw; ++x ) {
309 rp[0] = bp[0]; rp[1] = bp[1];
310 rp[2] = bp[2]; bp += bpp;
311 rp[3] = alpha; rp += 4;
318 void ResourcePixmap::draw_title(TrackCanvas *canvas,
319 Edit *edit, int64_t edit_x, int64_t edit_w,
320 int64_t pixmap_x, int64_t pixmap_w)
322 // coords relative to pixmap
323 int64_t total_x = edit_x - pixmap_x, total_w = edit_w;
324 int64_t x = total_x, w = total_w;
325 int left_margin = xS(10);
327 if( x < 0 ) { w -= -x; x = 0; }
328 if( w > pixmap_w ) w -= w - pixmap_w;
330 VFrame *title_bg = mwindow->theme->get_image("title_bg_data");
331 int color = mwindow->get_title_color(edit);
332 VFrame *title_bar = !color ? title_bg :
333 change_title_color(title_bg, color);
334 canvas->draw_3segmenth(x, 0, w, total_x, total_w, title_bar, this);
335 if( title_bar != title_bg ) delete title_bar;
337 char title[BCTEXTLEN];
338 edit->get_title(title);
339 canvas->set_color(mwindow->theme->title_color);
340 canvas->set_font(mwindow->theme->title_font);
342 // Justify the text on the left boundary of the edit if it is visible.
343 // Otherwise justify it on the left side of the screen.
344 int text_x = total_x + left_margin;
345 text_x = MAX(left_margin, text_x);
346 //printf("ResourcePixmap::draw_title 1 %d\n", text_x);
347 canvas->draw_text(text_x, // 2,
348 canvas->get_text_ascent(mwindow->theme->title_font) + yS(2),
349 title, strlen(title), this);
353 // Need to draw one more x
354 void ResourcePixmap::draw_audio_resource(TrackCanvas *canvas, Edit *edit, int x, int w)
357 if( !edit->asset && !edit->nested_edl ) return;
358 Indexable *indexable = 0;
359 if( edit->asset ) indexable = edit->asset;
360 if( edit->nested_edl ) indexable = edit->nested_edl;
361 // printf("ResourcePixmap::draw_audio_resource %d x=%d w=%d\n", __LINE__, x, w);
364 IndexState *index_state = indexable->index_state;
365 double asset_over_session = (double)indexable->get_sample_rate() /
366 mwindow->edl->session->sample_rate;
367 // Develop strategy for drawing
368 // printf("ResourcePixmap::draw_audio_resource %d %p %d\n",
371 // index_state->index_status);
372 switch( index_state->index_status )
374 case INDEX_NOTTESTED:
376 // Disabled. All files have an index.
377 // case INDEX_TOOSMALL:
378 // draw_audio_source(canvas, edit, x, w);
382 IndexFile indexfile(mwindow, indexable);
383 if( !indexfile.open_index() ) {
384 if( index_state->index_zoom >
385 mwindow->edl->local_session->zoom_sample *
386 asset_over_session ) {
387 draw_audio_source(canvas, edit, x, w);
390 indexfile.draw_index(canvas, this, edit, x, w);
392 indexfile.close_index();
397 if( !mwindow->preferences->rectify_audio ) {
398 int center_pixel = calculate_center_pixel(edit->track);
399 canvas->set_line_dashes(1);
400 canvas->set_color(mwindow->theme->zero_crossing_color);
401 canvas->draw_line(x, center_pixel, x + w, center_pixel, this);
402 canvas->set_line_dashes(0);
407 int ResourcePixmap::calculate_center_pixel(Track *track)
409 int rect_audio = mwindow->preferences->rectify_audio;
410 int center_pixel = !rect_audio ?
411 mwindow->edl->local_session->zoom_track / 2 :
412 mwindow->edl->local_session->zoom_track ;
413 if( track->show_titles() )
414 center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
418 void ResourcePixmap::draw_audio_source(TrackCanvas *canvas, Edit *edit, int x, int w)
421 Indexable *indexable = edit->get_source();
422 int center_pixel = calculate_center_pixel(edit->track);
423 int rect_audio = mwindow->preferences->rectify_audio;
424 int64_t scale_y = !rect_audio ?
425 mwindow->edl->local_session->zoom_y :
426 mwindow->edl->local_session->zoom_y * 2;
427 int y_max = center_pixel + scale_y / 2 - 1;
429 double project_zoom = mwindow->edl->local_session->zoom_sample;
430 FloatAutos *speed_autos = !edit->track->has_speed() ? 0 :
431 (FloatAutos *)edit->track->automation->autos[AUTOMATION_SPEED];
432 int64_t edit_position = (x + pixmap_x - edit_x) * project_zoom;
433 int64_t start_position = edit->startsource;
434 start_position += !speed_autos ? edit_position :
435 speed_autos->automation_integral(edit->startproject, edit_position, PLAY_FORWARD);
436 int64_t end_position = edit->startsource;
437 edit_position = (x + w + pixmap_x - edit_x) * project_zoom;
438 end_position += !speed_autos ? edit_position :
439 speed_autos->automation_integral(edit->startproject, edit_position, PLAY_FORWARD);
441 double session_sample_rate = mwindow->edl->session->sample_rate;
442 double asset_over_session = (double)indexable->get_sample_rate() / session_sample_rate;
443 start_position *= asset_over_session;
444 end_position *= asset_over_session;
445 int sample_size = end_position - start_position;
446 if( sample_size < 0 ) sample_size = 0;
447 int source_samples = sample_size + 1;
449 // Single sample zoom
450 if( mwindow->edl->local_session->zoom_sample == 1 ) {
453 canvas->set_color(mwindow->theme->audio_color);
455 if( indexable->is_asset ) {
456 mwindow->gui->unlock_window();
457 File *source = mwindow->audio_cache->check_out(edit->asset, mwindow->edl);
458 mwindow->gui->lock_window("draw_audio_source");
461 printf(_("ResourcePixmap::draw_audio_source: failed to check out %s for drawing.\n"), edit->asset->path);
465 source->set_audio_position(start_position);
466 source->set_channel(edit->channel);
467 buffer = new Samples(source_samples);
468 result = source->read_samples(buffer, source_samples);
469 mwindow->audio_cache->check_in(edit->asset);
472 if( mwindow->gui->render_engine &&
473 mwindow->gui->render_engine_id != indexable->id ) {
474 delete mwindow->gui->render_engine;
475 mwindow->gui->render_engine = 0;
478 if( !mwindow->gui->render_engine ) {
479 TransportCommand command;
480 command.command = NORMAL_FWD;
481 command.get_edl()->copy_all(edit->nested_edl);
482 command.change_type = CHANGE_ALL;
483 command.realtime = 0;
484 mwindow->gui->render_engine = new RenderEngine(0,
485 mwindow->preferences, 0, 0);
486 mwindow->gui->render_engine_id = edit->nested_edl->id;
487 mwindow->gui->render_engine->set_acache(mwindow->audio_cache);
488 mwindow->gui->render_engine->arm_command(&command);
491 if( mwindow->gui->render_engine->arender ) {
492 Samples *buffers[MAX_CHANNELS];
493 memset(buffers, 0, sizeof(buffers));
494 int nch = indexable->get_audio_channels(), ch = edit->channel;
495 for( int i=0; i<nch; ++i )
496 buffers[i] = new Samples(source_samples);
497 mwindow->gui->render_engine->arender->process_buffer(
498 buffers, source_samples, start_position);
499 for( int i=0; i<nch; ++i )
500 if( i != ch ) delete buffers[i];
501 buffer = buffers[ch];
506 double *samples = buffer->get_data();
507 double sample = !rect_audio ? samples[0] : fabs(samples[0]);
508 int y1 = center_pixel - sample * scale_y / 2;
509 int y2 = CLIP(y1, 0, y_max);
511 for( int x1=x; x1<w; ++x1 ) {
513 edit_position = (x1 + pixmap_x - edit_x) * project_zoom;
514 int64_t speed_position = edit->startsource;
515 speed_position += !speed_autos ? edit_position :
516 speed_autos->automation_integral(
517 edit->startproject, edit_position, PLAY_FORWARD);
518 int j = speed_position * asset_over_session - start_position;
519 CLAMP(j, 0, sample_size);
521 sample = !rect_audio ? samples[j] : fabs(samples[j]);
522 y1 = center_pixel - sample * scale_y / 2;
523 y2 = CLIP(y1, 0, y_max);
524 //printf("ResourcePixmap::draw_audio_source %d %d %d\n", __LINE__, y1, y2);
526 canvas->draw_bline(x1, y0, x2, y2, this);
528 canvas->draw_bline(x2, center_pixel, x2, y2, this);
535 edit_position = (x + pixmap_x - edit_x) * project_zoom;
536 int64_t speed_position = edit->startsource;
537 speed_position += !speed_autos ? edit_position :
538 speed_autos->automation_integral(
539 edit->startproject, edit_position, PLAY_FORWARD);
540 int64_t next_position = asset_over_session * speed_position;
541 // Multiple sample zoom
542 int first_pixel = 1, prev_y1 = -1, prev_y2 = y_max;
543 canvas->set_color(mwindow->theme->audio_color);
546 // Draw each pixel from the cache
547 //printf("ResourcePixmap::draw_audio_source %d x=%d w=%d\n", __LINE__, x, w);
548 for( int x2=x+w; x<x2; ++x ) {
549 int64_t prev_position = next_position;
550 edit_position = (x + pixmap_x - edit_x) * project_zoom;
551 speed_position = edit->startsource;
552 speed_position += !speed_autos ? edit_position :
553 speed_autos->automation_integral(
554 edit->startproject, edit_position, PLAY_FORWARD);
555 next_position = speed_position * asset_over_session;
556 // Starting sample of pixel relative to asset rate.
557 WaveCacheItem *item = mwindow->wave_cache->get_wave(indexable->id,
558 edit->channel, prev_position, next_position);
560 double item_low = !rect_audio ? item->low : fabs(item->low);
561 //printf("ResourcePixmap::draw_audio_source %d\n", __LINE__);
562 int y_lo = (int)(center_pixel - item_low * scale_y / 2);
563 int y1 = CLIP(y_lo, 0, y_max);
564 double item_high = !rect_audio ? item->high : fabs(item->high);
565 int y_hi = (int)(center_pixel - item_high * scale_y / 2);
566 int y2 = CLIP(y_hi, 0, y_max);
568 y_lo = MIN(y1,prev_y2);
569 y_hi = MAX(y2,prev_y1);
573 y_lo = y1; y_hi = y2;
575 prev_y1 = y1; prev_y2 = y2;
576 canvas->draw_line(x, !rect_audio ? y_lo : center_pixel, x, y_hi, this);
577 //printf("ResourcePixmap::draw_audio_source %d %d %d %d\n", __LINE__, x, y1, y2);
578 mwindow->wave_cache->unlock();
581 //printf("ResourcePixmap::draw_audio_source %d\n", __LINE__);
582 gui->resource_thread->add_wave(this,
583 canvas->pane->number, indexable, x,
584 edit->channel, prev_position, next_position);
585 first_pixel = 1; prev_y1 = -1; prev_y2 = y_max;
590 canvas->test_timer();
593 void ResourcePixmap::draw_wave(TrackCanvas *canvas,
594 int x, double high, double low)
596 int rect_audio = mwindow->preferences->rectify_audio;
597 if( rect_audio ) { low = fabs(low); high = fabs(high); }
598 int top_pixel = mwindow->edl->session->show_titles ? 0 :
599 mwindow->theme->get_image("title_bg_data")->get_h();
600 int center_pixel = !rect_audio ?
601 mwindow->edl->local_session->zoom_track / 2 + top_pixel :
602 mwindow->edl->local_session->zoom_track + top_pixel ;
603 int scale_y = !rect_audio ?
604 mwindow->edl->local_session->zoom_y / 2 :
605 mwindow->edl->local_session->zoom_y ;
606 int bottom_pixel = top_pixel + mwindow->edl->local_session->zoom_track;
607 int y1 = (int)(center_pixel - low * scale_y);
608 int y2 = (int)(center_pixel - high * scale_y);
609 CLAMP(y1, top_pixel, bottom_pixel);
610 CLAMP(y2, top_pixel, bottom_pixel);
611 canvas->set_color(mwindow->theme->audio_color);
612 canvas->draw_line(x, !rect_audio ? y1 : bottom_pixel, x, y2, this);
616 void ResourcePixmap::draw_video_resource(TrackCanvas *canvas,
617 Edit *edit, int64_t edit_x, int64_t edit_w, int64_t pixmap_x, int64_t pixmap_w,
618 int refresh_x, int refresh_w, int mode)
621 //BC_Signals::dump_stack();
623 // pixels spanned by a picon
624 int64_t picon_w = Units::round(edit->picon_w());
625 int64_t picon_h = edit->picon_h();
626 // if( picon_w <= 0 || picon_w > edit_w ) return;
627 // Don't draw video if picon is empty, or edit only hairline
628 if( picon_w < 1 || edit_w < 2 ) return;
629 // or bigger than edit and fills at less than 1.5 percent timeline
630 if( picon_w > edit_w && edit_w < canvas->get_w()/64 ) return;
632 // Frames spanned by a picon
633 double frame_w = edit->frame_w();
634 // pixels spanned by a frame
635 if( frame_w < picon_w ) frame_w = picon_w;
636 // Current pixel relative to pixmap
638 if( edit->track->show_titles() )
639 y += mwindow->theme->get_image("title_bg_data")->get_h();
641 // Frame in project touched by current pixel
642 FloatAutos *speed_autos = !edit->track->has_speed() ? 0 :
643 (FloatAutos *)edit->track->automation->autos[AUTOMATION_SPEED];
644 Indexable *indexable = edit->get_source();
645 double session_sample_rate = mwindow->edl->session->sample_rate;
646 double project_zoom = mwindow->edl->local_session->zoom_sample / session_sample_rate;
647 int skip_frames = Units::to_int64(((int64_t)refresh_x + pixmap_x - edit_x) / frame_w);
648 int x = Units::to_int64(skip_frames * frame_w) + edit_x - pixmap_x;
650 // Draw only cached frames
651 while( x < refresh_x + refresh_w ) {
652 int64_t edit_position =
653 edit->track->to_units((x + pixmap_x - edit_x) * project_zoom, 0);
654 int64_t speed_position = edit->startsource;
655 speed_position += !speed_autos ? edit_position :
656 speed_autos->automation_integral(
657 edit->startproject, edit_position, PLAY_FORWARD);
658 VFrame *picon_frame = indexable->id < 0 ? 0 :
659 mwindow->frame_cache->get_frame_ptr(speed_position, edit->channel,
660 mwindow->edl->session->frame_rate, BC_RGB888,
661 picon_w, picon_h, indexable->id);
662 int bg_color = gui->get_bg_color();
664 VFrame *frame = picon_frame;
665 int color = mwindow->get_title_color(edit);
667 int alpha = (~color >> 24) & 0xff;
668 frame = change_picon_alpha(picon_frame, alpha);
669 gui->set_bg_color(color & 0xffffff);
671 draw_vframe(frame, x, y, picon_w, picon_h, 0, 0);
672 if( frame != picon_frame ) {
674 gui->set_bg_color(bg_color);
676 mwindow->frame_cache->unlock();
678 else if( mode != IGNORE_THREAD ) {
679 // Set picon thread to draw in background
680 // printf("ResourcePixmap::draw_video_resource %d %d %lld\n",
681 // __LINE__, mwindow->frame_cache->total(), source_frame);
682 gui->resource_thread->add_picon(this, canvas->pane->number, x, y,
683 picon_w, picon_h, mwindow->edl->session->frame_rate,
684 speed_position, edit->channel, indexable);
687 canvas->test_timer();
693 void ResourcePixmap::draw_subttl_resource(TrackCanvas *canvas, Edit *edit, int x, int w)
695 SEdit *sedit = (SEdit *)edit;
696 char *text = sedit->get_text();
697 if( !*text || w < xS(10) ) return;
698 int center_pixel = canvas->resource_h() / 2;
699 if( edit->track->show_titles() )
700 center_pixel += mwindow->theme->get_image("title_bg_data")->get_h();
701 int64_t scale_y = mwindow->edl->local_session->zoom_y;
703 if( x0 < 0 ) x0 = -x0;
704 int x1 = (int)(pixmap_x - x0 + x);
705 int y_max = center_pixel + scale_y / 2 - 1;
706 int font = MEDIUMFONT, color = WHITE;
707 canvas->set_font(font);
708 canvas->set_color(color);
709 int ch = canvas->get_text_height(font);
710 int hh = canvas->get_text_height(font,text) + ch/2;
711 int y1 = y_max - hh - yS(10);
713 canvas->draw_text(x1, y1, text, -1, this);
716 void ResourcePixmap::dump()
718 printf("ResourcePixmap %p\n", this);
719 printf(" edit %jx edit_x %jd pixmap_x %jd pixmap_w %jd visible %d\n",
720 edit_id, edit_x, pixmap_x, pixmap_w, visible);