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.
6 /* From ppb_compositor_layer.idl modified Thu Aug 14 18:06:33 2014. */
8 #ifndef PPAPI_C_PPB_COMPOSITOR_LAYER_H_
9 #define PPAPI_C_PPB_COMPOSITOR_LAYER_H_
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"
20 #define PPB_COMPOSITORLAYER_INTERFACE_0_1 "PPB_CompositorLayer;0.1" /* dev */
21 #define PPB_COMPOSITORLAYER_INTERFACE_0_2 "PPB_CompositorLayer;0.2" /* dev */
32 * This enumeration contains blend modes used for computing the result pixels
33 * based on the source RGBA values in layers with the RGBA values that are
34 * already in the destination framebuffer.
35 * alpha_src, color_src: source alpha and color.
36 * alpha_dst, color_dst: destination alpha and color (before compositing).
37 * Below descriptions of the blend modes assume the colors are pre-multiplied.
38 * This interface is still in development (Dev API status) and may change,
39 * so is only supported on Dev channel and Canary currently.
43 * No blending, copy source to the destination directly.
47 * Source is placed over the destination.
48 * Resulting alpha = alpha_src + alpha_dst - alpha_src * alpha_dst
49 * Resulting color = color_src + color_dst * (1 - alpha_src)
51 PP_BLENDMODE_SRC_OVER
,
53 * The last blend mode.
55 PP_BLENDMODE_LAST
= PP_BLENDMODE_SRC_OVER
62 * @addtogroup Interfaces
66 * Defines the <code>PPB_CompositorLayer</code> interface. It is used by
67 * <code>PPB_Compositor</code>.
69 struct PPB_CompositorLayer_0_2
{ /* dev */
71 * Determines if a resource is a compositor layer resource.
73 * @param[in] resource The <code>PP_Resource</code> to test.
75 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
76 * resource is a compositor layer resource or <code>PP_FALSE</code>
79 PP_Bool (*IsCompositorLayer
)(PP_Resource resource
);
81 * Sets the color of a solid color layer. If the layer is uninitialized,
82 * it will initialize the layer first, and then set its color.
83 * If the layer has been initialized to another kind of layer, the layer will
84 * not be changed, and <code>PP_ERROR_BADARGUMENT</code> will be returned.
86 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
88 * param[in] red A <code>float</code> for the red color component. It will be
90 * param[in] green A <code>float</code> for the green color component. It will
91 * be clamped to [0, 1].
92 * param[in] blue A <code>float</code> for the blue color component. It will
93 * be clamped to [0, 1].
94 * param[in] alpha A <code>float</code> for the alpha color component. It will
95 * be clamped to [0, 1].
96 * param[in] size A <code>PP_Size</code> for the size of the layer before
99 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
101 int32_t (*SetColor
)(PP_Resource layer
,
106 const struct PP_Size
* size
);
108 * Sets the texture of a texture layer. If the layer is uninitialized,
109 * it will initialize the layer first, and then set its texture.
110 * The source rect will be set to ((0, 0), (1, 1)). If the layer has been
111 * initialized to another kind of layer, the layer will not be changed,
112 * and <code>PP_ERROR_BADARGUMENT</code> will be returned.
114 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
116 * param[in] context A <code>PP_Resource</code> corresponding to a graphics
117 * 3d resource which owns the GL texture.
118 * param[in] target GL texture target (GL_TEXTURE_2D, etc).
119 * param[in] texture A GL texture object id.
120 * param[in] size A <code>PP_Size</code> for the size of the layer before
122 * param[in] cc A <code>PP_CompletionCallback</code> to be called when
123 * the texture is released by Chromium compositor.
125 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
127 int32_t (*SetTexture
)(PP_Resource layer
,
131 const struct PP_Size
* size
,
132 struct PP_CompletionCallback cc
);
134 * Sets the image of an image layer. If the layer is uninitialized,
135 * it will initialize the layer first, and then set its image.
136 * The layer size will be set to the image's size. The source rect will be set
137 * to the full image. If the layer has been initialized to another kind of
138 * layer, the layer will not be changed, and <code>PP_ERROR_BADARGUMENT</code>
141 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
143 * param[in] image_data A <code>PP_Resource</code> corresponding to
144 * an image data resource.
145 * param[in] size A <code>PP_Size</code> for the size of the layer before
146 * transform. If NULL, the image's size will be used.
147 * param[in] cc A <code>PP_CompletionCallback</code> to be called when
148 * the image data is released by Chromium compositor.
150 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
152 int32_t (*SetImage
)(PP_Resource layer
,
153 PP_Resource image_data
,
154 const struct PP_Size
* size
,
155 struct PP_CompletionCallback cc
);
157 * Sets a clip rectangle for a compositor layer. The Chromium compositor
158 * applies a transform matrix on the layer first, and then clips the layer
159 * with the rectangle.
161 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
163 * param[in] rect The clip rectangle. The origin is top-left corner of
166 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
168 int32_t (*SetClipRect
)(PP_Resource layer
, const struct PP_Rect
* rect
);
170 * Sets a transform matrix which is used to composite the layer.
172 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
174 * param[in] matrix A float array with 16 elements. The matrix is
175 * column major. The default transform matrix is an identity matrix.
177 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
179 int32_t (*SetTransform
)(PP_Resource layer
, const float matrix
[16]);
181 * Sets the opacity value which will be applied to the layer. The effective
182 * value of each pixel is computed as:
185 * pixel.rgb = pixel.rgb * opacity;
186 * pixel.a = pixel.a * opactiy;
188 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
190 * param[in] opacity A <code>float</code> for the opacity value, The default
193 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
195 int32_t (*SetOpacity
)(PP_Resource layer
, float opacity
);
197 * Sets the blend mode which is used to composite the layer.
199 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
201 * param[in] mode A <code>PP_BlendMode</code>. The default mode is
202 * <code>PP_BLENDMODE_SRC_OVER</code>.
204 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
206 int32_t (*SetBlendMode
)(PP_Resource layer
, PP_BlendMode mode
);
208 * Sets a source rectangle for a texture layer or an image layer.
210 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
212 * param[in] rect A <code>PP_FloatRect</code> for an area of the source to
213 * consider. For a texture layer, rect is in uv coordinates. For an image
214 * layer, rect is in pixels. If the rect is beyond the dimensions of the
215 * texture or image, <code>PP_ERROR_BADARGUMENT</code> will be returned.
216 * If the layer size does not match the source rect size, bilinear scaling
219 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
221 int32_t (*SetSourceRect
)(PP_Resource layer
, const struct PP_FloatRect
* rect
);
223 * Sets the premultiplied alpha for an texture layer.
225 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
227 * param[in] premult A <code>PP_Bool</code> with <code>PP_TRUE</code> if
228 * pre-multiplied alpha is used.
230 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
232 int32_t (*SetPremultipliedAlpha
)(PP_Resource layer
, PP_Bool premult
);
235 struct PPB_CompositorLayer_0_1
{ /* dev */
236 PP_Bool (*IsCompositorLayer
)(PP_Resource resource
);
237 int32_t (*SetColor
)(PP_Resource layer
,
242 const struct PP_Size
* size
);
243 int32_t (*SetTexture
)(PP_Resource layer
,
246 const struct PP_Size
* size
,
247 struct PP_CompletionCallback cc
);
248 int32_t (*SetImage
)(PP_Resource layer
,
249 PP_Resource image_data
,
250 const struct PP_Size
* size
,
251 struct PP_CompletionCallback cc
);
252 int32_t (*SetClipRect
)(PP_Resource layer
, const struct PP_Rect
* rect
);
253 int32_t (*SetTransform
)(PP_Resource layer
, const float matrix
[16]);
254 int32_t (*SetOpacity
)(PP_Resource layer
, float opacity
);
255 int32_t (*SetBlendMode
)(PP_Resource layer
, PP_BlendMode mode
);
256 int32_t (*SetSourceRect
)(PP_Resource layer
, const struct PP_FloatRect
* rect
);
257 int32_t (*SetPremultipliedAlpha
)(PP_Resource layer
, PP_Bool premult
);
263 #endif /* PPAPI_C_PPB_COMPOSITOR_LAYER_H_ */