VS2013编译最简单的PPAPI插件
2016-01-08 21:56
302 查看
我想在CEF里使用PPAPI,CEF使用VS 2013 Update 4编译。因此我尝试了使用VS 2013来编译PPAPI插件。
PPAPI的代码在这里:https://chromium.googlesource.com/chromium/src/ppapi/,可以用下列命令check出来:
也可以下载master分支的tgz包。
复制ppapi/examples/stub/stub.c文件到项目文件夹下,并添加到项目里。做简单修改,打印点儿调试信息。stub.c内容如下:
PPP_InitializeModule,插件加载时会被调用,返回0表示成功
PPP_ShutdownModule,插件卸载时会被调用
PPP_GetInterface,浏览器创建插件实例时会被调用
这些函数在ppp.h中定义。实现这些函数时,使用PP_EXPORT宏修饰一下即可。
一个DLL,实现了上述三个函数,就可以做为PPAPI插件来用了,不过只是样子货,只能看到被加载、创建,干不了什么实际的事儿,是个PPAPI 版本的Hello World。
后面我们会改造stub,显示点东西出来。
CEF Windows开发环境搭建
CEF加载PPAPI插件
PPAPI的代码在这里:https://chromium.googlesource.com/chromium/src/ppapi/,可以用下列命令check出来:
[code]git clone https://chromium.googlesource.com/chromium/src/ppapi
也可以下载master分支的tgz包。
VS工程
新建一个Win32项目,类型选DLL,去掉预编译头文件stdafx.h和stdafx.cpp,并且在项目属性–>配置属性–>C/C++–>预编译头,把预编译头选项的值设置为不使用预编译头。复制ppapi/examples/stub/stub.c文件到项目文件夹下,并添加到项目里。做简单修改,打印点儿调试信息。stub.c内容如下:
[code]// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This is the simplest possible C Pepper plugin that does nothing. If you're // using C++, you will want to look at stub.cc which uses the more convenient // C++ wrappers. #include <stddef.h> #include <stdint.h> #include <Windows.h> #include <tchar.h> #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/ppb.h" #include "ppapi/c/ppp.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/ppp_instance.h" PP_Module g_module_id; PPB_GetInterface g_get_browser_interface = NULL; PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id, PPB_GetInterface get_browser_interface) { // Save the global module information for later. g_module_id = module_id; g_get_browser_interface = get_browser_interface; OutputDebugString(_T("PPP_InitializeModule was called\r\n")); return PP_OK; } PP_EXPORT void PPP_ShutdownModule() { OutputDebugString(_T("PPP_ShutdownModule was called\r\n")); } PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { // You will normally implement a getter for at least PPP_INSTANCE_INTERFACE // here. OutputDebugString(_T("PPP_GetInterface was called\r\n")); return NULL; }
PPAPI plugin
参考https://code.google.com/p/ppapi/wiki/GettingStarted,C语言版的PPAPI plugin,必须实现下列函数:PPP_InitializeModule,插件加载时会被调用,返回0表示成功
PPP_ShutdownModule,插件卸载时会被调用
PPP_GetInterface,浏览器创建插件实例时会被调用
这些函数在ppp.h中定义。实现这些函数时,使用PP_EXPORT宏修饰一下即可。
一个DLL,实现了上述三个函数,就可以做为PPAPI插件来用了,不过只是样子货,只能看到被加载、创建,干不了什么实际的事儿,是个PPAPI 版本的Hello World。
后面我们会改造stub,显示点东西出来。
CEF Windows开发环境搭建
CEF加载PPAPI插件
相关文章推荐
- 冒泡排序法
- Java读取并修改图片的像素值
- std::set自定义比较函数
- HDOJ 2042 不容易系列之二
- How to refresh materialized view in oracle
- uva-211-The Domino Effect
- vim使用系统剪切板
- 队列
- 一张图解释Linux的目录结构
- lwip中Nagle 算法实现
- 《笨办法学Python》 第8课手记
- Mac 词典工具推荐:Youdao Alfred Workflow(可同步单词本)
- 【Android Studio】常用快捷键
- 造轮子:线程的小用
- 文章收录机制探讨
- 在aspx网页中使用program控件
- poj3468 A Simple Problem with Integers 基础线段树or树状数组
- freemark换行输出
- Android图片处理
- Socket