当前位置: 首页>>代码示例>>C++>>正文


C++ pp_resource_acquire函数代码示例

本文整理汇总了C++中pp_resource_acquire函数的典型用法代码示例。如果您正苦于以下问题:C++ pp_resource_acquire函数的具体用法?C++ pp_resource_acquire怎么用?C++ pp_resource_acquire使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pp_resource_acquire函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ppb_url_response_info_get_body_as_file_ref

PP_Resource
ppb_url_response_info_get_body_as_file_ref(PP_Resource response)
{
    struct pp_url_response_info_s *ri = pp_resource_acquire(response,PP_RESOURCE_URL_RESPONSE_INFO);
    if (!ri) {
        trace_error("%s, bad resource\n", __func__);
        return 0;
    }
    struct pp_url_loader_s *ul = ri->url_loader;

    PP_Resource file_ref = pp_resource_allocate(PP_RESOURCE_FILE_REF, ri->instance);
    struct pp_file_ref_s *fr = pp_resource_acquire(file_ref, PP_RESOURCE_FILE_REF);
    if (!fr) {
        trace_error("%s, resource allocation failure\n", __func__);
        pp_resource_release(response);
        return 0;
    }

    fr->fd = dup(ul->fd);
    fr->type = PP_FILE_REF_TYPE_FD;

    pp_resource_release(file_ref);
    pp_resource_release(response);

    return file_ref;
}
开发者ID:WizardGed,项目名称:freshplayerplugin,代码行数:26,代码来源:ppb_url_response_info.c

示例2: ppb_url_loader_get_response_info

PP_Resource
ppb_url_loader_get_response_info(PP_Resource loader)
{
    struct pp_url_loader_s *ul = pp_resource_acquire(loader, PP_RESOURCE_URL_LOADER);
    if (!ul) {
        trace_error("%s, bad resource\n", __func__);
        return 0;
    }
    PP_Resource response_info = pp_resource_allocate(PP_RESOURCE_URL_RESPONSE_INFO, ul->instance);
    struct pp_url_response_info_s *ri = pp_resource_acquire(response_info,
                                                            PP_RESOURCE_URL_RESPONSE_INFO);
    if (!ri) {
        trace_error("%s, resource allocation failure\n", __func__);
        pp_resource_release(loader);
        return 0;
    }

    pp_resource_ref(loader);
    ri->url_loader_id = loader;
    ri->url_loader = ul;

    pp_resource_release(response_info);
    pp_resource_release(loader);
    return response_info;
}
开发者ID:Artanejp,项目名称:freshplayerplugin,代码行数:25,代码来源:ppb_url_loader.c

示例3: ppb_flash_message_loop_run

int32_t
ppb_flash_message_loop_run(PP_Resource flash_message_loop)
{
    struct pp_flash_message_loop_s *fml =
                        pp_resource_acquire(flash_message_loop, PP_RESOURCE_FLASH_MESSAGE_LOOP);
    if (!fml) {
        trace_error("%s, bad resource\n", __func__);
        return PP_ERROR_BADRESOURCE;
    }

    PP_Resource message_loop = ppb_message_loop_get_current();
    fml->running = 1;
    fml->message_loop = message_loop;
    fml->depth = ppb_message_loop_get_depth(message_loop) + 1;

    pp_resource_ref(flash_message_loop);        // prevent destroy of running loop
    pp_resource_release(flash_message_loop);

    // launching nested loop without depth increase to prevent hang up of previously pushed tasks
    ppb_message_loop_run_int(message_loop, ML_NESTED);

    fml = pp_resource_acquire(flash_message_loop, PP_RESOURCE_FLASH_MESSAGE_LOOP);
    if (fml) {
        fml->running = 0;
        pp_resource_release(flash_message_loop);
    }

    pp_resource_unref(flash_message_loop);
    return PP_OK;
}
开发者ID:WizardGed,项目名称:freshplayerplugin,代码行数:30,代码来源:ppb_flash_message_loop.c

示例4: ppb_audio_get_current_config

PP_Resource
ppb_audio_get_current_config(PP_Resource audio)
{
    struct pp_audio_s *a = pp_resource_acquire(audio, PP_RESOURCE_AUDIO);
    if (!a) {
        trace_error("%s, bad resource\n", __func__);
        return 0;
    }

    PP_Resource audio_config = pp_resource_allocate(PP_RESOURCE_AUDIO_CONFIG, a->instance);
    struct pp_audio_config_s *ac = pp_resource_acquire(audio_config, PP_RESOURCE_AUDIO_CONFIG);
    if (!ac) {
        trace_error("%s, resource allocation failure\n", __func__);
        audio_config = 0;
        goto err;
    }

    ac->sample_rate = a->sample_rate;
    ac->sample_frame_count = a->sample_frame_count;

    pp_resource_release(audio_config);

err:
    pp_resource_release(audio);
    return audio_config;
}
开发者ID:i-rinat,项目名称:freshplayerplugin,代码行数:26,代码来源:ppb_audio.c

示例5: ppb_host_resolver_get_net_address_1_0

PP_Resource
ppb_host_resolver_get_net_address_1_0(PP_Resource host_resolver, uint32_t index)
{
    PP_Resource net_address = 0;
    struct pp_host_resolver_s *hr = pp_resource_acquire(host_resolver, PP_RESOURCE_HOST_RESOLVER);
    if (!hr) {
        trace_error("%s, bad resource\n", __func__);
        goto err_1;
    }

    if (index >= hr->addr_count)
        goto err_2;

    net_address = pp_resource_allocate(PP_RESOURCE_NET_ADDRESS, hr->instance);
    struct pp_net_address_s *na = pp_resource_acquire(net_address, PP_RESOURCE_NET_ADDRESS);
    if (!na) {
        trace_error("%s, resource allocation failed\n", __func__);
        goto err_2;
    }

    memcpy(&na->addr, &hr->addrs[index], sizeof(struct PP_NetAddress_Private));
    pp_resource_release(net_address);

err_2:
    pp_resource_release(host_resolver);
err_1:
    return net_address;
}
开发者ID:WizardGed,项目名称:freshplayerplugin,代码行数:28,代码来源:ppb_host_resolver.c

示例6: ppb_video_decoder_assign_picture_buffers

void
ppb_video_decoder_assign_picture_buffers(PP_Resource video_decoder, uint32_t no_of_buffers,
                                         const struct PP_PictureBuffer_Dev buffers[])
{
    struct pp_video_decoder_s *vd = pp_resource_acquire(video_decoder, PP_RESOURCE_VIDEO_DECODER);
    if (!vd) {
        trace_error("%s, bad resource\n", __func__);
        goto err_1;
    }

    struct pp_graphics3d_s *g3d = pp_resource_acquire(vd->graphics3d, PP_RESOURCE_GRAPHICS3D);
    if (!g3d) {
        trace_error("%s, bad graphics3d context\n", __func__);
        goto err_2;
    }

    vd->buffers = malloc(no_of_buffers * sizeof(*vd->buffers));
    if (!vd->buffers) {
        trace_error("%s, memory allocation failure\n", __func__);
        goto err_3;
    }

    vd->buffer_count = no_of_buffers;
    for (uintptr_t k = 0; k < no_of_buffers; k ++) {
        vd->buffers[k].id =         buffers[k].id;
        vd->buffers[k].width =      buffers[k].size.width;
        vd->buffers[k].height =     buffers[k].size.height;
        vd->buffers[k].texture_id = buffers[k].texture_id;
        vd->buffers[k].used =       0;

        pthread_mutex_lock(&display.lock);
        vd->buffers[k].pixmap = XCreatePixmap(display.x, DefaultRootWindow(display.x),
                                              buffers[k].size.width, buffers[k].size.height,
                                              g3d->depth);
        int tfp_pixmap_attrs[] = {
            GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
            GLX_MIPMAP_TEXTURE_EXT, GL_FALSE,
            GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
            GL_NONE
        };
        vd->buffers[k].glx_pixmap = glXCreatePixmap(display.x, g3d->fb_config,
                                                    vd->buffers[k].pixmap, tfp_pixmap_attrs);
        pthread_mutex_unlock(&display.lock);
        if (vd->buffers[k].glx_pixmap == None) {
            trace_error("%s, failed to create GLX pixmap\n", __func__);
            goto err_3;
        }
    }

err_3:
    pp_resource_release(vd->graphics3d);
err_2:
    pp_resource_release(video_decoder);
err_1:
    ;
}
开发者ID:kubrickfr,项目名称:freshplayerplugin,代码行数:56,代码来源:ppb_video_decoder.c

示例7: ppb_browser_font_trusted_draw_text_at

PP_Bool
ppb_browser_font_trusted_draw_text_at(PP_Resource font, PP_Resource image_data,
                                      const struct PP_BrowserFont_Trusted_TextRun *text,
                                      const struct PP_Point *position, uint32_t color,
                                      const struct PP_Rect *clip, PP_Bool image_data_is_opaque)
{
    (void)image_data_is_opaque; // TODO: is it worth implementing?
    struct pp_browser_font_s *bf = pp_resource_acquire(font, PP_RESOURCE_BROWSER_FONT);
    if (!bf)
        return PP_FALSE;
    struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA);
    if (!id) {
        pp_resource_release(font);
        return PP_FALSE;
    }

    cairo_t *cr = cairo_create(id->cairo_surf);
    if (clip) {
        cairo_rectangle(cr, clip->point.x, clip->point.y, clip->size.width, clip->size.height);
        cairo_clip(cr);
    }

    PangoFontMetrics *m = pango_font_get_metrics(bf->font, NULL);
    int32_t ascent = pango_font_metrics_get_ascent(m) / PANGO_SCALE;
    cairo_surface_mark_dirty(id->cairo_surf);
    if (position)
        cairo_move_to(cr, position->x, position->y - ascent);
    else
        cairo_move_to(cr, 0, 0);
    pango_font_metrics_unref(m);

    cairo_set_source_rgba(cr, ((color >> 16) & 0xffu) / 255.0,
                              ((color >> 8) & 0xffu) / 255.0,
                              ((color >> 0) & 0xffu) / 255.0,
                              ((color >> 24) & 0xffu) / 255.0);

    PangoLayout *layout = pango_cairo_create_layout(cr);
    uint32_t len = 0;
    const char *s = "";
    if (text->text.type == PP_VARTYPE_STRING)
        s = ppb_var_var_to_utf8(text->text, &len);

    // TODO: factor into rtl direction
    pango_layout_set_font_description(layout, bf->font_desc);
    pango_layout_set_text(layout, s, len);
    pango_cairo_layout_path(cr, layout);
    cairo_fill(cr);
    g_object_unref(layout);
    cairo_surface_flush(id->cairo_surf);
    cairo_destroy(cr);

    pp_resource_release(font);
    pp_resource_release(image_data);
    return PP_FALSE;
}
开发者ID:evilpie,项目名称:freshplayerplugin,代码行数:55,代码来源:ppb_browser_font_trusted.c

示例8: do_ppb_audio_create

static
PP_Resource
do_ppb_audio_create(PP_Instance instance, PP_Resource audio_config,
                    PPB_Audio_Callback_1_0 audio_callback_1_0,
                    PPB_Audio_Callback     audio_callback_1_1, void *user_data)
{
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return 0;
    }

    if (!audio_callback_1_0 && !audio_callback_1_1)
        return PP_ERROR_BADARGUMENT;

    PP_Resource audio = pp_resource_allocate(PP_RESOURCE_AUDIO, pp_i);
    struct pp_audio_s *a = pp_resource_acquire(audio, PP_RESOURCE_AUDIO);
    if (!a) {
        trace_error("%s, resource allocation failure\n", __func__);
        return 0;
    }

    struct pp_audio_config_s *ac = pp_resource_acquire(audio_config, PP_RESOURCE_AUDIO_CONFIG);
    if (!ac) {
        trace_error("%s, bad audio config\n", __func__);
        goto err;
    }

    a->sample_rate = ac->sample_rate;
    a->sample_frame_count = ac->sample_frame_count;
    pp_resource_release(audio_config);

    a->callback_1_0 = audio_callback_1_0;
    a->callback_1_1 = audio_callback_1_1;
    a->user_data = user_data;
    a->stream_ops = audio_select_implementation();
    if (a->stream_ops == NULL) {
        trace_error("%s, no viable audio implementation\n", __func__);
        goto err;
    }

    a->stream = a->stream_ops->create_playback_stream(a->sample_rate, a->sample_frame_count,
                                                      playback_cb, a);
    if (!a->stream) {
        trace_error("%s, can't create playback stream\n", __func__);
        goto err;
    }

    pp_resource_release(audio);
    return audio;
err:
    pp_resource_release(audio);
    pp_resource_expunge(audio);
    return 0;
}
开发者ID:i-rinat,项目名称:freshplayerplugin,代码行数:55,代码来源:ppb_audio.c

示例9: ppb_instance_bind_graphics

PP_Bool
ppb_instance_bind_graphics(PP_Instance instance, PP_Resource device)
{
    PP_Bool retval;
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return PP_FALSE;
    }

    if (device == 0) {
        // unbind
        pthread_mutex_lock(&pp_i->lock);
        pp_i->graphics = 0;
        pthread_mutex_unlock(&pp_i->lock);
        return PP_TRUE;
    }

    struct pp_graphics2d_s *g2d = pp_resource_acquire(device, PP_RESOURCE_GRAPHICS2D);
    struct pp_graphics3d_s *g3d = pp_resource_acquire(device, PP_RESOURCE_GRAPHICS3D);

    if (g2d) {
        if (pp_i != g2d->instance) {
            retval = PP_FALSE;
            goto done;
        }

        pthread_mutex_lock(&pp_i->lock);
        pp_i->graphics = device;
        pthread_mutex_unlock(&pp_i->lock);
        retval = PP_TRUE;
    } else if (g3d) {
        if (pp_i != g3d->instance) {
            retval = PP_FALSE;
            goto done;
        }

        pthread_mutex_lock(&pp_i->lock);
        pp_i->graphics = device;
        pthread_mutex_unlock(&pp_i->lock);
        pp_resource_release(device);
        retval = PP_TRUE;
    } else {
        trace_warning("%s, unsupported graphics resource %d on instance %d\n", __func__,
                      device, instance);
        retval = PP_FALSE;
    }

done:
    pp_resource_release(device);
    return retval;
}
开发者ID:Jalakas,项目名称:freshplayerplugin,代码行数:52,代码来源:ppb_instance.c

示例10: ppb_image_data_create

PP_Resource
ppb_image_data_create(PP_Instance instance, PP_ImageDataFormat format,
                      const struct PP_Size *size, PP_Bool init_to_zero)
{
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return 0;
    }
    PP_Resource image_data = pp_resource_allocate(PP_RESOURCE_IMAGE_DATA, pp_i);
    struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA);
    if (!id) {
        trace_error("%s, failed to create image data resource\n", __func__);
        return 0;
    }

    id->format = format;
    id->width = size->width;
    id->height = size->height;
    id->stride = id->width * 4;

    (void)init_to_zero; // ignore flag, always clear memory
    id->data = calloc(id->stride * id->height, 1);
    if (!id->data) {
        pp_resource_release(image_data);
        ppb_core_release_resource(image_data);
        trace_error("%s, can't allocate memory for image\n", __func__);
        return 0;
    }

    id->cairo_surf = cairo_image_surface_create_for_data((void *)id->data, CAIRO_FORMAT_ARGB32,
                                                         id->width, id->height, id->stride);
    pp_resource_release(image_data);
    return image_data;
}
开发者ID:WizardGed,项目名称:freshplayerplugin,代码行数:35,代码来源:ppb_image_data.c

示例11: ppb_keyboard_input_event_create_1_2

PP_Resource
ppb_keyboard_input_event_create_1_2(PP_Instance instance, PP_InputEvent_Type type,
                                    PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code,
                                    struct PP_Var character_text, struct PP_Var code)
{
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return 0;
    }
    PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i);
    struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT);
    if (!ie) {
        trace_error("%s, can't allocate memory\n", __func__);
        return 0;
    }
    ie->event_class = PP_INPUTEVENT_CLASS_KEYBOARD;
    ie->type = type;
    ie->time_stamp = time_stamp;
    ie->modifiers = modifiers;
    ie->key_code = key_code;
    ie->character_text = character_text;
    ie->code = code;
    ppb_var_add_ref(character_text);
    ppb_var_add_ref(code);

    pp_resource_release(input_event);
    return input_event;
}
开发者ID:Artanejp,项目名称:freshplayerplugin,代码行数:29,代码来源:ppb_input_event.c

示例12: ppb_wheel_input_event_create

PP_Resource
ppb_wheel_input_event_create(PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers,
                             const struct PP_FloatPoint *wheel_delta,
                             const struct PP_FloatPoint *wheel_ticks, PP_Bool scroll_by_page)
{
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return 0;
    }
    PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i);
    struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT);
    if (!ie) {
        trace_error("%s, can't allocate memory\n", __func__);
        return 0;
    }
    ie->event_class = PP_INPUTEVENT_CLASS_WHEEL;
    ie->time_stamp = time_stamp;
    ie->modifiers = modifiers;
    ie->wheel_delta.x = wheel_delta ? wheel_delta->x : 0;
    ie->wheel_delta.y = wheel_delta ? wheel_delta->y : 0;
    ie->wheel_ticks.x = wheel_ticks ? wheel_ticks->x : 0;
    ie->wheel_ticks.y = wheel_ticks ? wheel_ticks->y : 0;
    ie->scroll_by_page = scroll_by_page;

    pp_resource_release(input_event);
    return input_event;
}
开发者ID:Artanejp,项目名称:freshplayerplugin,代码行数:28,代码来源:ppb_input_event.c

示例13: ppb_mouse_input_event_create

PP_Resource
ppb_mouse_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp,
                             uint32_t modifiers, PP_InputEvent_MouseButton mouse_button,
                             const struct PP_Point *mouse_position, int32_t click_count,
                             const struct PP_Point *mouse_movement)
{
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return 0;
    }
    PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i);
    struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT);
    if (!ie) {
        trace_error("%s, can't allocate memory\n", __func__);
        return 0;
    }
    ie->event_class = PP_INPUTEVENT_CLASS_MOUSE;
    ie->type = type;
    ie->time_stamp = time_stamp;
    ie->modifiers = modifiers;
    ie->mouse_button = mouse_button;
    ie->mouse_position.x = mouse_position ? mouse_position->x : 0;
    ie->mouse_position.y = mouse_position ? mouse_position->y : 0;
    ie->click_count = click_count;
    ie->mouse_movement.x = mouse_movement ? mouse_movement->x : 0;
    ie->mouse_movement.y = mouse_movement ? mouse_movement->y : 0;

    pp_resource_release(input_event);
    return input_event;
}
开发者ID:Artanejp,项目名称:freshplayerplugin,代码行数:31,代码来源:ppb_input_event.c

示例14: ppb_video_capture_create

PP_Resource
ppb_video_capture_create(PP_Instance instance)
{
    const struct PPP_VideoCapture_Dev_0_1 *ppp_video_capture_dev;
    struct pp_instance_s *pp_i = tables_get_pp_instance(instance);
    if (!pp_i) {
        trace_error("%s, bad instance\n", __func__);
        return 0;
    }

    ppp_video_capture_dev = ppp_get_interface(PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1);
    if (!ppp_video_capture_dev) {
        trace_error("%s, no viable %s\n", __func__, PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1);
        return 0;
    }

    PP_Resource video_capture = pp_resource_allocate(PP_RESOURCE_VIDEO_CAPTURE, pp_i);
    struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE);
    if (!vc) {
        trace_error("%s, resource allocation failure\n", __func__);
        return 0;
    }

    vc->fd = -1;
    vc->ppp_video_capture_dev = ppp_video_capture_dev;

    pp_resource_release(video_capture);
    return video_capture;
}
开发者ID:eltictacdicta,项目名称:freshplayerplugin,代码行数:29,代码来源:ppb_video_capture.c

示例15: ppb_host_resolver_resolve

int32_t
ppb_host_resolver_resolve(PP_Resource host_resolver, const char *host, uint16_t port,
                          const struct PP_HostResolver_Private_Hint *hint,
                          struct PP_CompletionCallback callback)
{
    struct pp_host_resolver_s *hr = pp_resource_acquire(host_resolver, PP_RESOURCE_HOST_RESOLVER);
    if (!hr) {
        trace_error("%s, bad resource\n", __func__);
        return PP_ERROR_BADRESOURCE;
    }

    hr->host = nullsafe_strdup(host);

    struct async_network_task_s *task = async_network_task_create();

    task->type =        ASYNC_NETWORK_HOST_RESOLVE;
    task->resource =    host_resolver;
    task->host =        nullsafe_strdup(host);
    task->port =        port;
    task->callback =    callback;
    task->callback_ml = ppb_message_loop_get_current();

    pp_resource_release(host_resolver);
    async_network_task_push(task);

    return PP_OK_COMPLETIONPENDING;
}
开发者ID:WizardGed,项目名称:freshplayerplugin,代码行数:27,代码来源:ppb_host_resolver.c


注:本文中的pp_resource_acquire函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。