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