Esempio n. 1
0
    bool ktx_texture::consistency_check() const
    {
        if (!check_header())
            return false;

        uint32_t block_dim = 0, bytes_per_block = 0;
        if ((!m_header.m_glType) || (!m_header.m_glFormat))
        {
            if ((m_header.m_glType) || (m_header.m_glFormat))
                return false;
            if (!ktx_get_ogl_fmt_desc(m_header.m_glInternalFormat, m_header.m_glType, block_dim, bytes_per_block))
                return false;
            if (block_dim == 1)
                return false;
            //if ((get_width() % block_dim) || (get_height() % block_dim))
            //   return false;
        }
        else
        {
            if (!ktx_get_ogl_fmt_desc(m_header.m_glFormat, m_header.m_glType, block_dim, bytes_per_block))
                return false;
            if (block_dim > 1)
                return false;
        }
        if ((m_block_dim != block_dim) || (m_bytes_per_block != bytes_per_block))
            return false;

        uint32_t total_expected_images = get_total_images();
        if (m_image_data.size() != total_expected_images)
            return false;

        for (uint32_t mip_level = 0; mip_level < get_num_mips(); mip_level++)
        {
            uint32_t mip_width, mip_height, mip_depth;
            get_mip_dim(mip_level, mip_width, mip_height, mip_depth);

            const uint32_t mip_row_blocks = (mip_width + m_block_dim - 1) / m_block_dim;
            const uint32_t mip_col_blocks = (mip_height + m_block_dim - 1) / m_block_dim;
            if ((!mip_row_blocks) || (!mip_col_blocks))
                return false;

            for (uint32_t array_element = 0; array_element < get_array_size(); array_element++)
            {
                for (uint32_t face = 0; face < get_num_faces(); face++)
                {
                    for (uint32_t zslice = 0; zslice < mip_depth; zslice++)
                    {
                        const uint8_vec &image_data = get_image_data(get_image_index(mip_level, array_element, face, zslice));

                        uint32_t expected_image_size = mip_row_blocks * mip_col_blocks * m_bytes_per_block;
                        if (image_data.size() != expected_image_size)
                            return false;
                    }
                }
            }
        }

        return true;
    }
Esempio n. 2
0
void SUV::build_bg_data()
{
// Audio settings
	channel_bg_data = new VFrame(get_image_data("channel_bg.png"));
	channel_position_data = new VFrame(get_image_data("channel_position.png"));

// Track bitmaps
	new_image("resource1024", "resource1024.png");
	new_image("resource512", "resource512.png");
	new_image("resource256", "resource256.png");
	new_image("resource128", "resource128.png");
	new_image("resource64", "resource64.png");
	new_image("resource32", "resource32.png");
	new_image("plugin_bg_data", "plugin_bg.png");
	new_image("title_bg_data", "title_bg.png");
	new_image("vtimebar_bg_data", "vwindow_timebar.png");
}
Esempio n. 3
0
void BlueDotTheme::build_bg_data()
{
// Audio settings
	channel_bg_data = new VFrame(get_image_data("channel_bg.png"));
	channel_position_data = new VFrame(get_image_data("channel_position.png"));

// Track bitmaps
	new_image("resource1024", "resource1024.png");
	new_image("resource512", "resource512.png");
	new_image("resource256", "resource256.png");
	new_image("resource128", "resource128.png");
	new_image("resource64", "resource64.png");
	new_image("resource32", "resource32.png");
//Graphic Copied from default. Improve!!
	new_image("plugin_bg_data", "plugin_bg.png");
	new_image("title_bg_data", "title_bg.png");
	new_image("vtimebar_bg_data", "vwindow_timebar.png");
}
Esempio n. 4
0
int make_font(struct fixed_font *font, const char *skin_id, const char *data_id)
{
	struct data_entry *entry;
	struct image_data *data;
	if (get_image_data(skin_id, data_id, NULL, &entry, &data))
		return -1;
	initialize_fixed_font(font, data->rgba, data->x + ' ', data->y + ' ',
			      data->w, data->h);
	put_image_data(entry, data);
	return 0;
}
void DefaultTheme::build_icons()
{
	mwindow_icon = new VFrame(get_image_data("heroine_icon.png"));
	vwindow_icon = new VFrame(get_image_data("heroine_icon.png"));
	cwindow_icon = new VFrame(get_image_data("heroine_icon.png"));
	awindow_icon = new VFrame(get_image_data("heroine_icon.png"));
	record_icon = new VFrame(get_image_data("heroine_icon.png"));
	clip_icon = new VFrame(get_image_data("clip_icon.png"));
}
Esempio n. 6
0
void SUV::build_overlays()
{
	keyframe_data = new VFrame(get_image_data("keyframe3.png"));
	camerakeyframe_data = new VFrame(get_image_data("camerakeyframe.png"));
	maskkeyframe_data = new VFrame(get_image_data("maskkeyframe.png"));
	modekeyframe_data = new VFrame(get_image_data("modekeyframe.png"));
	pankeyframe_data = new VFrame(get_image_data("pankeyframe.png"));
	projectorkeyframe_data = new VFrame(get_image_data("projectorkeyframe.png"));
}
Esempio n. 7
0
static VALUE
image_create_cairo_surface(VALUE obj)
{
    cairo_surface_t* cairo_surface;
    cairo_format_t cairo_format;
    unsigned char* data;
    VALUE surface;
    struct image_data* image = get_image_data(obj);

    data = xmalloc(sizeof(unsigned char)*RSTRING_LEN(image->buffer));
    MEMCPY(data, RSTRING_PTR(image->buffer), unsigned char, RSTRING_LEN(image->buffer));

    cairo_format = pixel_format_to_cairo_format(image->pixel_format);
    cairo_surface = cairo_image_surface_create_for_data(
	    data, cairo_format, (int)image->width, (int)image->height,
	    (int)image->stride*pixel_format_size(image->pixel_format));
    cairo_surface_set_user_data(cairo_surface, &cairo_data_key, data, image_surface_did_destroyed);
    surface = CRSURFACE2RVAL_WITH_DESTROY(cairo_surface);
    return surface;
}
Esempio n. 8
0
struct renderer_texture *make_texture(struct renderer *renderer,
				      const char *skin_id, const char *data_id)
{
	struct renderer_texture *texture = NULL;
	struct data_entry *entry;
	struct image_data *data;
	struct rgba rgba;
	if (get_image_data(skin_id, data_id, NULL, &entry, &data))
		goto bail_out;
	if (!initialize_rgba(&rgba, data->w, data->h)) {
		copy_rgba(data->rgba, *data->x, *data->y, data->w, data->h,
			  &rgba, 0, 0);
		texture = create_renderer_texture(renderer, &rgba);
		finalize_rgba(&rgba);
	} else
		log_w(_s("out of memory"));
	put_image_data(entry, data);
bail_out:
	return texture;
}
Esempio n. 9
0
static int initialize_menu_renderer_image(
	struct menu_renderer_image *self, struct renderer *renderer,
	const struct b6_clock *clock, float x, float y, float w, float h,
	float pos, float speed, const char *skin_id, const char *data_id,
	const struct renderer_observer_ops *ops)
{
	struct renderer_base *root = get_renderer_base(renderer);
	struct renderer_texture *texture[2];
	struct data_entry *entry;
	struct image_data *data;
	struct rgba rgba;
	self->base = NULL;
	if (get_image_data(skin_id, data_id, NULL, &entry, &data))
		return -1;
	initialize_rgba(&rgba, data->w, data->h);
	copy_rgba(data->rgba, *data->x, *data->y, data->w, data->h,
		  &rgba, 0, 0);
	texture[0] = create_renderer_texture_or_die(renderer, &rgba);
	make_shadow_rgba(&rgba);
	texture[1] = create_renderer_texture_or_die(renderer, &rgba);
	finalize_rgba(&rgba);
	self->base = create_renderer_base_or_die(renderer, root, "base", x, y);
	self->tile[1] = create_renderer_tile_or_die(
		renderer, create_renderer_base_or_die(renderer, self->base,
						      "shadow", 3, 3),
		0, 0, w, h, texture[1]);
	self->tile[0] = create_renderer_tile_or_die(
		renderer, create_renderer_base_or_die(renderer, self->base,
						      "image", 0, 0),
		0, 0, w, h, texture[0]);
	put_image_data(entry, data);
	if (ops->on_render == menu_renderer_image_on_render_v)
		setup_linear(&self->linear, clock, self->base->y, pos, speed);
	else
		setup_linear(&self->linear, clock, self->base->x, pos, speed);
	add_renderer_observer(renderer, setup_renderer_observer(
			&self->renderer_observer, data_id, ops));
	return 0;
}
Esempio n. 10
0
static VALUE
image_initialize(int argc, VALUE* argv, VALUE obj)
{
    struct image_data* image;
    VALUE buffer;
    rb_image_file_image_pixel_format_t pf;
    long wd, ht, st;

    process_arguments_of_image_initialize(argc, argv, &buffer, &pf, &wd, &ht, &st);
    assert(!NIL_P(buffer));
    assert(pf != RB_IMAGE_FILE_IMAGE_PIXEL_FORMAT_INVALID);
    assert(wd > 0);
    assert(ht > 0);
    assert(st >= wd);

    image = get_image_data(obj);
    image->buffer = buffer;
    image->pixel_format = pf;
    image->width = wd;
    image->height = ht;
    image->stride = st;

    return obj;
}
static gboolean
gst_video_info_update_from_image (GstVideoInfo * vip, GstVaapiImage * image)
{
  GstVideoFormat format;
  const guchar *data;
  guint i, num_planes, data_size, width, height;

  /* Reset format from image */
  format = gst_vaapi_image_get_format (image);
  gst_vaapi_image_get_size (image, &width, &height);
  gst_video_info_set_format (vip, format, width, height);

  num_planes = gst_vaapi_image_get_plane_count (image);
  g_return_val_if_fail (num_planes == GST_VIDEO_INFO_N_PLANES (vip), FALSE);

  /* Determine the base data pointer */
  data = get_image_data (image);
  g_return_val_if_fail (data != NULL, FALSE);
  data_size = gst_vaapi_image_get_data_size (image);

  /* Check that we don't have disjoint planes */
  for (i = 0; i < num_planes; i++) {
    const guchar *const plane = gst_vaapi_image_get_plane (image, i);
    if (plane - data > data_size)
      return FALSE;
  }

  /* Update GstVideoInfo structure */
  for (i = 0; i < num_planes; i++) {
    const guchar *const plane = gst_vaapi_image_get_plane (image, i);
    GST_VIDEO_INFO_PLANE_OFFSET (vip, i) = plane - data;
    GST_VIDEO_INFO_PLANE_STRIDE (vip, i) = gst_vaapi_image_get_pitch (image, i);
  }
  GST_VIDEO_INFO_SIZE (vip) = data_size;
  return TRUE;
}
void DefaultTheme::initialize()
{
	BC_Resources *resources = BC_WindowBase::get_resources();
	resources->generic_button_images = new_image_set(3, 
			"generic_up.png", 
			"generic_hi.png", 
			"generic_dn.png");
	resources->horizontal_slider_data = new_image_set(6,
			"hslider_fg_up.png",
			"hslider_fg_hi.png",
			"hslider_fg_dn.png",
			"hslider_bg_up.png",
			"hslider_bg_hi.png",
			"hslider_bg_dn.png");
	resources->progress_images = new_image_set(2,
			"progress_bg.png",
			"progress_hi.png");
	resources->tumble_data = new_image_set(4,
		"tumble_up.png",
		"tumble_hi.png",
		"tumble_botdn.png",
		"tumble_topdn.png");
	resources->listbox_button = new_image_set(3,
		"listbox_button_up.png",
		"listbox_button_hi.png",
		"listbox_button_dn.png");
	resources->listbox_column = new_image_set(3,
		"listbox_column_up.png",
		"listbox_column_hi.png",
		"listbox_column_dn.png");
	resources->pan_data = new_image_set(7,
			"pan_up.png", 
			"pan_hi.png", 
			"pan_popup.png", 
			"pan_channel.png", 
			"pan_stick.png", 
			"pan_channel_small.png", 
			"pan_stick_small.png");
	resources->pan_text_color = WHITE;

	resources->pot_images = new_image_set(3,
		"pot_up.png",
		"pot_hi.png",
		"pot_dn.png");

	resources->checkbox_images = new_image_set(5,
		"checkbox_up.png",
		"checkbox_uphi.png",
		"checkbox_checked.png",
		"checkbox_down.png",
		"checkbox_checkedhi.png");

	resources->radial_images = new_image_set(5,
		"radial_up.png",
		"radial_uphi.png",
		"radial_checked.png",
		"radial_down.png",
		"radial_checkedhi.png");

	resources->xmeter_images = new_image_set(6, 
		"xmeter_normal.png",
		"xmeter_green.png",
		"xmeter_red.png",
		"xmeter_yellow.png",
		"xmeter_white.png",
		"xmeter_over.png");
	resources->ymeter_images = new_image_set(6, 
		"ymeter_normal.png",
		"ymeter_green.png",
		"ymeter_red.png",
		"ymeter_yellow.png",
		"ymeter_white.png",
		"ymeter_over.png");

	resources->hscroll_data = new_image_set(10,
			"hscroll_center_up.png",
			"hscroll_center_hi.png",
			"hscroll_center_dn.png",
			"hscroll_bg.png",
			"hscroll_back_up.png",
			"hscroll_back_hi.png",
			"hscroll_back_dn.png",
			"hscroll_fwd_up.png",
			"hscroll_fwd_hi.png",
			"hscroll_fwd_dn.png");

	resources->vscroll_data = new_image_set(10,
			"vscroll_center_up.png",
			"vscroll_center_hi.png",
			"vscroll_center_dn.png",
			"vscroll_bg.png",
			"vscroll_back_up.png",
			"vscroll_back_hi.png",
			"vscroll_back_dn.png",
			"vscroll_fwd_up.png",
			"vscroll_fwd_hi.png",
			"vscroll_fwd_dn.png");

	resources->ok_images = new_button("ok.png", 
			"generic_up.png",
			"generic_hi.png",
			"generic_dn.png");

	resources->cancel_images = new_button("cancel.png", 
			"generic_up.png",
			"generic_hi.png",
			"generic_dn.png");


// Record windows
	rgui_batch = new_image("recordgui_batch.png");
	rgui_controls = new_image("recordgui_controls.png");
	rgui_list = new_image("recordgui_list.png");
	rmonitor_panel = new_image("recordmonitor_panel.png");
	rmonitor_meters = new_image("recordmonitor_meters.png");


// MWindow
	mbutton_left = new_image("mbutton_left.png");
	mbutton_right = new_image("mbutton_right.png");
	new_image("timebar_bg", "timebar_bg.png");
	new_image("timebar_brender", "timebar_brender.png");
	new_image("clock_bg", "mclock.png");
	new_image("patchbay_bg", "patchbay_bg.png");
	tracks_bg = new_image("tracks_bg.png");
	zoombar_left = new_image("zoombar_left.png");
	zoombar_right = new_image("zoombar_right.png");
	statusbar_left = new_image("statusbar_left.png");
	statusbar_right = new_image("statusbar_right.png");

// CWindow
	cpanel_bg = new_image("cpanel_bg.png");
	cbuttons_left = new_image("cbuttons_left.png");
	cbuttons_right = new_image("cbuttons_right.png");
	cmeter_bg = new_image("cmeter_bg.png");

// VWindow
	vbuttons_left = new_image("vbuttons_left.png");
	vbuttons_right = new_image("vbuttons_right.png");
	vmeter_bg = new_image("vmeter_bg.png");

	preferences_bg = new_image("preferences_bg.png");


	new_bg = new_image("new_bg.png");
	setformat_bg = new_image("setformat_bg2.png");


	timebar_view_data = new_image("timebar_view.png");

	setformat_w = 600;
	setformat_h = 560;
	setformat_x1 = 15;
	setformat_x2 = 100;

	setformat_x3 = 315;
	setformat_x4 = 415;
	setformat_y1 = 20;
	setformat_y2 = 85;
	setformat_y3 = 125;
	setformat_margin = 30;
	setformat_channels_x = 25;
	setformat_channels_y = 242;
	setformat_channels_w = 250;
	setformat_channels_h = 250;

	loadfile_pad = 70;
	browse_pad = 20;







	build_icons();
	build_bg_data();

	new_image_set("drawpatch_data", 5, "drawpatch_up.png", "drawpatch_hi.png", "drawpatch_checked.png", "drawpatch_dn.png", "drawpatch_checkedhi.png");
	new_image_set("expandpatch_data", 5, "expandpatch_up.png", "expandpatch_hi.png", "expandpatch_checked.png", "expandpatch_dn.png", "expandpatch_checkedhi.png");
	new_image_set("gangpatch_data", 5, "gangpatch_up.png", "gangpatch_hi.png", "gangpatch_checked.png", "gangpatch_dn.png", "gangpatch_checkedhi.png");
	new_image_set("mutepatch_data", 5, "mutepatch_up.png", "mutepatch_hi.png", "mutepatch_checked.png", "mutepatch_dn.png", "mutepatch_checkedhi.png");
	new_image_set("playpatch_data", 5, "playpatch_up.png", "playpatch_hi.png", "playpatch_checked.png", "playpatch_dn.png", "playpatch_checkedhi.png");
	new_image_set("recordpatch_data", 5, "recordpatch_up.png", "recordpatch_hi.png", "recordpatch_checked.png", "recordpatch_dn.png", "recordpatch_checkedhi.png");


	build_overlays();



	out_point = new_image_set(5,
		"out_up.png", 
		"out_hi.png", 
		"out_checked.png", 
		"out_dn.png", 
		"out_checkedhi.png");
	in_point = new_image_set(5,
		"in_up.png", 
		"in_hi.png", 
		"in_checked.png", 
		"in_dn.png", 
		"in_checkedhi.png");

	label_toggle = new_image_set(5,
		"labeltoggle_up.png", 
		"labeltoggle_uphi.png", 
		"label_checked.png", 
		"labeltoggle_dn.png", 
		"label_checkedhi.png");


	statusbar_cancel_data = new_image_set(3,
		"statusbar_cancel_up.png",
		"statusbar_cancel_hi.png",
		"statusbar_cancel_dn.png");


	VFrame *editpanel_up = new_image("editpanel_up.png");
	VFrame *editpanel_hi = new_image("editpanel_hi.png");
	VFrame *editpanel_dn = new_image("editpanel_dn.png");
	VFrame *editpanel_checked = new_image("editpanel_checked.png");
	VFrame *editpanel_checkedhi = new_image("editpanel_checkedhi.png");

	bottom_justify = new_button("bottom_justify.png", editpanel_up, editpanel_hi, editpanel_dn);
	center_justify = new_button("center_justify.png", editpanel_up, editpanel_hi, editpanel_dn);
	channel_data = new_button("channel.png", editpanel_up, editpanel_hi, editpanel_dn);
	new_button("copy.png", editpanel_up, editpanel_hi, editpanel_dn, "copy");
	new_button("cut.png", editpanel_up, editpanel_hi, editpanel_dn, "cut");
	new_button("fit.png", editpanel_up, editpanel_hi, editpanel_dn, "fit");
	new_button("fitautos.png", editpanel_up, editpanel_hi, editpanel_dn, "fitautos");
	new_button("inpoint.png", editpanel_up, editpanel_hi, editpanel_dn, "inbutton");
	new_button("label.png", editpanel_up, editpanel_hi, editpanel_dn, "labelbutton");
	left_justify = new_button("left_justify.png", editpanel_up, editpanel_hi, editpanel_dn);
	magnify_button_data = new_button("magnify.png", editpanel_up, editpanel_hi, editpanel_dn);
	middle_justify = new_button("middle_justify.png", editpanel_up, editpanel_hi, editpanel_dn);
	new_button("nextlabel.png", editpanel_up, editpanel_hi, editpanel_dn, "nextlabel");
	new_button("outpoint.png", editpanel_up, editpanel_hi, editpanel_dn, "outbutton");
	over_button = new_button("over.png", editpanel_up, editpanel_hi, editpanel_dn);
	overwrite_data = new_button("overwrite.png", editpanel_up, editpanel_hi, editpanel_dn);
	new_button("paste.png", editpanel_up, editpanel_hi, editpanel_dn, "paste");
	new_button("prevlabel.png", editpanel_up, editpanel_hi, editpanel_dn, "prevlabel");
	new_button("redo.png", editpanel_up, editpanel_hi, editpanel_dn, "redo");
	right_justify = new_button("right_justify.png", editpanel_up, editpanel_hi, editpanel_dn);
	splice_data = new_button("splice.png", editpanel_up, editpanel_hi, editpanel_dn);
	new_button("toclip.png", editpanel_up, editpanel_hi, editpanel_dn, "toclip");
	top_justify = new_button("top_justify.png", editpanel_up, editpanel_hi, editpanel_dn);
	new_button("undo.png", editpanel_up, editpanel_hi, editpanel_dn, "undo");
	wrench_data = new_button("wrench.png", editpanel_up, editpanel_hi, editpanel_dn);

// CWindow icons
	new_image("cwindow_inactive", "cwindow_inactive.png");
	new_image("cwindow_active", "cwindow_active.png");


	new_image_set("batch_render_start",
		3,
		"batchstart_up.png",
		"batchstart_hi.png",
		"batchstart_dn.png");
	new_image_set("batch_render_stop",
		3,
		"batchstop_up.png",
		"batchstop_hi.png",
		"batchstop_dn.png");
	new_image_set("batch_render_cancel",
		3,
		"batchcancel_up.png",
		"batchcancel_hi.png",
		"batchcancel_dn.png");

	new_toggle("arrow.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "arrow");
	new_toggle("autokeyframe.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "autokeyframe");
	camera_data = new_toggle("camera.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	crop_data = new_toggle("crop.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	new_toggle("ibeam.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi, "ibeam");
	magnify_data = new_toggle("magnify.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	mask_data = new_toggle("mask.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	proj_data = new_toggle("projector.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	protect_data = new_toggle("protect.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	show_meters = new_toggle("show_meters.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	titlesafe_data = new_toggle("titlesafe.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	tool_data = new_toggle("toolwindow.png", editpanel_up, editpanel_hi, editpanel_checked, editpanel_dn, editpanel_checkedhi);
	new_toggle("eyedrop.png", 
		editpanel_up, 
		editpanel_hi, 
		editpanel_checked, 
		editpanel_dn, 
		editpanel_checkedhi, 
		"cwindow_eyedrop");




	static VFrame **transport_bg = new_image_set(3,
		"transportup.png", 
		"transporthi.png", 
		"transportdn.png");
	build_transport("end", get_image_data("end.png"), transport_bg, 2);
	build_transport("fastfwd", get_image_data("fastfwd.png"), transport_bg, 1);
	build_transport("fastrev", get_image_data("fastrev.png"), transport_bg, 1);
	build_transport("play", get_image_data("play.png"), transport_bg, 1);
	build_transport("framefwd", get_image_data("framefwd.png"), transport_bg, 1);
	build_transport("framerev", get_image_data("framerev.png"), transport_bg, 1);
	build_transport("pause", get_image_data("pause.png"), transport_bg, 1);
	build_transport("record", get_image_data("record.png"), transport_bg, 1);
	build_transport("singleframe", get_image_data("singleframe.png"), transport_bg, 1);
	build_transport("reverse", get_image_data("reverse.png"), transport_bg, 1);
	build_transport("rewind", get_image_data("rewind.png"), transport_bg, 0);
	build_transport("stop", get_image_data("stop.png"), transport_bg, 1);
	build_transport("stoprec", get_image_data("stoprec.png"), transport_bg, 2);
	flush_images();

	title_font = MEDIUMFONT_3D;
	title_color = WHITE;
	recordgui_fixed_color = YELLOW;
	recordgui_variable_color = RED;

	channel_position_color = MEYELLOW;
	resources->meter_title_w = 25;
}
static gpointer
gst_vaapi_video_memory_map (GstVaapiVideoMemory * mem, gsize maxsize,
    guint flags)
{
  gpointer data;

  g_return_val_if_fail (mem, NULL);
  g_return_val_if_fail (mem->meta, NULL);

  if (mem->map_count == 0) {
    switch (flags & GST_MAP_READWRITE) {
      case 0:
        // No flags set: return a GstVaapiSurfaceProxy
        gst_vaapi_surface_proxy_replace (&mem->proxy,
            gst_vaapi_video_meta_get_surface_proxy (mem->meta));
        if (!mem->proxy)
          goto error_no_surface_proxy;
        if (!ensure_surface_is_current (mem))
          goto error_no_current_surface;
        mem->map_type = GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE;
        break;
      case GST_MAP_READ:
        // Only read flag set: return raw pixels
        if (!ensure_surface (mem))
          goto error_no_surface;
        if (!ensure_image (mem))
          goto error_no_image;
        if (!ensure_image_is_current (mem))
          goto error_no_current_image;
        if (!gst_vaapi_image_map (mem->image))
          goto error_map_image;
        mem->map_type = GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR;
        break;
      default:
        goto error_unsupported_map;
    }
  }

  switch (mem->map_type) {
    case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE:
      if (!mem->proxy)
        goto error_no_surface_proxy;
      data = mem->proxy;
      break;
    case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
      if (!mem->image)
        goto error_no_image;
      data = get_image_data (mem->image);
      break;
    default:
      goto error_unsupported_map_type;
  }
  mem->map_count++;
  return data;

  /* ERRORS */
error_unsupported_map:
  GST_ERROR ("unsupported map flags (0x%x)", flags);
  return NULL;
error_unsupported_map_type:
  GST_ERROR ("unsupported map type (%d)", mem->map_type);
  return NULL;
error_no_surface_proxy:
  GST_ERROR ("failed to extract GstVaapiSurfaceProxy from video meta");
  return NULL;
error_no_surface:
  GST_ERROR ("failed to extract VA surface from video buffer");
  return NULL;
error_no_current_surface:
  GST_ERROR ("failed to make surface current");
  return NULL;
error_no_image:
  GST_ERROR ("failed to extract VA image from video buffer");
  return NULL;
error_no_current_image:
  GST_ERROR ("failed to make image current");
  return NULL;
error_map_image:
  GST_ERROR ("failed to map VA image");
  return NULL;
}
Esempio n. 14
0
int			create_image(t_window *w, t_image *img)
{
	img->data = mlx_new_image(w->mlx_init, w->width, w->height);
	get_image_data(img);
	return (1);
}
Esempio n. 15
0
static VALUE
image_get_height(VALUE obj)
{
    struct image_data* image = get_image_data(obj);
    return LONG2NUM(image->height);
}
Esempio n. 16
0
static VALUE
image_get_row_stride(VALUE obj)
{
    struct image_data* image = get_image_data(obj);
    return LONG2NUM(image->stride);
}
Esempio n. 17
0
static VALUE
image_get_width(VALUE obj)
{
    struct image_data* image = get_image_data(obj);
    return LONG2NUM(image->width);
}
Esempio n. 18
0
static VALUE
image_get_pixel_format(VALUE obj)
{
    struct image_data* image = get_image_data(obj);
    return rb_image_file_image_pixel_format_to_symbol(image->pixel_format);
}
Esempio n. 19
0
VALUE
rb_image_file_image_get_buffer(VALUE obj)
{
    struct image_data* image = get_image_data(obj);
    return image->buffer;
}
Esempio n. 20
0
    bool ktx_texture::operator==(const ktx_texture &rhs) const
    {
        if (this == &rhs)
            return true;

// This is not super deep because I want to avoid poking around into internal state (such as the header)

#define CMP(x)      \
    if (x != rhs.x) \
        return false;
        CMP(get_ogl_internal_fmt());
        CMP(get_width());
        CMP(get_height());
        CMP(get_depth());
        CMP(get_num_mips());
        CMP(get_array_size());
        CMP(get_num_faces());
        CMP(is_compressed());
        CMP(get_block_dim());

        // The image fmt/type shouldn't matter with compressed textures.
        if (!is_compressed())
        {
            CMP(get_ogl_fmt());
            CMP(get_ogl_type());
        }

        CMP(get_total_images());

        CMP(get_opposite_endianness());

        // Do an order insensitive key/value comparison.
        dynamic_string_array lhs_keys;
        get_keys(lhs_keys);

        dynamic_string_array rhs_keys;
        rhs.get_keys(rhs_keys);

        if (lhs_keys.size() != rhs_keys.size())
            return false;

        lhs_keys.sort(dynamic_string_less_than_case_sensitive());
        rhs_keys.sort(dynamic_string_less_than_case_sensitive());

        for (uint32_t i = 0; i < lhs_keys.size(); i++)
            if (lhs_keys[i].compare(rhs_keys[i], true) != 0)
                return false;

        for (uint32_t i = 0; i < lhs_keys.size(); i++)
        {
            uint8_vec lhs_data, rhs_data;
            if (!get_key_value_data(lhs_keys[i].get_ptr(), lhs_data))
                return false;
            if (!get_key_value_data(lhs_keys[i].get_ptr(), rhs_data))
                return false;
            if (lhs_data != rhs_data)
                return false;
        }

        // Compare images.
        for (uint32_t l = 0; l < get_num_mips(); l++)
        {
            for (uint32_t a = 0; a < get_array_size(); a++)
            {
                for (uint32_t f = 0; f < get_num_faces(); f++)
                {
                    for (uint32_t z = 0; z < get_depth(); z++)
                    {
                        const uint8_vec &lhs_img = get_image_data(l, a, f, z);
                        const uint8_vec &rhs_img = rhs.get_image_data(l, a, f, z);

                        if (lhs_img != rhs_img)
                            return false;
                    }
                }
            }
        }
#undef CMP
        return true;
    }
Esempio n. 21
0
    bool ktx_texture::write_to_stream(data_stream_serializer &serializer, bool no_keyvalue_data) const
    {
        if (!consistency_check())
        {
            VOGL_ASSERT_ALWAYS;
            return false;
        }

        memcpy(m_header.m_identifier, s_ktx_file_id, sizeof(m_header.m_identifier));
        m_header.m_endianness = m_opposite_endianness ? KTX_OPPOSITE_ENDIAN : KTX_ENDIAN;

        if (m_block_dim == 1)
        {
            m_header.m_glTypeSize = ktx_get_ogl_type_size(m_header.m_glType);
            m_header.m_glBaseInternalFormat = m_header.m_glFormat;
        }
        else
        {
            m_header.m_glBaseInternalFormat = ktx_get_ogl_compressed_base_internal_fmt(m_header.m_glInternalFormat);
        }

        m_header.m_bytesOfKeyValueData = 0;
        if (!no_keyvalue_data)
        {
            for (uint32_t i = 0; i < m_key_values.size(); i++)
                m_header.m_bytesOfKeyValueData += sizeof(uint32_t) + ((m_key_values[i].size() + 3) & ~3);
        }

        if (m_opposite_endianness)
            m_header.endian_swap();

        bool success = (serializer.write(&m_header, sizeof(m_header), 1) == 1);

        if (m_opposite_endianness)
            m_header.endian_swap();

        if (!success)
            return success;

        uint32_t total_key_value_bytes = 0;
        const uint8_t padding[3] = { 0, 0, 0 };

        if (!no_keyvalue_data)
        {
            for (uint32_t i = 0; i < m_key_values.size(); i++)
            {
                uint32_t key_value_size = m_key_values[i].size();

                if (m_opposite_endianness)
                    key_value_size = utils::swap32(key_value_size);

                success = (serializer.write(&key_value_size, sizeof(key_value_size), 1) == 1);
                total_key_value_bytes += sizeof(key_value_size);

                if (m_opposite_endianness)
                    key_value_size = utils::swap32(key_value_size);

                if (!success)
                    return false;

                if (key_value_size)
                {
                    if (serializer.write(&m_key_values[i][0], key_value_size, 1) != 1)
                        return false;
                    total_key_value_bytes += key_value_size;

                    uint32_t num_padding = 3 - ((key_value_size + 3) % 4);
                    if ((num_padding) && (serializer.write(padding, num_padding, 1) != 1))
                        return false;
                    total_key_value_bytes += num_padding;
                }
            }
            (void)total_key_value_bytes;
        }

        VOGL_ASSERT(total_key_value_bytes == m_header.m_bytesOfKeyValueData);

        for (uint32_t mip_level = 0; mip_level < get_num_mips(); mip_level++)
        {
            uint32_t mip_width, mip_height, mip_depth;
            get_mip_dim(mip_level, mip_width, mip_height, mip_depth);

            const uint32_t mip_row_blocks = (mip_width + m_block_dim - 1) / m_block_dim;
            const uint32_t mip_col_blocks = (mip_height + m_block_dim - 1) / m_block_dim;
            if ((!mip_row_blocks) || (!mip_col_blocks))
                return false;

            uint32_t image_size = mip_row_blocks * mip_col_blocks * m_bytes_per_block;
            if ((m_header.m_numberOfArrayElements) || (get_num_faces() == 1))
                image_size *= (get_array_size() * get_num_faces() * mip_depth);

            if (!image_size)
            {
                VOGL_ASSERT_ALWAYS;
                return false;
            }

            if (m_opposite_endianness)
                image_size = utils::swap32(image_size);

            success = (serializer.write(&image_size, sizeof(image_size), 1) == 1);

            if (m_opposite_endianness)
                image_size = utils::swap32(image_size);

            if (!success)
                return false;

            uint32_t total_mip_size = 0;
            uint32_t total_image_data_size = 0;

            if ((!m_header.m_numberOfArrayElements) && (get_num_faces() == 6))
            {
                // plain non-array cubemap
                for (uint32_t face = 0; face < get_num_faces(); face++)
                {
                    const uint8_vec &image_data = get_image_data(get_image_index(mip_level, 0, face, 0));
                    if ((!image_data.size()) || (image_data.size() != image_size))
                        return false;

                    if (m_opposite_endianness)
                    {
                        uint8_vec tmp_image_data(image_data);
                        utils::endian_swap_mem(&tmp_image_data[0], tmp_image_data.size(), m_header.m_glTypeSize);
                        if (serializer.write(&tmp_image_data[0], tmp_image_data.size(), 1) != 1)
                            return false;
                    }
                    else if (serializer.write(&image_data[0], image_data.size(), 1) != 1)
                        return false;

                    // Not +=, but =, because of the silly image_size plain cubemap exception in the KTX file format
                    total_image_data_size = image_data.size();

                    uint32_t num_cube_pad_bytes = 3 - ((image_data.size() + 3) % 4);
                    if ((num_cube_pad_bytes) && (serializer.write(padding, num_cube_pad_bytes, 1) != 1))
                        return false;

                    total_mip_size += image_size + num_cube_pad_bytes;
                }
            }
            else
            {
                // 1D, 2D, 3D (normal or array texture), or array cubemap
                for (uint32_t array_element = 0; array_element < get_array_size(); array_element++)
                {
                    for (uint32_t face = 0; face < get_num_faces(); face++)
                    {
                        for (uint32_t zslice = 0; zslice < mip_depth; zslice++)
                        {
                            const uint8_vec &image_data = get_image_data(get_image_index(mip_level, array_element, face, zslice));
                            if (!image_data.size())
                                return false;

                            if (m_opposite_endianness)
                            {
                                uint8_vec tmp_image_data(image_data);
                                utils::endian_swap_mem(&tmp_image_data[0], tmp_image_data.size(), m_header.m_glTypeSize);
                                if (serializer.write(&tmp_image_data[0], tmp_image_data.size(), 1) != 1)
                                    return false;
                            }
                            else if (serializer.write(&image_data[0], image_data.size(), 1) != 1)
                                return false;

                            total_image_data_size += image_data.size();

                            total_mip_size += image_data.size();
                        }
                    }
                }

                uint32_t num_mip_pad_bytes = 3 - ((total_mip_size + 3) % 4);
                if ((num_mip_pad_bytes) && (serializer.write(padding, num_mip_pad_bytes, 1) != 1))
                    return false;
                total_mip_size += num_mip_pad_bytes;
            }

            VOGL_ASSERT((total_mip_size & 3) == 0);
            VOGL_ASSERT(total_image_data_size == image_size);
        }

        return true;
    }