bool vogl_default_framebuffer_state::deserialize(const json_node &node, const vogl_blob_manager &blob_manager)
{
    clear();

    if (!node.has_object("attribs"))
        return false;

    if (!m_fb_attribs.deserialize(*node.find_child_object("attribs")))
        return false;

    const json_node *pFramebuffers_array = node.find_child_array("framebuffers");
    if (pFramebuffers_array)
    {
        for (uint i = 0; i < math::minimum<uint>(cDefFramebufferTotal, pFramebuffers_array->size()); i++)
        {
            if ((pFramebuffers_array->is_child_object(i)) && (pFramebuffers_array->get_child(i)->size()))
            {
                if (!m_textures[i].deserialize(*pFramebuffers_array->get_child(i), blob_manager))
                    return false;
            }
        }
    }

    m_valid = true;

    return true;
}
示例#2
0
bool vogl_vao_state::serialize(json_node &node, vogl_blob_manager &blob_manager) const
{
    VOGL_FUNC_TRACER

    VOGL_NOTE_UNUSED(blob_manager);

    if (!m_is_valid)
        return false;

    node.add_key_value("handle", m_snapshot_handle);
    node.add_key_value("has_been_bound", m_has_been_bound);
    node.add_key_value("element_array_binding", m_element_array_binding);

    json_node &vertex_attribs_array = node.add_array("vertex_attribs");
    for (uint32_t i = 0; i < m_vertex_attribs.size(); i++)
    {
        const vogl_vertex_attrib_desc &desc = m_vertex_attribs[i];

        json_node &attribs_obj = vertex_attribs_array.add_object();
        attribs_obj.add_key_value("pointer", desc.m_pointer);
        attribs_obj.add_key_value("array_binding", desc.m_array_binding);
        attribs_obj.add_key_value("size", desc.m_size);
        attribs_obj.add_key_value("type", get_gl_enums().find_gl_name(desc.m_type));
        attribs_obj.add_key_value("stride", desc.m_stride);
        attribs_obj.add_key_value("integer", desc.m_integer);
        attribs_obj.add_key_value("divisor", desc.m_divisor);
        attribs_obj.add_key_value("enabled", desc.m_enabled);
        attribs_obj.add_key_value("normalized", desc.m_normalized);
    }

    return true;
}
示例#3
0
文件: json.cpp 项目: nitsel88/acl
json::json(const json_node& node)
{
	json_ = acl_json_create(node.get_json_node());
	root_ = NEW json_node(json_->root, this);
	buf_ = NULL;
	iter_ = NULL;
}
示例#4
0
bool vogl_vao_state::deserialize(const json_node &node, const vogl_blob_manager &blob_manager)
{
    VOGL_FUNC_TRACER

    VOGL_NOTE_UNUSED(blob_manager);

    clear();

    m_snapshot_handle = node.value_as_uint32("handle");
    m_has_been_bound = node.value_as_bool("has_been_bound", true);
    m_element_array_binding = node.value_as_uint32("element_array_binding");

    const json_node *pVertex_attribs_array = node.find_child_array("vertex_attribs");
    if (!pVertex_attribs_array)
        return false;

    m_vertex_attribs.resize(pVertex_attribs_array->size());
    for (uint32_t i = 0; i < pVertex_attribs_array->size(); i++)
    {
        vogl_vertex_attrib_desc &desc = m_vertex_attribs[i];

        const json_node *pAttribs_obj = pVertex_attribs_array->get_value_as_object(i);
        if (!pAttribs_obj)
            return false;

        desc.m_pointer = static_cast<vogl_trace_ptr_value>(pAttribs_obj->value_as_uint64("pointer"));

        // Fallback for old traces
        if ((!i) && (pAttribs_obj->has_key("element_array_binding")))
            m_element_array_binding = pAttribs_obj->value_as_uint32("element_array_binding");

        desc.m_array_binding = pAttribs_obj->value_as_uint32("array_binding");
        desc.m_size = pAttribs_obj->value_as_int("size");
        desc.m_type = vogl_get_json_value_as_enum(*pAttribs_obj, "type");
        desc.m_stride = pAttribs_obj->value_as_int("stride");
        desc.m_integer = pAttribs_obj->value_as_bool("integer");
        desc.m_divisor = pAttribs_obj->value_as_uint32("divisor");
        desc.m_enabled = pAttribs_obj->value_as_bool("enabled");
        desc.m_normalized = pAttribs_obj->value_as_bool("normalized");
    }

    m_is_valid = true;

    return true;
}
bool vogl_renderbuffer_desc::serialize(json_node &node) const
{
    VOGL_FUNC_TRACER

    node.add_key_value("width", m_width);
    node.add_key_value("height", m_height);
    node.add_key_value("internal_format", g_gl_enums.find_name(m_internal_format, "gl"));
    node.add_key_value("samples", m_samples);
    node.add_key_value("red_size", m_red_size);
    node.add_key_value("green_size", m_green_size);
    node.add_key_value("blue_size", m_blue_size);
    node.add_key_value("alpha_size", m_alpha_size);
    node.add_key_value("depth_size", m_depth_size);
    node.add_key_value("stencil_size", m_stencil_size);

    return true;
}
bool vogl_default_framebuffer_state::serialize(json_node &node, vogl_blob_manager &blob_manager) const
{
    if (!m_valid)
        return false;

    if (!m_fb_attribs.serialize(node.add_object("attribs")))
        return false;

    json_node &framebuffers_array = node.add_array("framebuffers");
    for (uint i = 0; i < cDefFramebufferTotal; i++)
    {
        json_node &object_node = framebuffers_array.add_object();
        if (m_textures[i].is_valid())
        {
            if (!m_textures[i].serialize(object_node, blob_manager))
                return false;
        }
    }

    return true;
}
bool vogl_display_list::deserialize(const json_node &node, const vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes)
{
    VOGL_FUNC_TRACER

    clear();

    m_handle = node.value_as_uint32("handle");
    m_valid = node.value_as_bool("valid", true);
    m_generating = node.value_as_bool("generating");
    m_xfont = node.value_as_bool("xfont");

    if (m_xfont)
    {
        m_xfont_glyph = node.value_as_int("xfont_glyph");
        m_xfont_name = node.value_as_string("xfont_name");
    }

    const json_node *pPackets_array = node.find_child_array("packets");
    if (pPackets_array)
    {
        if (!pPackets_array->are_all_children_objects())
        {
            clear();
            return false;
        }

        vogl_trace_packet packet(pCtypes);

        m_packets.resize(pPackets_array->size());
        for (uint i = 0; i < pPackets_array->size(); i++)
        {
            if (!packet.json_deserialize(*pPackets_array->get_child(i), "<display_list>", &blob_manager))
            {
                clear();
                return false;
            }

            if (!packet.serialize(m_packets.get_packet_buf(i)))
            {
                clear();
                return false;
            }
        }
    }

    return true;
}
bool vogl_renderbuffer_desc::deserialize(const json_node &node)
{
    VOGL_FUNC_TRACER

    clear();

    m_width = node.value_as_int("width");
    m_height = node.value_as_int("height");
    m_samples = node.value_as_int("samples");
    m_red_size = node.value_as_int("red_size");
    m_green_size = node.value_as_int("green_size");
    m_blue_size = node.value_as_int("blue_size");
    m_alpha_size = node.value_as_int("alpha_size");
    m_depth_size = node.value_as_int("depth_size");
    m_stencil_size = node.value_as_int("stencil_size");

    const char *pFmt = node.value_as_string_ptr("internal_format");
    if (!pFmt)
    {
        VOGL_ASSERT_ALWAYS;
        return false;
    }

    uint64_t enum_val = g_gl_enums.find_enum(pFmt);
    VOGL_ASSERT(enum_val != gl_enums::cUnknownEnum);
    if (enum_val == gl_enums::cUnknownEnum)
        return false;
    if (enum_val > cUINT32_MAX)
    {
        VOGL_ASSERT_ALWAYS;
        return false;
    }
    m_internal_format = static_cast<GLenum>(enum_val);

    return true;
}
bool vogl_display_list::serialize(json_node &node, vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes) const
{
    VOGL_FUNC_TRACER

    node.add_key_value("handle", m_handle);
    node.add_key_value("valid", m_valid);
    node.add_key_value("generating", m_generating);
    node.add_key_value("xfont", m_xfont);

    if (m_xfont)
    {
        node.add_key_value("xfont_glyph", m_xfont_glyph);
        node.add_key_value("xfont_name", m_xfont_name);
    }

    if (m_packets.size())
    {
        vogl_trace_packet::json_serialize_params params;
        params.m_pBlob_manager = &blob_manager;

        json_node &packets_array = node.add_array("packets");
        for (uint i = 0; i < m_packets.size(); i++)
        {
            const uint8_vec &packet_buf = m_packets.get_packet_buf(i);

            vogl_trace_packet packet(pCtypes);
            if (!packet.deserialize(packet_buf.get_ptr(), packet_buf.size(), true))
                return false;

            if (!packet.json_serialize(packets_array.add_object(), params))
                return false;
        }
    }

    return true;
}