1 /* Copyright 2014 The Chromium Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6 /* From ppb_compositor_layer.idl modified Wed Jun 4 11:17:54 2014. */ 7 8 #ifndef PPAPI_C_PPB_COMPOSITOR_LAYER_H_ 9 #define PPAPI_C_PPB_COMPOSITOR_LAYER_H_ 10 11 #include "ppapi/c/pp_bool.h" 12 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_macros.h" 14 #include "ppapi/c/pp_point.h" 15 #include "ppapi/c/pp_rect.h" 16 #include "ppapi/c/pp_resource.h" 17 #include "ppapi/c/pp_size.h" 18 #include "ppapi/c/pp_stdint.h" 19 20 #define PPB_COMPOSITORLAYER_INTERFACE_0_1 "PPB_CompositorLayer;0.1" /* dev */ 21 /** 22 * @file 23 */ 24 25 26 /** 27 * @addtogroup Enums 28 * @{ 29 */ 30 /** 31 * This enumeration contains blend modes used for computing the result pixels 32 * based on the source RGBA values in layers with the RGBA values that are 33 * already in the destination framebuffer. 34 * alpha_src, color_src: source alpha and color. 35 * alpha_dst, color_dst: destination alpha and color (before compositing). 36 * Below descriptions of the blend modes assume the colors are pre-multiplied. 37 * This interface is still in development (Dev API status) and may change, 38 * so is only supported on Dev channel and Canary currently. 39 */ 40 typedef enum { 41 /** 42 * No blending, copy source to the destination directly. 43 */ 44 PP_BLENDMODE_NONE, 45 /** 46 * Source is placed over the destination. 47 * Resulting alpha = alpha_src + alpha_dst - alpha_src * alpha_dst 48 * Resulting color = color_src + color_dst * (1 - alpha_src) 49 */ 50 PP_BLENDMODE_SRC_OVER, 51 /** 52 * The last blend mode. 53 */ 54 PP_BLENDMODE_LAST = PP_BLENDMODE_SRC_OVER 55 } PP_BlendMode; 56 /** 57 * @} 58 */ 59 60 /** 61 * @addtogroup Interfaces 62 * @{ 63 */ 64 /** 65 * Defines the <code>PPB_CompositorLayer</code> interface. It is used by 66 * <code>PPB_Compositor</code>. 67 */ 68 struct PPB_CompositorLayer_0_1 { /* dev */ 69 /** 70 * Determines if a resource is a compositor layer resource. 71 * 72 * @param[in] resource The <code>PP_Resource</code> to test. 73 * 74 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given 75 * resource is a compositor layer resource or <code>PP_FALSE</code> 76 * otherwise. 77 */ 78 PP_Bool (*IsCompositorLayer)(PP_Resource resource); 79 /** 80 * Sets the color of a solid color layer. If the layer is uninitialized, 81 * it will initialize the layer first, and then set its color. 82 * If the layer has been initialized to another kind of layer, the layer will 83 * not be changed, and <code>PP_ERROR_BADARGUMENT</code> will be returned. 84 * 85 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 86 * layer resource. 87 * param[in] red A <code>float</code> for the red color component. It will be 88 * clamped to [0, 1]. 89 * param[in] green A <code>float</code> for the green color component. It will 90 * be clamped to [0, 1]. 91 * param[in] blue A <code>float</code> for the blue color component. It will 92 * be clamped to [0, 1]. 93 * param[in] alpha A <code>float</code> for the alpha color component. It will 94 * be clamped to [0, 1]. 95 * param[in] size A <code>PP_Size</code> for the size of the layer before 96 * transform. 97 * 98 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 99 */ 100 int32_t (*SetColor)(PP_Resource layer, 101 float red, 102 float green, 103 float blue, 104 float alpha, 105 const struct PP_Size* size); 106 /** 107 * Sets the texture of a texture layer. If the layer is uninitialized, 108 * it will initialize the layer first, and then set its texture. 109 * The source rect will be set to ((0, 0), (1, 1)). If the layer has been 110 * initialized to another kind of layer, the layer will not be changed, 111 * and <code>PP_ERROR_BADARGUMENT</code> will be returned. 112 * 113 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 114 * layer resource. 115 * param[in] context A <code>PP_Resource</code> corresponding to a graphics 116 * 3d resource which owns the GL texture. 117 * param[in] texture A GL texture object id. 118 * param[in] size A <code>PP_Size</code> for the size of the layer before 119 * transform. 120 * param[in] cc A <code>PP_CompletionCallback</code> to be called when 121 * the texture is released by Chromium compositor. 122 * 123 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 124 */ 125 int32_t (*SetTexture)(PP_Resource layer, 126 PP_Resource context, 127 uint32_t texture, 128 const struct PP_Size* size, 129 struct PP_CompletionCallback cc); 130 /** 131 * Sets the image of an image layer. If the layer is uninitialized, 132 * it will initialize the layer first, and then set its image. 133 * The layer size will be set to the image's size. The source rect will be set 134 * to the full image. If the layer has been initialized to another kind of 135 * layer, the layer will not be changed, and <code>PP_ERROR_BADARGUMENT</code> 136 * will be returned. 137 * 138 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 139 * layer resource. 140 * param[in] image_data A <code>PP_Resource</code> corresponding to 141 * an image data resource. 142 * param[in] size A <code>PP_Size</code> for the size of the layer before 143 * transform. If NULL, the image's size will be used. 144 * param[in] cc A <code>PP_CompletionCallback</code> to be called when 145 * the image data is released by Chromium compositor. 146 * 147 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 148 */ 149 int32_t (*SetImage)(PP_Resource layer, 150 PP_Resource image_data, 151 const struct PP_Size* size, 152 struct PP_CompletionCallback cc); 153 /** 154 * Sets a clip rectangle for a compositor layer. The Chromium compositor 155 * applies a transform matrix on the layer first, and then clips the layer 156 * with the rectangle. 157 * 158 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 159 * layer resource. 160 * param[in] rect The clip rectangle. The origin is top-left corner of 161 * the plugin. 162 * 163 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 164 */ 165 int32_t (*SetClipRect)(PP_Resource layer, const struct PP_Rect* rect); 166 /** 167 * Sets a transform matrix which is used to composite the layer. 168 * 169 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 170 * layer resource. 171 * param[in] matrix A float array with 16 elements. The matrix is 172 * column major. The default transform matrix is an identity matrix. 173 * 174 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 175 */ 176 int32_t (*SetTransform)(PP_Resource layer, const float matrix[16]); 177 /** 178 * Sets the opacity value which will be applied to the layer. The effective 179 * value of each pixel is computed as: 180 * 181 * if (premult_alpha) 182 * pixel.rgb = pixel.rgb * opacity; 183 * pixel.a = pixel.a * opactiy; 184 * 185 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 186 * layer resource. 187 * param[in] opacity A <code>float</code> for the opacity value, The default 188 * value is 1.0f. 189 * 190 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 191 */ 192 int32_t (*SetOpacity)(PP_Resource layer, float opacity); 193 /** 194 * Sets the blend mode which is used to composite the layer. 195 * 196 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 197 * layer resource. 198 * param[in] mode A <code>PP_BlendMode</code>. The default mode is 199 * <code>PP_BLENDMODE_SRC_OVER</code>. 200 * 201 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 202 */ 203 int32_t (*SetBlendMode)(PP_Resource layer, PP_BlendMode mode); 204 /** 205 * Sets a source rectangle for a texture layer or an image layer. 206 * 207 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 208 * layer resource. 209 * param[in] rect A <code>PP_FloatRect</code> for an area of the source to 210 * consider. For a texture layer, rect is in uv coordinates. For an image 211 * layer, rect is in pixels. If the rect is beyond the dimensions of the 212 * texture or image, <code>PP_ERROR_BADARGUMENT</code> will be returned. 213 * If the layer size does not match the source rect size, bilinear scaling 214 * will be used. 215 * 216 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 217 */ 218 int32_t (*SetSourceRect)(PP_Resource layer, const struct PP_FloatRect* rect); 219 /** 220 * Sets the premultiplied alpha for an texture layer. 221 * 222 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor 223 * layer resource. 224 * param[in] premult A <code>PP_Bool</code> with <code>PP_TRUE</code> if 225 * pre-multiplied alpha is used. 226 * 227 * @return An int32_t containing a result code from <code>pp_errors.h</code>. 228 */ 229 int32_t (*SetPremultipliedAlpha)(PP_Resource layer, PP_Bool premult); 230 }; 231 /** 232 * @} 233 */ 234 235 #endif /* PPAPI_C_PPB_COMPOSITOR_LAYER_H_ */ 236 237