diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 16:16:50 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 16:16:50 +0000 |
commit | 1758e88fd909ea0ffd49621e8066ffad5627ffdf (patch) | |
tree | c304a5eed047cae5665f5af1739d84655fb5815d /ppapi/c | |
parent | e7d8b51953b7d3b2b8a0aba46132305b32f3efce (diff) | |
download | chromium_src-1758e88fd909ea0ffd49621e8066ffad5627ffdf.zip chromium_src-1758e88fd909ea0ffd49621e8066ffad5627ffdf.tar.gz chromium_src-1758e88fd909ea0ffd49621e8066ffad5627ffdf.tar.bz2 |
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
Diffstat (limited to 'ppapi/c')
63 files changed, 4856 insertions, 0 deletions
diff --git a/ppapi/c/dev/pp_cursor_type_dev.h b/ppapi/c/dev/pp_cursor_type_dev.h new file mode 100644 index 0000000..b7a113a --- /dev/null +++ b/ppapi/c/dev/pp_cursor_type_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. + +#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_ diff --git a/ppapi/c/dev/pp_file_info_dev.h b/ppapi/c/dev/pp_file_info_dev.h new file mode 100644 index 0000000..c1e1a07 --- /dev/null +++ b/ppapi/c/dev/pp_file_info_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_ diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h new file mode 100644 index 0000000..92b9f37 --- /dev/null +++ b/ppapi/c/dev/pp_video_dev.h @@ -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_ diff --git a/ppapi/c/dev/ppb_audio_config_dev.h b/ppapi/c/dev/ppb_audio_config_dev.h new file mode 100644 index 0000000..01079a9 --- /dev/null +++ b/ppapi/c/dev/ppb_audio_config_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_ + diff --git a/ppapi/c/dev/ppb_audio_dev.h b/ppapi/c/dev/ppb_audio_dev.h new file mode 100644 index 0000000..cc567414 --- /dev/null +++ b/ppapi/c/dev/ppb_audio_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_ + diff --git a/ppapi/c/dev/ppb_audio_trusted_dev.h b/ppapi/c/dev/ppb_audio_trusted_dev.h new file mode 100644 index 0000000..acb883f --- /dev/null +++ b/ppapi/c/dev/ppb_audio_trusted_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_ + diff --git a/ppapi/c/dev/ppb_buffer_dev.h b/ppapi/c/dev/ppb_buffer_dev.h new file mode 100644 index 0000000..416ab0b --- /dev/null +++ b/ppapi/c/dev/ppb_buffer_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_ + diff --git a/ppapi/c/dev/ppb_char_set_dev.h b/ppapi/c/dev/ppb_char_set_dev.h new file mode 100644 index 0000000..382e1a8 --- /dev/null +++ b/ppapi/c/dev/ppb_char_set_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_ diff --git a/ppapi/c/dev/ppb_cursor_control_dev.h b/ppapi/c/dev/ppb_cursor_control_dev.h new file mode 100644 index 0000000..7a38767 --- /dev/null +++ b/ppapi/c/dev/ppb_cursor_control_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_ + diff --git a/ppapi/c/dev/ppb_directory_reader_dev.h b/ppapi/c/dev/ppb_directory_reader_dev.h new file mode 100644 index 0000000..84983f5 --- /dev/null +++ b/ppapi/c/dev/ppb_directory_reader_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_ diff --git a/ppapi/c/dev/ppb_file_chooser_dev.h b/ppapi/c/dev/ppb_file_chooser_dev.h new file mode 100644 index 0000000..d5b06faa --- /dev/null +++ b/ppapi/c/dev/ppb_file_chooser_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_ diff --git a/ppapi/c/dev/ppb_file_io_dev.h b/ppapi/c/dev/ppb_file_io_dev.h new file mode 100644 index 0000000..1dfefd1 --- /dev/null +++ b/ppapi/c/dev/ppb_file_io_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_ diff --git a/ppapi/c/dev/ppb_file_io_trusted_dev.h b/ppapi/c/dev/ppb_file_io_trusted_dev.h new file mode 100644 index 0000000..f4915fa --- /dev/null +++ b/ppapi/c/dev/ppb_file_io_trusted_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_ diff --git a/ppapi/c/dev/ppb_file_ref_dev.h b/ppapi/c/dev/ppb_file_ref_dev.h new file mode 100644 index 0000000..fd3a602 --- /dev/null +++ b/ppapi/c/dev/ppb_file_ref_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_ diff --git a/ppapi/c/dev/ppb_file_system_dev.h b/ppapi/c/dev/ppb_file_system_dev.h new file mode 100644 index 0000000..9f93a1a --- /dev/null +++ b/ppapi/c/dev/ppb_file_system_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_ diff --git a/ppapi/c/dev/ppb_find_dev.h b/ppapi/c/dev/ppb_find_dev.h new file mode 100644 index 0000000..ffd7ca8 --- /dev/null +++ b/ppapi/c/dev/ppb_find_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_ diff --git a/ppapi/c/dev/ppb_font_dev.h b/ppapi/c/dev/ppb_font_dev.h new file mode 100644 index 0000000..48dc91f --- /dev/null +++ b/ppapi/c/dev/ppb_font_dev.h @@ -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_ diff --git a/ppapi/c/dev/ppb_fullscreen_dev.h b/ppapi/c/dev/ppb_fullscreen_dev.h new file mode 100644 index 0000000..9730b3e --- /dev/null +++ b/ppapi/c/dev/ppb_fullscreen_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_ diff --git a/ppapi/c/dev/ppb_graphics_3d_dev.h b/ppapi/c/dev/ppb_graphics_3d_dev.h new file mode 100644 index 0000000..142c2f2 --- /dev/null +++ b/ppapi/c/dev/ppb_graphics_3d_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_ + diff --git a/ppapi/c/dev/ppb_opengles_dev.h b/ppapi/c/dev/ppb_opengles_dev.h new file mode 100644 index 0000000..c397beb --- /dev/null +++ b/ppapi/c/dev/ppb_opengles_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_ + diff --git a/ppapi/c/dev/ppb_scrollbar_dev.h b/ppapi/c/dev/ppb_scrollbar_dev.h new file mode 100644 index 0000000..4b365bb --- /dev/null +++ b/ppapi/c/dev/ppb_scrollbar_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_ diff --git a/ppapi/c/dev/ppb_testing_dev.h b/ppapi/c/dev/ppb_testing_dev.h new file mode 100644 index 0000000..16c2bd4 --- /dev/null +++ b/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_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_ diff --git a/ppapi/c/dev/ppb_transport_dev.h b/ppapi/c/dev/ppb_transport_dev.h new file mode 100644 index 0000000..821557d --- /dev/null +++ b/ppapi/c/dev/ppb_transport_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_ + diff --git a/ppapi/c/dev/ppb_url_loader_dev.h b/ppapi/c/dev/ppb_url_loader_dev.h new file mode 100644 index 0000000..44f4dc90 --- /dev/null +++ b/ppapi/c/dev/ppb_url_loader_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_ diff --git a/ppapi/c/dev/ppb_url_loader_trusted_dev.h b/ppapi/c/dev/ppb_url_loader_trusted_dev.h new file mode 100644 index 0000000..4eabe14 --- /dev/null +++ b/ppapi/c/dev/ppb_url_loader_trusted_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_ diff --git a/ppapi/c/dev/ppb_url_request_info_dev.h b/ppapi/c/dev/ppb_url_request_info_dev.h new file mode 100644 index 0000000..2503a0c --- /dev/null +++ b/ppapi/c/dev/ppb_url_request_info_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_ diff --git a/ppapi/c/dev/ppb_url_response_info_dev.h b/ppapi/c/dev/ppb_url_response_info_dev.h new file mode 100644 index 0000000..8e3a9e4 --- /dev/null +++ b/ppapi/c/dev/ppb_url_response_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_ diff --git a/ppapi/c/dev/ppb_url_util_dev.h b/ppapi/c/dev/ppb_url_util_dev.h new file mode 100644 index 0000000..c16e59d --- /dev/null +++ b/ppapi/c/dev/ppb_url_util_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_ + diff --git a/ppapi/c/dev/ppb_var_deprecated.h b/ppapi/c/dev/ppb_var_deprecated.h new file mode 100644 index 0000000..51194b2 --- /dev/null +++ b/ppapi/c/dev/ppb_var_deprecated.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_ + diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h new file mode 100644 index 0000000..33274de --- /dev/null +++ b/ppapi/c/dev/ppb_video_decoder_dev.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_ diff --git a/ppapi/c/dev/ppb_widget_dev.h b/ppapi/c/dev/ppb_widget_dev.h new file mode 100644 index 0000000..0319b22 --- /dev/null +++ b/ppapi/c/dev/ppb_widget_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_ diff --git a/ppapi/c/dev/ppb_zoom_dev.h b/ppapi/c/dev/ppb_zoom_dev.h new file mode 100644 index 0000000..e6046e1 --- /dev/null +++ b/ppapi/c/dev/ppb_zoom_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_ diff --git a/ppapi/c/dev/ppp_class_deprecated.h b/ppapi/c/dev/ppp_class_deprecated.h new file mode 100644 index 0000000..d8a1349 --- /dev/null +++ b/ppapi/c/dev/ppp_class_deprecated.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_ + diff --git a/ppapi/c/dev/ppp_cursor_control_dev.h b/ppapi/c/dev/ppp_cursor_control_dev.h new file mode 100644 index 0000000..b9403f4 --- /dev/null +++ b/ppapi/c/dev/ppp_cursor_control_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_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_ + diff --git a/ppapi/c/dev/ppp_find_dev.h b/ppapi/c/dev/ppp_find_dev.h new file mode 100644 index 0000000..98586a3 --- /dev/null +++ b/ppapi/c/dev/ppp_find_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_ diff --git a/ppapi/c/dev/ppp_graphics_3d_dev.h b/ppapi/c/dev/ppp_graphics_3d_dev.h new file mode 100644 index 0000000..2dc4402 --- /dev/null +++ b/ppapi/c/dev/ppp_graphics_3d_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_ + diff --git a/ppapi/c/dev/ppp_printing_dev.h b/ppapi/c/dev/ppp_printing_dev.h new file mode 100644 index 0000000..0a4316e --- /dev/null +++ b/ppapi/c/dev/ppp_printing_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_ + diff --git a/ppapi/c/dev/ppp_scrollbar_dev.h b/ppapi/c/dev/ppp_scrollbar_dev.h new file mode 100644 index 0000000..73688f42 --- /dev/null +++ b/ppapi/c/dev/ppp_scrollbar_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_ diff --git a/ppapi/c/dev/ppp_selection_dev.h b/ppapi/c/dev/ppp_selection_dev.h new file mode 100644 index 0000000..bcdc97d --- /dev/null +++ b/ppapi/c/dev/ppp_selection_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_ diff --git a/ppapi/c/dev/ppp_widget_dev.h b/ppapi/c/dev/ppp_widget_dev.h new file mode 100644 index 0000000..26a4847 --- /dev/null +++ b/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_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_ diff --git a/ppapi/c/dev/ppp_zoom_dev.h b/ppapi/c/dev/ppp_zoom_dev.h new file mode 100644 index 0000000..725ff69 --- /dev/null +++ b/ppapi/c/dev/ppp_zoom_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_ diff --git a/ppapi/c/pp_completion_callback.h b/ppapi/c/pp_completion_callback.h new file mode 100644 index 0000000..3944a815 --- /dev/null +++ b/ppapi/c/pp_completion_callback.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_ diff --git a/ppapi/c/pp_errors.h b/ppapi/c/pp_errors.h new file mode 100644 index 0000000..a5ab5d1 --- /dev/null +++ b/ppapi/c/pp_errors.h @@ -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_ diff --git a/ppapi/c/pp_input_event.h b/ppapi/c/pp_input_event.h new file mode 100644 index 0000000..eddfb2d --- /dev/null +++ b/ppapi/c/pp_input_event.h @@ -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_ diff --git a/ppapi/c/pp_instance.h b/ppapi/c/pp_instance.h new file mode 100644 index 0000000..6f78f11 --- /dev/null +++ b/ppapi/c/pp_instance.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_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_ diff --git a/ppapi/c/pp_module.h b/ppapi/c/pp_module.h new file mode 100644 index 0000000..5376207 --- /dev/null +++ b/ppapi/c/pp_module.h @@ -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_ diff --git a/ppapi/c/pp_point.h b/ppapi/c/pp_point.h new file mode 100644 index 0000000..24bb775 --- /dev/null +++ b/ppapi/c/pp_point.h @@ -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_ diff --git a/ppapi/c/pp_rect.h b/ppapi/c/pp_rect.h new file mode 100644 index 0000000..8b76ebd --- /dev/null +++ b/ppapi/c/pp_rect.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_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_ diff --git a/ppapi/c/pp_resource.h b/ppapi/c/pp_resource.h new file mode 100644 index 0000000..755995a --- /dev/null +++ b/ppapi/c/pp_resource.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_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_ diff --git a/ppapi/c/pp_size.h b/ppapi/c/pp_size.h new file mode 100644 index 0000000..3ad2084 --- /dev/null +++ b/ppapi/c/pp_size.h @@ -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_ diff --git a/ppapi/c/pp_stdint.h b/ppapi/c/pp_stdint.h new file mode 100644 index 0000000..3bb11b9 --- /dev/null +++ b/ppapi/c/pp_stdint.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_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_ diff --git a/ppapi/c/pp_time.h b/ppapi/c/pp_time.h new file mode 100644 index 0000000..7dec91a --- /dev/null +++ b/ppapi/c/pp_time.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. + +#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_ diff --git a/ppapi/c/pp_var.h b/ppapi/c/pp_var.h new file mode 100644 index 0000000..75a9492 --- /dev/null +++ b/ppapi/c/pp_var.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_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_ diff --git a/ppapi/c/ppb.h b/ppapi/c/ppb.h new file mode 100644 index 0000000..1f525cd --- /dev/null +++ b/ppapi/c/ppb.h @@ -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_ diff --git a/ppapi/c/ppb_class.h b/ppapi/c/ppb_class.h new file mode 100644 index 0000000..c4718dd --- /dev/null +++ b/ppapi/c/ppb_class.h @@ -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_ + diff --git a/ppapi/c/ppb_core.h b/ppapi/c/ppb_core.h new file mode 100644 index 0000000..2e1b30c --- /dev/null +++ b/ppapi/c/ppb_core.h @@ -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_ diff --git a/ppapi/c/ppb_graphics_2d.h b/ppapi/c/ppb_graphics_2d.h new file mode 100644 index 0000000..6a15b14 --- /dev/null +++ b/ppapi/c/ppb_graphics_2d.h @@ -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_ diff --git a/ppapi/c/ppb_image_data.h b/ppapi/c/ppb_image_data.h new file mode 100644 index 0000000..905e694 --- /dev/null +++ b/ppapi/c/ppb_image_data.h @@ -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_ diff --git a/ppapi/c/ppb_instance.h b/ppapi/c/ppb_instance.h new file mode 100644 index 0000000..3815650 --- /dev/null +++ b/ppapi/c/ppb_instance.h @@ -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_ diff --git a/ppapi/c/ppb_var.h b/ppapi/c/ppb_var.h new file mode 100644 index 0000000..9de1121 --- /dev/null +++ b/ppapi/c/ppb_var.h @@ -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_ + diff --git a/ppapi/c/ppp.h b/ppapi/c/ppp.h new file mode 100644 index 0000000..67d66c3 --- /dev/null +++ b/ppapi/c/ppp.h @@ -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_ diff --git a/ppapi/c/ppp_instance.h b/ppapi/c/ppp_instance.h new file mode 100644 index 0000000..a7b72e7 --- /dev/null +++ b/ppapi/c/ppp_instance.h @@ -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_ diff --git a/ppapi/c/trusted/ppb_image_data_trusted.h b/ppapi/c/trusted/ppb_image_data_trusted.h new file mode 100644 index 0000000..b72dcc2 --- /dev/null +++ b/ppapi/c/trusted/ppb_image_data_trusted.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_ |