0

Move PPAPI into the Chrome repo. The old repo was

http://ppapi.googlecode.com/

TEST=none
BUG=none

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64613 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
brettw@chromium.org
2010-11-01 16:16:50 +00:00
parent e7d8b51953
commit 1758e88fd9
209 changed files with 21306 additions and 0 deletions
ppapi
GLES2
LICENSE
c
codereview.settings
cpp
documentation
example
examples
ppapi.gyp
tests

607
ppapi/GLES2/gl2.h Normal file

@ -0,0 +1,607 @@
// 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.
#ifndef __gl2_h_
#define __gl2_h_
#include "../c/dev/ppb_opengles_dev.h"
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* OpenGL ES core versions */
#define GL_ES_VERSION_2_0 1
/* ClearBufferMask */
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
/* Boolean */
#define GL_FALSE 0
#define GL_TRUE 1
/* BeginMode */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
/* AlphaFunction (not supported in ES20 */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* BlendingFactorDest */
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
/* BlendingFactorSrc */
/* GL_ZERO */
/* GL_ONE */
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */
/* BlendEquationSeparate */
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
#define GL_BLEND_EQUATION_ALPHA 0x883D
/* BlendSubtract */
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
/* Separate Blend Functions */
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
#define GL_BLEND_SRC_ALPHA 0x80CB
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
/* CullFaceMode */
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
/* DepthFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* EnableCap */
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
#define GL_SCISSOR_TEST 0x0C11
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_COVERAGE 0x80A0
/* ErrorCode */
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505
#define GL_CONTEXT_LOST 0x300E // TODO(gman: What value?
/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
/* GetPName */
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_STENCIL_BACK_FUNC 0x8800
#define GL_STENCIL_BACK_FAIL 0x8801
#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
#define GL_STENCIL_BACK_REF 0x8CA3
#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
/* GL_SCISSOR_TEST */
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_ALPHA_BITS 0x0D55
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
/* GL_POLYGON_OFFSET_FILL */
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* HintTarget */
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* DataType */
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
/* PixelFormat */
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
/* PixelType */
/* GL_UNSIGNED_BYTE */
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
/* Shaders */
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_SHADER_TYPE 0x8B4F
#define GL_DELETE_STATUS 0x8B80
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_ATTACHED_SHADERS 0x8B85
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GL_ACTIVE_ATTRIBUTES 0x8B89
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
/* StencilFunction */
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
/* StencilOp */
/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* TextureMagFilter */
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
/* TextureMinFilter */
/* GL_NEAREST */
/* GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
/* TextureParameterName */
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
/* TextureTarget */
/* GL_TEXTURE_2D */
#define GL_TEXTURE 0x1702
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
/* TextureUnit */
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
#define GL_TEXTURE3 0x84C3
#define GL_TEXTURE4 0x84C4
#define GL_TEXTURE5 0x84C5
#define GL_TEXTURE6 0x84C6
#define GL_TEXTURE7 0x84C7
#define GL_TEXTURE8 0x84C8
#define GL_TEXTURE9 0x84C9
#define GL_TEXTURE10 0x84CA
#define GL_TEXTURE11 0x84CB
#define GL_TEXTURE12 0x84CC
#define GL_TEXTURE13 0x84CD
#define GL_TEXTURE14 0x84CE
#define GL_TEXTURE15 0x84CF
#define GL_TEXTURE16 0x84D0
#define GL_TEXTURE17 0x84D1
#define GL_TEXTURE18 0x84D2
#define GL_TEXTURE19 0x84D3
#define GL_TEXTURE20 0x84D4
#define GL_TEXTURE21 0x84D5
#define GL_TEXTURE22 0x84D6
#define GL_TEXTURE23 0x84D7
#define GL_TEXTURE24 0x84D8
#define GL_TEXTURE25 0x84D9
#define GL_TEXTURE26 0x84DA
#define GL_TEXTURE27 0x84DB
#define GL_TEXTURE28 0x84DC
#define GL_TEXTURE29 0x84DD
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
/* Uniform Types */
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
#define GL_INT_VEC2 0x8B53
#define GL_INT_VEC3 0x8B54
#define GL_INT_VEC4 0x8B55
#define GL_BOOL 0x8B56
#define GL_BOOL_VEC2 0x8B57
#define GL_BOOL_VEC3 0x8B58
#define GL_BOOL_VEC4 0x8B59
#define GL_FLOAT_MAT2 0x8B5A
#define GL_FLOAT_MAT3 0x8B5B
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
/* Vertex Arrays */
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
/* Read Format */
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
/* Shader Source */
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
/* Shader Binary */
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
/* Shader Precision-Specified Types */
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
/* Framebuffer Object. */
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGB565 0x8D62
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_STENCIL_INDEX 0x1901
#define GL_STENCIL_INDEX8 0x8D48
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
#define GL_NONE 0
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
/*-------------------------------------------------------------------------
* GL core functions.
*-----------------------------------------------------------------------*/
#undef GL_APICALL
#define GL_APICALL
#undef GL_APIENTRY
#define GL_APIENTRY
// The client must set this to point to the Pepper OpenGLES interface once it
// is obtained. PPAPI C++ wrappers will do this for you.
#ifdef __cplusplus
extern "C" {
#endif
extern const struct PPB_OpenGLES_Dev* pepper_opengl_interface;
#ifdef __cplusplus
}
#endif
#define glActiveTexture pepper_opengl_interface->ActiveTexture
#define glAttachShader pepper_opengl_interface->AttachShader
#define glBindAttribLocation pepper_opengl_interface->BindAttribLocation
#define glBindBuffer pepper_opengl_interface->BindBuffer
#define glBindFramebuffer pepper_opengl_interface->BindFramebuffer
#define glBindRenderbuffer pepper_opengl_interface->BindRenderbuffer
#define glBindTexture pepper_opengl_interface->BindTexture
#define glBlendColor pepper_opengl_interface->BlendColor
#define glBlendEquation pepper_opengl_interface->BlendEquation
#define glBlendEquationSeparate pepper_opengl_interface->BlendEquationSeparate
#define glBlendFunc pepper_opengl_interface->BlendFunc
#define glBlendFuncSeparate pepper_opengl_interface->BlendFuncSeparate
#define glBufferData pepper_opengl_interface->BufferData
#define glBufferSubData pepper_opengl_interface->BufferSubData
#define glCheckFramebufferStatus pepper_opengl_interface->CheckFramebufferStatus
#define glClear pepper_opengl_interface->Clear
#define glClearColor pepper_opengl_interface->ClearColor
#define glClearDepthf pepper_opengl_interface->ClearDepthf
#define glClearStencil pepper_opengl_interface->ClearStencil
#define glColorMask pepper_opengl_interface->ColorMask
#define glCompileShader pepper_opengl_interface->CompileShader
#define glCompressedTexImage2D pepper_opengl_interface->CompressedTexImage2D
#define glCompressedTexSubImage2D pepper_opengl_interface->CompressedTexSubImage2D
#define glCopyTexImage2D pepper_opengl_interface->CopyTexImage2D
#define glCopyTexSubImage2D pepper_opengl_interface->CopyTexSubImage2D
#define glCreateProgram pepper_opengl_interface->CreateProgram
#define glCreateShader pepper_opengl_interface->CreateShader
#define glCullFace pepper_opengl_interface->CullFace
#define glDeleteBuffers pepper_opengl_interface->DeleteBuffers
#define glDeleteFramebuffers pepper_opengl_interface->DeleteFramebuffers
#define glDeleteProgram pepper_opengl_interface->DeleteProgram
#define glDeleteRenderbuffers pepper_opengl_interface->DeleteRenderbuffers
#define glDeleteShader pepper_opengl_interface->DeleteShader
#define glDeleteTextures pepper_opengl_interface->DeleteTextures
#define glDepthFunc pepper_opengl_interface->DepthFunc
#define glDepthMask pepper_opengl_interface->DepthMask
#define glDepthRangef pepper_opengl_interface->DepthRangef
#define glDetachShader pepper_opengl_interface->DetachShader
#define glDisable pepper_opengl_interface->Disable
#define glDisableVertexAttribArray pepper_opengl_interface->DisableVertexAttribArray
#define glDrawArrays pepper_opengl_interface->DrawArrays
#define glDrawElements pepper_opengl_interface->DrawElements
#define glEnable pepper_opengl_interface->Enable
#define glEnableVertexAttribArray pepper_opengl_interface->EnableVertexAttribArray
#define glFinish pepper_opengl_interface->Finish
#define glFlush pepper_opengl_interface->Flush
#define glFramebufferRenderbuffer pepper_opengl_interface->FramebufferRenderbuffer
#define glFramebufferTexture2D pepper_opengl_interface->FramebufferTexture2D
#define glFrontFace pepper_opengl_interface->FrontFace
#define glGenBuffers pepper_opengl_interface->GenBuffers
#define glGenerateMipmap pepper_opengl_interface->GenerateMipmap
#define glGenFramebuffers pepper_opengl_interface->GenFramebuffers
#define glGenRenderbuffers pepper_opengl_interface->GenRenderbuffers
#define glGenTextures pepper_opengl_interface->GenTextures
#define glGetActiveAttrib pepper_opengl_interface->GetActiveAttrib
#define glGetActiveUniform pepper_opengl_interface->GetActiveUniform
#define glGetAttachedShaders pepper_opengl_interface->GetAttachedShaders
#define glGetAttribLocation pepper_opengl_interface->GetAttribLocation
#define glGetBooleanv pepper_opengl_interface->GetBooleanv
#define glGetBufferParameteriv pepper_opengl_interface->GetBufferParameteriv
#define glGetError pepper_opengl_interface->GetError
#define glGetFloatv pepper_opengl_interface->GetFloatv
#define glGetFramebufferAttachmentParameteriv pepper_opengl_interface->GetFramebufferAttachmentParameteriv
#define glGetIntegerv pepper_opengl_interface->GetIntegerv
#define glGetProgramiv pepper_opengl_interface->GetProgramiv
#define glGetProgramInfoLog pepper_opengl_interface->GetProgramInfoLog
#define glGetRenderbufferParameteriv pepper_opengl_interface->GetRenderbufferParameteriv
#define glGetShaderiv pepper_opengl_interface->GetShaderiv
#define glGetShaderInfoLog pepper_opengl_interface->GetShaderInfoLog
#define glGetShaderPrecisionFormat pepper_opengl_interface->GetShaderPrecisionFormat
#define glGetShaderSource pepper_opengl_interface->GetShaderSource
#define glGetString pepper_opengl_interface->GetString
#define glGetTexParameterfv pepper_opengl_interface->GetTexParameterfv
#define glGetTexParameteriv pepper_opengl_interface->GetTexParameteriv
#define glGetUniformfv pepper_opengl_interface->GetUniformfv
#define glGetUniformiv pepper_opengl_interface->GetUniformiv
#define glGetUniformLocation pepper_opengl_interface->GetUniformLocation
#define glGetVertexAttribfv pepper_opengl_interface->GetVertexAttribfv
#define glGetVertexAttribiv pepper_opengl_interface->GetVertexAttribiv
#define glGetVertexAttribPointerv pepper_opengl_interface->GetVertexAttribPointerv
#define glHint pepper_opengl_interface->Hint
#define glIsBuffer pepper_opengl_interface->IsBuffer
#define glIsEnabled pepper_opengl_interface->IsEnabled
#define glIsFramebuffer pepper_opengl_interface->IsFramebuffer
#define glIsProgram pepper_opengl_interface->IsProgram
#define glIsRenderbuffer pepper_opengl_interface->IsRenderbuffer
#define glIsShader pepper_opengl_interface->IsShader
#define glIsTexture pepper_opengl_interface->IsTexture
#define glLineWidth pepper_opengl_interface->LineWidth
#define glLinkProgram pepper_opengl_interface->LinkProgram
#define glPixelStorei pepper_opengl_interface->PixelStorei
#define glPolygonOffset pepper_opengl_interface->PolygonOffset
#define glReadPixels pepper_opengl_interface->ReadPixels
#define glReleaseShaderCompiler pepper_opengl_interface->ReleaseShaderCompiler
#define glRenderbufferStorage pepper_opengl_interface->RenderbufferStorage
#define glSampleCoverage pepper_opengl_interface->SampleCoverage
#define glScissor pepper_opengl_interface->Scissor
#define glShaderBinary pepper_opengl_interface->ShaderBinary
#define glShaderSource pepper_opengl_interface->ShaderSource
#define glStencilFunc pepper_opengl_interface->StencilFunc
#define glStencilFuncSeparate pepper_opengl_interface->StencilFuncSeparate
#define glStencilMask pepper_opengl_interface->StencilMask
#define glStencilMaskSeparate pepper_opengl_interface->StencilMaskSeparate
#define glStencilOp pepper_opengl_interface->StencilOp
#define glStencilOpSeparate pepper_opengl_interface->StencilOpSeparate
#define glTexImage2D pepper_opengl_interface->TexImage2D
#define glTexParameterf pepper_opengl_interface->TexParameterf
#define glTexParameterfv pepper_opengl_interface->TexParameterfv
#define glTexParameteri pepper_opengl_interface->TexParameteri
#define glTexParameteriv pepper_opengl_interface->TexParameteriv
#define glTexSubImage2D pepper_opengl_interface->TexSubImage2D
#define glUniform1f pepper_opengl_interface->Uniform1f
#define glUniform1fv pepper_opengl_interface->Uniform1fv
#define glUniform1i pepper_opengl_interface->Uniform1i
#define glUniform1iv pepper_opengl_interface->Uniform1iv
#define glUniform2f pepper_opengl_interface->Uniform2f
#define glUniform2fv pepper_opengl_interface->Uniform2fv
#define glUniform2i pepper_opengl_interface->Uniform2i
#define glUniform2iv pepper_opengl_interface->Uniform2iv
#define glUniform3f pepper_opengl_interface->Uniform3f
#define glUniform3fv pepper_opengl_interface->Uniform3fv
#define glUniform3i pepper_opengl_interface->Uniform3i
#define glUniform3iv pepper_opengl_interface->Uniform3iv
#define glUniform4f pepper_opengl_interface->Uniform4f
#define glUniform4fv pepper_opengl_interface->Uniform4fv
#define glUniform4i pepper_opengl_interface->Uniform4i
#define glUniform4iv pepper_opengl_interface->Uniform4iv
#define glUniformMatrix2fv pepper_opengl_interface->UniformMatrix2fv
#define glUniformMatrix3fv pepper_opengl_interface->UniformMatrix3fv
#define glUniformMatrix4fv pepper_opengl_interface->UniformMatrix4fv
#define glUseProgram pepper_opengl_interface->UseProgram
#define glValidateProgram pepper_opengl_interface->ValidateProgram
#define glVertexAttrib1f pepper_opengl_interface->VertexAttrib1f
#define glVertexAttrib1fv pepper_opengl_interface->VertexAttrib1fv
#define glVertexAttrib2f pepper_opengl_interface->VertexAttrib2f
#define glVertexAttrib2fv pepper_opengl_interface->VertexAttrib2fv
#define glVertexAttrib3f pepper_opengl_interface->VertexAttrib3f
#define glVertexAttrib3fv pepper_opengl_interface->VertexAttrib3fv
#define glVertexAttrib4f pepper_opengl_interface->VertexAttrib4f
#define glVertexAttrib4fv pepper_opengl_interface->VertexAttrib4fv
#define glVertexAttribPointer pepper_opengl_interface->VertexAttribPointer
#define glViewport pepper_opengl_interface->Viewport
#endif /* __gl2_h_ */

269
ppapi/GLES2/khrplatform.h Normal file

@ -0,0 +1,269 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* $Revision: 7820 $ on $Date: 2009-04-03 13:46:26 -0700 (Fri, 03 Apr 2009) $
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by sending them to the public Khronos Bugzilla
* (http://khronos.org/bugzilla) by filing a bug against product
* "Khronos (general)" component "Registry".
*
* A predefined template which fills in some of the bug fields can be
* reached using http://tinyurl.com/khrplatform-h-bugreport, but you
* must create a Bugzilla login first.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

27
ppapi/LICENSE Normal file

@ -0,0 +1,27 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@ -0,0 +1,53 @@
// 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.
#ifndef PPAPI_C_DEV_PP_CURSORTYPE_DEV_H_
#define PPAPI_C_DEV_PP_CURSORTYPE_DEV_H_
enum PP_CursorType_Dev {
PP_CURSORTYPE_POINTER = 0,
PP_CURSORTYPE_CROSS = 1,
PP_CURSORTYPE_HAND = 2,
PP_CURSORTYPE_IBEAM = 3,
PP_CURSORTYPE_WAIT = 4,
PP_CURSORTYPE_HELP = 5,
PP_CURSORTYPE_EASTRESIZE = 6,
PP_CURSORTYPE_NORTHRESIZE = 7,
PP_CURSORTYPE_NORTHEASTRESIZE = 8,
PP_CURSORTYPE_NORTHWESTRESIZE = 9,
PP_CURSORTYPE_SOUTHRESIZE = 10,
PP_CURSORTYPE_SOUTHEASTRESIZE = 11,
PP_CURSORTYPE_SOUTHWESTRESIZE = 12,
PP_CURSORTYPE_WESTRESIZE = 13,
PP_CURSORTYPE_NORTHSOUTHRESIZE = 14,
PP_CURSORTYPE_EASTWESTRESIZE = 15,
PP_CURSORTYPE_NORTHEASTSOUTHWESTRESIZE = 16,
PP_CURSORTYPE_NORTHWESTSOUTHEASTRESIZE = 17,
PP_CURSORTYPE_COLUMNRESIZE = 18,
PP_CURSORTYPE_ROWRESIZE = 19,
PP_CURSORTYPE_MIDDLEPANNING = 20,
PP_CURSORTYPE_EASTPANNING = 21,
PP_CURSORTYPE_NORTHPANNING = 22,
PP_CURSORTYPE_NORTHEASTPANNING = 23,
PP_CURSORTYPE_NORTHWESTPANNING = 24,
PP_CURSORTYPE_SOUTHPANNING = 25,
PP_CURSORTYPE_SOUTHEASTPANNING = 26,
PP_CURSORTYPE_SOUTHWESTPANNING = 27,
PP_CURSORTYPE_WESTPANNING = 28,
PP_CURSORTYPE_MOVE = 29,
PP_CURSORTYPE_VERTICALTEXT = 30,
PP_CURSORTYPE_CELL = 31,
PP_CURSORTYPE_CONTEXTMENU = 32,
PP_CURSORTYPE_ALIAS = 33,
PP_CURSORTYPE_PROGRESS = 34,
PP_CURSORTYPE_NODROP = 35,
PP_CURSORTYPE_COPY = 36,
PP_CURSORTYPE_NONE = 37,
PP_CURSORTYPE_NOTALLOWED = 38,
PP_CURSORTYPE_ZOOMIN = 39,
PP_CURSORTYPE_ZOOMOUT = 40,
PP_CURSORTYPE_CUSTOM = 41
};
#endif // PPAPI_C_DEV_PP_CURSORTYPE_DEV_H_

@ -0,0 +1,32 @@
// 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.
#ifndef PPAPI_C_DEV_PP_FILE_INFO_DEV_H_
#define PPAPI_C_DEV_PP_FILE_INFO_DEV_H_
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
typedef enum {
PP_FILETYPE_REGULAR,
PP_FILETYPE_DIRECTORY,
PP_FILETYPE_OTHER // A catch-all for unidentified types.
} PP_FileType_Dev;
typedef enum {
PP_FILESYSTEMTYPE_EXTERNAL,
PP_FILESYSTEMTYPE_LOCALPERSISTENT,
PP_FILESYSTEMTYPE_LOCALTEMPORARY
} PP_FileSystemType_Dev;
struct PP_FileInfo_Dev {
int64_t size; // Measured in bytes
PP_FileType_Dev type;
PP_FileSystemType_Dev system_type;
PP_Time creation_time;
PP_Time last_access_time;
PP_Time last_modified_time;
};
#endif // PPAPI_C_DEV_PP_FILE_INFO_DEV_H_

290
ppapi/c/dev/pp_video_dev.h Normal file

@ -0,0 +1,290 @@
// 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.
#ifndef PPAPI_C_DEV_PP_VIDEO_DEV_H_
#define PPAPI_C_DEV_PP_VIDEO_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
enum PP_VideoKey_Dev {
PP_VIDEOKEY_NONE = 0,
// Value is type of PP_VideoCodecId.
PP_VIDEOKEY_CODECID,
// Value is type of PP_VideoOperation.
PP_VIDEOKEY_OPERATION,
// Value is type of PP_VideoCodecProfile.
PP_VIDEOKEY_CODECPROFILE,
// Value is type of PP_VideoCodecLevel.
PP_VIDEOKEY_CODECLEVEL,
// Value is 0 or 1.
PP_VIDEOKEY_ACCELERATION,
// Value is type of PP_VideoPayloadFormat.
PP_VIDEOKEY_PAYLOADFORMAT,
// Value is type of PP_VideoFrameColorType.
PP_VIDEOKEY_COLORTYPE,
// Value is type of PP_VideoFrameSurfaceType.
PP_VIDEOKEY_SURFACETYPE,
// Value is type of PP_VideoFrameInfoFlag.
PP_VIDEOKEY_FRAMEINFOFLAG,
// Subset for H.264 features, value of 1 means supported. This is needed in
// case decoder has partial support for certain profile.
PP_VIDEOKEY_H264FEATURE_FMO = 0x100,
PP_VIDEOKEY_H264FEATURE_ASO,
PP_VIDEOKEY_H264FEATURE_INTERLACE,
PP_VIDEOKEY_H264FEATURE_CABAC,
PP_VIDEOKEY_H264FEATURE_WEIGHTEDPREDICTION
};
enum PP_VideoDecoderEvent_Dev {
PP_VIDEODECODEREVENT_NONE = 0,
// Signaling that an error has been hit.
PP_VIDEODECODEREVENT_ERROR,
// Signaling new width/height of video frame
PP_VIDEODECODEREVENT_NEWDIMENSION,
// Signaling new cropping rectangle
PP_VIDEODECODEREVENT_NEWCROP
};
enum PP_VideoDecodeError_Dev {
PP_VIDEODECODEERROR_NONE = 0,
PP_VIDEODECODEERROR_NOTSUPPORTED,
PP_VIDEODECODEERROR_INSUFFICIENTRESOURCES,
PP_VIDEODECODEERROR_UNDEFINED,
PP_VIDEODECODEERROR_BADINPUT,
PP_VIDEODECODEERROR_HARDWARE
};
enum PP_VideoCodecId_Dev {
PP_VIDEODECODECID_NONE = 0,
PP_VIDEODECODECID_H264,
PP_VIDEODECODECID_VC1,
PP_VIDEODECODECID_MPEG2,
PP_VIDEODECODECID_VP8
};
enum PP_VideoOperation_Dev {
PP_VIDEOOPERATION_NONE = 0,
PP_VIDEOOPERATION_DECODE,
PP_VIDEOOPERATION_ENCODE
};
enum PP_VideoCodecProfile_Dev {
PP_VIDEOCODECPROFILE_NONE = 0,
PP_VIDEOCODECPROFILE_H264_BASELINE,
PP_VIDEOCODECPROFILE_H264_MAIN,
PP_VIDEOCODECPROFILE_H264_EXTENDED,
PP_VIDEOCODECPROFILE_H264_HIGH,
PP_VIDEOCODECPROFILE_H264_SCALABLEBASELINE,
PP_VIDEOCODECPROFILE_H264_SCALABLEHIGH,
PP_VIDEOCODECPROFILE_H264_STEREOHIGH,
PP_VIDEOCODECPROFILE_H264_MULTIVIEWHIGH,
PP_VIDEOCODECPROFILE_VC1_SIMPLE = 0x40,
PP_VIDEOCODECPROFILE_VC1_MAIN,
PP_VIDEOCODECPROFILE_VC1_ADVANCED,
PP_VIDEOCODECPROFILE_MPEG2_SIMPLE = 0x80,
PP_VIDEOCODECPROFILE_MPEG2_MAIN,
PP_VIDEOCODECPROFILE_MPEG2_SNR,
PP_VIDEOCODECPROFILE_MPEG2_SPATIAL,
PP_VIDEOCODECPROFILE_MPEG2_HIGH
};
enum PP_VideoCodecLevel_Dev {
PP_VIDEOCODECLEVEL_NONE = 0,
PP_VIDEOCODECLEVEL_H264_10,
PP_VIDEOCODECLEVEL_H264_1B,
PP_VIDEOCODECLEVEL_H264_11,
PP_VIDEOCODECLEVEL_H264_12,
PP_VIDEOCODECLEVEL_H264_13,
PP_VIDEOCODECLEVEL_H264_20,
PP_VIDEOCODECLEVEL_H264_21,
PP_VIDEOCODECLEVEL_H264_22,
PP_VIDEOCODECLEVEL_H264_30,
PP_VIDEOCODECLEVEL_H264_31,
PP_VIDEOCODECLEVEL_H264_32,
PP_VIDEOCODECLEVEL_H264_40,
PP_VIDEOCODECLEVEL_H264_41,
PP_VIDEOCODECLEVEL_H264_42,
PP_VIDEOCODECLEVEL_H264_50,
PP_VIDEOCODECLEVEL_H264_51,
PP_VIDEOCODECLEVEL_VC1_LOW = 0x40,
PP_VIDEOCODECLEVEL_VC1_MEDIUM,
PP_VIDEOCODECLEVEL_VC1_HIGH,
PP_VIDEOCODECLEVEL_VC1_L0,
PP_VIDEOCODECLEVEL_VC1_L1,
PP_VIDEOCODECLEVEL_VC1_L2,
PP_VIDEOCODECLEVEL_VC1_L3,
PP_VIDEOCODECLEVEL_VC1_L4,
PP_VIDEOCODECLEVEL_MPEG2_LOW = 0x80,
PP_VIDEOCODECLEVEL_MPEG2_MAIN,
PP_VIDEOCODECLEVEL_MPEG2_HIGH1440,
PP_VIDEOCODECLEVEL_MPEG2_HIGH
};
enum PP_VideoPayloadFormat_Dev {
PP_VIDEOPAYLOADFORMAT_NONE = 0,
PP_VIDEOPAYLOADFORMAT_BYTESTREAM,
PP_VIDEOPAYLOADFORMAT_RTPPAYLOAD
};
enum PP_VideoFrameColorType_Dev {
PP_VIDEOFRAMECOLORTYPE_NONE = 0,
PP_VIDEOFRAMECOLORTYPE_RGB565,
PP_VIDEOFRAMECOLORTYPE_ARGB8888,
PP_VIDEOFRAMECOLORTYPE_YUV,
PP_VIDEOFRAMECOLORTYPE_Monochrome,
PP_VIDEOFRAMECOLORTYPE_YUV420PLANAR,
PP_VIDEOFRAMECOLORTYPE_YUV422PLANAR,
PP_VIDEOFRAMECOLORTYPE_YUV444PLANAR
};
enum PP_VideoFrameSurfaceType_Dev {
PP_VIDEOFRAMESURFACETYPE_NONE = 0,
PP_VIDEOFRAMESURFACETYPE_SYSTEMMEMORY,
PP_VIDEOFRAMESURFACETYPE_GLTEXTURE,
PP_VIDEOFRAMESURFACETYPE_PIXMAP
};
enum PP_VideoFrameInfoFlag_Dev {
PP_VIDEOFRAMEINFOFLAG_NONE = 0,
// Indicate this is the end of stream. Used by both plugin and browser.
PP_VIDEOFRAMEINFOFLAG_EOS = 1 << 0,
// Decode the frame only, don't return decoded frame. Used by plugin.
PP_VIDEOFRAMEINFOFLAG_NOEMIT = 1 << 1,
// Indicate this is an anchor frame. Used by plugin.
PP_VIDEOFRAMEINFOFLAG_SYNCFRAME = 1 << 2,
// Indicate the decoded frame has data corruption. Used by browser.
PP_VIDEOFRAMEINFOFLAG_DATACORRUPT = 1 << 3
};
enum PP_VideoFrameBufferConst_Dev {
// YUV formats
PP_VIDEOFRAMEBUFFER_YPLANE = 0,
PP_VIDEOFRAMEBUFFER_UPLANE = 1,
PP_VIDEOFRAMEBUFFER_VPLANE = 2,
PP_VIDEOFRAMEBUFFER_NUMBERYUVPLANES = 3,
// RGBA formats
PP_VIDEOFRAMEBUFFER_RGBAPLANE = 0,
PP_VIDEOFRAMEBUFFER_NUMBERRGBAPLANES = 1,
PP_VIDEOFRAMEBUFFER_MAXNUMBERPLANES = 4
};
typedef int64_t PP_VideoDecodeData_Dev;
// Array of key/value pairs describing video configuration.
// It could include any keys from PP_VideoKey. Its last element shall be
// PP_VIDEOKEY_NONE with no corresponding value.
// An example:
// {
// PP_VIDEOKEY_CODECID, PP_VIDEODECODECID_H264,
// PP_VIDEOKEY_OPERATION, PP_VIDEOOPERATION_DECODE,
// PP_VIDEOKEY_CODECPROFILE, PP_VIDEOCODECPROFILE_H264_HIGH,
// PP_VIDEOKEY_CODECLEVEL, PP_VIDEOCODECLEVEL_H264_41,
// PP_VIDEOKEY_ACCELERATION, 1
// PP_VIDEOKEY_NONE,
// };
typedef int32_t* PP_VideoConfig_Dev;
typedef int32_t PP_VideoConfigElement_Dev;
// The data structure for compressed data buffer.
struct PP_VideoCompressedDataBuffer_Dev {
// The buffer is created through PPB_Buffer API.
// TODO(wjia): would uint8_t* be good, too?
PP_Resource buffer;
// number of bytes with real data in the buffer.
int32_t filled_size;
// Time stamp of the frame in microsecond.
uint64_t time_stamp_us;
// Bit mask of PP_VideoFrameInfoFlag.
uint32_t flags;
};
struct PP_VideoFrameBuffer_Dev {
union {
struct {
int32_t planes;
struct {
int32_t width;
int32_t height;
int32_t stride;
// TODO(wjia): uint8* would be better for some cases.
PP_Resource buffer;
} data_plane[PP_VIDEOFRAMEBUFFER_MAXNUMBERPLANES];
} sys_mem;
// Handle for pixmap, gl texture, etc.
void* handle;
} buffer;
// Storage for decoder to save some private data. It could be useful when
// plugin returns frame buffer to decoder.
void* private_handle;
};
struct PP_VideoUncompressedDataBuffer_Dev {
PP_VideoConfig_Dev format;
struct PP_VideoFrameBuffer_Dev buffer;
// Time stamp of the frame in microsecond.
uint64_t time_stamp_us;
// Bit mask of PP_VideoFrameInfoFlag.
uint32_t flags;
// Output from decoder, indicating the decoded frame has error pixels. This
// could be resulted from corrupted input bit stream and error concealment
// in decoding.
// TODO(wjia): add more info about error pixels, such as error MB map, etc.
bool has_error;
};
// Plugin callback for decoder to deliver decoded frame buffers.
// |format| in |buffer| specifies the format of decoded frame, with
// PP_VIDEOKEY_COLORTYPE and PP_VIDEOKEY_SURFACETYPE required.
typedef void (*PP_VideoDecodeOutputCallback_Func_Dev)(
PP_Instance instance,
struct PP_VideoUncompressedDataBuffer_Dev* buffer);
// Plugin callback for decoder to return input data buffers.
// Plugin can optionally provide this callback only when it wants to recycle
// input data buffers.
typedef void (*PP_VideoDecodeInputCallback_Func_Dev)(
PP_Instance instance,
struct PP_VideoCompressedDataBuffer_Dev* buffer);
// Event handling Function for decoder to deliver events to plugin.
// The correspondence between event and data1, data2:
// When event == PP_VIDEODECODEREVENT_ERROR,
// data1 is type of PP_VideoDecodeError id and data2 is ignored;
// When event == PP_VIDEODECODEREVENT_NEWDIMENSION,
// data1 is type of PP_Size*, data2 is ignored;
// When event == PP_VIDEODECODEREVENT_NEWCROP,
// data1 is type of PP_Rect*, data2 is ignored;
typedef void (*PP_VideoDecodeEventHandler_Func_Dev)(
PP_Instance instance,
PP_VideoDecoderEvent_Dev event,
PP_VideoDecodeData_Dev data1,
PP_VideoDecodeData_Dev data2);
// Requested decoder configuration and callback from plugin.
struct PP_VideoDecoderConfig_Dev {
PP_VideoConfig_Dev input_format;
PP_VideoConfig_Dev output_format;
PP_VideoDecodeOutputCallback_Func_Dev output_callback;
PP_VideoDecodeInputCallback_Func_Dev input_callback;
PP_VideoDecodeEventHandler_Func_Dev event_handler;
};
#endif // PPAPI_C_DEV_PP_VIDEO_DEV_H_

@ -0,0 +1,94 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_
#define PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_AUDIO_CONFIG_DEV_INTERFACE "PPB_AudioConfig(Dev);0.2"
enum {
PP_AUDIOMINSAMPLEFRAMECOUNT = 64,
PP_AUDIOMAXSAMPLEFRAMECOUNT = 32768
};
typedef enum {
PP_AUDIOSAMPLERATE_NONE = 0,
PP_AUDIOSAMPLERATE_44100 = 44100,
PP_AUDIOSAMPLERATE_48000 = 48000
} PP_AudioSampleRate_Dev;
/**
* Audio configuration. This base configuration interface supports only stereo
* 16bit output. This class is not mutable, therefore it is okay to access
* instances from different threads.
*/
struct PPB_AudioConfig_Dev {
/**
* Create a 16 bit stereo config with the given sample rate. We guarantee
* that PP_AUDIOSAMPLERATE_44100 and PP_AUDIOSAMPLERATE_48000 sample rates
* are supported. The |sample_frame_count| should be the result of calling
* RecommendSampleFrameCount. If the sample frame count or bit rate aren't
* supported, this function will fail and return a null resource.
*
* A single sample frame on a stereo device means one value for the left
* channel and one value for the right channel.
*
* Buffer layout for a stereo int16 configuration:
* int16_t *buffer16;
* buffer16[0] is the first left channel sample
* buffer16[1] is the first right channel sample
* buffer16[2] is the second left channel sample
* buffer16[3] is the second right channel sample
* ...
* buffer16[2 * (sample_frame_count - 1)] is the last left channel sample
* buffer16[2 * (sample_frame_count - 1) + 1] is the last right channel sample
* Data will always be in the native endian format of the platform.
*/
PP_Resource (*CreateStereo16Bit)(PP_Module module,
PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count);
/*
* Returns a supported sample frame count closest to the given requested
* count. The sample frame count determines the overall latency of audio.
* Since one "frame" is always buffered in advance, smaller frame counts
* will yield lower latency, but higher CPU utilization.
*
* Supported sample frame counts will vary by hardware and system (consider
* that the local system might be anywhere from a cell phone or a high-end
* audio workstation). Sample counts less than PP_AUDIOMINSAMPLEFRAMECOUNT
* and greater than PP_AUDIOMAXSAMPLEFRAMECOUNT are never supported on any
* system, but values in between aren't necessarily valid. This function
* will return a supported count closest to the requested value.
*
* If you pass 0 as the requested sample count, the recommended sample for
* the local system is returned.
*/
uint32_t (*RecommendSampleFrameCount)(uint32_t requested_sample_frame_count);
/**
* Returns true if the given resource is an AudioConfig object.
*/
bool (*IsAudioConfig)(PP_Resource resource);
/**
* Returns the sample rate for the given AudioConfig resource. If the
* resource is invalid, this will return PP_AUDIOSAMPLERATE_NONE.
*/
PP_AudioSampleRate_Dev (*GetSampleRate)(PP_Resource config);
/**
* Returns the sample frame count for the given AudioConfig resource. If the
* resource is invalid, this will return 0. See RecommendSampleFrameCount for
* more on sample frame counts.
*/
uint32_t (*GetSampleFrameCount)(PP_Resource config);
};
#endif // PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_

@ -0,0 +1,71 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_AUDIO_DEV_H_
#define PPAPI_C_DEV_PPB_AUDIO_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_AUDIO_DEV_INTERFACE "PPB_Audio(Dev);0.2"
// Callback function type for SetCallback.
typedef void (*PPB_Audio_Callback)(void* sample_buffer,
size_t buffer_size_in_bytes,
void* user_data);
// Callback-based audio interface. User of audio must set the callback that will
// be called each time that the buffer needs to be filled.
//
// A C++ example:
//
// void audio_callback(void* sample_buffer,
// size_t buffer_size_in_bytes,
// void* user_data) {
// ... fill in the buffer with samples ...
// }
//
// uint32_t obtained;
// AudioConfig config(PP_AUDIOSAMPLERATE_44100, 4096, &obtained);
// Audio audio(config, audio_callback, NULL);
// audio.StartPlayback();
//
struct PPB_Audio_Dev {
// Creates a paused audio interface. No sound will be heard until
// StartPlayback() is called. The callback is called with the buffer address
// and given user data whenever the buffer needs to be filled. From within the
// callback, you should not call PPB_Audio functions. The callback will be
// called on a different thread than the one which created the interface. For
// performance-critical applications (i.e. low-latency audio), the callback
// should avoid blocking or calling functions that can obtain locks, such as
// malloc. The layout and the size of the buffer passed to the audio callback
// will be determined by the device configuration and is specified in the
// AudioConfig documentation. If the configuration cannot be honored, or the
// callback is null, the function returns 0.
PP_Resource (*Create)(PP_Instance instance, PP_Resource config,
PPB_Audio_Callback audio_callback, void* user_data);
/**
* Returns true if the given resource is an Audio resource.
*/
bool (*IsAudio)(PP_Resource resource);
// Get the current configuration.
PP_Resource (*GetCurrentConfig)(PP_Resource audio);
// Start the playback. Begin periodically calling the callback. If called
// while playback is already in progress, will return true and be a no-op.
// On error, return false.
bool (*StartPlayback)(PP_Resource audio);
// Stop the playback. If playback is already stopped, this is a no-op and
// returns true. On error, returns false. If a callback is in progress,
// StopPlayback will block until callback completes.
bool (*StopPlayback)(PP_Resource audio);
};
#endif // PPAPI_C_DEV_PPB_DEVICE_CONTEXT_AUDIO_DEV_H_

@ -0,0 +1,27 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_AUDIO_TRUSTED_DEV_H_
#define PPAPI_C_DEV_PPB_AUDIO_TRUSTED_DEV_H_
#include "ppapi/c/pp_resource.h"
#define PPB_AUDIO_TRUSTED_DEV_INTERFACE "PPB_AudioTrusted(Dev);0.1"
// This interface is used to get access to the audio buffer and a socket on
// which the client can block until the audio is ready to accept more data.
// This interface should be used by NaCl to implement the Audio interface.
struct PPB_AudioTrusted_Dev {
// Returns a Buffer object that has the audio buffer.
PP_Resource (*GetBuffer)(PP_Resource audio);
// Returns a select()-able/Wait()-able OS-specific descriptor. The browser
// will put a byte on the socket each time the buffer is ready to be filled.
// The plugin can then implement its own audio thread using select()/poll() to
// block until the browser is ready to receive data.
int (*GetOSDescriptor)(PP_Resource audio);
};
#endif // PPAPI_C_DEV_PPB_AUDIO_TRUSTED_DEV_H_

@ -0,0 +1,36 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_BUFFER_DEV_H_
#define PPAPI_C_DEV_PPB_BUFFER_DEV_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_BUFFER_DEV_INTERFACE "PPB_Buffer(Dev);0.1"
struct PPB_Buffer_Dev {
// Allocates a buffer of the given size in bytes. The return value will have
// a non-zero ID on success, or zero on failure. Failure means the module
// handle was invalid. The buffer will be initialized to contain zeroes.
PP_Resource (*Create)(PP_Module module, int32_t size_in_bytes);
// Returns true if the given resource is a Buffer. Returns false if the
// resource is invalid or some type other than a Buffer.
bool (*IsBuffer)(PP_Resource resource);
// Gets the size of the buffer. Returns true on success, false
// if the resource is not a buffer. On failure, |*size_in_bytes| is not set.
bool (*Describe)(PP_Resource resource, int32_t* size_in_bytes);
// Maps this buffer into the plugin address space and returns a pointer to the
// beginning of the data.
void* (*Map)(PP_Resource resource);
void (*Unmap)(PP_Resource resource);
};
#endif // PPAPI_C_DEV_PPB_BUFFER_DEV_H_

@ -0,0 +1,78 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_
#define PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
#define PPB_CHAR_SET_DEV_INTERFACE "PPB_CharSet(Dev);0.1"
// Specifies the error behavior for the character set conversion functions.
// This will affect two cases: where the input is not encoded correctly, and
// when the requested character can not be converted to the destination
// character set.
enum PP_CharSet_ConversionError {
// Causes the entire conversion to fail if an error is encountered. The
// conversion function will return NULL.
PP_CHARSET_CONVERSIONERROR_FAIL,
// Silently skips over errors. Unrepresentable characters and input encoding
// errors will be removed from the output.
PP_CHARSET_CONVERSIONERROR_SKIP,
// Replaces the error or unrepresentable character with a substitution
// character. When converting to a Unicode character set (UTF-8 or UTF-16)
// it will use the unicode "substitution character" U+FFFD. When converting
// to another character set, the character will be charset-specific. For
// many languages this will be the representation of the '?' character.
PP_CHARSET_CONVERSIONERROR_SUBSTITUTE,
};
struct PPB_CharSet_Dev {
// Converts the UTF-16 string pointed to in |*utf16| to an 8-bit string in the
// specified code page. |utf16_len| is measured in UTF-16 units, not bytes.
// This value may not be NULL.
//
// The return value is a NULL-terminated 8-bit string corresponding to the
// new character set, or NULL on failure. THIS STRING MUST BE FREED USING
// PPB_Core::MemFree(). The length of the returned string, not including the
// terminating NULL, will be placed into *output_length. When there is no
// error, the result will always be non-NULL, even if the output is 0-length.
// In this case, it will only contain the terminator. You must still call
// MemFree any time the return value is non-NULL.
//
// This function will return NULL if there was an error converting the string
// and you requested PP_CHARSET_CONVERSIONERROR_FAIL, or the output character
// set was unknown.
char* (*UTF16ToCharSet)(const uint16_t* utf16, uint32_t utf16_len,
const char* output_char_set,
PP_CharSet_ConversionError on_error,
uint32_t* output_length);
// Same as UTF16ToCharSet except converts in the other direction. The input
// is in the given charset, and the |input_len| is the number of bytes in
// the |input| string. |*output_length| is the number of 16-bit values in
// the output not counting the terminating NULL.
//
// Since UTF16 can represent every Unicode character, the only time the
// replacement character will be used is if the encoding in the input string
// is incorrect.
uint16_t* (*CharSetToUTF16)(const char* input, uint32_t input_len,
const char* input_char_set,
PP_CharSet_ConversionError on_error,
uint32_t* output_length);
// Returns a string var representing the current multi-byte character set of
// the current system.
//
// WARNING: You really shouldn't be using this function unless you're dealing
// with legacy data. You should be using UTF-8 or UTF-16 and you don't have
// to worry about the character sets.
PP_Var (*GetDefaultCharSet)(PP_Module module);
};
#endif // PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_

@ -0,0 +1,56 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_
#define PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_
#include "ppapi/c/dev/pp_cursor_type_dev.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_resource.h"
#define PPB_CURSOR_CONTROL_DEV_INTERFACE "PPB_CursorControl(Dev);0.1"
struct PPB_CursorControl_Dev {
// Set a cursor. If "type" is PP_CURSOR_TYPE_CUSTOM, then "custom_image"
// must be an ImageData resource containing the cursor and "hot_spot" must
// contain the offset within that image that refers to the cursor's position.
bool (*SetCursor)(PP_Instance instance,
enum PP_CursorType_Dev type,
PP_Resource custom_image,
const struct PP_Point* hot_spot);
// This method causes the cursor to be moved to the center of the
// instance and be locked, preventing the user from moving it.
// The cursor is implicitly hidden from the user while locked.
// Cursor lock may only be requested in response to a
// PP_InputEvent_MouseDown, and then only if the event was generated via
// user gesture.
//
// While the cursor is locked, any movement of the mouse will
// generate a PP_InputEvent_Type_MouseMove, whose x and y values
// indicate the position the cursor would have been moved to had
// the cursor not been locked, and had the screen been infinite in size.
//
// The browser may revoke cursor lock for reasons including but not
// limited to the user pressing the ESC key, the user activating
// another program via a reserved keystroke (e.g., ALT+TAB), or
// some other system event.
//
// Returns true if the cursor could be locked.
bool (*LockCursor)(PP_Instance);
// Causes the cursor to be unlocked, allowing it to track user
// movement again.
bool (*UnlockCursor)(PP_Instance);
// Returns true if the cursor is locked.
bool (*HasCursorLock)(PP_Instance);
// Returns true if the cursor can be locked.
bool (*CanLockCursor)(PP_Instance);
};
#endif // PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_

@ -0,0 +1,52 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_
#define PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
struct PP_CompletionCallback;
struct PP_DirectoryEntry_Dev {
PP_Resource file_ref;
PP_FileType_Dev file_type;
};
#define PPB_DIRECTORYREADER_DEV_INTERFACE "PPB_DirectoryReader(Dev);0.1"
struct PPB_DirectoryReader_Dev {
// Creates a DirectoryReader for the given directory. Upon success, the
// corresponding directory is classified as "in use" by the resulting
// DirectoryReader object until such time as the DirectoryReader object is
// destroyed.
PP_Resource (*Create)(PP_Resource directory_ref);
// Returns true if the given resource is a DirectoryReader. Returns false if
// the resource is invalid or some type other than a DirectoryReader.
bool (*IsDirectoryReader)(PP_Resource resource);
// Reads the next entry in the directory. Return PP_OK and sets
// entry->file_ref to 0 to indicate reaching the end of the directory. If
// entry->file_ref is non-zero when passed to GetNextEntry, it will be
// released before the next file_ref is stored.
//
// EXAMPLE USAGE:
//
// PP_Resource reader = reader_funcs->Create(dir_ref);
// PP_DirectoryEntry entry = {0};
// while (reader_funcs->GetNextEntry(reader, &entry,
// PP_BlockUntilComplete()) == PP_OK) {
// ProcessDirectoryEntry(entry);
// }
// core_funcs->ReleaseResource(reader);
//
int32_t (*GetNextEntry)(PP_Resource directory_reader,
struct PP_DirectoryEntry_Dev* entry,
struct PP_CompletionCallback callback);
};
#endif // PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_

@ -0,0 +1,57 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_
#define PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
struct PP_CompletionCallback;
typedef enum {
PP_FILECHOOSERMODE_OPEN,
PP_FILECHOOSERMODE_OPENMULTIPLE
// TODO(darin): Should there be a way to choose a directory?
} PP_FileChooserMode_Dev;
struct PP_FileChooserOptions_Dev {
PP_FileChooserMode_Dev mode;
// A comma-separated list of MIME types such as audio/*,text/plain. The
// dialog may restrict selectable files to the specified MIME types.
// TODO(darin): What if the mime type is unknown to the system? The plugin
// may wish to describe the mime type and provide a matching file extension.
// It is more webby to use mime types here instead of file extensions.
const char* accept_mime_types;
};
#define PPB_FILECHOOSER_DEV_INTERFACE "PPB_FileChooser(Dev);0.1"
struct PPB_FileChooser_Dev {
// Creates a file chooser dialog with the specified options. The chooser is
// associated with a particular instance, so that it may be positioned on the
// screen relative to the tab containing the instance. Returns 0 if passed
// an invalid instance.
PP_Resource (*Create)(PP_Instance instance,
const struct PP_FileChooserOptions_Dev* options);
// Returns true if the given resource is a FileChooser. Returns false if the
// resource is invalid or some type other than a FileChooser.
bool (*IsFileChooser)(PP_Resource resource);
// Prompts the user to choose a file or files.
int32_t (*Show)(PP_Resource chooser, struct PP_CompletionCallback callback);
// After a successful call to Show, this method may be used to query the
// chosen files. It should be called in a loop until it returns 0.
// Depending on the PP_ChooseFileMode requested when the FileChooser was
// created, the file refs will either be readable or writable. Their file
// system type will be PP_FileSystemType_External. If the user chose no
// files or cancelled the dialog, then this method will simply return 0
// the first time it is called.
PP_Resource (*GetNextChosenFile)(PP_Resource chooser);
};
#endif // PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_

@ -0,0 +1,115 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FILE_IO_DEV_H_
#define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
struct PP_CompletionCallback;
struct PP_FileInfo_Dev;
typedef enum {
// Requests read access to a file.
PP_FILEOPENFLAG_READ = 1 << 0,
// Requests write access to a file. May be combined with
// PP_FILEOPENFLAG_READ to request read and write access.
PP_FILEOPENFLAG_WRITE = 1 << 1,
// Requests that the file be created if it does not exist. If the file
// already exists, then this flag is ignored unless PP_FILEOPENFLAG_EXCLUSIVE
// was also specified, in which case FileIO::Open will fail.
PP_FILEOPENFLAG_CREATE = 1 << 2,
// Requests that the file be truncated to length 0 if it exists and is a
// regular file. PP_FILEOPENFLAG_WRITE must also be specified.
PP_FILEOPENFLAG_TRUNCATE = 1 << 3,
// Requests that the file is created when this flag is combined with
// PP_FILEOPENFLAG_CREATE. If this flag is specified, and the file already
// exists, then the FileIO::Open call will fail.
PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4
} PP_FileOpenFlags_Dev;
#define PPB_FILEIO_DEV_INTERFACE "PPB_FileIO(Dev);0.1"
// Use this interface to operate on a regular file (PP_FileType_Regular).
struct PPB_FileIO_Dev {
// Creates a new FileIO object. Returns 0 if the module is invalid.
PP_Resource (*Create)(PP_Module module);
// Returns true if the given resource is a FileIO. Returns false if the
// resource is invalid or some type other than a FileIO.
bool (*IsFileIO)(PP_Resource resource);
// Open the specified regular file for I/O according to the given open flags,
// which is a bit-mask of the PP_FileOpenFlags values. Upon success, the
// corresponding file is classified as "in use" by this FileIO object until
// such time as the FileIO object is closed or destroyed.
int32_t (*Open)(PP_Resource file_io,
PP_Resource file_ref,
int32_t open_flags,
struct PP_CompletionCallback callback);
// Queries info about the file opened by this FileIO object. Fails if the
// FileIO object has not been opened.
int32_t (*Query)(PP_Resource file_io,
PP_FileInfo_Dev* info,
struct PP_CompletionCallback callback);
// Updates timestamps for the file opened by this FileIO object. Fails if
// the FileIO object has not been opened.
int32_t (*Touch)(PP_Resource file_io,
PP_Time last_access_time,
PP_Time last_modified_time,
struct PP_CompletionCallback callback);
// Read from an offset in the file. The size of the buffer must be large
// enough to hold the specified number of bytes to read. May perform a
// partial read. Returns the number of bytes read or an error code. If the
// return value is 0, then it indicates that end-of-file was reached. It is
// valid to call Read multiple times with a completion callback to queue up
// parallel reads from the file at different offsets.
int32_t (*Read)(PP_Resource file_io,
int64_t offset,
char* buffer,
int32_t bytes_to_read,
struct PP_CompletionCallback callback);
// Write to an offset in the file. May perform a partial write. Returns the
// number of bytes written or an error code. It is valid to call Write
// multiple times with a completion callback to queue up parallel writes to
// the file at different offsets. The FileIO object must have been opened
// with write access.
int32_t (*Write)(PP_Resource file_io,
int64_t offset,
const char* buffer,
int32_t bytes_to_write,
struct PP_CompletionCallback callback);
// Sets the length of the file. If the file size is extended, then the
// extended area of the file is zero-filled. The FileIO object must have
// been opened with write access.
int32_t (*SetLength)(PP_Resource file_io,
int64_t length,
struct PP_CompletionCallback callback);
// Flush changes to disk. This call can be very expensive!
int32_t (*Flush)(PP_Resource file_io,
struct PP_CompletionCallback callback);
// Cancels any IO that may be pending, and closes the FileIO object. Any
// pending callbacks will still run, reporting PP_Error_Aborted if pending IO
// was interrupted. It is NOT valid to call Open again after a call to this
// method. Note: If the FileIO object is destroyed, and it is still open,
// then it will be implicitly closed, so you are not required to call the
// Close method.
void (*Close)(PP_Resource file_io);
};
#endif // PPAPI_C_DEV_PPB_FILE_IO_DEV_H_

@ -0,0 +1,45 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FILE_IO_TRUSTED_DEV_H_
#define PPAPI_C_DEV_PPB_FILE_IO_TRUSTED_DEV_H_
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
struct PP_CompletionCallback;
#define PPB_FILEIOTRUSTED_DEV_INTERFACE "PPB_FileIOTrusted(Dev);0.1"
// Available only to trusted implementations.
struct PPB_FileIOTrusted_Dev {
// Returns a POSIX file descriptor corresponding to the given FileIO object.
// The FileIO object must have been opened with a successful call to
// FileIO::Open. The file descriptor will be closed automatically when the
// FileIO object is closed or destroyed.
int32_t (*GetOSFileDescriptor)(PP_Resource file_io);
// Notifies the browser that underlying file will be modified. This gives
// the browser the opportunity to apply quota restrictions and possibly
// return an error to indicate that the write is not allowed.
int32_t (*WillWrite)(PP_Resource file_io,
int64_t offset,
int32_t bytes_to_write,
struct PP_CompletionCallback callback);
// Notifies the browser that underlying file will be modified. This gives
// the browser the opportunity to apply quota restrictions and possibly
// return an error to indicate that the write is not allowed.
int32_t (*WillSetLength)(PP_Resource file_io,
int64_t length,
struct PP_CompletionCallback callback);
// TODO(darin): Maybe unify the above into a single WillChangeFileSize
// method? The above methods have the advantage of mapping to PPB_FileIO
// Write and SetLength calls. WillChangeFileSize would require the caller to
// compute the file size resulting from a Write call, which may be
// undesirable.
};
#endif // PPAPI_C_DEV_PPB_FILE_IO_TRUSTED_DEV_H_

@ -0,0 +1,88 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FILE_REF_DEV_H_
#define PPAPI_C_DEV_PPB_FILE_REF_DEV_H_
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
#define PPB_FILEREF_DEV_INTERFACE "PPB_FileRef(Dev);0.2"
// A FileRef is a "weak pointer" to a file in a file system. It contains a
// PP_FileSystemType identifier and a file path string.
struct PPB_FileRef_Dev {
// Creates a weak pointer to a file in the given filesystem. File paths are
// POSIX style. Returns 0 if the path is malformed.
PP_Resource (*Create)(PP_Resource file_system, const char* path);
// Returns true if the given resource is a FileRef. Returns false if the
// resource is invalid or some type other than a FileRef.
bool (*IsFileRef)(PP_Resource resource);
// Returns the file system identifier of this file.
PP_FileSystemType_Dev (*GetFileSystemType)(PP_Resource file_ref);
// Returns the name of the file.
struct PP_Var (*GetName)(PP_Resource file_ref);
// Returns the absolute path of the file. This method fails if the file
// system type is PP_FileSystemType_External.
struct PP_Var (*GetPath)(PP_Resource file_ref);
// Returns the parent directory of this file. If file_ref points to the root
// of the filesystem, then the root is returned. This method fails if the
// file system type is PP_FileSystemType_External.
PP_Resource (*GetParent)(PP_Resource file_ref);
// Makes a new directory in the filesystem as well as any parent directories
// if the make_ancestors parameter is true. It is not valid to make a
// directory in the external filesystem. Fails if the directory already
// exists or if ancestor directories do not exist and make_ancestors was not
// passed as true.
int32_t (*MakeDirectory)(PP_Resource directory_ref,
bool make_ancestors,
struct PP_CompletionCallback callback);
// Queries info about the file. You must have read access to this file if it
// exists in the external filesystem.
int32_t (*Query)(PP_Resource file_ref,
struct PP_FileInfo_Dev* info,
struct PP_CompletionCallback callback);
// Updates timestamps for a file. You must have write access to the file if
// it exists in the external filesystem.
int32_t (*Touch)(PP_Resource file_ref,
PP_Time last_access_time,
PP_Time last_modified_time,
struct PP_CompletionCallback callback);
// Delete a file or directory. If file_ref refers to a directory, then the
// directory must be empty. It is an error to delete a file or directory
// that is in use. It is not valid to delete a file in the external
// filesystem.
int32_t (*Delete)(PP_Resource file_ref,
struct PP_CompletionCallback callback);
// Rename a file or directory. file_ref and new_file_ref must both refer to
// files in the same filesystem. It is an error to rename a file or
// directory that is in use. It is not valid to rename a file in the
// external filesystem.
int32_t (*Rename)(PP_Resource file_ref,
PP_Resource new_file_ref,
struct PP_CompletionCallback callback);
// TODO(darin): Add these conversion routines.
#if 0
// Convert a DOM File object to a FileRef object.
PP_Resource (*FromFileObject)(PP_Var file_object);
// Convert a FileRef object to a DOM File object.
PP_Var (*ToFileObject)(PP_Resource file_ref);
#endif
};
#endif // PPAPI_C_DEV_PPB_FILE_REF_DEV_H_

@ -0,0 +1,29 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FILE_SYSTEM_DEV_H_
#define PPAPI_C_DEV_PPB_FILE_SYSTEM_DEV_H_
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
struct PP_CompletionCallback;
#define PPB_FILESYSTEM_DEV_INTERFACE "PPB_FileSystem(Dev);0.2"
struct PPB_FileSystem_Dev {
// Creates a weak pointer to the filesystem of the given type.
PP_Resource (*Create)(PP_Instance instance, PP_FileSystemType_Dev type);
// Opens the file system. A file system must be opened before running any
// other operation on it.
int32_t (*Open)(PP_Resource file_system,
int64_t expected_size,
struct PP_CompletionCallback callback);
};
#endif // PPAPI_C_DEV_PPB_FILE_SYSTEM_DEV_H_

@ -0,0 +1,28 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FIND_DEV_H_
#define PPAPI_C_DEV_PPB_FIND_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_FIND_DEV_INTERFACE "PPB_Find(Dev);0.1"
struct PPB_Find_Dev {
// Updates the number of find results for the current search term. If
// there are no matches 0 should be passed in. Only when the plugin has
// finished searching should it pass in the final count with finalResult set
// to true.
void (*NumberOfFindResultsChanged)(PP_Instance instance,
int32_t total,
bool final_result);
// Updates the index of the currently selected search item.
void (*SelectedFindResultChanged)(PP_Instance instance,
int32_t index);
};
#endif // PPAPI_C_DEV_PPB_FIND_DEV_H_

161
ppapi/c/dev/ppb_font_dev.h Normal file

@ -0,0 +1,161 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FONT_DEV_H_
#define PPAPI_C_DEV_PPB_FONT_DEV_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
#define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.1"
struct PP_Point;
struct PP_Rect;
typedef enum {
// Uses the user's default web page font (normally either the default serif
// or sans serif font).
PP_FONTFAMILY_DEFAULT = 0,
// These families will use the default web page font corresponding to the
// given family.
PP_FONTFAMILY_SERIF = 1,
PP_FONTFAMILY_SANSSERIF = 2,
PP_FONTFAMILY_MONOSPACE = 3
} PP_FontFamily_Dev;
typedef enum {
PP_FONTWEIGHT_100 = 0,
PP_FONTWEIGHT_200,
PP_FONTWEIGHT_300,
PP_FONTWEIGHT_400,
PP_FONTWEIGHT_500,
PP_FONTWEIGHT_600,
PP_FONTWEIGHT_700,
PP_FONTWEIGHT_800,
PP_FONTWEIGHT_900,
PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400,
PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700
} PP_FontWeight_Dev;
struct PP_FontDescription_Dev {
// Font face name as a string. This can also be a Null var, in which case the
// generic family will be obeyed.
struct PP_Var face;
// When face is a Null string, this specifies the generic font family type
// to use. If the face is specified, this will be ignored.
PP_FontFamily_Dev family;
uint32_t size;
// Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD.
PP_FontWeight_Dev weight;
bool italic;
bool small_caps;
// Adjustment to apply to letter and word spacing, respectively. Initialize
// to 0 to get normal spacing. Negative values bring letters/words closer
// together, positive values separate them.
int letter_spacing;
int word_spacing;
};
struct PP_FontMetrics_Dev {
int32_t height;
int32_t ascent;
int32_t descent;
int32_t line_spacing;
int32_t x_height;
};
struct PP_TextRun_Dev {
// This var must either be a string or a null var (which will be treated as
// a 0-length string).
struct PP_Var text;
// Set to true if the text is right-to-left.
bool rtl;
// Set to true to force the directionality of the text regardless of content
bool override_direction;
};
struct PPB_Font_Dev {
// Returns a font which best matches the given description. The return value
// will have a non-zero ID on success, or zero on failure.
PP_Resource (*Create)(PP_Module module,
const struct PP_FontDescription_Dev* description);
// Returns true if the given resource is a Font. Returns false if the
// resource is invalid or some type other than a Font.
bool (*IsFont)(PP_Resource resource);
// Loads the description and metrics of the font into the given structures.
// The description will be different than the description the font was
// created with since it will be filled with the real values from the font
// that was actually selected.
//
// The PP_Var in the description should be of type Void on input. On output,
// this will contain the string and will have a reference count of 1. The
// plugin is responsible for calling Release on this var.
//
// Returns true on success, false if the font is invalid or if the Var in
// the description isn't Null (to prevent leaks).
bool (*Describe)(PP_Resource font,
struct PP_FontDescription_Dev* description,
struct PP_FontMetrics_Dev* metrics);
// Draws the text to the image buffer.
//
// The given point represents the baseline of the left edge of the font,
// regardless of whether it is left-to-right or right-to-left (in the case of
// RTL text, this will actually represent the logical end of the text).
//
// The clip is optional and may be NULL. In this case, the text will be
// clipped to the image.
//
// The image_data_is_opaque flag indicates whether subpixel antialiasing can
// be performend, if it is supported. When the image below the text is
// opaque, subpixel antialiasing is supported and you should set this to true
// to pick up the user's default preferences. If your plugin is partially
// transparent, then subpixel antialiasing is not possible and grayscale
// antialiasing will be used instead (assuming the user has antialiasing
// enabled at all).
bool (*DrawTextAt)(PP_Resource font,
PP_Resource image_data,
const struct PP_TextRun_Dev* text,
const struct PP_Point* position,
uint32_t color,
const struct PP_Rect* clip,
bool image_data_is_opaque);
// Returns the width of the given string. If the font is invalid or the var
// isn't a valid string, this will return -1.
//
// Note that this function handles complex scripts such as Arabic, combining
// accents, etc. so that adding the width of substrings won't necessarily
// produce the correct width of the entire string.
int32_t (*MeasureText)(PP_Resource font,
const struct PP_TextRun_Dev* text);
// Returns the character at the given pixel X position from the beginning of
// the string. This handles complex scripts such as Arabic, where characters
// may be combined or replaced depending on the context.
uint32_t (*CharacterOffsetForPixel)(PP_Resource font,
const struct PP_TextRun_Dev* text,
int32_t pixel_position);
// Returns the horizontal advance to the given character if the string was
// placed at the given position. This handles complex scripts such as Arabic,
// where characters may be combined or replaced depending on context.
int32_t (*PixelOffsetForCharacter)(PP_Resource font,
const struct PP_TextRun_Dev* text,
uint32_t char_offset);
};
#endif // PPAPI_C_DEV_PPB_FONT_DEV_H_

@ -0,0 +1,27 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_FULLSCREEN_DEV_H_
#define PPAPI_C_DEV_PPB_FULLSCREEN_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_FULLSCREEN_DEV_INTERFACE "PPB_Fullscreen(Dev);0.1"
// Use this interface to change a plugin instance to fullscreen mode.
struct PPB_Fullscreen_Dev {
// Checks whether the plugin instance is currently in fullscreen mode.
bool (*IsFullscreen)(PP_Instance instance);
// Switches the plugin instance to/from fullscreen mode. Returns true on
// success, false on failure.
// When in fullscreen mode, the plugin will be transparently scaled to the
// size of the screen. It will not receive a ViewChanged event, and doesn't
// need to rebind the graphics context. The pending flushes will execute
// normally, to the new fullscreen window.
bool (*SetFullscreen)(PP_Instance instance, bool fullscreen);
};
#endif // PPAPI_C_DEV_PPB_FULLSCREEN_DEV_H_

@ -0,0 +1,103 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_
#define PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
// Example usage from plugin code:
//
// PP_Resource context = device->Create(module, config, contextAttribList);
// CHECK(context);
//
// // Present one frame.
// CHECK(device->MakeCurrent(context));
// glClear(GL_COLOR_BUFFER);
// CHECK(device->MakeCurrent(NULL));
// CHECK(device->SwapBuffers(context));
//
// // Shutdown.
// core->ReleaseResource(context);
#define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.1"
// These are the same error codes as used by EGL.
enum {
PP_GRAPHICS_3D_ERROR_SUCCESS = 0x3000,
PP_GRAPHICS_3D_ERROR_NOT_INITIALIZED = 0x3001,
PP_GRAOHICS_3D_ERROR_BAD_CONTEXT = 0x3006,
PP_GRAPHICS_3D_ERROR_BAD_PARAMETER = 0x300C,
PP_GRAPHICS_3D_ERROR_CONTEXT_LOST = 0x300E
};
// QueryString targets, matching EGL ones.
enum {
EGL_VENDOR = 0x3053,
EGL_VERSION = 0x3054,
EGL_EXTENSIONS = 0x3055,
EGL_CLIENT_APIS = 0x308D
};
struct PPB_Graphics3D_Dev {
bool (*IsGraphics3D)(PP_Resource resource);
// EGL-like configuration ----------------------------------------------------
bool (*GetConfigs)(int32_t* configs,
int32_t config_size,
int32_t* num_config);
bool (*ChooseConfig)(const int32_t* attrib_list,
int32_t* configs,
int32_t config_size,
int32_t* num_config);
// TODO(apatrick): What to do if the browser window is moved to
// another display? Do the configs potentially change?
bool (*GetConfigAttrib)(int32_t config, int32_t attribute, int32_t* value);
const char* (*QueryString)(int32_t name);
// ---------------------------------------------------------------------------
// Create a reference counted 3D context. Releasing a context while it is
// current automatically sets the current context to NULL. This is only true
// for the releasing thread. Releasing a context while it is current on
// another thread leads to undefined behavior.
PP_Resource (*CreateContext)(PP_Instance instance,
int32_t config,
int32_t share_context,
const int32_t* attrib_list);
// Get the address of any GL functions, whether core or part of an extension.
// Any thread.
void* (*GetProcAddress)(const char* name);
// Make a particular context current of the calling thread.
bool (*MakeCurent)(PP_Resource context);
// Returns the calling thread's current context or NULL if no context is
// current.
PP_Resource (*GetCurrentContext)();
// Snapshots the rendered frame and makes it available for composition with
// the rest of the page. The alpha channel is used for translucency effects.
// One means fully opaque. Zero means fully transparent. Any thread.
// TODO(apatrick): premultiplied alpha or linear alpha? Premultiplied alpha is
// better for correct alpha blending effect. Most existing OpenGL code assumes
// linear. I could convert from linear to premultiplied during the copy from
// back-buffer to offscreen "front-buffer".
bool (*SwapBuffers)(PP_Resource context);
// Returns the current error for this thread. This is not associated with a
// particular context. It is distinct from the GL error returned by
// glGetError.
uint32_t (*GetError)();
};
#endif // PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_

@ -0,0 +1,248 @@
// 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 file is auto-generated. DO NOT EDIT!
// This interface is used to access common and lite profile OpenGL ES 2.0
// functions.
#ifndef PPAPI_C_DEV_PPB_OPENGLES_DEV_H_
#define PPAPI_C_DEV_PPB_OPENGLES_DEV_H_
#include "../../GLES2/khrplatform.h"
#define PPB_OPENGLES_DEV_INTERFACE "PPB_OpenGLES(Dev);2.0"
typedef unsigned int GLenum;
typedef void GLvoid;
typedef khronos_intptr_t GLintptr;
typedef int GLsizei;
typedef khronos_ssize_t GLsizeiptr;
typedef int GLint;
typedef unsigned char GLboolean;
typedef unsigned int GLuint;
typedef unsigned int GLbitfield;
typedef short GLshort;
typedef float GLfloat;
typedef float GLclampf;
typedef signed char GLbyte;
typedef unsigned char GLubyte;
typedef int GLfixed;
typedef unsigned short GLushort;
typedef int GLclampx;
struct PPB_OpenGLES_Dev {
void (*ActiveTexture)(GLenum texture);
void (*AttachShader)(GLuint program, GLuint shader);
void (*BindAttribLocation)(GLuint program, GLuint index, const char* name);
void (*BindBuffer)(GLenum target, GLuint buffer);
void (*BindFramebuffer)(GLenum target, GLuint framebuffer);
void (*BindRenderbuffer)(GLenum target, GLuint renderbuffer);
void (*BindTexture)(GLenum target, GLuint texture);
void (*BlendColor)(
GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void (*BlendEquation)(GLenum mode);
void (*BlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
void (*BlendFunc)(GLenum sfactor, GLenum dfactor);
void (*BlendFuncSeparate)(
GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
void (*BufferData)(
GLenum target, GLsizeiptr size, const void* data, GLenum usage);
void (*BufferSubData)(
GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
GLenum (*CheckFramebufferStatus)(GLenum target);
void (*Clear)(GLbitfield mask);
void (*ClearColor)(
GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void (*ClearDepthf)(GLclampf depth);
void (*ClearStencil)(GLint s);
void (*ColorMask)(
GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void (*CompileShader)(GLuint shader);
void (*CompressedTexImage2D)(
GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei imageSize, const void* data);
void (*CompressedTexSubImage2D)(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLsizei imageSize, const void* data);
void (*CopyTexImage2D)(
GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
GLsizei width, GLsizei height, GLint border);
void (*CopyTexSubImage2D)(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x,
GLint y, GLsizei width, GLsizei height);
GLuint (*CreateProgram)();
GLuint (*CreateShader)(GLenum type);
void (*CullFace)(GLenum mode);
void (*DeleteBuffers)(GLsizei n, const GLuint* buffers);
void (*DeleteFramebuffers)(GLsizei n, const GLuint* framebuffers);
void (*DeleteProgram)(GLuint program);
void (*DeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers);
void (*DeleteShader)(GLuint shader);
void (*DeleteTextures)(GLsizei n, const GLuint* textures);
void (*DepthFunc)(GLenum func);
void (*DepthMask)(GLboolean flag);
void (*DepthRangef)(GLclampf zNear, GLclampf zFar);
void (*DetachShader)(GLuint program, GLuint shader);
void (*Disable)(GLenum cap);
void (*DisableVertexAttribArray)(GLuint index);
void (*DrawArrays)(GLenum mode, GLint first, GLsizei count);
void (*DrawElements)(
GLenum mode, GLsizei count, GLenum type, const void* indices);
void (*Enable)(GLenum cap);
void (*EnableVertexAttribArray)(GLuint index);
void (*Finish)();
void (*Flush)();
void (*FramebufferRenderbuffer)(
GLenum target, GLenum attachment, GLenum renderbuffertarget,
GLuint renderbuffer);
void (*FramebufferTexture2D)(
GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level);
void (*FrontFace)(GLenum mode);
void (*GenBuffers)(GLsizei n, GLuint* buffers);
void (*GenerateMipmap)(GLenum target);
void (*GenFramebuffers)(GLsizei n, GLuint* framebuffers);
void (*GenRenderbuffers)(GLsizei n, GLuint* renderbuffers);
void (*GenTextures)(GLsizei n, GLuint* textures);
void (*GetActiveAttrib)(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
GLint* size, GLenum* type, char* name);
void (*GetActiveUniform)(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
GLint* size, GLenum* type, char* name);
void (*GetAttachedShaders)(
GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
GLint (*GetAttribLocation)(GLuint program, const char* name);
void (*GetBooleanv)(GLenum pname, GLboolean* params);
void (*GetBufferParameteriv)(GLenum target, GLenum pname, GLint* params);
GLenum (*GetError)();
void (*GetFloatv)(GLenum pname, GLfloat* params);
void (*GetFramebufferAttachmentParameteriv)(
GLenum target, GLenum attachment, GLenum pname, GLint* params);
void (*GetIntegerv)(GLenum pname, GLint* params);
void (*GetProgramiv)(GLuint program, GLenum pname, GLint* params);
void (*GetProgramInfoLog)(
GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
void (*GetRenderbufferParameteriv)(
GLenum target, GLenum pname, GLint* params);
void (*GetShaderiv)(GLuint shader, GLenum pname, GLint* params);
void (*GetShaderInfoLog)(
GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
void (*GetShaderPrecisionFormat)(
GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
void (*GetShaderSource)(
GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
const GLubyte* (*GetString)(GLenum name);
void (*GetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params);
void (*GetTexParameteriv)(GLenum target, GLenum pname, GLint* params);
void (*GetUniformfv)(GLuint program, GLint location, GLfloat* params);
void (*GetUniformiv)(GLuint program, GLint location, GLint* params);
GLint (*GetUniformLocation)(GLuint program, const char* name);
void (*GetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params);
void (*GetVertexAttribiv)(GLuint index, GLenum pname, GLint* params);
void (*GetVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer);
void (*Hint)(GLenum target, GLenum mode);
GLboolean (*IsBuffer)(GLuint buffer);
GLboolean (*IsEnabled)(GLenum cap);
GLboolean (*IsFramebuffer)(GLuint framebuffer);
GLboolean (*IsProgram)(GLuint program);
GLboolean (*IsRenderbuffer)(GLuint renderbuffer);
GLboolean (*IsShader)(GLuint shader);
GLboolean (*IsTexture)(GLuint texture);
void (*LineWidth)(GLfloat width);
void (*LinkProgram)(GLuint program);
void (*PixelStorei)(GLenum pname, GLint param);
void (*PolygonOffset)(GLfloat factor, GLfloat units);
void (*ReadPixels)(
GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, void* pixels);
void (*ReleaseShaderCompiler)();
void (*RenderbufferStorage)(
GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void (*SampleCoverage)(GLclampf value, GLboolean invert);
void (*Scissor)(GLint x, GLint y, GLsizei width, GLsizei height);
void (*ShaderBinary)(
GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary,
GLsizei length);
void (*ShaderSource)(
GLuint shader, GLsizei count, const char** str, const GLint* length);
void (*StencilFunc)(GLenum func, GLint ref, GLuint mask);
void (*StencilFuncSeparate)(
GLenum face, GLenum func, GLint ref, GLuint mask);
void (*StencilMask)(GLuint mask);
void (*StencilMaskSeparate)(GLenum face, GLuint mask);
void (*StencilOp)(GLenum fail, GLenum zfail, GLenum zpass);
void (*StencilOpSeparate)(
GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
void (*TexImage2D)(
GLenum target, GLint level, GLint internalformat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type,
const void* pixels);
void (*TexParameterf)(GLenum target, GLenum pname, GLfloat param);
void (*TexParameterfv)(GLenum target, GLenum pname, const GLfloat* params);
void (*TexParameteri)(GLenum target, GLenum pname, GLint param);
void (*TexParameteriv)(GLenum target, GLenum pname, const GLint* params);
void (*TexSubImage2D)(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLenum type, const void* pixels);
void (*Uniform1f)(GLint location, GLfloat x);
void (*Uniform1fv)(GLint location, GLsizei count, const GLfloat* v);
void (*Uniform1i)(GLint location, GLint x);
void (*Uniform1iv)(GLint location, GLsizei count, const GLint* v);
void (*Uniform2f)(GLint location, GLfloat x, GLfloat y);
void (*Uniform2fv)(GLint location, GLsizei count, const GLfloat* v);
void (*Uniform2i)(GLint location, GLint x, GLint y);
void (*Uniform2iv)(GLint location, GLsizei count, const GLint* v);
void (*Uniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
void (*Uniform3fv)(GLint location, GLsizei count, const GLfloat* v);
void (*Uniform3i)(GLint location, GLint x, GLint y, GLint z);
void (*Uniform3iv)(GLint location, GLsizei count, const GLint* v);
void (*Uniform4f)(
GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void (*Uniform4fv)(GLint location, GLsizei count, const GLfloat* v);
void (*Uniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
void (*Uniform4iv)(GLint location, GLsizei count, const GLint* v);
void (*UniformMatrix2fv)(
GLint location, GLsizei count, GLboolean transpose,
const GLfloat* value);
void (*UniformMatrix3fv)(
GLint location, GLsizei count, GLboolean transpose,
const GLfloat* value);
void (*UniformMatrix4fv)(
GLint location, GLsizei count, GLboolean transpose,
const GLfloat* value);
void (*UseProgram)(GLuint program);
void (*ValidateProgram)(GLuint program);
void (*VertexAttrib1f)(GLuint indx, GLfloat x);
void (*VertexAttrib1fv)(GLuint indx, const GLfloat* values);
void (*VertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
void (*VertexAttrib2fv)(GLuint indx, const GLfloat* values);
void (*VertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
void (*VertexAttrib3fv)(GLuint indx, const GLfloat* values);
void (*VertexAttrib4f)(
GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void (*VertexAttrib4fv)(GLuint indx, const GLfloat* values);
void (*VertexAttribPointer)(
GLuint indx, GLint size, GLenum type, GLboolean normalized,
GLsizei stride, const void* ptr);
void (*Viewport)(GLint x, GLint y, GLsizei width, GLsizei height);
void (*SwapBuffers)();
GLuint (*GetMaxValueInBuffer)(
GLuint buffer_id, GLsizei count, GLenum type, GLuint offset);
void (*GenSharedIds)(
GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids);
void (*DeleteSharedIds)(GLuint namespace_id, GLsizei n, const GLuint* ids);
void (*RegisterSharedIds)(GLuint namespace_id, GLsizei n, const GLuint* ids);
GLboolean (*CommandBufferEnable)(const char* feature);
void* (*MapBufferSubData)(
GLuint target, GLintptr offset, GLsizeiptr size, GLenum access);
void (*UnmapBufferSubData)(const void* mem);
void* (*MapTexSubImage2D)(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLenum type, GLenum access);
void (*UnmapTexSubImage2D)(const void* mem);
};
#endif // PPAPI_C_DEV_PPB_OPENGLES_DEV_H_

@ -0,0 +1,62 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_SCROLLBAR_DEV_H_
#define PPAPI_C_DEV_PPB_SCROLLBAR_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
struct PP_Rect;
typedef enum {
PP_SCROLLBY_PIXEL = 0,
PP_SCROLLBY_LINE = 1,
PP_SCROLLBY_PAGE = 2,
PP_SCROLLBY_DOCUMENT = 3
} PP_ScrollBy_Dev;
#define PPB_SCROLLBAR_DEV_INTERFACE "PPB_Scrollbar(Dev);0.1"
// The interface for a scrollbar. A scrollbar is a widget, so the functions
// in PPB_Widget can also be used with scrollbar objects.
struct PPB_Scrollbar_Dev {
// Create a new scrollbar. Returns 0 if the instance is invalid.
PP_Resource (*Create)(PP_Instance instance,
bool vertical);
// Returns true if the given resource is a Scrollbar. Returns false if the
// resource is invalid or some type other than a scrollbar.
bool (*IsScrollbar)(PP_Resource resource);
// Gets the thickness of a scrollbar.
uint32_t (*GetThickness)();
// Get/set the value of the scrollbar.
uint32_t (*GetValue)(PP_Resource scrollbar);
void (*SetValue)(PP_Resource scrollbar,
uint32_t value);
// Set the document size (i.e. total length of the region that's being
// scrolled).
void (*SetDocumentSize)(PP_Resource scrollbar,
uint32_t size);
// Updates the tickmarks. Only valid for vertical scrollbars. "tick_marks"
// contains "count" PP_Rect objects.
void (*SetTickMarks)(PP_Resource scrollbar,
const struct PP_Rect* tick_marks,
uint32_t count);
// Scroll by "multiplier" pixels/lines/pages units. Positive values are
// forward and negative are backward. If "unit" is document then any positive
// value goes to the end while any negative value goes to the beginning.
void (*ScrollBy)(PP_Resource scrollbar,
PP_ScrollBy_Dev unit,
int32_t multiplier);
};
#endif // PPAPI_C_DEV_PPB_SCROLLBAR_DEV_H_

@ -0,0 +1,70 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_TESTING_DEV_H_
#define PPAPI_C_DEV_PPB_TESTING_DEV_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
struct PP_Point;
#define PPB_TESTING_DEV_INTERFACE "PPB_Testing(Dev);0.2"
// This interface contains functions used for unit testing. Do not use in
// production code. They are not guaranteed to be available in normal plugin
// environments so you should not depend on them.
struct PPB_Testing_Dev {
// Reads the bitmap data out of the backing store for the given
// DeviceContext2D and into the given image. If the data was successfully
// read, it will return true.
//
// This function should not generally be necessary for normal plugin
// operation. If you want to update portions of a device, the expectation is
// that you will either regenerate the data, or maintain a backing store
// pushing updates to the device from your backing store via PaintImageData.
// Using this function will introduce an extra copy which will make your
// plugin slower. In some cases, this may be a very expensive operation (it
// may require slow cross-process transitions or graphics card readbacks).
//
// Data will be read into the image starting at |top_left| in the device
// context, and proceeding down and to the right for as many pixels as the
// image is large. If any part of the image bound would fall outside of the
// backing store of the device if positioned at |top_left|, this function
// will fail and return false.
//
// The image format must be of the format
// PPB_ImageData.GetNativeImageDataFormat() or this function will fail and
// return false.
//
// The returned image data will represent the current status of the backing
// store. This will not include any paint, scroll, or replace operations
// that have not yet been flushed; these operations are only reflected in
// the backing store (and hence ReadImageData) until after a Flush()
// operation has completed.
bool (*ReadImageData)(PP_Resource device_context_2d,
PP_Resource image,
const struct PP_Point* top_left);
// Runs a nested message loop. The plugin will be reentered from this call.
// This function is used for unit testing the API. The normal pattern is to
// issue some asynchronous call that has a callback. Then you call
// RunMessageLoop which will suspend the plugin and go back to processing
// messages, giving the asynchronous operation time to complete. In your
// callback, you save the data and call QuitMessageLoop, which will then
// pop back up and continue with the test. This avoids having to write a
// complicated state machine for simple tests for asynchronous APIs.
void (*RunMessageLoop)();
// Posts a quit message for the outermost nested message loop. Use this to
// exit and return back to the caller after you call RunMessageLoop.
void (*QuitMessageLoop)();
// Returns the number of live objects (resources + strings + objects)
// associated with this plugin module. Used for detecting leaks.
uint32_t (*GetLiveObjectCount)(PP_Module module);
};
#endif // PPAPI_C_DEV_PPB_TESTING_DEV_H_

@ -0,0 +1,70 @@
// 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.
#ifndef PPAPI_C_PPB_TRANSPORT_DEV_H_
#define PPAPI_C_PPB_TRANSPORT_DEV_H_
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
#define PPB_TRANSPORT_DEV_INTERFACE "PPB_Transport;0.1"
struct PPB_Transport_Dev {
// Creates a new transport object with the specified name
// using the specified protocol.
PP_Resource (*CreateTransport)(PP_Module module,
const char* name,
const char* proto);
// Returns whether or not resource is a Transport
bool (*IsTransport)(PP_Resource resource);
// Returns whether the transport is currently writable
// (i.e. can send data to the remote peer)
bool (*IsWritable)(PP_Resource transport);
// TODO(juberti): other getters/setters
// connect state
// connect type, protocol
// RTT
// Establishes a connection to the remote peer.
// Returns PP_ERROR_WOULDBLOCK and notifies on |cb|
// when connectivity is established (or timeout occurs).
int32_t (*Connect)(PP_Resource transport,
PP_CompletionCallback cb);
// Obtains another ICE candidate address to be provided
// to the remote peer. Returns PP_ERROR_WOULDBLOCK
// if there are no more addresses to be sent.
int32_t (*GetNextAddress)(PP_Resource transport,
PP_Var* address,
PP_CompletionCallback cb);
// Provides an ICE candidate address that was received
// from the remote peer.
int32_t (*ReceiveRemoteAddress)(PP_Resource transport,
PP_Var address);
// Like recv(), receives data. Returns PP_ERROR_WOULDBLOCK
// if there is currently no data to receive.
int32_t (*Recv)(PP_Resource transport,
void* data,
uint32_t len,
PP_CompletionCallback cb);
// Like send(), sends data. Returns PP_ERROR_WOULDBLOCK
// if the socket is currently flow-controlled.
int32_t (*Send)(PP_Resource transport,
const void* data,
uint32_t len,
PP_CompletionCallback cb);
// Disconnects from the remote peer.
int32_t (*Close)(PP_Resource transport);
};
#endif // PPAPI_C_PPB_TRANSPORT_DEV_H_

@ -0,0 +1,101 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_URL_LOADER_DEV_H_
#define PPAPI_C_DEV_PPB_URL_LOADER_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
struct PP_CompletionCallback;
#define PPB_URLLOADER_DEV_INTERFACE "PPB_URLLoader(Dev);0.1"
// The interface for loading URLs.
//
// Typical steps for loading an URL:
// 1- Create an URLLoader object.
// 2- Create an URLRequestInfo object and set properties on it.
// 3- Call URLLoader's Open method passing the URLRequestInfo.
// 4- When Open completes, call GetResponseInfo to examine the response headers.
// 5- Then call ReadResponseBody to stream the data for the response.
//
// Alternatively, if PP_URLREQUESTPROPERTY_STREAMTOFILE was set on the
// URLRequestInfo, then call FinishStreamingToFile at step #5 to wait for the
// downloaded file to be complete. The downloaded file may be accessed via the
// GetBody method of the URLResponseInfo returned in step #4.
//
struct PPB_URLLoader_Dev {
// Create a new URLLoader object. Returns 0 if the instance is invalid. The
// URLLoader is associated with a particular instance, so that any UI dialogs
// that need to be shown to the user can be positioned relative to the window
// containing the instance. It is also important for security reasons to
// know the origin of the URL request.
PP_Resource (*Create)(PP_Instance instance);
// Returns true if the given resource is an URLLoader. Returns false if the
// resource is invalid or some type other than an URLLoader.
bool (*IsURLLoader)(PP_Resource resource);
// Begins loading the URLRequestInfo. Completes when response headers are
// received or when an error occurs. Use the GetResponseInfo method to
// access the response headers.
int32_t (*Open)(PP_Resource loader,
PP_Resource request_info,
struct PP_CompletionCallback callback);
// If the current URLResponseInfo object corresponds to a redirect, then call
// this method to follow the redirect.
int32_t (*FollowRedirect)(PP_Resource loader,
struct PP_CompletionCallback callback);
// Returns the current upload progress, which is meaningful after Open has
// been called, and the request given to Open must have been configured with
// PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS set to true. Progress only
// refers to the request body. This data is only available if the
// PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS was set to true on the
// URLRequestInfo. This method returns false if upload progress is not
// available.
bool (*GetUploadProgress)(PP_Resource loader,
int64_t* bytes_sent,
int64_t* total_bytes_to_be_sent);
// Returns the current download progress, which is meaningful after Open has
// been called. Progress only refers to the response body. The total bytes
// to be received may be unknown, in which case -1 is returned. This method
// returns false if download progress is not available.
bool (*GetDownloadProgress)(PP_Resource loader,
int64_t* bytes_received,
int64_t* total_bytes_to_be_received);
// Returns the current URLResponseInfo object.
PP_Resource (*GetResponseInfo)(PP_Resource loader);
// Call this method to read the response body. The size of the buffer must
// be large enough to hold the specified number of bytes to read. May
// perform a partial read. Returns the number of bytes read or an error
// code.
int32_t (*ReadResponseBody)(PP_Resource loader,
char* buffer,
int32_t bytes_to_read,
struct PP_CompletionCallback callback);
// If PP_URLREQUESTPROPERTY_STREAMTOFILE was set on the URLRequestInfo passed
// to the Open method, then this method may be used to wait for the response
// body to be completely downloaded to the file provided by URLResponseInfo's
// GetBody method.
int32_t (*FinishStreamingToFile)(PP_Resource loader,
struct PP_CompletionCallback callback);
// Cancels any IO that may be pending, and closes the URLLoader object. Any
// pending callbacks will still run, reporting PP_ERROR_ABORTED if pending IO
// was interrupted. It is NOT valid to call Open again after a call to this
// method. Note: If the URLLoader object is destroyed, and it is still open,
// then it will be implicitly closed, so you are not required to call the
// Close method.
void (*Close)(PP_Resource loader);
};
#endif // PPAPI_C_DEV_PPB_URL_LOADER_DEV_H_

@ -0,0 +1,19 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_URL_LOADER_TRUSTED_DEV_H_
#define PPAPI_C_DEV_PPB_URL_LOADER_TRUSTED_DEV_H_
#include "ppapi/c/pp_resource.h"
#define PPB_URLLOADERTRUSTED_DEV_INTERFACE "PPB_URLLoaderTrusted(Dev);0.1"
// Available only to trusted implementations.
struct PPB_URLLoaderTrusted_Dev {
// Grant this URLLoader the capability to make unrestricted cross-origin
// requests.
void (*GrantUniversalAccess)(PP_Resource loader);
};
#endif // PPAPI_C_DEV_PPB_URL_LOADER_DEV_H_

@ -0,0 +1,71 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_URL_REQUEST_INFO_DEV_H_
#define PPAPI_C_DEV_PPB_URL_REQUEST_INFO_DEV_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
struct PP_Var;
typedef enum {
PP_URLREQUESTPROPERTY_URL, // string
PP_URLREQUESTPROPERTY_METHOD, // string
PP_URLREQUESTPROPERTY_HEADERS, // string, \n-delim
PP_URLREQUESTPROPERTY_STREAMTOFILE, // bool (default=false)
PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, // bool (default=true)
PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS // bool (default=false)
// TODO(darin): Add security/privacy options?
} PP_URLRequestProperty_Dev;
#define PPB_URLREQUESTINFO_DEV_INTERFACE "PPB_URLRequestInfo(Dev);0.1"
struct PPB_URLRequestInfo_Dev {
// Create a new URLRequestInfo object. Returns 0 if the module is invalid.
PP_Resource (*Create)(PP_Module module);
// Returns true if the given resource is an URLRequestInfo. Returns false if
// the resource is invalid or some type other than an URLRequestInfo.
bool (*IsURLRequestInfo)(PP_Resource resource);
// Sets a request property. Returns false if any of the parameters are
// invalid. The value property must be the correct type according to the
// property being set.
bool (*SetProperty)(PP_Resource request,
PP_URLRequestProperty_Dev property,
struct PP_Var value);
// Append data to the request body.
//
// A Content-Length request header will be automatically generated.
//
// Returns false if any of the parameters are invalid.
bool (*AppendDataToBody)(PP_Resource request, const char* data, uint32_t len);
// Append a file reference to be uploaded.
//
// A sub-range of the file starting from start_offset may be specified. If
// number_of_bytes is -1, then the sub-range to upload extends to the end of
// the file.
//
// An optional (non-zero) last modified time stamp may be provided, which
// will be used to validate that the file was not modified since the given
// time before it is uploaded. The upload will fail with an error code of
// PP_Error_FileChanged if the file has been modified since the given time.
// If expected_last_modified_time is 0, then no validation is performed.
//
// A Content-Length request header will be automatically generated.
//
// Returns false if any of the parameters are invalid.
bool (*AppendFileToBody)(PP_Resource request,
PP_Resource file_ref,
int64_t start_offset,
int64_t number_of_bytes,
PP_Time expected_last_modified_time);
};
#endif // PPAPI_C_DEV_PPB_URL_REQUEST_INFO_DEV_H_

@ -0,0 +1,41 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_URL_RESPONSE_INFO_DEV_H_
#define PPAPI_C_DEV_PPB_URL_RESPONSE_INFO_DEV_H_
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
typedef enum {
PP_URLRESPONSEPROPERTY_URL, // string
PP_URLRESPONSEPROPERTY_REDIRECTURL, // string
PP_URLRESPONSEPROPERTY_REDIRECTMETHOD, // string
PP_URLRESPONSEPROPERTY_STATUSCODE, // int32
PP_URLRESPONSEPROPERTY_STATUSLINE, // string
PP_URLRESPONSEPROPERTY_HEADERS // string, \n-delim
} PP_URLResponseProperty_Dev;
#define PPB_URLRESPONSEINFO_DEV_INTERFACE "PPB_URLResponseInfo(Dev);0.1"
struct PPB_URLResponseInfo_Dev {
// Returns true if the given resource is an URLResponseInfo. Returns false if
// the resource is invalid or some type other than an URLResponseInfo.
bool (*IsURLResponseInfo)(PP_Resource resource);
// Gets a response property. Return PP_VarType_Void if an input parameter is
// invalid.
PP_Var (*GetProperty)(PP_Resource response,
PP_URLResponseProperty_Dev property);
// Returns a FileRef pointing to the file containing the response body. This
// is only valid if PP_URLREQUESTPROPERTY_STREAMTOFILE was set on the
// URLRequestInfo used to produce this response. This file remains valid
// until the URLLoader associated with this URLResponseInfo is closed or
// destroyed. Returns 0 if PP_URLREQUESTPROPERTY_STREAMTOFILE was not
// requested or if the URLLoader has not been opened yet.
PP_Resource (*GetBody)(PP_Resource response);
};
#endif // PPAPI_C_DEV_PPB_URL_RESPONSE_INFO_DEV_H_

@ -0,0 +1,111 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_
#define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
#define PPB_URLUTIL_DEV_INTERFACE "PPB_UrlUtil(Dev);0.1"
// A component specifies the range of the part of the URL. The begin specifies
// the index into the string of the first character of that component. The len
// specifies the length of that component.
//
// This range does not include any special delimiter for that component, so
// the scheme doesn't include the trailing colon, the username and password
// don't include the @ and :, the port doesn't include the colon, the query
// doesn't include the ?, and the ref doesn't include the #.
//
// The exception is that the path *does* include the first /, since that's an
// integral part of the path.
//
// If the component is not present at all, begin will be 0 and len will be -1.
// If the component is present but empty, the length will be 0 instead. Example:
// http://foo/search -> query = (0, -1)
// http://foo/search? -> query = (18, 0)
struct PP_UrlComponent_Dev {
int32_t begin;
int32_t len;
};
struct PP_UrlComponents_Dev {
PP_UrlComponent_Dev scheme;
PP_UrlComponent_Dev username;
PP_UrlComponent_Dev password;
PP_UrlComponent_Dev host;
PP_UrlComponent_Dev port;
PP_UrlComponent_Dev path;
PP_UrlComponent_Dev query;
PP_UrlComponent_Dev ref;
};
// URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit
// strings. You can pass non-ASCII characters which will be interpreted as
// UTF-8. Canonicalized URL strings returned by these functions will be ASCII
// except for the reference fragment (stuff after the '#') which will be
// encoded as UTF-8.
struct PPB_UrlUtil_Dev {
// Canonicalizes the given URL string according to the rules of the host
// browser. If the URL is invalid or the var is not a string, this will
// return a Null var and the components structure will be unchanged.
//
// The components pointer, if non-NULL and the canonicalized URL is valid,
// will identify the components of the resulting URL. Components may be NULL
// to specify that no component information is necessary.
struct PP_Var (*Canonicalize)(struct PP_Var url,
struct PP_UrlComponents_Dev* components);
// Resolves the given URL relative to the given base URL. The resulting URL
// is returned as a string. If the resolution is invalid or either of the
// inputs are not strings, a Null var will be returned. The resulting URL
// will also be canonicalized according to the rules of the browser.
//
// Note that the "relative" URL bay in fact be absolute, in which case it
// will be returned. This function is identical to resolving the full URL
// for an <a href="..."> on a web page. Attempting to resolve a relative URL
// on a base URL that doesn't support this (e.g. "data") will fail and will
// return a Null var, unless the relative URL is itself absolute.
//
// The components pointer, if non-NULL and the canonicalized URL is valid,
// will identify the components of the resulting URL. Components may be NULL
// to specify that no component information is necessary.
struct PP_Var (*ResolveRelativeToUrl)(
struct PP_Var base_url,
struct PP_Var relative_string,
struct PP_UrlComponents_Dev* components);
// Identical to ResolveRelativeToUrl except that the base URL is the base
// URL of the document containing the given plugin instance.
//
// Danger: This will be identical to resolving a relative URL on the page,
// and might be overridden by the page to something different than its actual
// URL via the <base> tag. Therefore, resolving a relative URL of "" won't
// necessarily give you the URL of the page!
struct PP_Var (*ResolveRelativeToDocument)(
PP_Instance instance,
struct PP_Var relative_string,
struct PP_UrlComponents_Dev* components);
// Checks whether the given two URLs are in the same security origin. Returns
// false if either of the URLs are invalid.
bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b);
// Checks whether the document hosting the given plugin instance can access
// the given URL according to the same origin policy of the browser. Returns
// false if the instance or the URL is invalid.
bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url);
// Checks whether the document containing the |active| plugin instance can
// access the document containing the |target| plugin instance according to
// the security policy of the browser. This includes the same origin policy
// and any cross-origin capabilities enabled by the document. If either of
// the plugin instances are invalid, returns false.
bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target);
};
#endif // PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_

@ -0,0 +1,243 @@
// 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.
#ifndef PPAPI_C_PPB_VAR_DEPRECATED_H_
#define PPAPI_C_PPB_VAR_DEPRECATED_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
struct PPP_Class_Deprecated;
#define PPB_VAR_DEPRECATED_INTERFACE "PPB_Var(Deprecated);0.1"
/**
* @file
* Defines the PPB_Var_Deprecated struct.
* See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
* for general information on using this interface.
* {PENDING: Should the generated doc really be pointing to methods?}
*
* @addtogroup PPB
* @{
*/
struct PPB_Var_Deprecated {
/**
* Adds a reference to the given var. If this is not a refcounted object,
* this function will do nothing so you can always call it no matter what the
* type.
*/
void (*AddRef)(struct PP_Var var);
/**
* Removes a reference to given var, deleting it if the internal refcount
* becomes 0. If the given var is not a refcounted object, this function will
* do nothing so you can always call it no matter what the type.
*/
void (*Release)(struct PP_Var var);
/**
* Creates a string var from a string. The string must be encoded in valid
* UTF-8 and is NOT NULL-terminated, the length must be specified in |len|.
* It is an error if the string is not valid UTF-8.
*
* If the length is 0, the |data| pointer will not be dereferenced and may
* be NULL. Note, however, that if you do this, the "NULL-ness" will not be
* preserved, as VarToUtf8 will never return NULL on success, even for empty
* strings.
*
* The resulting object will be a refcounted string object. It will be
* AddRef()ed for the caller. When the caller is done with it, it should be
* Release()d.
*
* On error (basically out of memory to allocate the string, or input that
* is not valid UTF-8), this function will return a Null var.
*/
struct PP_Var (*VarFromUtf8)(PP_Module module,
const char* data, uint32_t len);
/**
* Converts a string-type var to a char* encoded in UTF-8. This string is NOT
* NULL-terminated. The length will be placed in |*len|. If the string is
* valid but empty the return value will be non-NULL, but |*len| will still
* be 0.
*
* If the var is not a string, this function will return NULL and |*len| will
* be 0.
*
* The returned buffer will be valid as long as the underlying var is alive.
* If the plugin frees its reference, the string will be freed and the pointer
* will be to random memory.
*/
const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len);
/**
* Returns true if the property with the given name exists on the given
* object, false if it does not. Methods are also counted as properties.
*
* The name can either be a string or an integer var. It is an error to pass
* another type of var as the name.
*
* If you pass an invalid name or object, the exception will be set (if it is
* non-NULL, and the return value will be false).
*/
bool (*HasProperty)(struct PP_Var object,
struct PP_Var name,
struct PP_Var* exception);
/**
* Identical to HasProperty, except that HasMethod additionally checks if the
* property is a function.
*/
bool (*HasMethod)(struct PP_Var object,
struct PP_Var name,
struct PP_Var* exception);
/**
* Returns the value of the given property. If the property doesn't exist, the
* exception (if non-NULL) will be set and a "Void" var will be returned.
*/
struct PP_Var (*GetProperty)(struct PP_Var object,
struct PP_Var name,
struct PP_Var* exception);
/**
* Retrieves all property names on the given object. Property names include
* methods.
*
* If there is a failure, the given exception will be set (if it is non-NULL).
* On failure, |*properties| will be set to NULL and |*property_count| will be
* set to 0.
*
* A pointer to the array of property names will be placesd in |*properties|.
* The caller is responsible for calling Release() on each of these properties
* (as per normal refcounted memory management) as well as freeing the array
* pointer with PPB_Core.MemFree().
*
* This function returns all "enumerable" properties. Some JavaScript
* properties are "hidden" and these properties won't be retrieved by this
* function, yet you can still set and get them.
*
* Example:
* <pre> uint32_t count;
* PP_Var* properties;
* ppb_var.GetAllPropertyNames(object, &count, &properties);
*
* ...use the properties here...
*
* for (uint32_t i = 0; i < count; i++)
* ppb_var.Release(properties[i]);
* ppb_core.MemFree(properties); </pre>
*/
void (*GetAllPropertyNames)(struct PP_Var object,
uint32_t* property_count,
struct PP_Var** properties,
struct PP_Var* exception);
/**
* Sets the property with the given name on the given object. The exception
* will be set, if it is non-NULL, on failure.
*/
void (*SetProperty)(struct PP_Var object,
struct PP_Var name,
struct PP_Var value,
struct PP_Var* exception);
/**
* Removes the given property from the given object. The property name must
* be an string or integer var, using other types will throw an exception
* (assuming the exception pointer is non-NULL).
*/
void (*RemoveProperty)(struct PP_Var object,
struct PP_Var name,
struct PP_Var* exception);
// TODO(brettw) need native array access here.
/**
* Invoke the function |method_name| on the given object. If |method_name|
* is a Null var, the default method will be invoked, which is how you can
* invoke function objects.
*
* Unless it is type Null, |method_name| must be a string. Unlike other
* Var functions, integer lookup is not supported since you can't call
* functions on integers in JavaScript.
*
* Pass the arguments to the function in order in the |argv| array, and the
* number of arguments in the |argc| parameter. |argv| can be NULL if |argc|
* is zero.
*
* Example:
* Call(obj, VarFromUtf8("DoIt"), 0, NULL, NULL) = obj.DoIt() in JavaScript.
* Call(obj, PP_MakeNull(), 0, NULL, NULL) = obj() in JavaScript.
*/
struct PP_Var (*Call)(struct PP_Var object,
struct PP_Var method_name,
uint32_t argc,
struct PP_Var* argv,
struct PP_Var* exception);
/**
* Invoke the object as a constructor.
*
* For example, if |object| is |String|, this is like saying |new String| in
* JavaScript.
*/
struct PP_Var (*Construct)(struct PP_Var object,
uint32_t argc,
struct PP_Var* argv,
struct PP_Var* exception);
/**
* If the object is an instance of the given class, then this method returns
* true and sets *object_data to the value passed to CreateObject provided
* object_data is non-NULL. Otherwise, this method returns false.
*/
bool (*IsInstanceOf)(struct PP_Var var,
const struct PPP_Class_Deprecated* object_class,
void** object_data);
/**
* Creates an object that the plugin implements. The plugin supplies a
* pointer to the class interface it implements for that object, and its
* associated internal data that represents that object.
*
* The returned object will have a reference count of 1. When the reference
* count reached 0, the class' Destruct function wlil be called.
*
* On failure, this will return a null var. This probably means the module
* was invalid.
*
* Example: Say we're implementing a "Point" object.
* <pre> void PointDestruct(void* object) {
* delete (Point*)object;
* }
*
* const PPP_Class_Deprecated point_class = {
* ... all the other class functions go here ...
* &PointDestruct
* };
*
* * The plugin's internal object associated with the point.
* class Point {
* ...
* };
*
* PP_Var MakePoint(int x, int y) {
* return CreateObject(&point_class, new Point(x, y));
* }</pre>
*/
struct PP_Var (*CreateObject)(PP_Module module,
const struct PPP_Class_Deprecated* object_class,
void* object_data);
};
/**
* @}
* End addtogroup PPB
*/
#endif // PPAPI_C_PPB_VAR_DEPRECATED_H_

@ -0,0 +1,86 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_
#define PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_
#include "ppapi/c/dev/pp_video_dev.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_completion_callback.h"
#define PPB_VIDEODECODER_DEV_INTERFACE "PPB_VideoDecoder(Dev);0.1"
struct PPB_VideoDecoder_Dev {
// Queries capability of the decoder for |codec|.
// |codec| is the requested codec id.
// |configs| is a pointer to a buffer containing |config_size| elements.
// The number of configurations is returned in |num_config|. Element 0 through
// |num_config| - 1 of |configs| are filled in with valid PP_VideoConfig's.
// No more than |config_size| PP_VideoConfig's will be returned even if more
// are available on the device.
// When this function is called with |configs| = NULL, then no configurations
// are returned, but the total number of configurations available will be
// returned in |num_config|.
//
// Returns true on success, false otherwise.
// NOTE: browser owns the memory of all PP_VideoConfig's.
bool (*GetConfig)(PP_Instance instance,
PP_VideoCodecId_Dev codec,
PP_VideoConfig_Dev* configs,
int32_t config_size,
int32_t* num_config);
// Creates a video decoder with requested |decoder_config|.
// |input_format| in |decoder_config| specifies the format of input access
// unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required.
// Plugin has the option to specify codec profile/level and other
// information such as PP_VIDEOKEY_ACCELERATION, to let browser choose
// the most appropriate decoder.
//
// |output_format| in |decoder_config| specifies desired decoded frame buffer
// format, with PP_VIDEOKEY_COLORTYPE and PP_VIDEOKEY_SURFACETYPE required.
//
// |output_callback| in |decoder_config| specifies the callback function
// for decoder to deliver decoded frame buffers. Decoder shall retain it.
//
// |input_callback| in |decoder_config| specifies the callback function
// for decoder to return compressed data buffers to plugin. Decoder shall
// retain it. When plugin doesn't expect buffer recycling, it shall set
// |input_callback| to NULL. In this case, plugin shall allocate buffer via
// |MemAlloc| in PPB_Core interface, and decoder will free buffer via
// |MemFree| in the same API.
//
// |event_handler| in |decoder_config| specifies the function for decoder
// to deliver events to plugin. Decoder shall retain it.
//
// The created decoder is returned as PP_Resource. NULL means failure.
PP_Resource (*Create)(PP_Instance instance,
const struct PP_VideoDecoderConfig_Dev* decoder_config);
// Sends bit stream in |input_buffer| to the decoder.
// This is a non-blocking call.
// The decoded frame will be returned by decoder calling |output_callback|
// provided by plugin during creation of decoder.
// The input data buffer is returned to plugin by decoder only when plugin
// provides |input_callback|.
// Returns true on decoder successfully accepting buffer, false otherwise.
//
bool (*Decode)(PP_Resource decoder,
struct PP_VideoCompressedDataBuffer_Dev* input_buffer);
// Requests the decoder to flush its input and output buffers. Once done with
// flushing, the decode will call the |callback|.
int32_t (*Flush)(PP_Resource decoder,
PP_CompletionCallback callback);
// Plugin sends uncompressed data buffers to the decoder.
// Returns true on decoder successfully accepting the buffer, false otherwise.
bool (*ReturnUncompressedDataBuffer)(
PP_Resource decoder,
struct PP_VideoUncompressedDataBuffer_Dev* buffer);
};
#endif // PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_

@ -0,0 +1,39 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_WIDGET_DEV_H_
#define PPAPI_C_DEV_PPB_WIDGET_DEV_H_
#include "ppapi/c/pp_resource.h"
struct PP_Rect;
struct PP_InputEvent;
#define PPB_WIDGET_DEV_INTERFACE "PPB_Widget(Dev);0.1"
// The interface for reusing browser widgets.
struct PPB_Widget_Dev {
// Returns true if the given resource is a Widget. Returns false if the
// resource is invalid or some type other than an Widget.
bool (*IsWidget)(PP_Resource resource);
// Paint the given rectangle of the widget into the given image.
// Returns true on success, false on failure
bool (*Paint)(PP_Resource widget,
const struct PP_Rect* rect,
PP_Resource image);
// Pass in an event to a widget. It'll return true if the event was consumed.
bool (*HandleEvent)(PP_Resource widget,
const struct PP_InputEvent* event);
// Get/set the location of the widget.
bool (*GetLocation)(PP_Resource widget,
struct PP_Rect* location);
void (*SetLocation)(PP_Resource widget,
const struct PP_Rect* location);
};
#endif // PPAPI_C_DEV_PPB_WIDGET_DEV_H_

@ -0,0 +1,28 @@
// 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.
#ifndef PPAPI_C_DEV_PPB_ZOOM_DEV_H_
#define PPAPI_C_DEV_PPB_ZOOM_DEV_H_
#include "ppapi/c/pp_instance.h"
// Zoom interface should only apply to those full-page "plugin-document".
#define PPB_ZOOM_DEV_INTERFACE "PPB_Zoom(Dev);0.1"
struct PPB_Zoom_Dev {
// Informs the browser about the new zoom factor for the plugin (see
// ppp_zoom_dev.h for a description of zoom factor). The plugin should only
// call this function if the zoom change was triggered by the browser, it's
// only needed in case a plugin can update its own zoom, say because of its
// own UI.
void (*ZoomChanged)(PP_Instance instance,
double factor);
// Sets the mininum and maximium zoom factors.
void (*ZoomLimitsChanged)(PP_Instance instance,
double minimum_factor,
double maximium_factor);
};
#endif // PPAPI_C_DEV_PPB_ZOOM_DEV_H_

@ -0,0 +1,134 @@
// 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.
#ifndef PPAPI_C_PPP_CLASS_DEPRECATED_H_
#define PPAPI_C_PPP_CLASS_DEPRECATED_H_
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
/**
* @file
* Defines the PPP_Class_Deprecated struct.
*
* @addtogroup PPP
* @{
*/
struct PP_Var;
/**
* Interface for the plugin to implement JavaScript-accessible objects.
*
* This interface has no interface name. Instead, the plugin passes a pointer
* to this interface to PPB_Var_Deprecated.CreateObject that corresponds to the
* object being implemented.
*
* See the PPB_Var_Deprecated interface for more information on these functions.
* This interface just allows you to implement the "back end" of those
* functions, so most of the contract is specified in that interface.
*
* See
* http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
* for general information on using and implementing vars.
*/
struct PPP_Class_Deprecated {
/**
* |name| is guaranteed to be an integer or string type var. Exception is
* guaranteed non-NULL. An integer is used for |name| when implementing
* array access into the object. This test should only return true for
* properties that are not methods. Use HasMethod() to handle methods.
*/
bool (*HasProperty)(void* object,
struct PP_Var name,
struct PP_Var* exception);
/**
* |name| is guaranteed to be a string-type. Exception is guaranteed non-NULL.
* If the method does not exist, return false and don't set the exception.
* Errors in this function will probably not occur in general usage, but
* if you need to throw an exception, still return false.
*/
bool (*HasMethod)(void* object,
struct PP_Var name,
struct PP_Var* exception);
/**
* |name| is guaranteed to be a string-type or an integer-type var. Exception
* is guaranteed non-NULL. An integer is used for |name| when implementing
* array access into the object. If the property does not exist, set the
* exception and return a var of type Void. A property does not exist if
* a call HasProperty() for the same |name| would return false.
*/
struct PP_Var (*GetProperty)(void* object,
struct PP_Var name,
struct PP_Var* exception);
/**
* Exception is guaranteed non-NULL.
*
* This should include all enumerable properties, including methods. Be sure
* to set |*property_count| to 0 and |properties| to NULL in all failure
* cases, these should never be unset when calling this function. The
* pointers passed in are guaranteed not to be NULL, so you don't have to
* NULL check them.
*
* If you have any properties, allocate the property array with
* PPB_Core.MemAlloc(sizeof(PP_Var) * property_count) and add a reference
* to each property on behalf of the caller. The caller is responsible for
* Release()ing each var and calling PPB_Core.MemFree on the property pointer.
*/
void (*GetAllPropertyNames)(void* object,
uint32_t* property_count,
struct PP_Var** properties,
struct PP_Var* exception);
/**
* |name| is guaranteed to be an integer or string type var. Exception is
* guaranteed non-NULL.
*/
void (*SetProperty)(void* object,
struct PP_Var name,
struct PP_Var value,
struct PP_Var* exception);
/**
* |name| is guaranteed to be an integer or string type var. Exception is
* guaranteed non-NULL.
*/
void (*RemoveProperty)(void* object,
struct PP_Var name,
struct PP_Var* exception);
// TODO(brettw) need native array access here.
/**
* |name| is guaranteed to be a string type var. Exception is guaranteed
* non-NULL
*/
struct PP_Var (*Call)(void* object,
struct PP_Var method_name,
uint32_t argc,
struct PP_Var* argv,
struct PP_Var* exception);
/** Exception is guaranteed non-NULL. */
struct PP_Var (*Construct)(void* object,
uint32_t argc,
struct PP_Var* argv,
struct PP_Var* exception);
/**
* Called when the reference count of the object reaches 0. Normally, plugins
* would free their internal data pointed to by the |object| pointer.
*/
void (*Deallocate)(void* object);
};
/**
* @}
* End addtogroup PPP
*/
#endif // PPAPI_C_PPP_CLASS_DEPRECATED_H_

@ -0,0 +1,19 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_CURSOR_CONTROL_DEV_H_
#define PPAPI_C_DEV_PPP_CURSOR_CONTROL_DEV_H_
#include "ppapi/c/pp_instance.h"
#define PPP_CURSOR_CONTROL_DEV_INTERFACE "PPP_CursorControl(Dev);0.1"
struct PPP_CursorControl_Dev {
// Called when the instance looses the cursor lock, e.g. because the user
// pressed the ESC key.
void (*CursorLockLost)(PP_Instance instance);
};
#endif // PPAPI_C_DEV_PPP_CURSOR_CONTROL_DEV_H_

@ -0,0 +1,33 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_FIND_DEV_H_
#define PPAPI_C_DEV_PPP_FIND_DEV_H_
#include "ppapi/c/pp_instance.h"
#define PPP_FIND_DEV_INTERFACE "PPP_Find(Dev);0.1"
struct PPP_Find_Dev {
// Finds the given UTF-8 text starting at the current selection. The number of
// results will be updated asynchronously via NumberOfFindResultsChanged in
// PPB_Find. Note that multiple StartFind calls can happen before StopFind is
// called in the case of the search term changing.
//
// Return false if plugin doesn't support find in page. Consequently, it won't
// call any callbacks.
bool (*StartFind)(PP_Instance instance,
const char* text,
bool case_sensitive);
// Go to the next/previous result.
void (*SelectFindResult)(PP_Instance instance,
bool forward);
// Tells the plugin that the find operation has stopped, so it should clear
// any highlighting.
void (*StopFind)(PP_Instance instance);
};
#endif // PPAPI_C_DEV_PPP_FIND_DEV_H_

@ -0,0 +1,18 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_GRAPHICS_3D_DEV_H_
#define PPAPI_C_DEV_PPP_GRAPHICS_3D_DEV_H_
#include "ppapi/c/pp_instance.h"
#define PPP_GRAPHICS_3D_DEV_INTERFACE "PPP_Graphics_3D(Dev);0.1"
struct PPP_Graphics3D_Dev {
// Called when the OpenGL ES window is invalidated and needs to be repainted.
void (*Graphics3DContextLost)(PP_Instance instance);
};
#endif // PPAPI_C_DEV_PPP_GRAPHICS_3D_DEV_H_

@ -0,0 +1,74 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_PRINTING_DEV_H_
#define PPAPI_C_DEV_PPP_PRINTING_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
typedef enum {
PP_PRINTORIENTATION_NORMAL = 0,
PP_PRINTORIENTATION_ROTATED_90_CW = 1,
PP_PRINTORIENTATION_ROTATED_180 = 2,
PP_PRINTORIENTATION_ROTATED_90_CCW = 3
} PP_PrintOrientation_Dev;
typedef enum {
PP_PRINTOUTPUTFORMAT_RASTER = 0,
PP_PRINTOUTPUTFORMAT_PDF = 1,
PP_PRINTOUTPUTFORMAT_POSTSCRIPT = 2
} PP_PrintOutputFormat_Dev;
struct PP_PrintSettings_Dev {
// This is the size of the printable area in points (1/72 of an inch)
struct PP_Rect printable_area;
int32_t dpi;
PP_PrintOrientation_Dev orientation;
bool grayscale;
PP_PrintOutputFormat_Dev format;
};
// Specifies a contiguous range of page numbers to be printed.
// The page numbers use a zero-based index.
struct PP_PrintPageNumberRange_Dev {
uint32_t first_page_number;
uint32_t last_page_number;
};
// Interface for the plugin to implement printing.
#define PPP_PRINTING_DEV_INTERFACE "PPP_Printing(Dev);0.1"
struct PPP_Printing_Dev {
// Returns array of supported print output formats. The array is allocated
// using PPB_Core.MemAlloc. The caller is responsible for freeing the array
// using PPB_Core.MemFree.
// Sets |*format_count| to 0 returns NULL if printing is not supported at all.
PP_PrintOutputFormat_Dev* (*QuerySupportedFormats)(PP_Instance instance,
uint32_t* format_count);
// Begins a print session with the given print settings. Calls to PrintPage
// can only be made after a successful call to Begin. Returns the number of
// pages required for the print output at the given page size (0 indicates
// a failure).
int32_t (*Begin)(PP_Instance instance,
const struct PP_PrintSettings_Dev* print_settings);
// Prints the specified pages using the format specified in Begin.
// Returns a resource that represents the printed output.
// This is a PPB_ImageData resource if the output format is
// PP_PrintOutputFormat_Raster and a PPB_Blob otherwise. Returns 0 on failure.
PP_Resource (*PrintPages)(
PP_Instance instance,
const struct PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count);
// Ends the print session. Further calls to PrintPage will fail.
void (*End)(PP_Instance instance);
};
#endif // PPAPI_C_DEV_PPP_PRINTING_DEV_H_

@ -0,0 +1,22 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_SCROLLBAR_DEV_H_
#define PPAPI_C_DEv_PPP_SCROLLBAR_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
// Interface for the plugin to implement when using a scrollbar widget.
#define PPP_SCROLLBAR_DEV_INTERFACE "PPP_Scrollbar(Dev);0.1"
struct PPP_Scrollbar_Dev {
// Informs the instance that the scrollbar's value has changed.
void (*ValueChanged)(PP_Instance instance,
PP_Resource scrollbar,
uint32_t value);
};
#endif // PPAPI_C_DEV_PPP_SCROLLBAR_DEV_H_

@ -0,0 +1,23 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_SELECTION_DEV_H_
#define PPAPI_C_DEV_PPP_SELECTION_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_var.h"
#define PPP_SELECTION_DEV_INTERFACE "PPP_Selection(Dev);0.1"
struct PPP_Selection_Dev {
/**
* Returns the selection, either as plain text or as html depending on "html".
* If nothing is selected, or if the given format is unavailable, return a
* void string.
*/
struct PP_Var (*GetSelectedText)(PP_Instance instance,
bool html);
};
#endif // PPAPI_C_DEV_PPP_SELECTION_DEV_H_

@ -0,0 +1,22 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_WIDGET_DEV_H_
#define PPAPI_C_DEV_PPP_WIDGET_DEV_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_rect.h"
// Interface for the plugin to implement when using a widget.
#define PPP_WIDGET_DEV_INTERFACE "PPP_Widget(Dev);0.1"
struct PPP_Widget_Dev {
// Informs the instance that the given rectangle needs to be repainted.
void (*Invalidate)(PP_Instance instance,
PP_Resource widget,
const struct PP_Rect* dirty_rect);
};
#endif // PPAPI_C_DEV_PPP_WIDGET_DEV_H_

@ -0,0 +1,22 @@
// 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.
#ifndef PPAPI_C_DEV_PPP_ZOOM_DEV_H_
#define PPAPI_C_DEV_PPP_ZOOM_DEV_H_
#include "ppapi/c/pp_instance.h"
// Zoom interface should only apply to those full-page "plugin-document".
#define PPP_ZOOM_DEV_INTERFACE "PPP_Zoom(Dev);0.1"
struct PPP_Zoom_Dev {
// Instruct plug-in to zoom according to the given factor and whether the zoom
// only applies to text only. The scale factor is the percentage divided by
// 100, i.e. 150% zoom is 1.5.
void (*Zoom)(PP_Instance instance,
double factor,
bool text_only);
};
#endif // PPAPI_C_DEV_PPP_ZOOM_DEV_H_

@ -0,0 +1,64 @@
// 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.
#ifndef PPAPI_C_PP_COMPLETION_CALLBACK_H_
#define PPAPI_C_PP_COMPLETION_CALLBACK_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include <stdlib.h>
#include "ppapi/c/pp_stdint.h"
typedef void (*PP_CompletionCallback_Func)(void* user_data, int32_t result);
/**
* Any method that takes a PP_CompletionCallback has the option of completing
* asynchronously if the operation would block. Such a method should return
* PP_Error_WouldBlock to indicate when the method will complete
* asynchronously. If the completion callback is NULL, then the operation will
* block if necessary to complete its work. PP_BlockUntilComplete() provides a
* convenient way to specify blocking behavior.
*
* The result parameter passes an int32_t that if negative indicates an error
* code. Otherwise the result value indicates success. If it is a positive
* value then it may carry additional information.
*/
struct PP_CompletionCallback {
PP_CompletionCallback_Func func;
void* user_data;
};
inline struct PP_CompletionCallback PP_MakeCompletionCallback(
PP_CompletionCallback_Func func,
void* user_data) {
struct PP_CompletionCallback cc = { func, user_data };
return cc;
}
inline void PP_RunCompletionCallback(struct PP_CompletionCallback* cc,
int32_t res) {
cc->func(cc->user_data, res);
}
/**
* Use this in place of an actual completion callback to request blocking
* behavior. If specified, the calling thread will block until a method
* completes. This is only usable from background threads.
*/
inline struct PP_CompletionCallback PP_BlockUntilComplete() {
return PP_MakeCompletionCallback(NULL, NULL);
}
/**
* @}
* End of addtogroup PP
*/
#endif // PPAPI_C_PP_COMPLETION_CALLBACK_H_

82
ppapi/c/pp_errors.h Normal file

@ -0,0 +1,82 @@
// 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.
#ifndef PPAPI_C_PP_ERRORS_H_
#define PPAPI_C_PP_ERRORS_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
/** Errors are negative valued. */
enum {
PP_OK = 0,
/**
* Returned by a function, taking a PP_CompletionCallback, that cannot
* complete synchronously. This return value indicates that the given
* callback will be asynchronously notified of the final result once it is
* available.
*/
PP_ERROR_WOULDBLOCK = -1,
/** Indicates failure for unspecified reasons. */
PP_ERROR_FAILED = -2,
/**
* Indicates failure due to an asynchronous operation being interrupted,
* typically as a result of user action.
*/
PP_ERROR_ABORTED = -3,
/** Indicates failure due to an invalid argument. */
PP_ERROR_BADARGUMENT = -4,
/** Indicates failure due to an invalid PP_Resource. */
PP_ERROR_BADRESOURCE = -5,
/** Indicates failure due to an unavailable PPAPI interface. */
PP_ERROR_NOINTERFACE = -6,
/** Indicates failure due to insufficient privileges. */
PP_ERROR_NOACCESS = -7,
/** Indicates failure due to insufficient memory. */
PP_ERROR_NOMEMORY = -8,
/** Indicates failure due to insufficient storage space. */
PP_ERROR_NOSPACE = -9,
/** Indicates failure due to insufficient storage quota. */
PP_ERROR_NOQUOTA = -10,
/** Indicates failure due to an action already being in progress. */
PP_ERROR_INPROGRESS = -11,
/** Indicates failure due to a file that does not exist. */
PP_ERROR_FILENOTFOUND = -20,
/** Indicates failure due to a file that already exists. */
PP_ERROR_FILEEXISTS = -21,
/** Indicates failure due to a file that is too big. */
PP_ERROR_FILETOOBIG = -22,
/** Indicates failure due to a file having been modified unexpectedly. */
PP_ERROR_FILECHANGED = -23,
/** Indicates failure due to a time limit being exceeded. */
PP_ERROR_TIMEDOUT = -30
};
/**
* @}
* End of addtogroup PP
*/
#endif // PPAPI_C_PP_ERRORS_H_

181
ppapi/c/pp_input_event.h Normal file

@ -0,0 +1,181 @@
// 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.
#ifndef PPAPI_C_PP_INPUT_EVENT_H_
#define PPAPI_C_PP_INPUT_EVENT_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
typedef enum {
PP_INPUTEVENT_MOUSEBUTTON_NONE = -1,
PP_INPUTEVENT_MOUSEBUTTON_LEFT = 0,
PP_INPUTEVENT_MOUSEBUTTON_MIDDLE = 1,
PP_INPUTEVENT_MOUSEBUTTON_RIGHT = 2
} PP_InputEvent_MouseButton;
typedef enum {
PP_INPUTEVENT_TYPE_UNDEFINED = -1,
PP_INPUTEVENT_TYPE_MOUSEDOWN = 0,
PP_INPUTEVENT_TYPE_MOUSEUP = 1,
PP_INPUTEVENT_TYPE_MOUSEMOVE = 2,
PP_INPUTEVENT_TYPE_MOUSEENTER = 3,
PP_INPUTEVENT_TYPE_MOUSELEAVE = 4,
PP_INPUTEVENT_TYPE_MOUSEWHEEL = 5,
PP_INPUTEVENT_TYPE_RAWKEYDOWN = 6,
PP_INPUTEVENT_TYPE_KEYDOWN = 7,
PP_INPUTEVENT_TYPE_KEYUP = 8,
PP_INPUTEVENT_TYPE_CHAR = 9
} PP_InputEvent_Type;
typedef enum {
PP_INPUTEVENT_MODIFIER_SHIFTKEY = 1 << 0,
PP_INPUTEVENT_MODIFIER_CONTROLKEY = 1 << 1,
PP_INPUTEVENT_MODIFIER_ALTKEY = 1 << 2,
PP_INPUTEVENT_MODIFIER_METAKEY = 1 << 3,
PP_INPUTEVENT_MODIFIER_ISKEYPAD = 1 << 4,
PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT = 1 << 5,
PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN = 1 << 6,
PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN = 1 << 7,
PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN = 1 << 8,
PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY = 1 << 9,
PP_INPUTEVENT_MODIFIER_NUMLOCKKEY = 1 << 10
} PP_InputEvent_Modifier;
/**
* An event representing a key up or down event.
*
* Key up and down events correspond to physical keys on the keyboard. The
* actual character that the user typed (if any) will be delivered in a
* "character" event.
*
* If the user kills focus on the plugin while a key is down, you may not get
* a key up event. For example, if the plugin has focus and the user presses
* and holds shift, the plugin will see a "shift down" message. Then if they
* click elsewhere on the web page, the plugin focus will be lost and no more
* input events will be delivered. If you depend on getting key up events, you
* will also want to handle "lost focus" as the equivalent of "all keys up."
*/
struct PP_InputEvent_Key {
/** A combination of the EVENT_MODIFIER flags. */
uint32_t modifier;
/**
* The key code.
*
* TODO(brettw) define what these actually are.
*/
uint32_t key_code;
};
/**
* An event representing a typed character.
*
* Normally, the program will receive a key down event, followed by a character
* event, followed by a key up event. The character event will have any
* modifier keys applied. Obvious examples are symbols, where Shift-5 gives you
* a '%'. The key down and up events will give you the scan code for the "5"
* key, and the character event will give you the '%' character.
*
* You may not get a character event for all key down if the key doesn't
* generate a character. Likewise, you may actually get multiple character
* events in a row. For example, some locales have an accent key that modifies
* the next character typed. You might get this stream of events: accent down,
* accent up (it didn't generate a character), letter key down, letter with
* accent character event (it was modified by the previous accent key), letter
* key up. If the letter can't be combined with the accent, like an umlaut and
* an 'R', the system might send unlaut down, umlaut up, 'R' key down, umlaut
* character ("whoops, I can't combine it with 'R', I better just send the raw
* unlaut so it isn't lost"), 'R' character event, 'R' key up.
*/
struct PP_InputEvent_Character {
/** A combination of the EVENT_MODIFIER flags. */
uint32_t modifier;
/**
* The character the user typed, as a single null-terminated UTF-8 character.
* Any unused bytes will be filled with null bytes. Since the maximum UTF-8
* character is 4 bytes, there will always be at least one null at the end
* so you can treat this as a null-termianted UTF-8 string.
*/
char text[5];
};
/** Represents a mouse event for everything other than the mouse wheel. */
struct PP_InputEvent_Mouse {
/** A combination of the EVENT_MODIFIER flags. */
uint32_t modifier;
/**
* Which button changed in the case of mouse down or up events. For mouse
* move, enter, and leave events, this will be PP_EVENT_MOUSEBUTTON_NONE.
*/
PP_InputEvent_MouseButton button;
/**
* The coordinates of the mouse when the event occurred.
*
* In most cases these coordinates will just be integers, but they may not
* be in some cases. For example, the plugin element might be arbitrarily
* scaled or transformed in the DOM, and translating a mouse event into the
* coordinate space of the plugin will give non-integer values.
*/
float x;
float y;
/** TODO(brettw) figure out exactly what this means. */
int32_t click_count;
};
struct PP_InputEvent_Wheel {
/** A combination of the EVENT_MODIFIER flags. */
uint32_t modifier;
float delta_x;
float delta_y;
float wheel_ticks_x;
float wheel_ticks_y;
bool scroll_by_page;
};
struct PP_InputEvent {
/** Identifies the type of the event. */
PP_InputEvent_Type type;
/**
* When this event was generated. This is not relative to any particular
* epoch, the most you can do is compare time stamps.
*/
PP_TimeTicks time_stamp;
/** Event-specific data. */
union {
struct PP_InputEvent_Key key;
struct PP_InputEvent_Character character;
struct PP_InputEvent_Mouse mouse;
struct PP_InputEvent_Wheel wheel;
/**
* Allows new events to be added without changing the size of this
* struct.
*/
char padding[64];
} u;
};
/**
* @}
* End of addtogroup PP
*/
#endif // PPAPI_C_PP_INPUT_EVENT_H_

33
ppapi/c/pp_instance.h Normal file

@ -0,0 +1,33 @@
// 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.
#ifndef PPAPI_C_PP_INSTANCE_H_
#define PPAPI_C_PP_INSTANCE_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include "ppapi/c/pp_stdint.h"
/** A PP_Instance uniquely identifies one plugin instance, which is one time
* that a page says \<embed>. There can be multiple instances of the same plugin
* type on a page that will all be in the same module.
*
* The identifier is an opaque handle assigned by the browser to the plugin. It
* is guaranteed never to be 0, so a plugin can initialize it to 0 to
* indicate a "NULL handle."
*/
typedef int64_t PP_Instance;
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_INSTANCE_H_

30
ppapi/c/pp_module.h Normal file

@ -0,0 +1,30 @@
// 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.
#ifndef PPAPI_C_PP_MODULE_H_
#define PPAPI_C_PP_MODULE_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include "ppapi/c/pp_stdint.h"
/**
* A module uniquely identifies one plugin library. The identifier is an opaque
* handle assigned by the browser to the plugin. It is guaranteed never to be
* 0, so a plugin can initialize it to 0 to indicate a "NULL handle."
*/
typedef int64_t PP_Module;
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_MODULE_H_

35
ppapi/c/pp_point.h Normal file

@ -0,0 +1,35 @@
// 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.
#ifndef PPAPI_C_PP_POINT_H_
#define PPAPI_C_PP_POINT_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include "ppapi/c/pp_stdint.h"
struct PP_Point {
int32_t x;
int32_t y;
};
inline struct PP_Point PP_MakePoint(int32_t x, int32_t y) {
struct PP_Point ret;
ret.x = x;
ret.y = y;
return ret;
}
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_POINT_H_

39
ppapi/c/pp_rect.h Normal file

@ -0,0 +1,39 @@
// 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.
#ifndef PPAPI_C_PP_RECT_H_
#define PPAPI_C_PP_RECT_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/c/pp_stdint.h"
struct PP_Rect {
struct PP_Point point;
struct PP_Size size;
};
inline struct PP_Rect PP_MakeRectFromXYWH(int32_t x, int32_t y,
int32_t w, int32_t h) {
struct PP_Rect ret;
ret.point.x = x;
ret.point.y = y;
ret.size.width = w;
ret.size.height = h;
return ret;
}
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_RECT_H_

39
ppapi/c/pp_resource.h Normal file

@ -0,0 +1,39 @@
// 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.
#ifndef PPAPI_C_PP_RESOURCE_H_
#define PPAPI_C_PP_RESOURCE_H_
#include "ppapi/c/pp_stdint.h"
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
/**
* A resource is data associated with the Pepper plugin interface. While a
* Var represents something callable to JS or from the plugin to the DOM, a
* resource has no meaning or visibility outside of the plugin interface.
*
* Resources are reference counted. Use AddRefResource and ReleaseResource to
* manage your reference count of a resource. The data will be automatically
* destroyed when the internal reference count reaches 0.
*
* Value is an opaque handle assigned by the browser to the resource. It is
* guaranteed never to be 0 for a valid resource, so a plugin can initialize
* it to 0 to indicate a "NULL handle." Some interfaces may return a NULL
* resource to indicate failure.
*/
typedef int64_t PP_Resource;
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_RESOURCE_H_

34
ppapi/c/pp_size.h Normal file

@ -0,0 +1,34 @@
// 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.
#ifndef PPAPI_C_PP_SIZE_H_
#define PPAPI_C_PP_SIZE_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include "ppapi/c/pp_stdint.h"
struct PP_Size {
int32_t width;
int32_t height;
};
inline struct PP_Size PP_MakeSize(int32_t w, int32_t h) {
struct PP_Size ret;
ret.width = w;
ret.height = h;
return ret;
}
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_SIZE_H_

36
ppapi/c/pp_stdint.h Normal file

@ -0,0 +1,36 @@
// 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.
#ifndef PPAPI_C_PP_STDINT_H_
#define PPAPI_C_PP_STDINT_H_
/**
* @file
* Provides a definition of C99 sized types
* across different compilers.
*
* @addtogroup PP
* @{
*/
#if defined(_MSC_VER)
typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned int uint32_t;
typedef int int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#include <stddef.h> // Needed for size_t.
#endif
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_STDINT_H_

38
ppapi/c/pp_time.h Normal file

@ -0,0 +1,38 @@
// 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.
#ifndef PPAPI_C_PP_TIME_H_
#define PPAPI_C_PP_TIME_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
/**
* PP_Time represents the "wall clock time" according to the browser and is
* defined as the number of seconds since the Epoch (00:00:00 UTC, January 1,
* 1970).
*/
typedef double PP_Time;
/**
* Represents time ticks which is measured in seconds and is used for indicating
* the time that certain messages were received. In contrast to PP_Time, it
* does not correspond to any actual wall clock time and will not change
* discontinuously if the user changes their computer clock.
*
* The units are in seconds, but are not measured relative to any particular
* epoch, so the most you can do is compare two values.
*/
typedef double PP_TimeTicks;
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_TIME_H_

88
ppapi/c/pp_var.h Normal file

@ -0,0 +1,88 @@
// 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.
#ifndef PPAPI_C_PP_VAR_H_
#define PPAPI_C_PP_VAR_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PP
* @{
*/
#include "ppapi/c/pp_stdint.h"
typedef enum {
PP_VARTYPE_UNDEFINED,
PP_VARTYPE_NULL,
PP_VARTYPE_BOOL,
PP_VARTYPE_INT32,
PP_VARTYPE_DOUBLE,
PP_VARTYPE_STRING,
PP_VARTYPE_OBJECT
} PP_VarType;
/**
* Do not rely on having a predictable and reproducible
* int/double differentiation.
* JavaScript has a "number" type for holding a number, and
* does not differentiate between floating point and integer numbers. The
* JavaScript library will try to optimize operations by using integers
* when possible, but could end up with doubles depending on how the number
* was arrived at.
*
* Your best bet is to have a wrapper for variables
* that always gets out the type you expect, converting as necessary.
*/
struct PP_Var {
PP_VarType type;
union {
bool as_bool;
int32_t as_int;
double as_double;
/**
* Internal ID for strings and objects. The identifier is an opaque handle
* assigned by the browser to the plugin. It is guaranteed never to be 0,
* so a plugin can initialize this ID to 0 to indicate a "NULL handle."
*/
int64_t as_id;
} value;
};
inline struct PP_Var PP_MakeUndefined() {
struct PP_Var result = { PP_VARTYPE_UNDEFINED, {0} };
return result;
}
inline struct PP_Var PP_MakeNull() {
struct PP_Var result = { PP_VARTYPE_NULL, {0} };
return result;
}
inline struct PP_Var PP_MakeBool(bool value) {
struct PP_Var result = { PP_VARTYPE_BOOL, {0} };
result.value.as_bool = value;
return result;
}
inline struct PP_Var PP_MakeInt32(int32_t value) {
PP_Var result = { PP_VARTYPE_INT32, {0} };
result.value.as_int = value;
return result;
}
inline struct PP_Var PP_MakeDouble(double value) {
PP_Var result = { PP_VARTYPE_DOUBLE, {0} };
result.value.as_double = value;
return result;
}
/**
* @}
* End addtogroup PP
*/
#endif // PPAPI_C_PP_VAR_H_

26
ppapi/c/ppb.h Normal file

@ -0,0 +1,26 @@
// 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.
#ifndef PPAPI_C_PPB_H_
#define PPAPI_C_PPB_H_
/**
* @file
* Defines the API ...
*
* @addtogroup PPB
* @{
*/
/**
* Returns an interface pointer for the interface of the given name, or NULL
* if the interface is not supported. Interface names should be ASCII.
*/
typedef const void* (*PPB_GetInterface)(const char* interface_name);
/**
* @}
* End addtogroup PPB
*/
#endif // PPAPI_C_PPB_H_

121
ppapi/c/ppb_class.h Normal file

@ -0,0 +1,121 @@
// 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.
#ifndef PPAPI_C_PPB_CLASS_H_
#define PPAPI_C_PPB_CLASS_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/ppb_var.h"
#define PPB_CLASS_INTERFACE "PPB_Class;0.1"
/**
* @file
* Defines the PPB_Class struct.
*
* @addtogroup PPB
* @{
*/
/**
* Function callback.
*
* native_ptr will always be the native_ptr used to create this_object. If
* this object was not created in this module, native_ptr will be NULL. There
* is no other type protection - if your module contains two objects with
* different native_ptr information, make sure you can handle the case of
* JS calling one object's function with another object set as this.
*/
typedef PP_Var (*PP_ClassFunction)(void* native_ptr, PP_Var this_object,
PP_Var* args, uint32_t argc,
PP_Var* exception);
typedef void (*PP_ClassDestructor)(void* native_ptr);
/**
* One property of a class.
*
* It can be either a value property, in which case it need to have getter
* and/or setter fields set, and method NULL, or a function, in which case it
* needs to have method set, and getter/setter set to NULL. It is an error to
* have method and either getter or setter set, as it is an error to not provide
* any of them.
*
* Not providing a getter will be equivalent to having a getter which returns
* undefined. Not providing a setter will be equivalent to providing a setter
* which doesn't do anything.
*/
struct PP_ClassProperty {
const char* name;
PP_ClassFunction method;
PP_ClassFunction getter;
PP_ClassFunction setter;
uint32_t modifiers;
};
/** Interface for implementing JavaScript-accessible objects.
*
*
* Example usage:
*
* struct PP_ClassProperty properties[] = {
* { "method", methodFunc },
* { "hiddenMethod", hiddenMethodFunc, NULL, NULL,
* PP_OBJECTPROPERTY_MODIFIER_DONTENUM },
* { "property", NULL, propertyGetter, propertySetter },
* { "readonlyProperty", NULL, propertyGetter, NULL,
* PP_OBJECTPROPERTY_MODIFIER_READONLY },
* { NULL }
* };
*
* PP_Resource object_template =
* Create(module, &operator delete, NULL, properties);
*
* ...
*
* struct NativeData { int blah; ... }; // Can be anything.
* NativeData* native_data = new NativeData;
* native_data->blah = 123; // Initialize native data.
*
* PP_Var object = Instantiate(object_template, native_data);
*
* Please also see:
* http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
* for general information on using and implementing vars.
*/
struct PPB_Class {
/**
* Creates a class containing given methods and properties.
*
* Properties list is terminated with a NULL-named property. New instances are
* created using Instantiate(). Each instance carries one void* of native
* state, which is passed to Instantiate(). When the instance is finalized,
* the destructor function is called to destruct the native state.
*
* If invoke handler is specified, then the instances can be used as
* functions.
*/
PP_Resource (*Create)(PP_Module module,
PP_ClassDestructor destruct,
PP_ClassFunction invoke,
PP_ClassProperty* properties);
/**
* Creates an instance of the given class, and attaches given native pointer
* to it.
*
* If the class_object is invalid, throws an exception.
*/
PP_Var (*Instantiate)(PP_Resource class_object,
void* native_ptr, PP_Var* exception);
};
/**
* @}
* End addtogroup PPP
*/
#endif // PPAPI_C_PPP_CLASS_H_

92
ppapi/c/ppb_core.h Normal file

@ -0,0 +1,92 @@
// 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.
#ifndef PPAPI_C_PPB_CORE_H_
#define PPAPI_C_PPB_CORE_H_
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
#include "ppapi/c/pp_var.h"
struct PP_CompletionCallback;
#define PPB_CORE_INTERFACE "PPB_Core;0.1"
/**
* @file
* Defines the API ...
*
* @addtogroup PPB
* @{
*/
/** {PENDING: describe PPB_CORE} */
struct PPB_Core {
/** Same as AddRefVar for Resources. */
void (*AddRefResource)(PP_Resource resource);
/** Same as ReleaseVar for Resources. */
void (*ReleaseResource)(PP_Resource resource);
/**
* Allocate memory.
*
* @return NULL If the allocation fails.
*/
void* (*MemAlloc)(size_t num_bytes);
/** Free memory; it's safe to pass NULL. */
void (*MemFree)(void* ptr);
/**
* Returns the "wall clock time" according to the browser.
*
* See the definition of PP_Time.
*/
PP_Time (*GetTime)();
/**
* Returns the "tick time" according to the browser. This clock is used by
* the browser when passing some event times to the plugin (e.g., via the
* PP_InputEvent::time_stamp_seconds field). It is not correlated to any
* actual wall clock time (like GetTime()). Because of this, it will not run
* change if the user changes their computer clock.
*
* TODO(brettw) http://code.google.com/p/chromium/issues/detail?id=57448
* This currently does change with wall clock time, but will be fixed in
* a future release.
*/
PP_TimeTicks (*GetTimeTicks)();
/**
* Schedules work to be executed on the main plugin thread after the
* specified delay. The delay may be 0 to specify a call back as soon as
* possible.
*
* The |result| parameter will just be passed as the second argument as the
* callback. Many applications won't need this, but it allows a plugin to
* emulate calls of some callbacks which do use this value.
*
* NOTE: If the browser is shutting down or if the plugin has no instances,
* then the callback function may not be called.
*/
void (*CallOnMainThread)(int32_t delay_in_milliseconds,
struct PP_CompletionCallback callback,
int32_t result);
/**
* Returns true if the current thread is the main pepper thread.
*
* This is useful for implementing sanity checks, and deciding if dispatching
* via CallOnMainThread() is required.
*/
bool (*IsMainThread)();
};
/**
* @}
* End addtogroup PPB
*/
#endif // PPAPI_C_DEV_PPB_CORE_DEV_H_

223
ppapi/c/ppb_graphics_2d.h Normal file

@ -0,0 +1,223 @@
// 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.
#ifndef PPAPI_C_PPB_GRAPHICS_2D_H_
#define PPAPI_C_PPB_GRAPHICS_2D_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
struct PP_CompletionCallback;
struct PP_Point;
struct PP_Rect;
struct PP_Size;
#define PPB_GRAPHICS_2D_INTERFACE "PPB_Graphics2D;0.1"
/**
* @file
* Defines the PPB_Graphics2D struct.
*
* @addtogroup PPB
* @{
*/
/** {PENDING: describe PPB_Graphics2D. */
struct PPB_Graphics2D {
/**
* The returned graphics context will not be bound to any plugin instance on
* creation (call BindGraphics on the plugin instance to do that. The
* graphics context has a lifetime that can exceed that of the given plugin
* instance.
*
* Set the is_always_opaque flag if you know that you will be painting only
* opaque data to this context. This will disable blending when compositing
* the plugin with the web page, which will give slightly higher performance.
*
* If you set is_always_opaque, your alpha channel should always be set to
* 0xFF or there may be painting artifacts. Being opaque will allow the
* browser to do a memcpy rather than a blend to paint the plugin, and this
* means your alpha values will get set on the page backing store. If these
* values are incorrect, it could mess up future blending.
*
* If you aren't sure, it is always correct to specify that it it not opaque.
*/
PP_Resource (*Create)(PP_Module module,
const struct PP_Size* size,
bool is_always_opaque);
/**
* Returns true if the given resource is a valid Graphics2D, false if it
* is an invalid resource or is a resource of another type.
*/
bool (*IsGraphics2D)(PP_Resource resource);
/**
* Retrieves the configuration for the given graphics context, filling the
* given values (which must not be NULL). On success, returns true. If the
* resource is invalid, the output parameters will be set to 0 and it will
* return false.
*/
bool (*Describe)(PP_Resource graphics_2d,
struct PP_Size* size,
bool* is_always_opqaue);
/**
* Enqueues a paint of the given image into the context. THIS HAS NO EFFECT
* UNTIL YOU CALL Flush(). As a result, what counts is the contents of the
* bitmap when you call Flush, not when you call this function.
*
* The given image will be placed at |top_left| from the top left of the
* context's internal backing store. Then the src_rect will be copied into the
* backing store. This parameter may not be NULL.
*
* The src_rect is specified in the coordinate system of the image being
* painted, not the context. For the common case of copying the entire image,
* you may specify a NULL |src_rect| pointer. If you are frequently updating
* the entire image, consider using SwapImageData which will give slightly
* higher performance.
*
* The painted area of the source bitmap must fall entirely within the
* context. Attempting to paint outside of the context will result in an
* error. However, the source bitmap may fall outside the context, as long
* as the src_rect subset of it falls entirely within the context.
*/
void (*PaintImageData)(PP_Resource graphics_2d,
PP_Resource image_data,
const struct PP_Point* top_left,
const struct PP_Rect* src_rect);
/**
* Enqueues a scroll of the context's backing store. THIS HAS NO EFFECT UNTIL
* YOU CALL Flush(). The data within the given clip rect (you may specify
* NULL to scroll the entire region) will be shifted by (dx, dy) pixels.
*
* This will result in some exposed region which will have undefined
* contents. The plugin should call PaintImageData on these exposed regions
* to give the correct contents.
*
* The scroll can be larger than the area of the clip rect, which means the
* current image will be scrolled out of the rect. This is not an error but
* will be a no-op.
*/
void (*Scroll)(PP_Resource graphics_2d,
const struct PP_Rect* clip_rect,
const struct PP_Point* amount);
/**
* This function provides a slightly more efficient way to paint the entire
* plugin's image. Normally, calling PaintImageData requires that the browser
* copy the pixels out of the image and into the graphics context's backing
* store. This function replaces the graphics context's backing store with the
* given image, avoiding the copy.
*
* The new image must be the exact same size as this graphics context. If the
* new image uses a different image format than the browser's native bitmap
* format (use PPB_ImageData.GetNativeImageDataFormat to retrieve this), then
* a conversion will be done inside the browser which may slow the performance
* a little bit.
*
* THE NEW IMAGE WILL NOT BE PAINTED UNTIL YOU CALL FLUSH.
*
* After this call, you should take care to release your references to the
* image. If you paint to the image after a Swap, there is the possibility of
* significant painting artifacts because the page might use partially-
* rendered data when copying out of the backing store.
*
* In the case of an animation, you will want to allocate a new image for the
* next frame. It is best if you wait until the flush callback has executed
* before allocating this bitmap. This gives the browser the option of
* caching the previous backing store and handing it back to you (assuming
* the sizes match). In the optimal case, this means no bitmaps are allocated
* during the animation, and the backing store and "front buffer" (which the
* plugin is painting into) are just being swapped back and forth.
*/
void (*ReplaceContents)(PP_Resource graphics_2d, PP_Resource image_data);
/**
* Flushes any enqueued paint, scroll, and swap commands for the backing
* store. This actually executes the updates, and causes a repaint of the
* webpage, assuming this graphics context is bound to a plugin instance. This
* can run in two modes:
*
* - In synchronous mode, you specify NULL for the callback and the callback
* data. This function will block the calling thread until the image has
* been painted to the screen. It is not legal to block the main thread of
* the plugin, you can use synchronous mode only from background threads.
*
* - In asynchronous mode, you specify a callback function and the argument
* for that callback function. The callback function will be executed on
* the calling thread when the image has been painted to the screen. While
* you are waiting for a Flush callback, additional calls to Flush will
* fail.
*
* Because the callback is executed (or thread unblocked) only when the
* plugin's current state is actually on the screen, this function provides a
* way to rate limit animations. By waiting until the image is on the screen
* before painting the next frame, you can ensure you're not generating
* updates faster than the screen can be updated.
*
* <dl>
* <dt>Unbound contexts</dt>
* <dd>
* If the context is not bound to a plugin instance, you will
* still get a callback. It will execute after the Flush function returns
* to avoid reentrancy. Of course, it will not wait until anything is
* painted to the screen because there will be nothing on the screen. The
* timing of this callback is not guaranteed and may be deprioritized by
* the browser because it is not affecting the user experience.
* </dd>
*
* <dt>Off-screen instances</dt>
* <dd>
* If the context is bound to an instance that is
* currently not visible (for example, scrolled out of view) it will behave
* like the "unbound context" case.
* </dd>
*
* <dt>Detaching a context</dt>
* <dd>
* If you detach a context from a plugin instance, any
* pending flush callbacks will be converted into the "unbound context"
* case.
* </dd>
*
* <dt>Released contexts</dt>
* <dd>
* A callback may or may not still get called even if you have released all
* of your references to the context. This can occur if there are internal
* references to the context that means it has not been internally
* destroyed (for example, if it is still bound to an instance) or due to
* other implementation details. As a result, you should be careful to
* check that flush callbacks are for the context you expect and that
* you're capable of handling callbacks for context that you may have
* released your reference to.
* </dd>
*
* <dt>Shutdown</dt>
* <dd>
* If a plugin instance is removed when a Flush is pending, the
* callback will not be executed.
* </dd>
* </dl>
*
* Returns PP_OK on success, PP_Error_BadResource if the graphics context is
* invalid, PP_Error_BadArgument if the callback is null and Flush is being
* called from the main thread of the plugin, or PP_Error_InProgress if a
* Flush is already pending that has not issued its callback yet. In the
* failure case, nothing will be updated and no callback will be scheduled.
*/
// TODO(darin): We should ensure that the completion callback always runs, so
// that it is easier for consumers to manage memory referenced by a callback.
int32_t (*Flush)(PP_Resource graphics_2d,
struct PP_CompletionCallback callback);
};
/**
* @}
* End addtogroup PPB
*/
#endif // PPAPI_C_PPB_GRAPHICS_2D_H_

99
ppapi/c/ppb_image_data.h Normal file

@ -0,0 +1,99 @@
// 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.
#ifndef PPAPI_C_PPB_IMAGE_DATA_H_
#define PPAPI_C_PPB_IMAGE_DATA_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_size.h"
#include "ppapi/c/pp_stdint.h"
typedef enum {
PP_IMAGEDATAFORMAT_BGRA_PREMUL,
PP_IMAGEDATAFORMAT_RGBA_PREMUL
} PP_ImageDataFormat;
struct PP_ImageDataDesc {
PP_ImageDataFormat format;
// Size of the bitmap in pixels.
PP_Size size;
// The row width in bytes. This may be different than width * 4 since there
// may be padding at the end of the lines.
int32_t stride;
};
#define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.1"
/**
* @file
* Defines the API ...
*
* @addtogroup PPB
* @{
*/
struct PPB_ImageData {
/**
* Returns the browser's preferred format for image data. This format will be
* the format is uses internally for painting. Other formats may require
* internal conversions to paint or may have additional restrictions depending
* on the function.
*/
PP_ImageDataFormat (*GetNativeImageDataFormat)();
/**
* Returns true if the given image data format is supported by the browser.
*/
bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format);
/**
* Allocates an image data resource with the given format and size. The
* return value will have a nonzero ID on success, or zero on failure.
* Failure means the module handle, image size, or format was invalid.
*
* Set the init_to_zero flag if you want the bitmap initialized to
* transparent during the creation process. If this flag is not set, the
* current contents of the bitmap will be undefined, and the plugin should
* be sure to set all the pixels.
*
* For security reasons, if uninitialized, the bitmap will not contain random
* memory, but may contain data from a previous image produced by the same
* plugin if the bitmap was cached and re-used.
*/
PP_Resource (*Create)(PP_Module module,
PP_ImageDataFormat format,
const struct PP_Size* size,
bool init_to_zero);
/**
* Returns true if the given resource is an image data. Returns false if the
* resource is invalid or some type other than an image data.
*/
bool (*IsImageData)(PP_Resource image_data);
/**
* Computes the description of the image data. Returns true on success, false
* if the resource is not an image data. On false, the |desc| structure will
* be filled with 0.
*/
bool (*Describe)(PP_Resource image_data,
struct PP_ImageDataDesc* desc);
/**
* Maps this bitmap into the plugin address space and returns a pointer to the
* beginning of the data.
*/
void* (*Map)(PP_Resource image_data);
void (*Unmap)(PP_Resource image_data);
};
/**
* @}
* End addtogroup PPB
*/
#endif // PPAPI_C_PPB_IMAGE_DATA_H_

89
ppapi/c/ppb_instance.h Normal file

@ -0,0 +1,89 @@
// 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.
#ifndef PPAPI_C_PPB_INSTANCE_H_
#define PPAPI_C_PPB_INSTANCE_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.1"
/**
* @file
* Defines the API ...
*
* @addtogroup PPB
* @{
*/
struct PPB_Instance {
/** Returns a reference to the DOM window containing this instance. */
struct PP_Var (*GetWindowObject)(PP_Instance instance);
/** Returns a reference to the DOM element containing this instance. */
struct PP_Var (*GetOwnerElementObject)(PP_Instance instance);
/**
* Binds the given graphics device as the current drawing surface. The
* contents of this device is what will be displayed in the plugin's area
* on the web page. The device must be a 2D or a 3D device.
*
* You can pass a NULL resource as the device parameter to unbind all
* devices from the given instance. The instance will then appear
* transparent. Re-binding the same device will return true and will do
* nothing. Unbinding a device will drop any pending flush callbacks.
*
* Any previously-bound device will be Release()d. It is an error to bind
* a device when it is already bound to another plugin instance. If you want
* to move a device between instances, first unbind it from the old one, and
* then rebind it to the new one.
*
* Returns true if the bind was successful. False means the device was not
* the correct type. On success, a reference to the device will be held by
* the plugin instance, so the caller can release its reference if it
* chooses.
*
* Binding a device will invalidate that portion of the web page to flush the
* contents of the new device to the screen.
*/
bool (*BindGraphics)(PP_Instance instance, PP_Resource device);
/**
* Returns true if the instance is full-frame. Such a plugin represents the
* entire document in a frame rather than an embedded resource. This can
* happen if the user does a top level navigation or the page specifies an
* iframe to a resource with a MIME type registered by the plugin.
*/
bool (*IsFullFrame)(PP_Instance instance);
/**
* Executes the given script in the context of the frame containing the
* plugin.
*
* The exception, if any, will be returned in *exception. As
* with the PPB_Var interface, the exception parameter,
* if non-NULL, must be initialized
* to a void exception or the function will immediately return. On success,
* the exception parameter will be set to a "void" var. On failure, the return
* value will be a "void" var.
*
* @param script A string containing the JavaScript to execute.
* @param exception Initialize this to NULL if you don't want exception info;
* initialize this to a void exception if you do.
* See the function description for details.
*
* @return The result of the script execution,
* or a "void" var if execution failed.
*/
PP_Var (*ExecuteScript)(PP_Instance instance, PP_Var script,
PP_Var* exception);
};
/**
* @}
* End addtogroup PPB
*/
#endif // PPAPI_C_PPB_INSTANCE_H_

295
ppapi/c/ppb_var.h Normal file

@ -0,0 +1,295 @@
// 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.
#ifndef PPAPI_C_PPB_VAR_H_
#define PPAPI_C_PPB_VAR_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
#define PPB_VAR_INTERFACE "PPB_Var;0.1"
/**
* @file
* Defines the PPB_Var struct.
* See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
* for general information on using this interface.
* {PENDING: Should the generated doc really be pointing to methods?}
*
* @addtogroup PPB
* @{
*/
enum PP_ObjectProperty_Modifier {
PP_OBJECTPROPERTY_MODIFIER_NONE = 0,
PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0,
PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1,
PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2,
PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3
};
struct PP_ObjectProperty {
PP_Var name;
PP_Var value;
PP_Var getter;
PP_Var setter;
uint32_t modifiers;
};
/**
* PPB_Var API
*
* JavaScript specification:
*
* When referencing JS specification, we will refer to ECMAScript, 5th edition,
* and we will put section numbers in square brackets.
*
* Exception handling:
*
* If an exception parameter is NULL, then any exceptions that happen during the
* execution of the function will be ignored. If it is non-NULL, and has a type
* of PP_VARTYPE_UNDEFINED, then if an exception is thrown it will be stored in
* the exception variable. It it is non-NULL and not PP_VARTYPE_UNDEFINED, then
* the function is a no-op, and, if it returns a value, it will return
* PP_VARTYPE_UNDEFINED. This can be used to chain together multiple calls and
* only check the exception at the end.
*
* Make sure not to intermix non-JS with JS calls when relying on this behavior
* to catch JS exceptions, as non-JS functions will still execute!
* JS engine's exceptions will always be of type PP_VARTYPE_OBJECT. However,
* PP_Var interface can also throw PP_VARTYPE_STRING exceptions, in situations
* where there's no JS execution context defined. These are usually invalid
* parameter errors - passing an invalid PP_Var value, for example, will always
* result in an PP_VARTYPE_STRING exception. Exceptions will not be of any other
* type.
* TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module,
* instance, resource, string and object ids.
*/
struct PPB_Var {
/**
* Adds a reference to the given var. If this is not a refcounted object,
* this function will do nothing so you can always call it no matter what the
* type.
*/
void (*AddRef)(struct PP_Var var);
/**
* Removes a reference to given var, deleting it if the internal refcount
* becomes 0. If the given var is not a refcounted object, this function will
* do nothing so you can always call it no matter what the type.
*/
void (*Release)(struct PP_Var var);
/**
* Creates a string var from a string. The string must be encoded in valid
* UTF-8 and is NOT NULL-terminated, the length must be specified in |len|.
* It is an error if the string is not valid UTF-8.
*
* If the length is 0, the |data| pointer will not be dereferenced and may
* be NULL. Note, however, that if you do this, the "NULL-ness" will not be
* preserved, as VarToUtf8 will never return NULL on success, even for empty
* strings.
*
* The resulting object will be a refcounted string object. It will be
* AddRef()ed for the caller. When the caller is done with it, it should be
* Release()d.
*
* On error (basically out of memory to allocate the string, or input that
* is not valid UTF-8), this function will return a Null var.
*/
struct PP_Var (*VarFromUtf8)(PP_Module module,
const char* data, uint32_t len);
/**
* Converts a string-type var to a char* encoded in UTF-8. This string is NOT
* NULL-terminated. The length will be placed in |*len|. If the string is
* valid but empty the return value will be non-NULL, but |*len| will still
* be 0.
*
* If the var is not a string, this function will return NULL and |*len| will
* be 0.
*
* The returned buffer will be valid as long as the underlying var is alive.
* If the plugin frees its reference, the string will be freed and the pointer
* will be to random memory.
*/
const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len);
/**
* Convert a variable to a different type using rules from ECMAScript
* specification, section [9].
*
* For conversions from/to PP_VARTYPE_OBJECT, the instance must be specified,
* or an exception of type PP_VARTYPE_STRING will be thrown.
*/
PP_Var (*ConvertType)(PP_Instance instance,
struct PP_Var var,
PP_VarType new_type,
PP_Var* exception);
/**
* Sets a property on the object, similar to Object.prototype.defineProperty.
*
* First, if object is not PP_VARTYPE_OBJECT, throw an exception.
* TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
* don't have the JS context to create new objects, we might throw a string.
* Then, the property's 'name' field is converted to string using
* ConvertType (ToString [9.8]).
* After that, defineOwnProperty [8.12.9, 15.4.5.1] is called with the
* property.
* To set a simple property, set the value and set modifiers to default
* (Writable|Enumerable|Configurable|HasValue), see [8.12.15] and
* function PPB_MakeSimpleProperty.
*/
void (*DefineProperty)(struct PP_Var object,
struct PP_ObjectProperty property,
PP_Var* exception);
/**
* Tests whether an object has a property with a given name.
*
* First, if object is not PP_VARTYPE_OBJECT, throw an exception.
* TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
* don't have the JS context to create new objects, we might throw a string.
* Then, convert 'property' to string using ConvertType (ToString [9.8]).
* Then return true if the given property exists on the object [8.12.6].
*/
bool (*HasProperty)(struct PP_Var object,
struct PP_Var property,
struct PP_Var* exception);
/**
* Returns a given property of the object.
*
* First, if object is not PP_VARTYPE_OBJECT, throw an exception.
* TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
* don't have the JS context to create new objects, we might throw a string.
* Then, convert 'property' to string using ConvertType (ToString [9.8]).
* Then return the given property of the object [8.12.2].
*/
PP_Var (*GetProperty)(struct PP_Var object,
struct PP_Var property,
struct PP_Var* exception);
/**
* Delete a property from the object, return true if succeeded.
*
* True is returned if the property didn't exist in the first place.
*
* First, if object is not PP_VARTYPE_OBJECT, throw an exception.
* TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
* don't have the JS context to create new objects, we might throw a string.
* Then, convert 'property' to string using ConvertType (ToString [9.8]).
* Then delete the given property of the object [8.12.7].
*/
bool (*DeleteProperty)(struct PP_Var object,
struct PP_Var property,
struct PP_Var* exception);
/**
* Retrieves all property names on the given object. Property names include
* methods.
*
* If object is not PP_VARTYPE_OBJECT, throw an exception.
* TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
* don't have the JS context to create new objects, we might throw a string.
*
* If there is a failure, the given exception will be set (if it is non-NULL).
* On failure, |*properties| will be set to NULL and |*property_count| will be
* set to 0.
*
* A pointer to the array of property names will be placed in |*properties|.
* The caller is responsible for calling Release() on each of these properties
* (as per normal refcounted memory management) as well as freeing the array
* pointer with PPB_Core.MemFree().
*
* This function returns all "enumerable" properties. Some JavaScript
* properties are "hidden" and these properties won't be retrieved by this
* function, yet you can still set and get them. You can use JS
* Object.getOwnPropertyNames() to access these properties.
*
* Example:
* <pre> uint32_t count;
* PP_Var* properties;
* ppb_var.EnumerateProperties(object, &count, &properties);
*
* ...use the properties here...
*
* for (uint32_t i = 0; i < count; i++)
* ppb_var.Release(properties[i]);
* ppb_core.MemFree(properties); </pre>
*/
void (*EnumerateProperties)(struct PP_Var object,
uint32_t* property_count,
struct PP_Var** properties,
struct PP_Var* exception);
/**
* Check if an object is a JS Function [9.11].
*/
bool (*IsCallable)(struct PP_Var object);
/**
* Call the functions.
*
* Similar to Function.prototype.call [15.3.4.4]. It will throw a TypeError
* and return undefined if object is not PP_VARTYPE_OBJECT, or is not
* callable.
*
* Pass the arguments to the function in order in the |argv| array, and the
* number of arguments in the |argc| parameter. |argv| can be NULL if |argc|
* is zero.
*
* Example:
* Call(obj.GetProperty("DoIt"), obj, 0, NULL, NULL)
* Equivalent to obj.DoIt() in JavaScript.
*
* Call(obj, PP_MakeUndefined(), 0, NULL, NULL)
* Equivalent to obj() in JavaScript.
*/
struct PP_Var (*Call)(struct PP_Var object,
struct PP_Var this_object,
uint32_t argc,
struct PP_Var* argv,
struct PP_Var* exception);
/**
* Invoke the object as a constructor. It will throw a |TypeError| and return
* |undefined| if |object| is not PP_VARTYPE_OBJECT, or cannot be used as a
* constructor.
*
* Pass the arguments to the function in order in the |argv| array, and the
* number of arguments in the |argc| parameter. |argv| can be NULL if |argc|
* is zero.
*
* For example, if |object| is |String|, this is like saying |new String| in
* JavaScript. Similar to the [[Construct]] internal method [13.2.2].
*
* For examples, to construct an empty object, do:
* GetWindow().GetProperty("Object").Construct(0, NULL);
*/
struct PP_Var (*Construct)(struct PP_Var object,
uint32_t argc,
struct PP_Var* argv,
struct PP_Var* exception);
};
inline struct PP_ObjectProperty PP_MakeSimpleProperty(PP_Var name,
PP_Var value) {
struct PP_ObjectProperty result = {
name, value, PP_MakeUndefined(), PP_MakeUndefined(),
PP_OBJECTPROPERTY_MODIFIER_HASVALUE };
return result;
}
/**
* @}
* End addtogroup PPB
*/
#endif // PPAPI_C_PPB_VAR_H_

60
ppapi/c/ppp.h Normal file

@ -0,0 +1,60 @@
// 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.
#ifndef PPAPI_C_PPP_H_
#define PPAPI_C_PPP_H_
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/ppb.h"
#if __GNUC__ >= 4
#define PP_EXPORT __attribute__ ((visibility("default")))
#elif defined(_MSC_VER)
#define PP_EXPORT __declspec(dllexport)
#endif
/**
* @file
* Defines the API ...
*
* {PENDING: undefine PP_EXPORT?}
* @addtogroup PPP
* @{
*/
// We don't want name mangling for these external functions. We only need
// 'extern "C"' if we're compiling with a C++ compiler.
#ifdef __cplusplus
extern "C" {
#endif
/**
* Entrypoint for the module.
*
* Returns PP_OK on success, any other value on failure. Failure indicates to
* the browser that this plugin can not be used. In this case, the plugin will
* be unloaded and ShutdownModule will NOT be called.
*/
PP_EXPORT int32_t PPP_InitializeModule(PP_Module module,
PPB_GetInterface get_browser_interface);
/** Called before the plugin module is unloaded. */
PP_EXPORT void PPP_ShutdownModule();
/**
* Returns an interface pointer for the interface of the given name, or NULL
* if the interface is not supported. Interface names should be ASCII.
*/
PP_EXPORT const void* PPP_GetInterface(const char* interface_name);
#ifdef __cplusplus
} // extern "C"
#endif
/**
* @}
* End addtogroup PPP
*/
#endif // PPAPI_C_PPP_H_

133
ppapi/c/ppp_instance.h Normal file

@ -0,0 +1,133 @@
// 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.
#ifndef PPAPI_C_PPP_INSTANCE_H_
#define PPAPI_C_PPP_INSTANCE_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/pp_resource.h"
struct PP_InputEvent;
struct PP_Var;
#define PPP_INSTANCE_INTERFACE "PPP_Instance;0.1"
/**
* @file
* Defines the API ...
*
* @addtogroup PPP
* @{
*/
struct PPP_Instance {
/**
* Called when a new plugin is instantiated on the web page. The identifier
* of the new instance will be passed in as the first argument (this value is
* generated by the browser and is an opaque handle).
*
* It's possible for more than one plugin instance to be created within the
* same module (i.e. you may get more than one OnCreate without an OnDestroy
* in between).
*
* If the plugin reports failure from this function, the plugin will be
* deleted and OnDestroy will be called.
*/
bool (*DidCreate)(PP_Instance instance,
uint32_t argc,
const char* argn[],
const char* argv[]);
/**
* Called when the plugin instance is destroyed. This will always be called,
* even if Create returned failure. The plugin should deallocate any data
* associated with the instance.
*/
void (*DidDestroy)(PP_Instance instance);
/**
* Called when the position, the size, or the clip rect has changed.
*
* The |position| is the location on the page of this plugin instance. This is
* relative to the top left corner of the viewport, which changes as the page
* is scrolled.
*
* The |clip| indicates the visible region of the plugin instance. This is
* relative to the top left of the plugin's coordinate system (not the page).
* If the plugin is invisible, the clip rect will be (0, 0, 0, 0).
*/
void (*DidChangeView)(PP_Instance instance,
const struct PP_Rect* position,
const struct PP_Rect* clip);
/**
* Notification that the given plugin instance has gained or lost focus.
* Having focus means that keyboard events will be sent to your plugin
* instance. A plugin's default condition is that it will not have focus.
*
* Note: clicks on your plugins will give focus only if you handle the
* click event. You signal if you handled it by returning true from
* HandleInputEvent. Otherwise the browser will bubble the event and give
* focus to the element on the page that actually did end up consuming it.
* If you're not getting focus, check to make sure you're returning true from
* the mouse click in HandleInputEvent.
*/
void (*DidChangeFocus)(PP_Instance instance, bool has_focus);
/**
* General handler for input events. Returns true if the event was handled or
* false if it was not.
*
* If the event was handled, it will not be forwarded to the web page or
* browser. If it was not handled, it will bubble according to the normal
* rules. So it is important that a plugin respond accurately with whether
* event propogation should continue.
*
* Event propogation also controls focus. If you handle an event like a mouse
* event, typically your plugin will be given focus. Returning false means
* that the click will be given to a lower part of the page and the plugin
* will not receive focus. This allows a plugin to be partially transparent,
* where clicks on the transparent areas will behave like clicks to the
* underlying page.
*/
bool (*HandleInputEvent)(PP_Instance instance,
const struct PP_InputEvent* event);
/**
* Called after Initialize for a full-frame plugin that was instantiated
* based on the MIME type of a DOMWindow navigation. This only applies to
* plugins that are registered to handle certain MIME types (not current
* Native Client plugins).
*
* The given url_loader corresponds to a PPB_URLLoader instance that is
* already opened. Its response headers may be queried using
* PPB_URLLoader::GetResponseInfo. The url loader is not addrefed on behalf
* of the plugin, if you're going to keep a reference to it, you need to
* addref it yourself.
*
* This method returns false if the plugin cannot handle the data. In
* response to this method, the plugin should call ReadResponseBody to read
* the incoming data.
*/
bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader);
/**
* Returns a Var representing the instance object to the web page. Normally
* this will be a PPP_Class object that exposes certain methods the page
* may want to call.
*
* On Failure, the returned var should be a "void" var.
*
* The returned PP_Var should have a reference added for the caller, which
* will be responsible for Release()ing that reference.
*/
struct PP_Var (*GetInstanceObject)(PP_Instance instance);
};
/**
* @}
* End addtogroup PPP
*/
#endif // PPAPI_C_PPP_INSTANCE_H_

@ -0,0 +1,21 @@
// 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.
#ifndef PPAPI_C_TRUSTED_PPB_IMAGE_DATA_TRUSTED_H_
#define PPAPI_C_TRUSTED_PPB_IMAGE_DATA_TRUSTED_H_
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_resource.h"
#define PPB_IMAGEDATA_TRUSTED_INTERFACE "PPB_ImageDataTrusted;0.1"
struct PPB_ImageDataTrusted {
/**
* Returns the internal shared memory pointer associated with the given
* ImageData resource. Used for proxying. Returns the handle or 0 on failure.
*/
uint64_t (*GetNativeMemoryHandle)(PP_Resource image_data);
};
#endif // PPAPI_C_TRUSTED_PPB_IMAGE_DATA_TRUSTED_H_

@ -0,0 +1,5 @@
# This file is used by gcl to get repository specific information.
CODE_REVIEW_SERVER: codereview.chromium.org
CC_LIST: chromium-reviews@chromium.org
VIEW_VC: http://code.google.com/p/ppapi/source/detail?r=

@ -0,0 +1,313 @@
// 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.
#ifndef PPAPI_CPP_COMPLETION_CALLBACK_H_
#define PPAPI_CPP_COMPLETION_CALLBACK_H_
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/non_thread_safe_ref_count.h"
namespace pp {
// A CompletionCallback provides a wrapper around PP_CompletionCallback.
class CompletionCallback {
public:
// Use this special constructor to create a 'blocking' CompletionCallback
// that may be passed to a method to indicate that the calling thread should
// be blocked until the asynchronous operation corresponding to the method
// completes.
struct Block {};
CompletionCallback(Block) {
cc_ = PP_BlockUntilComplete();
}
CompletionCallback(PP_CompletionCallback_Func func, void* user_data) {
cc_ = PP_MakeCompletionCallback(func, user_data);
}
// Call this method to explicitly run the CompletionCallback. Normally, the
// system runs a CompletionCallback after an asynchronous operation
// completes, but programs may wish to run the CompletionCallback manually
// in order to reuse the same code paths.
void Run(int32_t result) {
PP_DCHECK(cc_.func);
PP_RunCompletionCallback(&cc_, result);
}
const PP_CompletionCallback& pp_completion_callback() const { return cc_; }
protected:
PP_CompletionCallback cc_;
};
// CompletionCallbackFactory<T> may be used to create CompletionCallback
// objects that are bound to member functions.
//
// If a factory is destroyed, then any pending callbacks will be cancelled
// preventing any bound member functions from being called. The CancelAll
// method allows pending callbacks to be cancelled without destroying the
// factory.
//
// NOTE: by default, CompletionCallbackFactory<T> isn't thread safe, but you can
// make it more thread-friendly by passing a thread-safe refcounting class as
// the second template element. However, it only guarantees safety for
// *creating* a callback from another thread, the callback itself needs to
// execute on the same thread as the thread that creates/destroys the factory.
// With this restriction, it is safe to create the CompletionCallbackFactory on
// the main thread, create callbacks from any thread and pass them to
// CallOnMainThread.
//
// EXAMPLE USAGE:
//
// class MyHandler {
// public:
// MyHandler() : factory_(this), offset_(0) {
// }
//
// void ProcessFile(const FileRef& file) {
// CompletionCallback cc = factory_.NewCallback(&MyHandler::DidOpen);
// int32_t rv = fio_.Open(file, PP_FileOpenFlag_Read, cc);
// if (rv != PP_ERROR_WOULDBLOCK)
// cc.Run(rv);
// }
//
// private:
// CompletionCallback NewCallback() {
// return factory_.NewCallback(&MyHandler::DidCompleteIO);
// }
//
// void DidOpen(int32_t result) {
// if (result == PP_OK) {
// // The file is open, and we can begin reading.
// offset_ = 0;
// ReadMore();
// } else {
// // Failed to open the file with error given by 'result'.
// }
// }
//
// void DidRead(int32_t result) {
// if (result > 0) {
// // buf_ now contains 'result' number of bytes from the file.
// ProcessBytes(buf_, result);
// offset_ += result;
// ReadMore();
// } else {
// // Done reading (possibly with an error given by 'result').
// }
// }
//
// void ReadMore() {
// CompletionCallback cc = factory_.NewCallback(&MyHandler::DidRead);
// int32_t rv = fio_.Read(offset_, buf_, sizeof(buf_), cc);
// if (rv != PP_ERROR_WOULDBLOCK)
// cc.Run(rv);
// }
//
// void ProcessBytes(const char* bytes, int32_t length) {
// // Do work ...
// }
//
// pp::CompletionCallbackFactory<MyHandler> factory_;
// pp::FileIO fio_;
// char buf_[4096];
// int64_t offset_;
// };
//
template <typename T, typename RefCount = NonThreadSafeRefCount>
class CompletionCallbackFactory {
public:
explicit CompletionCallbackFactory(T* object = NULL)
: object_(object) {
InitBackPointer();
}
~CompletionCallbackFactory() {
ResetBackPointer();
}
// Cancels all CompletionCallbacks allocated from this factory.
void CancelAll() {
ResetBackPointer();
InitBackPointer();
}
void Initialize(T* object) {
PP_DCHECK(object);
PP_DCHECK(!object_); // May only initialize once!
object_ = object;
}
T* GetObject() {
return object_;
}
// Allocates a new, single-use CompletionCallback. The CompletionCallback
// must be run in order for the memory allocated by NewCallback to be freed.
// If after passing the CompletionCallback to a PPAPI method, the method does
// not return PP_ERROR_WOULDBLOCK, then you should manually call the
// CompletionCallback's Run method otherwise memory will be leaked.
template <typename Method>
CompletionCallback NewCallback(Method method) {
PP_DCHECK(object_);
return NewCallbackHelper(Dispatcher0<Method>(method));
}
// A copy of "a" will be passed to "method" when the completion callback
// runs.
//
// Method should be of type:
// void (T::*)(int32_t result, const A& a)
//
template <typename Method, typename A>
CompletionCallback NewCallback(Method method, const A& a) {
PP_DCHECK(object_);
return NewCallbackHelper(Dispatcher1<Method, A>(method, a));
}
// A copy of "a" and "b" will be passed to "method" when the completion
// callback runs.
//
// Method should be of type:
// void (T::*)(int32_t result, const A& a, const B& b)
//
template <typename Method, typename A, typename B>
CompletionCallback NewCallback(Method method, const A& a, const B& b) {
PP_DCHECK(object_);
return NewCallbackHelper(Dispatcher2<Method, A, B>(method, a, b));
}
private:
class BackPointer {
public:
typedef CompletionCallbackFactory<T, RefCount> FactoryType;
BackPointer(FactoryType* factory)
: factory_(factory) {
}
void AddRef() {
ref_.AddRef();
}
void Release() {
if (ref_.Release() == 0)
delete this;
}
void DropFactory() {
factory_ = NULL;
}
T* GetObject() {
return factory_ ? factory_->GetObject() : NULL;
}
private:
RefCount ref_;
FactoryType* factory_;
};
template <typename Dispatcher>
class CallbackData {
public:
CallbackData(BackPointer* back_pointer, const Dispatcher& dispatcher)
: back_pointer_(back_pointer),
dispatcher_(dispatcher) {
back_pointer_->AddRef();
}
~CallbackData() {
back_pointer_->Release();
}
static void Thunk(void* user_data, int32_t result) {
Self* self = static_cast<Self*>(user_data);
T* object = self->back_pointer_->GetObject();
if (object)
self->dispatcher_(object, result);
delete self;
}
private:
typedef CallbackData<Dispatcher> Self;
BackPointer* back_pointer_;
Dispatcher dispatcher_;
};
template <typename Method>
class Dispatcher0 {
public:
Dispatcher0(Method method) : method_(method) {
}
void operator()(T* object, int32_t result) {
(object->*method_)(result);
}
private:
Method method_;
};
template <typename Method, typename A>
class Dispatcher1 {
public:
Dispatcher1(Method method, const A& a)
: method_(method),
a_(a) {
}
void operator()(T* object, int32_t result) {
(object->*method_)(result, a_);
}
private:
Method method_;
A a_;
};
template <typename Method, typename A, typename B>
class Dispatcher2 {
public:
Dispatcher2(Method method, const A& a, const B& b)
: method_(method),
a_(a),
b_(b) {
}
void operator()(T* object, int32_t result) {
(object->*method_)(result, a_, b_);
}
private:
Method method_;
A a_;
B b_;
};
void InitBackPointer() {
back_pointer_ = new BackPointer(this);
back_pointer_->AddRef();
}
void ResetBackPointer() {
back_pointer_->DropFactory();
back_pointer_->Release();
}
template <typename Dispatcher>
CompletionCallback NewCallbackHelper(const Dispatcher& dispatcher) {
PP_DCHECK(object_); // Expects a non-null object!
return CompletionCallback(
&CallbackData<Dispatcher>::Thunk,
new CallbackData<Dispatcher>(back_pointer_, dispatcher));
}
// Disallowed:
CompletionCallbackFactory(const CompletionCallbackFactory&);
CompletionCallbackFactory& operator=(const CompletionCallbackFactory&);
T* object_;
BackPointer* back_pointer_;
};
} // namespace pp
#endif // PPAPI_CPP_COMPLETION_CALLBACK_H_

25
ppapi/cpp/core.cc Normal file

@ -0,0 +1,25 @@
// 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.
#include "ppapi/cpp/core.h"
#include "ppapi/cpp/completion_callback.h"
namespace pp {
// This function is implemented in the .cc file to avoid including completion
// callback all over the project.
void Core::CallOnMainThread(int32_t delay_in_milliseconds,
const CompletionCallback& callback,
int32_t result) {
return interface_->CallOnMainThread(delay_in_milliseconds,
callback.pp_completion_callback(),
result);
}
bool Core::IsMainThread() {
return interface_->IsMainThread();
}
} // namespace pp

67
ppapi/cpp/core.h Normal file

@ -0,0 +1,67 @@
// 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.
#ifndef PPAPI_CPP_CORE_H_
#define PPAPI_CPP_CORE_H_
#include "ppapi/c/ppb_core.h"
namespace pp {
class CompletionCallback;
class Module;
// Simple wrapper around the PPB_Core interface. Some of these wrappers add
// nothing over the C interface, but some allow the use of C++ arguments.
class Core {
public:
// Note that we explicitly don't expose Resource& versions of this function
// since Resource will normally manage the refcount properly. These should
// be called only when doing manual management on raw PP_Resource handles,
// which should be fairly rare.
void AddRefResource(PP_Resource resource) {
interface_->AddRefResource(resource);
}
void ReleaseResource(PP_Resource resource) {
interface_->ReleaseResource(resource);
}
void* MemAlloc(size_t num_bytes) {
return interface_->MemAlloc(num_bytes);
}
void MemFree(void* ptr) {
interface_->MemFree(ptr);
}
PP_Time GetTime() {
return interface_->GetTime();
}
PP_TimeTicks GetTimeTicks() {
return interface_->GetTimeTicks();
}
void CallOnMainThread(int32_t delay_in_milliseconds,
const CompletionCallback& callback,
int32_t result = 0);
bool IsMainThread();
private:
// Allow Module to construct.
friend class Module;
// Only module should make this class so this constructor is private.
Core(const PPB_Core* inter) : interface_(inter) {}
// Copy and assignment are disallowed.
Core(const Core& other);
Core& operator=(const Core& other);
const PPB_Core* interface_;
};
} // namespace pp
#endif // PPAPI_CPP_CORE_H_

@ -0,0 +1,39 @@
// 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.
#include "ppapi/cpp/dev/audio_config_dev.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
DeviceFuncs<PPB_AudioConfig_Dev> audio_cfg_f(PPB_AUDIO_CONFIG_DEV_INTERFACE);
namespace pp {
AudioConfig_Dev::AudioConfig_Dev()
: sample_rate_(PP_AUDIOSAMPLERATE_NONE),
sample_frame_count_(0) {
}
AudioConfig_Dev::AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count)
: sample_rate_(sample_rate),
sample_frame_count_(sample_frame_count) {
if (audio_cfg_f) {
PassRefFromConstructor(audio_cfg_f->CreateStereo16Bit(
Module::Get()->pp_module(), sample_rate,
sample_frame_count));
}
}
// static
uint32_t AudioConfig_Dev::RecommendSampleFrameCount(
uint32_t requested_sample_frame_count) {
if (!audio_cfg_f)
return 0;
return audio_cfg_f->RecommendSampleFrameCount(requested_sample_frame_count);
}
} // namespace pp

@ -0,0 +1,57 @@
// 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.
#ifndef PPAPI_CPP_DEV_AUDIO_CONFIG_DEV_H_
#define PPAPI_CPP_DEV_AUDIO_CONFIG_DEV_H_
#include "ppapi/c/dev/ppb_audio_config_dev.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/cpp/resource.h"
namespace pp {
// Typical usage:
//
// // Create an audio config with a supported frame count.
// uint32_t sample_frame_count =
// AudioConfig_Dev::RecommendSampleFrameCount(4096);
// AudioConfig_Dev config(PP_AUDIOSAMPLERATE_44100, sample_frame_count);
// if (config.is_null())
// return false; // Couldn't configure audio.
//
// // Then use the config to create your audio resource.
// Audio_dev audio(..., config, ...);
// if (audio.is_null())
// return false; // Couldn't create audio.
class AudioConfig_Dev : public Resource {
public:
AudioConfig_Dev();
// Creates an audio config based on the given sample rate and frame count.
// If the rate and frame count aren't supported, the resulting resource
// will be is_null(). Pass the result of RecommendSampleFrameCount as the
// semple frame count.
//
// See PPB_AudioConfigDev.CreateStereo16Bit for more.
AudioConfig_Dev(PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count);
// Returns a supported frame count for use in the constructor.
//
// See PPB_AudioConfigDev.RecommendSampleFrameCount.
static uint32_t RecommendSampleFrameCount(
uint32_t requested_sample_frame_count);
PP_AudioSampleRate_Dev sample_rate() const { return sample_rate_; }
uint32_t sample_frame_count() { return sample_frame_count_; }
private:
PP_AudioSampleRate_Dev sample_rate_;
uint32_t sample_frame_count_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_AUDIO_CONFIG_DEV_H_

@ -0,0 +1,38 @@
// 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.
#include "ppapi/cpp/dev/audio_dev.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_Audio_Dev> audio_f(PPB_AUDIO_DEV_INTERFACE);
} // namespace
namespace pp {
Audio_Dev::Audio_Dev(const Instance& instance,
const AudioConfig_Dev& config,
PPB_Audio_Callback callback,
void* user_data)
: config_(config) {
if (audio_f) {
PassRefFromConstructor(audio_f->Create(instance.pp_instance(),
config.pp_resource(),
callback, user_data));
}
}
bool Audio_Dev::StartPlayback() {
return audio_f && audio_f->StartPlayback(pp_resource());
}
bool Audio_Dev::StopPlayback() {
return audio_f && audio_f->StopPlayback(pp_resource());
}
} // namespace pp

38
ppapi/cpp/dev/audio_dev.h Normal file

@ -0,0 +1,38 @@
// 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.
#ifndef PPAPI_CPP_DEV_AUDIO_DEV_H_
#define PPAPI_CPP_DEV_AUDIO_DEV_H_
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/dev/ppb_audio_dev.h"
#include "ppapi/cpp/dev/audio_config_dev.h"
#include "ppapi/cpp/dev/buffer_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/resource.h"
namespace pp {
class Audio_Dev : public Resource {
public:
Audio_Dev() {}
Audio_Dev(const Instance& instance,
const AudioConfig_Dev& config,
PPB_Audio_Callback callback,
void* user_data);
AudioConfig_Dev& config() { return config_; }
const AudioConfig_Dev& config() const { return config_; }
bool StartPlayback();
bool StopPlayback();
private:
AudioConfig_Dev config_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_AUDIO_DEV_H_

@ -0,0 +1,55 @@
// 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.
#include "ppapi/cpp/dev/buffer_dev.h"
#include "ppapi/c/dev/ppb_buffer_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_Buffer_Dev> buffer_f(PPB_BUFFER_DEV_INTERFACE);
} // namespace
namespace pp {
Buffer_Dev::Buffer_Dev() : data_(NULL), size_(0) {
}
Buffer_Dev::Buffer_Dev(const Buffer_Dev& other)
: Resource(other),
data_(other.data_),
size_(other.size_) {
}
Buffer_Dev::Buffer_Dev(int32_t size) : data_(NULL), size_(0) {
if (!buffer_f)
return;
PassRefFromConstructor(buffer_f->Create(Module::Get()->pp_module(), size));
if (!buffer_f->Describe(pp_resource(), &size_) ||
!(data_ = buffer_f->Map(pp_resource())))
*this = Buffer_Dev();
}
Buffer_Dev::~Buffer_Dev() {
}
Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& other) {
Buffer_Dev copy(other);
swap(copy);
return *this;
}
void Buffer_Dev::swap(Buffer_Dev& other) {
Resource::swap(other);
std::swap(size_, other.size_);
std::swap(data_, other.data_);
}
} // namespace pp

@ -0,0 +1,39 @@
// 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.
#ifndef PPAPI_CPP_DEV_BUFFER_DEV_H_
#define PPAPI_CPP_DEV_BUFFER_DEV_H_
#include "ppapi/cpp/resource.h"
namespace pp {
class Buffer_Dev : public Resource {
public:
// Creates an is_null() Buffer object.
Buffer_Dev();
Buffer_Dev(const Buffer_Dev& other);
// Allocates a new Buffer in the browser with the given size. The
// resulting object will be is_null() if the allocation failed.
explicit Buffer_Dev(int32_t size);
~Buffer_Dev();
Buffer_Dev& operator=(const Buffer_Dev& other);
void swap(Buffer_Dev& other);
int32_t size() const { return size_; }
void* data() const { return data_; }
private:
void* data_;
int32_t size_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_BUFFER_DEV_H_

@ -0,0 +1,41 @@
// 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.
#include "ppapi/cpp/dev/directory_entry_dev.h"
#include <string.h>
#include "ppapi/cpp/module.h"
namespace pp {
DirectoryEntry_Dev::DirectoryEntry_Dev() {
memset(&data_, 0, sizeof(data_));
}
DirectoryEntry_Dev::DirectoryEntry_Dev(const DirectoryEntry_Dev& other) {
data_.file_ref = other.data_.file_ref;
data_.file_type = other.data_.file_type;
if (data_.file_ref)
Module::Get()->core()->AddRefResource(data_.file_ref);
}
DirectoryEntry_Dev::~DirectoryEntry_Dev() {
if (data_.file_ref)
Module::Get()->core()->ReleaseResource(data_.file_ref);
}
DirectoryEntry_Dev& DirectoryEntry_Dev::operator=(
const DirectoryEntry_Dev& other) {
DirectoryEntry_Dev copy(other);
swap(copy);
return *this;
}
void DirectoryEntry_Dev::swap(DirectoryEntry_Dev& other) {
std::swap(data_.file_ref, other.data_.file_ref);
std::swap(data_.file_type, other.data_.file_type);
}
} // namespace pp

@ -0,0 +1,38 @@
// 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.
#ifndef PPAPI_CPP_DEV_DIRECTORY_ENTRY_DEV_H_
#define PPAPI_CPP_DEV_DIRECTORY_ENTRY_DEV_H_
#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/cpp/dev/file_ref_dev.h"
namespace pp {
class DirectoryEntry_Dev {
public:
DirectoryEntry_Dev();
DirectoryEntry_Dev(const DirectoryEntry_Dev& other);
~DirectoryEntry_Dev();
DirectoryEntry_Dev& operator=(const DirectoryEntry_Dev& other);
void swap(DirectoryEntry_Dev& other);
// Returns true if the DirectoryEntry is invalid or uninitialized.
bool is_null() const { return !data_.file_ref; }
// Returns the FileRef held by this DirectoryEntry.
FileRef_Dev file_ref() const { return FileRef_Dev(data_.file_ref); }
// Returns the type of the file referenced by this DirectoryEntry.
PP_FileType_Dev file_type() const { return data_.file_type; }
private:
friend class DirectoryReader_Dev;
PP_DirectoryEntry_Dev data_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_DIRECTORY_ENTRY_DEV_H_

@ -0,0 +1,53 @@
// 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.
#include "ppapi/cpp/dev/directory_reader_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/directory_entry_dev.h"
#include "ppapi/cpp/dev/file_ref_dev.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_DirectoryReader_Dev> directory_reader_f(
PPB_DIRECTORYREADER_DEV_INTERFACE);
} // namespace
namespace pp {
DirectoryReader_Dev::DirectoryReader_Dev(const FileRef_Dev& directory_ref) {
if (!directory_reader_f)
return;
PassRefFromConstructor(
directory_reader_f->Create(directory_ref.pp_resource()));
}
DirectoryReader_Dev::DirectoryReader_Dev(const DirectoryReader_Dev& other)
: Resource(other) {
}
DirectoryReader_Dev& DirectoryReader_Dev::operator=(
const DirectoryReader_Dev& other) {
DirectoryReader_Dev copy(other);
swap(copy);
return *this;
}
void DirectoryReader_Dev::swap(DirectoryReader_Dev& other) {
Resource::swap(other);
}
int32_t DirectoryReader_Dev::GetNextEntry(DirectoryEntry_Dev* entry,
const CompletionCallback& cc) {
if (!directory_reader_f)
return PP_ERROR_NOINTERFACE;
return directory_reader_f->GetNextEntry(pp_resource(), &entry->data_,
cc.pp_completion_callback());
}
} // namespace pp

@ -0,0 +1,36 @@
// 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.
#ifndef PPAPI_CPP_DEV_DIRECTORY_READER_DEV_H_
#define PPAPI_CPP_DEV_DIRECTORY_READER_DEV_H_
#include <stdlib.h>
#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/cpp/resource.h"
namespace pp {
class CompletionCallback;
class DirectoryEntry_Dev;
class FileRef_Dev;
class DirectoryReader_Dev : public Resource {
public:
// Creates a DirectoryReader for the given directory.
DirectoryReader_Dev(const FileRef_Dev& directory_ref);
DirectoryReader_Dev(const DirectoryReader_Dev& other);
DirectoryReader_Dev& operator=(const DirectoryReader_Dev& other);
void swap(DirectoryReader_Dev& other);
// See PPB_DirectoryReader::GetNextEntry.
int32_t GetNextEntry(DirectoryEntry_Dev* entry,
const CompletionCallback& cc);
};
} // namespace pp
#endif // PPAPI_CPP_DIRECTORY_READER_H_

@ -0,0 +1,58 @@
// 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.
#include "ppapi/cpp/dev/file_chooser_dev.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/file_ref_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_FileChooser_Dev> file_chooser_f(PPB_FILECHOOSER_DEV_INTERFACE);
} // namespace
namespace pp {
FileChooser_Dev::FileChooser_Dev(const Instance& instance,
const PP_FileChooserOptions_Dev& options) {
if (!file_chooser_f)
return;
PassRefFromConstructor(file_chooser_f->Create(instance.pp_instance(),
&options));
}
FileChooser_Dev::FileChooser_Dev(const FileChooser_Dev& other)
: Resource(other) {
}
FileChooser_Dev& FileChooser_Dev::operator=(const FileChooser_Dev& other) {
FileChooser_Dev copy(other);
swap(copy);
return *this;
}
void FileChooser_Dev::swap(FileChooser_Dev& other) {
Resource::swap(other);
}
int32_t FileChooser_Dev::Show(const CompletionCallback& cc) {
if (!file_chooser_f)
return PP_ERROR_NOINTERFACE;
return file_chooser_f->Show(pp_resource(), cc.pp_completion_callback());
}
FileRef_Dev FileChooser_Dev::GetNextChosenFile() const {
if (!file_chooser_f)
return FileRef_Dev();
return FileRef_Dev(FileRef_Dev::PassRef(),
file_chooser_f->GetNextChosenFile(pp_resource()));
}
} // namespace pp

@ -0,0 +1,38 @@
// 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.
#ifndef PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_
#define PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_
#include "ppapi/cpp/resource.h"
struct PP_FileChooserOptions_Dev;
namespace pp {
class CompletionCallback;
class FileRef_Dev;
class Instance;
class FileChooser_Dev : public Resource {
public:
// Creates an is_null() FileChooser object.
FileChooser_Dev() {}
FileChooser_Dev(const Instance& instance,
const PP_FileChooserOptions_Dev& options);
FileChooser_Dev(const FileChooser_Dev& other);
FileChooser_Dev& operator=(const FileChooser_Dev& other);
void swap(FileChooser_Dev& other);
// PPB_FileChooser methods:
int32_t Show(const CompletionCallback& cc);
FileRef_Dev GetNextChosenFile() const;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_FILE_CHOOSER_DEV_H_

@ -0,0 +1,135 @@
// 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.
#include "ppapi/cpp/dev/file_io_dev.h"
#include "ppapi/c/dev/ppb_file_io_dev.h"
#include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/file_ref_dev.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_FileIO_Dev> file_io_f(
PPB_FILEIO_DEV_INTERFACE);
DeviceFuncs<PPB_FileIOTrusted_Dev> file_io_trusted_f(
PPB_FILEIOTRUSTED_DEV_INTERFACE);
} // namespace
namespace pp {
FileIO_Dev::FileIO_Dev() {
if (!file_io_f)
return;
PassRefFromConstructor(file_io_f->Create(Module::Get()->pp_module()));
}
FileIO_Dev::FileIO_Dev(const FileIO_Dev& other)
: Resource(other) {
}
FileIO_Dev& FileIO_Dev::operator=(const FileIO_Dev& other) {
FileIO_Dev copy(other);
swap(copy);
return *this;
}
void FileIO_Dev::swap(FileIO_Dev& other) {
Resource::swap(other);
}
int32_t FileIO_Dev::Open(const FileRef_Dev& file_ref,
int32_t open_flags,
const CompletionCallback& cc) {
if (!file_io_f)
return PP_ERROR_NOINTERFACE;
return file_io_f->Open(pp_resource(), file_ref.pp_resource(), open_flags,
cc.pp_completion_callback());
}
int32_t FileIO_Dev::Query(PP_FileInfo_Dev* result_buf,
const CompletionCallback& cc) {
if (!file_io_f)
return PP_ERROR_NOINTERFACE;
return file_io_f->Query(pp_resource(), result_buf,
cc.pp_completion_callback());
}
int32_t FileIO_Dev::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc) {
if (!file_io_f)
return PP_ERROR_NOINTERFACE;
return file_io_f->Touch(pp_resource(), last_access_time, last_modified_time,
cc.pp_completion_callback());
}
int32_t FileIO_Dev::Read(int64_t offset,
char* buffer,
int32_t bytes_to_read,
const CompletionCallback& cc) {
if (!file_io_f)
return PP_ERROR_NOINTERFACE;
return file_io_f->Read(pp_resource(), offset, buffer, bytes_to_read,
cc.pp_completion_callback());
}
int32_t FileIO_Dev::Write(int64_t offset,
const char* buffer,
int32_t bytes_to_write,
const CompletionCallback& cc) {
if (!file_io_f)
return PP_ERROR_NOINTERFACE;
return file_io_f->Write(pp_resource(), offset, buffer, bytes_to_write,
cc.pp_completion_callback());
}
int32_t FileIO_Dev::SetLength(int64_t length,
const CompletionCallback& cc) {
if (!file_io_f)
return PP_ERROR_NOINTERFACE;
return file_io_f->SetLength(pp_resource(), length,
cc.pp_completion_callback());
}
int32_t FileIO_Dev::Flush(const CompletionCallback& cc) {
if (!file_io_f)
return PP_ERROR_NOINTERFACE;
return file_io_f->Flush(pp_resource(), cc.pp_completion_callback());
}
void FileIO_Dev::Close() {
if (!file_io_f)
return;
file_io_f->Close(pp_resource());
}
int32_t FileIO_Dev::GetOSFileDescriptor() {
if (!file_io_trusted_f)
return PP_ERROR_NOINTERFACE;
return file_io_trusted_f->GetOSFileDescriptor(pp_resource());
}
int32_t FileIO_Dev::WillWrite(int64_t offset,
int32_t bytes_to_write,
const CompletionCallback& cc) {
if (!file_io_trusted_f)
return PP_ERROR_NOINTERFACE;
return file_io_trusted_f->WillWrite(pp_resource(), offset, bytes_to_write,
cc.pp_completion_callback());
}
int32_t FileIO_Dev::WillSetLength(int64_t length,
const CompletionCallback& cc) {
if (!file_io_trusted_f)
return PP_ERROR_NOINTERFACE;
return file_io_trusted_f->WillSetLength(pp_resource(), length,
cc.pp_completion_callback());
}
} // namespace pp

@ -0,0 +1,61 @@
// 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.
#ifndef PPAPI_CPP_DEV_FILE_IO_DEV_H_
#define PPAPI_CPP_DEV_FILE_IO_DEV_H_
#include "ppapi/c/pp_time.h"
#include "ppapi/cpp/resource.h"
struct PP_FileInfo_Dev;
namespace pp {
class CompletionCallback;
class FileRef_Dev;
class FileIO_Dev : public Resource {
public:
FileIO_Dev();
FileIO_Dev(const FileIO_Dev& other);
FileIO_Dev& operator=(const FileIO_Dev& other);
void swap(FileIO_Dev& other);
// PPB_FileIO methods:
int32_t Open(const FileRef_Dev& file_ref,
int32_t open_flags,
const CompletionCallback& cc);
int32_t Query(PP_FileInfo_Dev* result_buf,
const CompletionCallback& cc);
int32_t Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc);
int32_t Read(int64_t offset,
char* buffer,
int32_t bytes_to_read,
const CompletionCallback& cc);
int32_t Write(int64_t offset,
const char* buffer,
int32_t bytes_to_write,
const CompletionCallback& cc);
int32_t SetLength(int64_t length,
const CompletionCallback& cc);
int32_t Flush(const CompletionCallback& cc);
void Close();
// PPB_FileIOTrusted methods:
// NOTE: These are only available to trusted plugins and will return
// PP_ERROR_NOINTERFACE if called from an untrusted plugin.
int32_t GetOSFileDescriptor();
int32_t WillWrite(int64_t offset,
int32_t bytes_to_write,
const CompletionCallback& cc);
int32_t WillSetLength(int64_t length,
const CompletionCallback& cc);
};
} // namespace pp
#endif // PPAPI_CPP_DEV_FILE_IO_DEV_H_

@ -0,0 +1,124 @@
// 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.
#include "ppapi/cpp/dev/file_ref_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/file_system_dev.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_FileRef_Dev> file_ref_f(PPB_FILEREF_DEV_INTERFACE);
} // namespace
namespace pp {
FileRef_Dev::FileRef_Dev(PP_Resource resource) : Resource(resource) {
}
FileRef_Dev::FileRef_Dev(PassRef, PP_Resource resource) {
PassRefFromConstructor(resource);
}
FileRef_Dev::FileRef_Dev(const FileSystem_Dev& file_system,
const char* path) {
if (!file_ref_f)
return;
PassRefFromConstructor(file_ref_f->Create(file_system.pp_resource(), path));
}
FileRef_Dev::FileRef_Dev(const FileRef_Dev& other)
: Resource(other) {
}
FileRef_Dev& FileRef_Dev::operator=(const FileRef_Dev& other) {
FileRef_Dev copy(other);
swap(copy);
return *this;
}
void FileRef_Dev::swap(FileRef_Dev& other) {
Resource::swap(other);
}
PP_FileSystemType_Dev FileRef_Dev::GetFileSystemType() const {
if (!file_ref_f)
return PP_FILESYSTEMTYPE_EXTERNAL;
return file_ref_f->GetFileSystemType(pp_resource());
}
Var FileRef_Dev::GetName() const {
if (!file_ref_f)
return Var();
return Var(Var::PassRef(), file_ref_f->GetName(pp_resource()));
}
Var FileRef_Dev::GetPath() const {
if (!file_ref_f)
return Var();
return Var(Var::PassRef(), file_ref_f->GetPath(pp_resource()));
}
FileRef_Dev FileRef_Dev::GetParent() const {
if (!file_ref_f)
return FileRef_Dev();
return FileRef_Dev(PassRef(), file_ref_f->GetParent(pp_resource()));
}
int32_t FileRef_Dev::MakeDirectory(const CompletionCallback& cc) {
if (!file_ref_f)
return PP_ERROR_NOINTERFACE;
return file_ref_f->MakeDirectory(pp_resource(),
false, // make_ancestors
cc.pp_completion_callback());
}
int32_t FileRef_Dev::MakeDirectoryIncludingAncestors(
const CompletionCallback& cc) {
if (!file_ref_f)
return PP_ERROR_NOINTERFACE;
return file_ref_f->MakeDirectory(pp_resource(),
true, // make_ancestors
cc.pp_completion_callback());
}
int32_t FileRef_Dev::Query(PP_FileInfo_Dev* result_buf,
const CompletionCallback& cc) {
if (!file_ref_f)
return PP_ERROR_NOINTERFACE;
return file_ref_f->Query(pp_resource(),
result_buf,
cc.pp_completion_callback());
}
int32_t FileRef_Dev::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc) {
if (!file_ref_f)
return PP_ERROR_NOINTERFACE;
return file_ref_f->Touch(pp_resource(),
last_access_time,
last_modified_time,
cc.pp_completion_callback());
}
int32_t FileRef_Dev::Delete(const CompletionCallback& cc) {
if (!file_ref_f)
return PP_ERROR_NOINTERFACE;
return file_ref_f->Delete(pp_resource(), cc.pp_completion_callback());
}
int32_t FileRef_Dev::Rename(const FileRef_Dev& new_file_ref,
const CompletionCallback& cc) {
if (!file_ref_f)
return PP_ERROR_NOINTERFACE;
return file_ref_f->Rename(pp_resource(),
new_file_ref.pp_resource(),
cc.pp_completion_callback());
}
} // namespace pp

@ -0,0 +1,71 @@
// 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.
#ifndef PPAPI_CPP_DEV_FILE_REF_DEV_H_
#define PPAPI_CPP_DEV_FILE_REF_DEV_H_
#include "ppapi/c/dev/ppb_file_ref_dev.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/cpp/resource.h"
#include "ppapi/cpp/var.h"
namespace pp {
class CompletionCallback;
class FileSystem_Dev;
class FileRef_Dev : public Resource {
public:
// Creates an is_null() FileRef object.
FileRef_Dev() {}
// This constructor is used when we've gotten a PP_Resource as a return value
// that we need to addref.
explicit FileRef_Dev(PP_Resource resource);
// This constructor is used when we've gotten a PP_Resource as a return value
// that has already been addref'ed for us.
struct PassRef {};
FileRef_Dev(PassRef, PP_Resource resource);
// Creates a FileRef pointing to a path in the given filesystem.
FileRef_Dev(const FileSystem_Dev& file_system, const char* path);
FileRef_Dev(const FileRef_Dev& other);
FileRef_Dev& operator=(const FileRef_Dev& other);
void swap(FileRef_Dev& other);
// Returns the file system type.
PP_FileSystemType_Dev GetFileSystemType() const;
// Returns the name of the file.
Var GetName() const;
// Returns the absolute path of the file. See PPB_FileRef::GetPath for more
// details.
Var GetPath() const;
// Returns the parent directory of this file. See PPB_FileRef::GetParent for
// more details.
FileRef_Dev GetParent() const;
int32_t MakeDirectory(const CompletionCallback& cc);
int32_t MakeDirectoryIncludingAncestors(const CompletionCallback& cc);
int32_t Query(PP_FileInfo_Dev* result_buf, const CompletionCallback& cc);
int32_t Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc);
int32_t Delete(const CompletionCallback& cc);
int32_t Rename(const FileRef_Dev& new_file_ref, const CompletionCallback& cc);
};
} // namespace pp
#endif // PPAPI_CPP_FILE_REF_H_

@ -0,0 +1,37 @@
// 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.
#include "ppapi/cpp/dev/file_system_dev.h"
#include "ppapi/c/dev/ppb_file_system_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/file_ref_dev.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_FileSystem_Dev> file_sys_f(PPB_FILESYSTEM_DEV_INTERFACE);
} // namespace
namespace pp {
FileSystem_Dev::FileSystem_Dev(Instance* instance,
PP_FileSystemType_Dev type) {
if (!file_sys_f)
return;
PassRefFromConstructor(file_sys_f->Create(instance->pp_instance(), type));
}
int32_t FileSystem_Dev::Open(int64_t expected_size,
const CompletionCallback& cc) {
if (!file_sys_f)
return PP_ERROR_NOINTERFACE;
return file_sys_f->Open(pp_resource(), expected_size,
cc.pp_completion_callback());
}
} // namespace pp

@ -0,0 +1,32 @@
// 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.
#ifndef PPAPI_CPP_DEV_FILE_SYSTEM_DEV_H_
#define PPAPI_CPP_DEV_FILE_SYSTEM_DEV_H_
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_time.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/resource.h"
struct PP_FileInfo_Dev;
namespace pp {
class CompletionCallback;
class FileRef_Dev;
// Wraps methods from ppb_file_system.h
class FileSystem_Dev : public Resource {
public:
FileSystem_Dev(Instance* instance, PP_FileSystemType_Dev type);
int32_t Open(int64_t expected_size, const CompletionCallback& cc);
};
} // namespace pp
#endif // PPAPI_CPP_DEV_FILE_SYSTEM_DEV_H_

75
ppapi/cpp/dev/find_dev.cc Normal file

@ -0,0 +1,75 @@
// 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.
#include "ppapi/cpp/dev/find_dev.h"
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace pp {
namespace {
static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE;
bool StartFind(PP_Instance instance,
const char* text,
bool case_sensitive) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
if (!object)
return false;
return static_cast<Find_Dev*>(object)->StartFind(text, case_sensitive);
}
void SelectFindResult(PP_Instance instance, bool forward) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
if (object)
static_cast<Find_Dev*>(object)->SelectFindResult(forward);
}
void StopFind(PP_Instance instance) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface);
if (object)
static_cast<Find_Dev*>(object)->StopFind();
}
const PPP_Find_Dev ppp_find = {
&StartFind,
&SelectFindResult,
&StopFind
};
DeviceFuncs<PPB_Find_Dev> ppb_find_f(PPB_FIND_DEV_INTERFACE);
} // namespace
Find_Dev::Find_Dev(Instance* instance) : associated_instance_(instance) {
pp::Module::Get()->AddPluginInterface(kPPPFindInterface, &ppp_find);
associated_instance_->AddPerInstanceObject(kPPPFindInterface, this);
}
Find_Dev::~Find_Dev() {
associated_instance_->RemovePerInstanceObject(kPPPFindInterface, this);
}
void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) {
if (ppb_find_f) {
ppb_find_f->NumberOfFindResultsChanged(associated_instance_->pp_instance(),
total, final_result);
}
}
void Find_Dev::SelectedFindResultChanged(int32_t index) {
if (ppb_find_f) {
ppb_find_f->SelectedFindResultChanged(associated_instance_->pp_instance(),
index);
}
}
} // namespace pp

61
ppapi/cpp/dev/find_dev.h Normal file

@ -0,0 +1,61 @@
// 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.
#ifndef PPAPI_CPP_DEV_FIND_DEV_H_
#define PPAPI_CPP_DEV_FIND_DEV_H_
#include <string>
#include "ppapi/c/dev/ppp_find_dev.h"
namespace pp {
class Instance;
// This class allows you to associate the PPP_Find and PPB_Find C-based
// interfaces with an object. It associates itself with the given instance, and
// registers as the global handler for handling the PPP_Find interface that the
// browser calls.
//
// You would typically use this either via inheritance on your instance:
// class MyInstance : public pp::Instance, public pp::Find_Dev {
// class MyInstance() : pp::Find_Dev(this) {
// }
// ...
// };
//
// or by composition:
// class MyFinder : public pp::Find {
// ...
// };
//
// class MyInstance : public pp::Instance {
// MyInstance() : finder_(this) {
// }
//
// MyFinder finder_;
// };
class Find_Dev {
public:
// The instance parameter must outlive this class.
Find_Dev(Instance* instance);
virtual ~Find_Dev();
// PPP_Find_Dev functions exposed as virtual functions for you to
// override.
virtual bool StartFind(const std::string& text, bool case_sensitive) = 0;
virtual void SelectFindResult(bool forward) = 0;
virtual void StopFind() = 0;
// PPB_Find_Def functions for you to call to report find results.
void NumberOfFindResultsChanged(int32_t total, bool final_result);
void SelectedFindResultChanged(int32_t index);
private:
Instance* associated_instance_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_FIND_DEV_H_

210
ppapi/cpp/dev/font_dev.cc Normal file

@ -0,0 +1,210 @@
// 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.
#include "ppapi/cpp/dev/font_dev.h"
#include <algorithm>
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/module_impl.h"
namespace {
DeviceFuncs<PPB_Font_Dev> font_f(PPB_FONT_DEV_INTERFACE);
} // namespace
namespace pp {
// FontDescription_Dev ---------------------------------------------------------
FontDescription_Dev::FontDescription_Dev() {
pp_font_description_.face = face_.pp_var();
set_family(PP_FONTFAMILY_DEFAULT);
set_size(0);
set_weight(PP_FONTWEIGHT_NORMAL);
set_italic(false);
set_small_caps(false);
set_letter_spacing(0);
set_word_spacing(0);
}
FontDescription_Dev::FontDescription_Dev(const FontDescription_Dev& other) {
set_face(other.face());
set_family(other.family());
set_size(other.size());
set_weight(other.weight());
set_italic(other.italic());
set_small_caps(other.small_caps());
set_letter_spacing(other.letter_spacing());
set_word_spacing(other.word_spacing());
}
FontDescription_Dev::~FontDescription_Dev() {
}
FontDescription_Dev& FontDescription_Dev::operator=(
const FontDescription_Dev& other) {
FontDescription_Dev copy(other);
swap(copy);
return *this;
}
void FontDescription_Dev::swap(FontDescription_Dev& other) {
// Need to fix up both the face and the pp_font_description_.face which the
// setter does for us.
Var temp = face();
set_face(other.face());
other.set_face(temp);
std::swap(pp_font_description_.family, other.pp_font_description_.family);
std::swap(pp_font_description_.size, other.pp_font_description_.size);
std::swap(pp_font_description_.weight, other.pp_font_description_.weight);
std::swap(pp_font_description_.italic, other.pp_font_description_.italic);
std::swap(pp_font_description_.small_caps,
other.pp_font_description_.small_caps);
std::swap(pp_font_description_.letter_spacing,
other.pp_font_description_.letter_spacing);
std::swap(pp_font_description_.word_spacing,
other.pp_font_description_.word_spacing);
}
// TextRun_Dev -----------------------------------------------------------------
TextRun_Dev::TextRun_Dev() {
pp_text_run_.text = text_.pp_var();
pp_text_run_.rtl = false;
pp_text_run_.override_direction = false;
}
TextRun_Dev::TextRun_Dev(const std::string& text,
bool rtl,
bool override_direction)
: text_(text) {
pp_text_run_.text = text_.pp_var();
pp_text_run_.rtl = rtl;
pp_text_run_.override_direction = override_direction;
}
TextRun_Dev::TextRun_Dev(const TextRun_Dev& other) : text_(other.text_) {
pp_text_run_.text = text_.pp_var();
pp_text_run_.rtl = other.pp_text_run_.rtl;
pp_text_run_.override_direction = other.pp_text_run_.override_direction;
}
TextRun_Dev::~TextRun_Dev() {
}
TextRun_Dev& TextRun_Dev::operator=(const TextRun_Dev& other) {
TextRun_Dev copy(other);
swap(copy);
return *this;
}
void TextRun_Dev::swap(TextRun_Dev& other) {
std::swap(text_, other.text_);
// Fix up both object's pp_text_run.text to point to their text_ member.
pp_text_run_.text = text_.pp_var();
other.pp_text_run_.text = other.text_.pp_var();
std::swap(pp_text_run_.rtl, other.pp_text_run_.rtl);
std::swap(pp_text_run_.override_direction,
other.pp_text_run_.override_direction);
}
// Font ------------------------------------------------------------------------
Font_Dev::Font_Dev(PP_Resource resource) : Resource(resource) {
}
Font_Dev::Font_Dev(const FontDescription_Dev& description) {
if (!font_f)
return;
PassRefFromConstructor(font_f->Create(
Module::Get()->pp_module(), &description.pp_font_description()));
}
Font_Dev::Font_Dev(const Font_Dev& other) : Resource(other) {
}
Font_Dev& Font_Dev::operator=(const Font_Dev& other) {
Font_Dev copy(other);
swap(copy);
return *this;
}
void Font_Dev::swap(Font_Dev& other) {
Resource::swap(other);
}
bool Font_Dev::Describe(FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) const {
if (!font_f)
return false;
// Be careful with ownership of the |face| string. It will come back with
// a ref of 1, which we want to assign to the |face_| member of the C++ class.
if (!font_f->Describe(pp_resource(), &description->pp_font_description_,
metrics))
return false;
description->face_ = Var(Var::PassRef(),
description->pp_font_description_.face);
return true;
}
bool Font_Dev::DrawTextAt(ImageData* dest,
const TextRun_Dev& text,
const Point& position,
uint32_t color,
const Rect& clip,
bool image_data_is_opaque) const {
if (!font_f)
return false;
return font_f->DrawTextAt(pp_resource(), dest->pp_resource(),
&text.pp_text_run(), &position.pp_point(),
color, &clip.pp_rect(), image_data_is_opaque);
}
int32_t Font_Dev::MeasureText(const TextRun_Dev& text) const {
if (!font_f)
return -1;
return font_f->MeasureText(pp_resource(), &text.pp_text_run());
}
uint32_t Font_Dev::CharacterOffsetForPixel(const TextRun_Dev& text,
int32_t pixel_position) const {
if (!font_f)
return 0;
return font_f->CharacterOffsetForPixel(pp_resource(), &text.pp_text_run(),
pixel_position);
}
int32_t Font_Dev::PixelOffsetForCharacter(const TextRun_Dev& text,
uint32_t char_offset) const {
if (!font_f)
return 0;
return font_f->PixelOffsetForCharacter(pp_resource(), &text.pp_text_run(),
char_offset);
}
bool Font_Dev::DrawSimpleText(ImageData* dest,
const std::string& text,
const Point& position,
uint32_t color,
bool image_data_is_opaque) const {
return DrawTextAt(dest, TextRun_Dev(text), position, color,
Rect(dest->size()), image_data_is_opaque);
}
int32_t Font_Dev::MeasureSimpleText(const std::string& text) const {
return MeasureText(TextRun_Dev(text));
}
} // namespace pp

139
ppapi/cpp/dev/font_dev.h Normal file

@ -0,0 +1,139 @@
// 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.
#ifndef PPAPI_CPP_DEV_FONT_DEV_H_
#define PPAPI_CPP_DEV_FONT_DEV_H_
#include <string>
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/cpp/resource.h"
#include "ppapi/cpp/var.h"
struct PP_FontDescription_Dev;
namespace pp {
class Font_dev;
class ImageData;
class Instance;
class Point;
class Rect;
// FontDescription_Dev ---------------------------------------------------------
class FontDescription_Dev {
public:
FontDescription_Dev();
FontDescription_Dev(const FontDescription_Dev& other);
~FontDescription_Dev();
const PP_FontDescription_Dev& pp_font_description() const {
return pp_font_description_;
}
FontDescription_Dev& operator=(const FontDescription_Dev& other);
void swap(FontDescription_Dev& other);
Var face() const { return face_; }
void set_face(const Var& face) {
face_ = face;
pp_font_description_.face = face_.pp_var();
}
PP_FontFamily_Dev family() const { return pp_font_description_.family; }
void set_family(PP_FontFamily_Dev f) { pp_font_description_.family = f; }
uint32_t size() const { return pp_font_description_.size; }
void set_size(uint32_t s) { pp_font_description_.size = s; }
PP_FontWeight_Dev weight() const { return pp_font_description_.weight; }
void set_weight(PP_FontWeight_Dev w) { pp_font_description_.weight = w; }
bool italic() const { return pp_font_description_.italic; }
void set_italic(bool i) { pp_font_description_.italic = i; }
bool small_caps() const { return pp_font_description_.small_caps; }
void set_small_caps(bool s) { pp_font_description_.small_caps = s; }
int letter_spacing() const { return pp_font_description_.letter_spacing; }
void set_letter_spacing(int s) { pp_font_description_.letter_spacing = s; }
int word_spacing() const { return pp_font_description_.word_spacing; }
void set_word_spacing(int w) { pp_font_description_.word_spacing = w; }
private:
friend class Font_Dev;
Var face_; // Manages memory for pp_font_description_.face
PP_FontDescription_Dev pp_font_description_;
};
// TextRun_Dev ---------------------------------------------------------------------
class TextRun_Dev {
public:
TextRun_Dev();
TextRun_Dev(const std::string& text,
bool rtl = false,
bool override_direction = false);
TextRun_Dev(const TextRun_Dev& other);
~TextRun_Dev();
TextRun_Dev& operator=(const TextRun_Dev& other);
void swap(TextRun_Dev& other);
const PP_TextRun_Dev& pp_text_run() const {
return pp_text_run_;
}
private:
Var text_; // Manages memory for the reference in pp_text_run_.
PP_TextRun_Dev pp_text_run_;
};
// Font ------------------------------------------------------------------------
// Provides access to system fonts.
class Font_Dev : public Resource {
public:
// Creates an is_null() Font object.
Font_Dev() {}
explicit Font_Dev(PP_Resource resource);
explicit Font_Dev(const FontDescription_Dev& description);
Font_Dev(const Font_Dev& other);
Font_Dev& operator=(const Font_Dev& other);
void swap(Font_Dev& other);
// PPB_Font methods:
bool Describe(FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) const;
bool DrawTextAt(ImageData* dest,
const TextRun_Dev& text,
const Point& position,
uint32_t color,
const Rect& clip,
bool image_data_is_opaque) const;
int32_t MeasureText(const TextRun_Dev& text) const;
uint32_t CharacterOffsetForPixel(const TextRun_Dev& text,
int32_t pixel_position) const;
int32_t PixelOffsetForCharacter(const TextRun_Dev& text,
uint32_t char_offset) const;
// Convenience function that assumes a left-to-right string with no clipping.
bool DrawSimpleText(ImageData* dest,
const std::string& text,
const Point& position,
uint32_t color,
bool image_data_is_opaque = false) const;
// Convenience function that assumes a left-to-right string.
int32_t MeasureSimpleText(const std::string& text) const;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_FONT_DEV_H_

@ -0,0 +1,39 @@
// 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.
#include "ppapi/cpp/dev/fullscreen_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace pp {
namespace {
DeviceFuncs<PPB_Fullscreen_Dev> ppb_fullscreen_f(PPB_FULLSCREEN_DEV_INTERFACE);
} // anonymous namespace
Fullscreen_Dev::Fullscreen_Dev(Instance* instance)
: associated_instance_(instance) {
}
Fullscreen_Dev::~Fullscreen_Dev() {
}
bool Fullscreen_Dev::IsFullscreen() {
return ppb_fullscreen_f && ppb_fullscreen_f->IsFullscreen(
associated_instance_->pp_instance());
}
bool Fullscreen_Dev::SetFullscreen(bool fullscreen) {
if (!ppb_fullscreen_f)
return false;
return ppb_fullscreen_f->SetFullscreen(associated_instance_->pp_instance(),
fullscreen);
}
} // namespace pp

@ -0,0 +1,31 @@
// 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.
#ifndef PPAPI_CPP_DEV_FULLSCREEN_DEV_H_
#define PPAPI_CPP_DEV_FULLSCREEN_DEV_H_
#include <string>
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
namespace pp {
class Instance;
class Fullscreen_Dev {
public:
Fullscreen_Dev(Instance* instance);
virtual ~Fullscreen_Dev();
// PPB_Fullscreen_Dev methods.
bool IsFullscreen();
bool SetFullscreen(bool fullscreen);
private:
Instance* associated_instance_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_FULLSCREEN_DEV_H_

@ -0,0 +1,43 @@
// 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.
#include "ppapi/cpp/dev/graphics_3d_client_dev.h"
#include "ppapi/c/dev/ppp_graphics_3d_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace pp {
namespace {
const char kPPPGraphics3DInterface[] = PPP_GRAPHICS_3D_DEV_INTERFACE;
void Graphics3D_ContextLost(PP_Instance instance) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPGraphics3DInterface);
if (!object)
return;
return static_cast<Graphics3DClient_Dev*>(object)->Graphics3DContextLost();
}
static PPP_Graphics3D_Dev graphics3d_interface = {
&Graphics3D_ContextLost,
};
} // namespace
Graphics3DClient_Dev::Graphics3DClient_Dev(Instance* instance)
: associated_instance_(instance) {
pp::Module::Get()->AddPluginInterface(kPPPGraphics3DInterface,
&graphics3d_interface);
associated_instance_->AddPerInstanceObject(kPPPGraphics3DInterface, this);
}
Graphics3DClient_Dev::~Graphics3DClient_Dev() {
associated_instance_->RemovePerInstanceObject(kPPPGraphics3DInterface, this);
}
} // namespace pp

@ -0,0 +1,36 @@
// 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.
#ifndef PPAPI_CPP_DEV_GRAPHICS_3D_CLIENT_DEV_H_
#define PPAPI_CPP_DEV_GRAPHICS_3D_CLIENT_DEV_H_
#include "ppapi/c/pp_stdint.h"
namespace pp {
class Instance;
class Rect;
class Scrollbar_Dev;
class Widget_Dev;
// This class provides a C++ interface for callbacks related to 3D. You
// would normally use multiple inheritance to derive from this class in your
// instance.
class Graphics3DClient_Dev {
public:
Graphics3DClient_Dev(Instance* instance);
virtual ~Graphics3DClient_Dev();
/**
* Notification that the context was lost for the 3D devices.
*/
virtual void Graphics3DContextLost() = 0;
private:
Instance* associated_instance_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_GRAPHICS_3D_CLIENT_DEV_H_

@ -0,0 +1,117 @@
// 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.
#include "ppapi/cpp/dev/graphics_3d_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/resource.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
extern "C" {
const PPB_OpenGLES_Dev* pepper_opengl_interface = NULL;
}
namespace {
DeviceFuncs<PPB_Graphics3D_Dev> graphics_3d_f(PPB_GRAPHICS_3D_DEV_INTERFACE);
DeviceFuncs<PPB_OpenGLES_Dev> opengles_f(PPB_OPENGLES_DEV_INTERFACE);
inline void InitializeOpenGLCInterface() {
if (!pepper_opengl_interface)
pepper_opengl_interface = &(*opengles_f);
}
} // namespace
namespace pp {
// static
bool Graphics3D_Dev::GetConfigs(int32_t *configs, int32_t config_size,
int32_t *num_config) {
if (graphics_3d_f)
return graphics_3d_f->GetConfigs(configs, config_size, num_config);
return false;
}
// static
bool Graphics3D_Dev::ChooseConfig(const int32_t *attrib_list, int32_t *configs,
int32_t config_size, int32_t *num_config) {
if (graphics_3d_f)
return graphics_3d_f->ChooseConfig(attrib_list, configs, config_size,
num_config);
return false;
}
// static
bool Graphics3D_Dev::GetConfigAttrib(int32_t config, int32_t attribute,
int32_t *value) {
if (graphics_3d_f)
return graphics_3d_f->GetConfigAttrib(config, attribute, value);
return false;
}
// static
const char* Graphics3D_Dev::QueryString(int32_t name) {
if (graphics_3d_f)
return graphics_3d_f->QueryString(name);
return NULL;
}
// static
void* Graphics3D_Dev::GetProcAddress(const char* name) {
if (graphics_3d_f)
return graphics_3d_f->GetProcAddress(name);
return NULL;
}
Graphics3D_Dev Graphics3D_Dev::FromResource(PP_Resource resource_id) {
if (graphics_3d_f && graphics_3d_f->IsGraphics3D(resource_id))
return Graphics3D_Dev(resource_id);
return Graphics3D_Dev();
}
bool Graphics3D_Dev::ResetCurrent() {
return graphics_3d_f && graphics_3d_f->MakeCurent(0);
}
Graphics3D_Dev Graphics3D_Dev::GetCurrentContext() {
if (graphics_3d_f)
return FromResource(graphics_3d_f->GetCurrentContext());
return Graphics3D_Dev();
}
uint32_t Graphics3D_Dev::GetError() {
if (graphics_3d_f)
return graphics_3d_f->GetError();
return PP_GRAPHICS_3D_ERROR_NOT_INITIALIZED;
}
const PPB_OpenGLES_Dev* Graphics3D_Dev::GetImplementation() {
return &(*opengles_f);
}
Graphics3D_Dev::Graphics3D_Dev(const Instance& instance,
int32_t config,
int32_t share_context,
const int32_t* attrib_list) {
if (graphics_3d_f && opengles_f) {
InitializeOpenGLCInterface();
PassRefFromConstructor(graphics_3d_f->CreateContext(instance.pp_instance(),
config, share_context,
attrib_list));
}
}
bool Graphics3D_Dev::MakeCurrent() const {
InitializeOpenGLCInterface();
return graphics_3d_f && graphics_3d_f->MakeCurent(pp_resource());
}
bool Graphics3D_Dev::SwapBuffers() const {
return graphics_3d_f && graphics_3d_f->SwapBuffers(pp_resource());
}
} // namespace pp

@ -0,0 +1,54 @@
// 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.
#ifndef PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_
#define PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_
#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
#include "ppapi/c/dev/ppb_opengles_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/resource.h"
namespace pp {
class Graphics3D_Dev : public Resource {
public:
static bool GetConfigs(int32_t* configs, int32_t config_size,
int32_t* num_config);
static bool ChooseConfig(const int32_t* attrib_list, int32_t* configs,
int32_t config_size, int32_t* num_config);
static bool GetConfigAttrib(int32_t config, int32_t attribute,
int32_t* value);
static const char* QueryString(int32_t name);
static void* GetProcAddress(const char* name);
static bool ResetCurrent();
static Graphics3D_Dev GetCurrentContext();
static uint32_t GetError();
static const PPB_OpenGLES_Dev* GetImplementation();
// Creates an is_null() Graphics3D object.
Graphics3D_Dev() {}
Graphics3D_Dev(const Instance& instance,
int32_t config,
int32_t share_context,
const int32_t* attrib_list);
bool MakeCurrent() const;
bool SwapBuffers() const;
protected:
explicit Graphics3D_Dev(PP_Resource resource_id) : Resource(resource_id) {}
static Graphics3D_Dev FromResource(PP_Resource resource_id);
};
} // namespace pp
#endif // PPAPI_CPP_DEV_GRAPHICS_3D_DEV_H_

@ -0,0 +1,74 @@
// 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.
#include "ppapi/cpp/dev/printing_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace pp {
namespace {
static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE;
PP_PrintOutputFormat_Dev* QuerySupportedFormats(PP_Instance instance,
uint32_t* format_count) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
if (!object)
return NULL;
return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(
format_count);
}
int32_t Begin(PP_Instance instance,
const struct PP_PrintSettings_Dev* print_settings) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
if (!object)
return 0;
return static_cast<Printing_Dev*>(object)->PrintBegin(*print_settings);
}
PP_Resource PrintPages(PP_Instance instance,
const struct PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
if (!object)
return 0;
return static_cast<Printing_Dev*>(object)->PrintPages(
page_ranges, page_range_count).detach();
}
void End(PP_Instance instance) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
if (object)
static_cast<Printing_Dev*>(object)->PrintEnd();
}
const PPP_Printing_Dev ppp_printing = {
&QuerySupportedFormats,
&Begin,
&PrintPages,
&End
};
} // namespace
Printing_Dev::Printing_Dev(Instance* instance)
: associated_instance_(instance) {
pp::Module::Get()->AddPluginInterface(kPPPPrintingInterface, &ppp_printing);
associated_instance_->AddPerInstanceObject(kPPPPrintingInterface, this);
}
Printing_Dev::~Printing_Dev() {
associated_instance_->RemovePerInstanceObject(kPPPPrintingInterface, this);
}
} // namespace pp

@ -0,0 +1,38 @@
// 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.
#ifndef PPAPI_CPP_DEV_PRINTING_DEV_H_
#define PPAPI_CPP_DEV_PRINTING_DEV_H_
#include "ppapi/c/dev/ppp_printing_dev.h"
#include "ppapi/cpp/resource.h"
namespace pp {
class Instance;
// You would typically use this either via inheritance on your instance or
// by composition: see find_dev.h for an example.
class Printing_Dev {
public:
// The instance parameter must outlive this class.
explicit Printing_Dev(Instance* instance);
virtual ~Printing_Dev();
// PPP_Printing_Dev functions exposed as virtual functions for you to
// override.
virtual PP_PrintOutputFormat_Dev* QuerySupportedPrintOutputFormats(
uint32_t* format_count) = 0;
virtual int32_t PrintBegin(const PP_PrintSettings_Dev& print_settings) = 0;
virtual Resource PrintPages(const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count) = 0;
virtual void PrintEnd() = 0;
private:
Instance* associated_instance_;
};
} // namespace pp
#endif // PPAPI_CPP_DEV_PRINTING_DEV_H_

Some files were not shown because too many files have changed in this diff Show More