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