quads.mojom revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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 5import "mojo/services/public/interfaces/geometry/geometry.mojom" 6import "mojo/services/public/interfaces/surfaces/surface_id.mojom" 7 8module mojo { 9 10struct Color { 11 uint32 rgba; 12}; 13 14// TODO(jamesr): Populate subtype fields. 15struct CheckerboardQuadState {}; 16 17struct DebugBorderQuadState {}; 18 19struct IoSurfaceContentQuadState {}; 20 21struct RenderPassQuadState {}; 22 23struct SolidColorQuadState { 24 Color color; 25 bool force_anti_aliasing_off; 26}; 27 28struct SurfaceQuadState { 29 SurfaceId surface; 30}; 31 32struct TextureQuadState { 33 uint32 resource_id; 34 bool premultiplied_alpha; 35 mojo.PointF uv_top_left; 36 mojo.PointF uv_bottom_right; 37 Color background_color; 38 float[4] vertex_opacity; 39 bool flipped; 40}; 41 42struct TiledContentQuadState {}; 43 44struct StreamVideoQuadState {}; 45 46struct YUVVideoQuadState {}; 47 48enum Material { 49 CHECKERBOARD = 1, 50 DEBUG_BORDER, 51 IO_SURFACE_CONTENT, 52 PICTURE_CONTENT, 53 RENDER_PASS, 54 SOLID_COLOR, 55 STREAM_VIDEO_CONTENT, 56 SURFACE_CONTENT, 57 TEXTURE_CONTENT, 58 TILED_CONTENT, 59 YUV_VIDEO_CONTENT, 60}; 61 62struct Quad { 63 Material material; 64 65 // This rect, after applying the quad_transform(), gives the geometry that 66 // this quad should draw to. This rect lives in content space. 67 mojo.Rect rect; 68 69 // This specifies the region of the quad that is opaque. This rect lives in 70 // content space. 71 mojo.Rect opaque_rect; 72 73 // Allows changing the rect that gets drawn to make it smaller. This value 74 // should be clipped to |rect|. This rect lives in content space. 75 mojo.Rect visible_rect; 76 77 // Allows changing the rect that gets drawn to make it smaller. This value 78 // should be clipped to |rect|. This rect lives in content space. 79 bool needs_blending; 80 81 // Index into the containing pass' shared quad state array which has state 82 // (transforms etc) shared by multiple quads. 83 int32 shared_quad_state_index; 84 85 // Only one of the following will be set, depending on the material. 86 CheckerboardQuadState checkerboard_quad_state; 87 DebugBorderQuadState debug_border_quad_state; 88 IoSurfaceContentQuadState io_surface_quad_state; 89 RenderPassQuadState render_pass_quad_state; 90 SolidColorQuadState solid_color_quad_state; 91 SurfaceQuadState surface_quad_state; 92 TextureQuadState texture_quad_state; 93 TiledContentQuadState tiled_content_quad_state; 94 StreamVideoQuadState stream_video_quad_state; 95 YUVVideoQuadState yuv_video_quad_state; 96}; 97 98enum SkXfermode { 99 kClear_Mode = 0, //!< [0, 0] 100 kSrc_Mode, //!< [Sa, Sc] 101 kDst_Mode, //!< [Da, Dc] 102 kSrcOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc] 103 kDstOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc] 104 kSrcIn_Mode, //!< [Sa * Da, Sc * Da] 105 kDstIn_Mode, //!< [Sa * Da, Sa * Dc] 106 kSrcOut_Mode, //!< [Sa * (1 - Da), Sc * (1 - Da)] 107 kDstOut_Mode, //!< [Da * (1 - Sa), Dc * (1 - Sa)] 108 kSrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc] 109 kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)] 110 kXor_Mode, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] 111 kPlus_Mode, //!< [Sa + Da, Sc + Dc] 112 kModulate_Mode, // multiplies all components (= alpha and color) 113 114 // Following blend modes are defined in the CSS Compositing standard: 115 // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending 116 kScreen_Mode, 117 kLastCoeffMode = kScreen_Mode, 118 119 kOverlay_Mode, 120 kDarken_Mode, 121 kLighten_Mode, 122 kColorDodge_Mode, 123 kColorBurn_Mode, 124 kHardLight_Mode, 125 kSoftLight_Mode, 126 kDifference_Mode, 127 kExclusion_Mode, 128 kMultiply_Mode, 129 kLastSeparableMode = kMultiply_Mode, 130 131 kHue_Mode, 132 kSaturation_Mode, 133 kColor_Mode, 134 kLuminosity_Mode, 135 kLastMode = kLuminosity_Mode 136}; 137 138struct SharedQuadState { 139 // Transforms from quad's original content space to its target content space. 140 mojo.Transform content_to_target_transform; 141 142 // This size lives in the content space for the quad's originating layer. 143 mojo.Size content_bounds; 144 145 // This rect lives in the content space for the quad's originating layer. 146 mojo.Rect visible_content_rect; 147 148 // This rect lives in the target content space. 149 mojo.Rect clip_rect; 150 151 bool is_clipped; 152 float opacity; 153 SkXfermode blend_mode; 154 int32 sorting_context_id; 155}; 156 157struct Pass { 158 int32 id; 159 mojo.Rect output_rect; 160 mojo.Rect damage_rect; 161 mojo.Transform transform_to_root_target; 162 bool has_transparent_background; 163 Quad[] quads; 164 SharedQuadState[] shared_quad_states; 165}; 166 167} 168