Service Worker: Cleanup on a renderer crash before the dispatcher host is destroyed
[chromium-blink-merge.git] / ppapi / api / ppb_compositor_layer.idl
blobed0967d4fa42a6a9d66d215f93777743a360a06e
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 */
6 [generate_thunk]
8 label Chrome {
9 [channel=dev] M37 = 0.1,
10 [channel=dev] M38 = 0.2
13 /**
14 * This enumeration contains blend modes used for computing the result pixels
15 * based on the source RGBA values in layers with the RGBA values that are
16 * already in the destination framebuffer.
17 * alpha_src, color_src: source alpha and color.
18 * alpha_dst, color_dst: destination alpha and color (before compositing).
19 * Below descriptions of the blend modes assume the colors are pre-multiplied.
20 * This interface is still in development (Dev API status) and may change,
21 * so is only supported on Dev channel and Canary currently.
23 enum PP_BlendMode {
24 /**
25 * No blending, copy source to the destination directly.
27 PP_BLENDMODE_NONE,
29 /**
30 * Source is placed over the destination.
31 * Resulting alpha = alpha_src + alpha_dst - alpha_src * alpha_dst
32 * Resulting color = color_src + color_dst * (1 - alpha_src)
34 PP_BLENDMODE_SRC_OVER,
36 /**
37 * The last blend mode.
39 PP_BLENDMODE_LAST = PP_BLENDMODE_SRC_OVER
42 /**
43 * Defines the <code>PPB_CompositorLayer</code> interface. It is used by
44 * <code>PPB_Compositor</code>.
46 interface PPB_CompositorLayer {
47 /**
48 * Determines if a resource is a compositor layer resource.
50 * @param[in] resource The <code>PP_Resource</code> to test.
52 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
53 * resource is a compositor layer resource or <code>PP_FALSE</code>
54 * otherwise.
56 PP_Bool IsCompositorLayer([in] PP_Resource resource);
58 /**
59 * Sets the color of a solid color layer. If the layer is uninitialized,
60 * it will initialize the layer first, and then set its color.
61 * If the layer has been initialized to another kind of layer, the layer will
62 * not be changed, and <code>PP_ERROR_BADARGUMENT</code> will be returned.
64 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
65 * layer resource.
66 * param[in] red A <code>float</code> for the red color component. It will be
67 * clamped to [0, 1].
68 * param[in] green A <code>float</code> for the green color component. It will
69 * be clamped to [0, 1].
70 * param[in] blue A <code>float</code> for the blue color component. It will
71 * be clamped to [0, 1].
72 * param[in] alpha A <code>float</code> for the alpha color component. It will
73 * be clamped to [0, 1].
74 * param[in] size A <code>PP_Size</code> for the size of the layer before
75 * transform.
77 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
79 int32_t SetColor([in] PP_Resource layer,
80 [in] float_t red,
81 [in] float_t green,
82 [in] float_t blue,
83 [in] float_t alpha,
84 [in] PP_Size size);
86 /**
87 * Sets the texture of a texture layer. If the layer is uninitialized,
88 * it will initialize the layer first, and then set its texture.
89 * The source rect will be set to ((0, 0), (1, 1)). If the layer has been
90 * initialized to another kind of layer, the layer will not be changed,
91 * and <code>PP_ERROR_BADARGUMENT</code> will be returned.
93 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
94 * layer resource.
95 * param[in] context A <code>PP_Resource</code> corresponding to a graphics
96 * 3d resource which owns the GL texture.
97 * param[in] texture A GL texture object id.
98 * param[in] size A <code>PP_Size</code> for the size of the layer before
99 * transform.
100 * param[in] cc A <code>PP_CompletionCallback</code> to be called when
101 * the texture is released by Chromium compositor.
103 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
105 int32_t SetTexture([in] PP_Resource layer,
106 [in] PP_Resource context,
107 [in] uint32_t texture,
108 [in] PP_Size size,
109 [in] PP_CompletionCallback cc);
112 * Sets the texture of a texture layer. If the layer is uninitialized,
113 * it will initialize the layer first, and then set its texture.
114 * The source rect will be set to ((0, 0), (1, 1)). If the layer has been
115 * initialized to another kind of layer, the layer will not be changed,
116 * and <code>PP_ERROR_BADARGUMENT</code> will be returned.
118 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
119 * layer resource.
120 * param[in] context A <code>PP_Resource</code> corresponding to a graphics
121 * 3d resource which owns the GL texture.
122 * param[in] target GL texture target (GL_TEXTURE_2D, etc).
123 * param[in] texture A GL texture object id.
124 * param[in] size A <code>PP_Size</code> for the size of the layer before
125 * transform.
126 * param[in] cc A <code>PP_CompletionCallback</code> to be called when
127 * the texture is released by Chromium compositor.
129 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
131 [version = 0.2]
132 int32_t SetTexture([in] PP_Resource layer,
133 [in] PP_Resource context,
134 [in] uint32_t target,
135 [in] uint32_t texture,
136 [in] PP_Size size,
137 [in] PP_CompletionCallback cc);
140 * Sets the image of an image layer. If the layer is uninitialized,
141 * it will initialize the layer first, and then set its image.
142 * The layer size will be set to the image's size. The source rect will be set
143 * to the full image. If the layer has been initialized to another kind of
144 * layer, the layer will not be changed, and <code>PP_ERROR_BADARGUMENT</code>
145 * will be returned.
147 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
148 * layer resource.
149 * param[in] image_data A <code>PP_Resource</code> corresponding to
150 * an image data resource.
151 * param[in] size A <code>PP_Size</code> for the size of the layer before
152 * transform. If NULL, the image's size will be used.
153 * param[in] cc A <code>PP_CompletionCallback</code> to be called when
154 * the image data is released by Chromium compositor.
156 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
158 int32_t SetImage([in] PP_Resource layer,
159 [in] PP_Resource image_data,
160 [in] PP_Size size,
161 [in] PP_CompletionCallback cc);
164 * Sets a clip rectangle for a compositor layer. The Chromium compositor
165 * applies a transform matrix on the layer first, and then clips the layer
166 * with the rectangle.
168 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
169 * layer resource.
170 * param[in] rect The clip rectangle. The origin is top-left corner of
171 * the plugin.
173 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
175 int32_t SetClipRect([in] PP_Resource layer,
176 [in] PP_Rect rect);
179 * Sets a transform matrix which is used to composite the layer.
181 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
182 * layer resource.
183 * param[in] matrix A float array with 16 elements. The matrix is
184 * column major. The default transform matrix is an identity matrix.
186 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
188 int32_t SetTransform([in] PP_Resource layer,
189 [in] float_t[16] matrix);
192 * Sets the opacity value which will be applied to the layer. The effective
193 * value of each pixel is computed as:
195 * if (premult_alpha)
196 * pixel.rgb = pixel.rgb * opacity;
197 * pixel.a = pixel.a * opactiy;
199 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
200 * layer resource.
201 * param[in] opacity A <code>float</code> for the opacity value, The default
202 * value is 1.0f.
204 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
206 int32_t SetOpacity([in] PP_Resource layer,
207 [in] float_t opacity);
210 * Sets the blend mode which is used to composite the layer.
212 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
213 * layer resource.
214 * param[in] mode A <code>PP_BlendMode</code>. The default mode is
215 * <code>PP_BLENDMODE_SRC_OVER</code>.
217 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
219 int32_t SetBlendMode([in] PP_Resource layer,
220 [in] PP_BlendMode mode);
223 * Sets a source rectangle for a texture layer or an image layer.
225 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
226 * layer resource.
227 * param[in] rect A <code>PP_FloatRect</code> for an area of the source to
228 * consider. For a texture layer, rect is in uv coordinates. For an image
229 * layer, rect is in pixels. If the rect is beyond the dimensions of the
230 * texture or image, <code>PP_ERROR_BADARGUMENT</code> will be returned.
231 * If the layer size does not match the source rect size, bilinear scaling
232 * will be used.
234 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
236 int32_t SetSourceRect([in] PP_Resource layer,
237 [in] PP_FloatRect rect);
240 * Sets the premultiplied alpha for an texture layer.
242 * param[in] layer A <code>PP_Resource</code> corresponding to a compositor
243 * layer resource.
244 * param[in] premult A <code>PP_Bool</code> with <code>PP_TRUE</code> if
245 * pre-multiplied alpha is used.
247 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
249 int32_t SetPremultipliedAlpha([in] PP_Resource layer,
250 [in] PP_Bool premult);