Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / mojo / services / public / interfaces / surfaces / quads.mojom
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 import "mojo/services/public/interfaces/geometry/geometry.mojom"
6 import "mojo/services/public/interfaces/surfaces/surface_id.mojom"
7
8 module mojo {
9
10 struct Color {
11   uint32 rgba;
12 };
13
14 // TODO(jamesr): Populate subtype fields.
15 struct CheckerboardQuadState {};
16
17 struct DebugBorderQuadState {};
18
19 struct IoSurfaceContentQuadState {};
20
21 struct RenderPassId {
22   int32 layer_id;
23   int32 index;
24 };
25
26 struct RenderPassQuadState {
27   RenderPassId render_pass_id;
28
29   // If nonzero, resource id of mask to use when drawing this pass.
30   uint32 mask_resource_id;
31   RectF mask_uv_rect;
32
33   // Post-processing filters, applied to the pixels in the render pass' texture.
34   // TODO(jamesr): Support
35   // FilterOperations filters;
36
37   // The scale from layer space of the root layer of the render pass to
38   // the render pass physical pixels. This scale is applied to the filter
39   // parameters for pixel-moving filters. This scale should include
40   // content-to-target-space scale, and device pixel ratio.
41   PointF filters_scale;
42
43   // Post-processing filters, applied to the pixels showing through the
44   // background of the render pass, from behind it.
45   // TODO(jamesr): Support
46   // FilterOperations background_filters;
47 };
48
49 struct SolidColorQuadState {
50   Color color;
51   bool force_anti_aliasing_off;
52 };
53
54 struct SurfaceQuadState {
55   SurfaceId surface;
56 };
57
58 struct TextureQuadState {
59   uint32 resource_id;
60   bool premultiplied_alpha;
61   PointF uv_top_left;
62   PointF uv_bottom_right;
63   Color background_color;
64   float[4] vertex_opacity;
65   bool flipped;
66 };
67
68 struct TileQuadState {
69   RectF tex_coord_rect;
70   Size texture_size;
71   bool swizzle_contents;
72   uint32 resource_id;
73 };
74
75 struct StreamVideoQuadState {};
76
77 enum YUVColorSpace {
78   REC_601,       // SDTV standard with restricted "studio swing" color range.
79   REC_601_JPEG,  // Full color range [0, 255] variant of the above.
80 };
81
82 struct YUVVideoQuadState {
83   RectF tex_coord_rect;
84   uint32 y_plane_resource_id;
85   uint32 u_plane_resource_id;
86   uint32 v_plane_resource_id;
87   uint32 a_plane_resource_id;
88   YUVColorSpace color_space;
89 };
90
91 enum Material {
92   CHECKERBOARD = 1,
93   DEBUG_BORDER,
94   IO_SURFACE_CONTENT,
95   PICTURE_CONTENT,
96   RENDER_PASS,
97   SOLID_COLOR,
98   STREAM_VIDEO_CONTENT,
99   SURFACE_CONTENT,
100   TEXTURE_CONTENT,
101   TILED_CONTENT,
102   YUV_VIDEO_CONTENT,
103 };
104
105 struct Quad {
106   Material material;
107
108   // This rect, after applying the quad_transform(), gives the geometry that
109   // this quad should draw to. This rect lives in content space.
110   Rect rect;
111
112   // This specifies the region of the quad that is opaque. This rect lives in
113   // content space.
114   Rect opaque_rect;
115
116   // Allows changing the rect that gets drawn to make it smaller. This value
117   // should be clipped to |rect|. This rect lives in content space.
118   Rect visible_rect;
119
120   // Allows changing the rect that gets drawn to make it smaller. This value
121   // should be clipped to |rect|. This rect lives in content space.
122   bool needs_blending;
123
124   // Index into the containing pass' shared quad state array which has state
125   // (transforms etc) shared by multiple quads.
126   int32 shared_quad_state_index;
127
128   // Only one of the following will be set, depending on the material.
129   CheckerboardQuadState? checkerboard_quad_state;
130   DebugBorderQuadState? debug_border_quad_state;
131   IoSurfaceContentQuadState? io_surface_quad_state;
132   RenderPassQuadState? render_pass_quad_state;
133   SolidColorQuadState? solid_color_quad_state;
134   SurfaceQuadState? surface_quad_state;
135   TextureQuadState? texture_quad_state;
136   TileQuadState? tile_quad_state;
137   StreamVideoQuadState? stream_video_quad_state;
138   YUVVideoQuadState? yuv_video_quad_state;
139 };
140
141 enum SkXfermode {
142   kClear_Mode = 0,    //!< [0, 0]
143   kSrc_Mode,      //!< [Sa, Sc]
144   kDst_Mode,      //!< [Da, Dc]
145   kSrcOver_Mode,  //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc]
146   kDstOver_Mode,  //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc]
147   kSrcIn_Mode,    //!< [Sa * Da, Sc * Da]
148   kDstIn_Mode,    //!< [Sa * Da, Sa * Dc]
149   kSrcOut_Mode,   //!< [Sa * (1 - Da), Sc * (1 - Da)]
150   kDstOut_Mode,   //!< [Da * (1 - Sa), Dc * (1 - Sa)]
151   kSrcATop_Mode,  //!< [Da, Sc * Da + (1 - Sa) * Dc]
152   kDstATop_Mode,  //!< [Sa, Sa * Dc + Sc * (1 - Da)]
153   kXor_Mode,      //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
154   kPlus_Mode,     //!< [Sa + Da, Sc + Dc]
155   kModulate_Mode, // multiplies all components (= alpha and color)
156
157   // Following blend modes are defined in the CSS Compositing standard:
158   // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending
159   kScreen_Mode,
160   kLastCoeffMode = kScreen_Mode,
161
162   kOverlay_Mode,
163   kDarken_Mode,
164   kLighten_Mode,
165   kColorDodge_Mode,
166   kColorBurn_Mode,
167   kHardLight_Mode,
168   kSoftLight_Mode,
169   kDifference_Mode,
170   kExclusion_Mode,
171   kMultiply_Mode,
172   kLastSeparableMode = kMultiply_Mode,
173
174   kHue_Mode,
175   kSaturation_Mode,
176   kColor_Mode,
177   kLuminosity_Mode,
178   kLastMode = kLuminosity_Mode
179 };
180
181 struct SharedQuadState {
182   // Transforms from quad's original content space to its target content space.
183   Transform content_to_target_transform;
184
185   // This size lives in the content space for the quad's originating layer.
186   Size content_bounds;
187
188   // This rect lives in the content space for the quad's originating layer.
189   Rect visible_content_rect;
190
191   // This rect lives in the target content space.
192   Rect clip_rect;
193
194   bool is_clipped;
195   float opacity;
196   SkXfermode blend_mode;
197   int32 sorting_context_id;
198 };
199
200 struct Pass {
201   int32 id;
202   Rect output_rect;
203   Rect damage_rect;
204   Transform transform_to_root_target;
205   bool has_transparent_background;
206   Quad[] quads;
207   SharedQuadState[] shared_quad_states;
208 };
209
210 }