// [[Rcpp::export]] Rcpp::List CPL_get_rgdal_drivers(int dummy) { int ndr = GetGDALDriverManager()->GetDriverCount(); Rcpp::CharacterVector name(ndr); Rcpp::CharacterVector long_name(ndr); Rcpp::LogicalVector create(ndr); Rcpp::LogicalVector copy(ndr); Rcpp::LogicalVector vattr(ndr); Rcpp::LogicalVector rattr(ndr); Rcpp::LogicalVector vsi_attr(ndr); for (int i = 0; i < ndr; i++) { GDALDriver *pDriver = GetGDALDriverManager()->GetDriver(i); name(i) = GDALGetDriverShortName( pDriver ); long_name(i) = GDALGetDriverLongName( pDriver ); create(i) = (pDriver->GetMetadataItem(GDAL_DCAP_CREATE) != NULL); copy(i) = (pDriver->GetMetadataItem(GDAL_DCAP_CREATECOPY) != NULL); vattr(i) = (pDriver->GetMetadataItem(GDAL_DCAP_VECTOR) != NULL); rattr(i) = (pDriver->GetMetadataItem(GDAL_DCAP_RASTER) != NULL); vsi_attr(i) = (pDriver->GetMetadataItem(GDAL_DCAP_VIRTUALIO) != NULL); } return Rcpp::DataFrame::create( Rcpp::Named("name") = name, Rcpp::Named("long_name") = long_name, Rcpp::Named("write") = create, Rcpp::Named("copy") = copy, Rcpp::Named("is_raster") = rattr, Rcpp::Named("is_vector") = vattr, Rcpp::Named("vsi") = vsi_attr); }
/*======================================================================== * rdeckwave4_mouse_handler *========================================================================*/ void rdeckwave4_mouse_handler(rwid * wid, int button_id, int button_state) { const int chan_state = (!wid->wdata) ? rval_get( chan0_state ) : rval_get( chan1_state ); /* playing => punch */ if ( chan_state == R_CHAN_LOADING_PLAY || chan_state == R_CHAN_PLAY ) { rdh_double* punch = (!wid->wdata) ? rdh_addr( chan0_punch ) : rdh_addr( chan1_punch ); if ( button_state == GLFW_PRESS ) { switch ( button_id ) { case GLFW_MOUSE_BUTTON_LEFT: { rdh_double_set( punch, 1 - R_PUNCH); } break; case GLFW_MOUSE_BUTTON_RIGHT: { rdh_double_set( punch, 1 + R_PUNCH ); break; } default: { ; } } }else { rdh_double_set( punch, 1); } } /* not playing => loop marker */ else{ rchan * chan = &(rattr(chans)[wid->wdata]); rtrack* track = chan->track; const double x_pushed = (double)rattr(mouse_x); const double pos = rchan_pos( chan, wid->x, wid->w, x_pushed ); if ( button_id == GLFW_MOUSE_BUTTON_LEFT ) { track->loop_in = pos; if ( pos > track->loop_out ) { track->loop_out = pos; } }else { track->loop_out = pos; if ( pos < track->loop_in ) { track->loop_in = pos; } } } }
/*======================================================================== * rdeckwave4_draw * * *========================================================================*/ void rdeckwave4_draw(rwid* wid) { rchan * chan = &(rattr(chans)[wid->wdata]); if ( rattr( resize_flag ) || rjog_shall_compute_tex(wid) ) { rwid_blit_black( wid ); rdeckwave4_postfx(wid); } if ( rattr( resize_flag ) || chan->buffer_len ) { rwid_blit_black( wid ); rdeckwave4_vertexrender(wid); rdeckwave4_postfx(wid); } }
/*======================================================================== * rdisplay_mainloop_cb_add * * *========================================================================*/ void rdisplay_mainloop_cb_add(int* state, void (*f_action)(void)) { rlspoll_cb* ls = &(rattr(poll_cbs)); rpoll_cb* pc = R_CALLOC( 1, sizeof( rpoll_cb ) ); pc->state = state; pc->f_action = f_action; rlspoll_cb_add( ls, pc ); }
/*======================================================================== * rvslider2_draw * * *========================================================================*/ void rvslider2_draw(rwid* wid) { rcairogl* cairogl = rlsrcairogl_get(&wid->textures, 0 ); const int tex_changed = rvslider2_shall_compute_tex(wid); const int vertex_changed = rvslider2_shall_compute_vertex(wid); /* texture render */ if ( rattr( resize_flag ) || tex_changed ) { rvslider2_texrender( wid ); rcairogl_texbind( cairogl, wid->w, wid->h ); } /* vertex render */ if ( rattr( resize_flag ) || tex_changed || vertex_changed ) { rcairogl_texblit(cairogl, wid->x, wid->y, wid->w, wid->h ); rvslider2_vertexrender(wid); } }
/*======================================================================== * rdisplay_poll_cbs * * *========================================================================*/ void rdisplay_poll_cbs( void ) { rlspoll_cb* ls = &(rattr(poll_cbs)); rlspoll_cb_iterator iter; rpoll_cb* poll_cb = rlspoll_cb_first( &iter, ls ); while (poll_cb) { if (*(poll_cb->state)) { poll_cb->f_action(); } poll_cb = rlspoll_cb_next( &iter ); } }
/*======================================================================== * rdisplay_poll_user_evts * * *========================================================================*/ void rdisplay_poll_user_evts( void ) { ruser_evtQ* Q = &(rattr(user_evtQ)); size_t i; rmutex_stack_lock( user_evts_mutex ); for (i = 0; i < Q->len; i++) { Q->f_evts[i](); Q->f_evts[i] = NULL; } Q->len = 0; rmutex_stack_unlock( user_evts_mutex ); }
static void relem(unsigned verb, SkStream& s, BMLW& rec, SkXMLWriter& writer) { int data = verb & 31; verb >>= 5; int elemIndex; if (verb == kStartElem_Value_Verb) { elemIndex = rec.fNextElem; // record before the ++ set(rec.fElems, rec.fNextElem++, s, data); } else { SkASSERT(verb == kStartElem_Index_Verb); elemIndex = rdata(s, data); } writer.startElement(rec.fElems[elemIndex]); for (;;) { verb = rbyte(s); switch (verb >> 5) { case kAttr_Value_Value_Verb: case kAttr_Value_Index_Verb: case kAttr_Index_Value_Verb: case kAttr_Index_Index_Verb: rattr(verb, s, rec, writer); break; case kStartElem_Value_Verb: case kStartElem_Index_Verb: relem(verb, s, rec, writer); break; case kEndElem_Verb: writer.endElement(); return; default: SkDEBUGFAIL("bad verb"); } } }
/*======================================================================== * rdisplay_ratio_compute * * *========================================================================*/ void rdisplay_ratio_compute(void) { double lratio, lratio_width, lratio_height; if ( (( rval_get( window_mode ) ) == RDISPLAY_FULLSCREEN) ) { lratio_width = (double)( rval_get( desktop_width ) ) / (double)( rattr( design_width ) ); lratio_height = (double)( rval_get( desktop_height ) ) / (double)( rattr( design_height ) ); } else { lratio_width = (double)( rval_get( window_width ) ) / (double)( rattr( design_width ) ); lratio_height = (double)( rval_get( window_height ) ) / (double)( rattr( design_height ) ); } lratio = R_MIN( lratio_width, lratio_height); rval_set( rdh_double, ratio_width, lratio_width); rval_set( rdh_double, ratio_height, lratio_height); rval_set( rdh_double, ratio, lratio); /* styles refresh */ { rlsstyle_iterator iter; rlsstyle* ls = &( rattr( styles ) ); rstyle* style = rlsstyle_first( &iter, ls ); while (style) { rstyle_refresh( style, lratio, lratio_width, lratio_height); style = rlsstyle_next( &iter ); } } /* wid ratio/blit */ { rlswid_iterator iter; rlswid* ls = &( rattr( wids ) ); rwid* wid = rlswid_first( &iter, ls ); while (wid) { /* [!] wid list shall sorted with parents first */ rwid_bb_compute( wid ); wid = rlswid_next( &iter ); } } }
/*======================================================================== * rdeckwave4_vertexrender * * *========================================================================*/ void rdeckwave4_vertexrender(rwid * wid) { const int x = wid->x; const int y = wid->y; const int w = wid->w; const int h = wid->h; const int h_half = wid->h >> 1; const int w_half = wid->w >> 1; const int h_half_y = h_half + y; int i; int x2; rchan * chan = &(rattr(chans)[wid->wdata]); rssstyle* sss = rwid_style_get( wid ); rRGB* prgb = &sss->colors[rcolor_fg]; rHSL hsl; rRGB rgb_mod; rdh_int* chan_state = (!wid->wdata) ? rdh_addr( chan0_state ) : rdh_addr( chan1_state ); rtrack* track = chan->track; const int state = rdh_get( chan_state ); if ( ( state != R_CHAN_LOADING_STOP ) && ( state != R_CHAN_LOADING_PLAY ) ) { int offset_waveform = ((int)(chan->wavebuffer_offset) / R_WAVEFORM_SAMPLING); glBegin(GL_LINES); i = w; x2 = x; do { const float min = (offset_waveform > w_half) ? chan->waveform_min[offset_waveform - w_half ] : 0; const float max = (offset_waveform > w_half) ? chan->waveform_max[offset_waveform - w_half ] : 0; rcolor_rgb_2_hsl(prgb, &hsl); hsl.l = 0.1 + (0.5 * max); hsl.h *= (0.9 + (0.1 * max)); rcolor_hsl_2_rgb(&hsl, &rgb_mod); rglColor3(rgb_mod); glVertex2d(x2, h_half_y + ( min * h_half)); glVertex2d(x2, h_half_y + ( max * h_half)); x2++; offset_waveform++; } while (--i); glEnd(); } if ( track ) { const double off_min = chan->wavebuffer_offset - (w_half * R_WAVEFORM_SAMPLING); const double off_max = off_min + w * R_WAVEFORM_SAMPLING; const double marker_size = (w * 0.01 ); glColor3f(0.7f, 0.7f, 0.7f); /* marker out */ { const double loop_out = track->loop_out; if ( (loop_out < off_max) && (loop_out > off_min) ) { const double x_pos = x + ( w * (( loop_out - chan->wavebuffer_offset + (w_half * R_WAVEFORM_SAMPLING) ) / ( off_max - off_min ) ) ); glBegin(GL_TRIANGLES); glVertex2d(x_pos, y + h ); glVertex2d(x_pos + marker_size, y + h ); glVertex2d(x_pos, y + h - marker_size ); glEnd(); } } /* marker in */ if (track) { const double loop_in = track->loop_in; if ( (loop_in < off_max) && (loop_in > off_min) ) { const double x_pos = x + ( w * (( loop_in - chan->wavebuffer_offset + (w_half * R_WAVEFORM_SAMPLING) ) / ( off_max - off_min ) ) ); glBegin(GL_TRIANGLES); glVertex2d(x_pos, y + h ); glVertex2d(x_pos - marker_size, y + h ); glVertex2d(x_pos, y + h - marker_size ); glEnd(); } } } chan->last_audio_buffer_offset = chan->audio_buffer_offset; }