static void draw_mipmap_tree(int x, int y) { int z, level; for (level = 0; level < TEX_LEVELS; level++) { int size = TEX_SIZE >> level; glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_LOD, level); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LOD, level); for (z = 0; z < size; z++) { if (level == 0) { draw_slice(x + (z % (TEX_SIZE/2)) * (DRAW_SIZE + 5), y + (z / (TEX_SIZE/2)) * (DRAW_SIZE + 5), z / (float)size); } else { draw_slice(x + z * (DRAW_SIZE + 5), y + (level + 1) * (DRAW_SIZE + 10), z / (float)size); } } } }
void BBPS::draw_data_augmentation(){ double a = model_->a(); double b = model_->b(); complete_data_suf_.clear(); const std::vector<Ptr<BinomialData> > & data(model_->dat()); int nobs = data.size(); for (int i = 0; i < nobs; ++i) { int y = data[i]->y(); int n = data[i]->n(); double theta; int failure_count = 0; do { // In obscure corner cases where either a or b is very close // to zero you can get theta == 0.0 or theta == 1.0 // numerically. In that case just keep trying. If it takes // more than 100 tries then something is really wrong. theta = rbeta_mt(rng(), y + a, n - y + b); if (++failure_count > 100) { report_error( "Too many attempts at rbeta in " "BetaBinomialPosteriorSampler::draw_data_augmentation"); } } while (theta == 0.0 || theta == 1.0 || !std::isfinite(theta)); complete_data_suf_.update_raw(theta); } draw_slice(); }
int draw_slice_unfilled(struct Colors *colors, int tc, double cx, double cy, /* circle center, in normalized coords. */ double r, /* circle radius, in normalized units */ double a1, /* arc start position, in degrees */ double a2 /* arc size, in degrees */ ) { draw_slice(colors, 0, 0., 0., tc, cx, cy, r, a1, a2); return 0; }
int draw_slice_filled(struct Colors *colors, DCELL fc, /* fill color */ int tc, /* text color */ double cx, double cy, /* circle center, in normalized coords. */ double r, /* circle radius, in normalized units */ double a1, /* arc start position, in degrees */ double a2 /* arc size, in degrees */ ) { draw_slice(colors, 1, fc, fc, tc, cx, cy, r, a1, a2); return 0; }
void BBPS::draw(){ switch (sampling_method_){ case SLICE: draw_slice(); return; case DATA_AUGMENTATION: draw_data_augmentation(); return; default: draw_data_augmentation(); return; } }
static uint32_t draw_image(mp_image_t *mpi){ uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31; // if -dr or -slices then do nothing: if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE; if(mpi->flags&MP_IMGFLAG_PLANAR){ // copy planar: draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y); } else { // copy packed: mem2agpcpy_pic(vid_data, mpi->planes[0], // dst,src mpi->w*(mpi->bpp/8), mpi->h, // w,h bespitch*2, mpi->stride[0]); // dstride,sstride } return VO_TRUE; }
/** @brief Render a frame on the screen. * @param mpi mpi structure with the decoded frame inside * @return VO_TRUE on success, VO_ERROR on failure */ static uint32_t render_d3d_frame(mp_image_t *mpi) { /* Uncomment when direct rendering is implemented. * if (mpi->flags & MP_IMGFLAG_DIRECT) ... */ /* If the D3D device is uncooperative (not initialized), return success. The device will be probed for reinitialization in the next flip_page() */ if (!priv->d3d_device) return VO_TRUE; if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) goto skip_upload; if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Copy a planar frame. */ draw_slice(mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); goto skip_upload; } /* If we're here, then we should lock the rect and copy a packed frame */ if (!priv->locked_rect.pBits) { if (FAILED(IDirect3DSurface9_LockRect(priv->d3d_surface, &priv->locked_rect, NULL, 0))) { mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Surface lock failed.\n"); return VO_ERROR; } } memcpy_pic(priv->locked_rect.pBits, mpi->planes[0], mpi->stride[0], mpi->height, priv->locked_rect.Pitch, mpi->stride[0]); skip_upload: /* This unlock is used for both slice_draw path and render_d3d_frame path. */ if (FAILED(IDirect3DSurface9_UnlockRect(priv->d3d_surface))) { mp_msg(MSGT_VO, MSGL_V, "<vo_direct3d>Surface unlock failed.\n"); return VO_ERROR; } priv->locked_rect.pBits = NULL; if (FAILED(IDirect3DDevice9_BeginScene(priv->d3d_device))) { mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>BeginScene failed.\n"); return VO_ERROR; } if (priv->is_clear_needed) { IDirect3DDevice9_Clear(priv->d3d_device, 0, NULL, D3DCLEAR_TARGET, 0, 0, 0); priv->is_clear_needed = 0; } if (FAILED(IDirect3DDevice9_StretchRect(priv->d3d_device, priv->d3d_surface, &priv->fs_panscan_rect, priv->d3d_backbuf, &priv->fs_movie_rect, D3DTEXF_LINEAR))) { mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>Copying frame to the backbuffer failed.\n"); return VO_ERROR; } if (FAILED(IDirect3DDevice9_EndScene(priv->d3d_device))) { mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>EndScene failed.\n"); return VO_ERROR; } return VO_TRUE; }
static int draw_frame(uint8_t *src[]) { int stride[] = { src_stride, 0, 0}; return draw_slice(src,stride,src_width, src_height,0,0); }
static void draw_osd(struct vo *vo, struct osd_state *osd) { struct xvctx *ctx = vo->priv; struct mp_image img = get_xv_buffer(vo, ctx->current_buf); struct mp_rect *src = &ctx->src_rect; struct mp_rect *dst = &ctx->dst_rect; int dw = dst->x1 - dst->x0, dh = dst->y1 - dst->y0; int sw = src->x1 - src->x0, sh = src->y1 - src->y0; double xvpar = (double)dw / dh * sh / sw; struct mp_osd_res res = { .w = ctx->image_width, .h = ctx->image_height, .display_par = vo->monitor_par / xvpar, .video_par = vo->aspdat.par, }; osd_draw_on_image_bk(osd, res, osd->vo_pts, 0, ctx->osd_backup, &img); } static int redraw_frame(struct vo *vo) { struct xvctx *ctx = vo->priv; struct mp_image img = get_xv_buffer(vo, ctx->visible_buf); mp_draw_sub_backup_restore(ctx->osd_backup, &img); ctx->current_buf = ctx->visible_buf; return true; } static void flip_page(struct vo *vo) { struct xvctx *ctx = vo->priv; put_xvimage(vo, ctx->xvimage[ctx->current_buf]); /* remember the currently visible buffer */ ctx->visible_buf = ctx->current_buf; ctx->current_buf = (ctx->current_buf + 1) % ctx->num_buffers; XFlush(vo->x11->display); return; } static int draw_slice(struct vo *vo, uint8_t *image[], int stride[], int w, int h, int x, int y) { struct xvctx *ctx = vo->priv; uint8_t *dst; XvImage *current_image = ctx->xvimage[ctx->current_buf]; dst = current_image->data + current_image->offsets[0] + current_image->pitches[0] * y + x; memcpy_pic(dst, image[0], w, h, current_image->pitches[0], stride[0]); x /= 2; y /= 2; w /= 2; h /= 2; dst = current_image->data + current_image->offsets[1] + current_image->pitches[1] * y + x; if (ctx->image_format != IMGFMT_YV12) memcpy_pic(dst, image[1], w, h, current_image->pitches[1], stride[1]); else memcpy_pic(dst, image[2], w, h, current_image->pitches[1], stride[2]); dst = current_image->data + current_image->offsets[2] + current_image->pitches[2] * y + x; if (ctx->image_format == IMGFMT_YV12) memcpy_pic(dst, image[1], w, h, current_image->pitches[1], stride[1]); else memcpy_pic(dst, image[2], w, h, current_image->pitches[1], stride[2]); mp_draw_sub_backup_reset(ctx->osd_backup); return 0; } static mp_image_t *get_screenshot(struct vo *vo) { struct xvctx *ctx = vo->priv; struct mp_image img = get_xv_buffer(vo, ctx->visible_buf); struct mp_image *res = alloc_mpi(img.w, img.h, img.imgfmt); copy_mpi(res, &img); vf_clone_mpi_attributes(res, &img); // try to get an image without OSD mp_draw_sub_backup_restore(ctx->osd_backup, res); res->display_w = vo->aspdat.prew; res->display_h = vo->aspdat.preh; return res; } static uint32_t draw_image(struct vo *vo, mp_image_t *mpi) { struct xvctx *ctx = vo->priv; if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) ; // done else if (mpi->flags & MP_IMGFLAG_PLANAR) draw_slice(vo, mpi->planes, mpi->stride, mpi->w, mpi->h, 0, 0); else if (mpi->flags & MP_IMGFLAG_YUV) // packed YUV: memcpy_pic(ctx->xvimage[ctx->current_buf]->data + ctx->xvimage[ctx->current_buf]->offsets[0], mpi->planes[0], mpi->w * (mpi->bpp / 8), mpi->h, ctx->xvimage[ctx->current_buf]->pitches[0], mpi->stride[0]); else return false; mp_draw_sub_backup_reset(ctx->osd_backup); return true; } static int query_format(struct xvctx *ctx, uint32_t format) { uint32_t i; int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_ACCEPT_STRIDE; // FIXME! check for DOWN /* check image formats */ for (i = 0; i < ctx->formats; i++) { if (ctx->fo[i].id == format) return flag; //xv_format = fo[i].id; } return 0; }