LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/pipe - SkPipeFormat.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 13 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2016 Google Inc.
       3             :  *
       4             :  * Use of this source code is governed by a BSD-style license that can be
       5             :  * found in the LICENSE file.
       6             :  */
       7             : 
       8             : #ifndef SkPipeFormat_DEFINED
       9             : #define SkPipeFormat_DEFINED
      10             : 
      11             : #include "SkTypes.h"
      12             : 
      13             : #define kDefinePicture_ExtPipeVerb  SkSetFourByteTag('s', 'k', 'p', 'i')
      14             : 
      15             : enum class SkPipeVerb : uint8_t {
      16             :     kSave,              // extra == 0
      17             :     kSaveLayer,
      18             :     kRestore,           // extra == 0
      19             :     kConcat,            // extra == SkMatrix::MaskType
      20             :     
      21             :     kClipRect,          // extra == (SkRegion::Op << 1) | isAntiAlias:1
      22             :     kClipRRect,         // extra == (SkRegion::Op << 1) | isAntiAlias:1
      23             :     kClipPath,          // extra == (SkRegion::Op << 1) | isAntiAlias:1
      24             :     kClipRegion,        // extra == (SkRegion::Op << 1)
      25             : 
      26             :     kDrawArc,           // extra == useCenter
      27             :     kDrawAtlas,         // extra == has_colors | has_cull | has_paint | mode
      28             :     kDrawDRRect,
      29             :     kDrawText,          // extra == byteLength:24 else next 32
      30             :     kDrawPosText,       // extra == byteLength:24 else next 32
      31             :     kDrawPosTextH,      // extra == byteLength:24 else next 32
      32             :     kDrawRegion,        // extra == size:24 of region, or 0 means next 32
      33             :     kDrawTextOnPath,
      34             :     kDrawTextBlob,
      35             :     kDrawTextRSXform,   // extra == (byteLength:23 << 1) else next 32 | has_cull_rect:1
      36             :     kDrawPatch,
      37             :     kDrawPaint,         // extra == 0
      38             :     kDrawPoints,        // extra == PointMode
      39             :     kDrawRect,          // extra == 0
      40             :     kDrawPath,          // extra == 0
      41             :     kDrawOval,          // extra == 0
      42             :     kDrawRRect,         // extra == 0
      43             :     
      44             :     kDrawImage,         // extra == has_paint:1
      45             :     kDrawImageRect,     // extra == constraint | has_src_rect | has_paint
      46             :     kDrawImageNine,     // extra == has_paint:1
      47             :     kDrawImageLattice,  // extra == x_count:8 | y_count:8 | has_paint:1
      48             :     
      49             :     kDrawVertices,
      50             :     
      51             :     kDrawPicture,       // extra == picture_index
      52             :     kDrawAnnotation,    // extra == (key_len_plus_1:23 << 1) else next 32 | has_data:1
      53             : 
      54             :     kDefineImage,       // extra == image_index
      55             :     kDefineTypeface,
      56             :     kDefineFactory,     // extra == factory_index (followed by padded getTypeName string)
      57             :     kDefinePicture,     // extra == 0 or forget_index + 1 (0 means we're defining a new picture)
      58             :     kEndPicture,        // extra == picture_index
      59             :     kWriteImage,        // extra == image_index
      60             :     kWritePicture,      // extra == picture_index
      61             : };
      62             : 
      63             : enum PaintUsage {
      64             :     kText_PaintUsage        = 1 << 0,
      65             :     kTextBlob_PaintUsage    = 1 << 1,
      66             :     kGeometry_PaintUsage    = 1 << 2,
      67             :     kImage_PaintUsage       = 1 << 3,
      68             :     kSaveLayer_PaintUsage   = 1 << 4,
      69             :     kDrawPaint_PaintUsage   = 1 << 5,
      70             :     kVertices_PaintUsage    = 1 << 6,
      71             :     kRespectsStroke_PaintUsage  = 1 << 7,
      72             :     kUnknown_PaintUsage     = 0xFF,
      73             : };
      74             : 
      75             : // must sum to <= 32
      76             : enum BitsPerField {
      77             :     kFlags_BPF      = 16,
      78             :     kFilter_BPF     = 2,
      79             :     kStyle_BPF      = 2,
      80             :     kCaps_BPF       = 2,
      81             :     kJoins_BPF      = 2,
      82             :     kHint_BPF       = 2,
      83             :     kAlign_BPF      = 2,
      84             :     kEncoding_BPF   = 2,
      85             : };
      86             : 
      87             : enum {
      88             :     kTextSize_NonDef    = 1 << 0,
      89             :     kTextScaleX_NonDef  = 1 << 1,
      90             :     kTextSkewX_NonDef   = 1 << 2,
      91             :     kStrokeWidth_NonDef = 1 << 3,
      92             :     kStrokeMiter_NonDef = 1 << 4,
      93             :     kColor_NonDef       = 1 << 5,
      94             :     kTypeface_NonDef    = 1 << 6,
      95             :     kPathEffect_NonDef  = 1 << 7,
      96             :     kShader_NonDef      = 1 << 8,
      97             :     kMaskFilter_NonDef  = 1 << 9,
      98             :     kColorFilter_NonDef = 1 << 10,
      99             :     kRasterizer_NonDef  = 1 << 11,
     100             :     kImageFilter_NonDef = 1 << 12,
     101             :     kDrawLooper_NonDef  = 1 << 13,
     102             : };
     103             : 
     104             : enum {
     105             :     kFlags_SaveLayerMask            = 0xFF,
     106             :     kHasBounds_SaveLayerMask        = 1 << 8,
     107             :     kHasPaint_SaveLayerMask         = 1 << 9,
     108             :     kHasBackdrop_SaveLayerMask      = 1 << 10,
     109             :     kDontClipToLayer_SaveLayerMask  = 1 << 11,
     110             : };
     111             : 
     112             : enum {
     113             :     kObjectDefinitionBits           = 20,
     114             :     kIndex_ObjectDefinitionMask     = ((1 << kObjectDefinitionBits) - 1),
     115             :     kUser_ObjectDefinitionMask      = 0x7 << kObjectDefinitionBits,
     116             :     kUndef_ObjectDefinitionMask     = 1 << 23,
     117             :     // (Undef:1 | User:3 | Index:20) must fit in extra:24
     118             : };
     119             : 
     120             : enum {
     121             :     kTypeMask_ConcatMask    = 0xF,
     122             :     kSetMatrix_ConcatMask   = 1 << 4,
     123             : };
     124             : 
     125             : enum {
     126             :     kMode_DrawAtlasMask         = 0xFF,
     127             :     kHasColors_DrawAtlasMask    = 1 << 8,
     128             :     kHasCull_DrawAtlasMask      = 1 << 9,
     129             :     kHasPaint_DrawAtlasMask     = 1 << 10,
     130             : };
     131             : 
     132             : enum {
     133             :     kHasPaint_DrawImageMask     = 1 << 0,
     134             : };
     135             : 
     136             : enum {
     137             :     kConstraint_DrawImageRectMask   = 1 << 0,
     138             :     kHasPaint_DrawImageRectMask     = 1 << 1,
     139             :     kHasSrcRect_DrawImageRectMask   = 1 << 2,
     140             : };
     141             : 
     142             : enum {
     143             :     kHasPaint_DrawImageNineMask     = 1 << 0,
     144             : };
     145             : 
     146             : enum {
     147             :     // picture_index takes the first kObjectDefinitionBits bits
     148             :     kHasMatrix_DrawPictureExtra = 1 << 21,
     149             :     kHasPaint_DrawPictureExtra  = 1 << 22,
     150             : };
     151             : 
     152             : enum {
     153             :     kIndex_DefineFactoryExtraBits       = 10,
     154             :     kNameLength_DefineFactoryExtraBits  = 14,   // includes trailing 0
     155             :     kNameLength_DefineFactoryExtraMask  = (1 << kNameLength_DefineFactoryExtraBits) - 1,
     156             : };
     157             : 
     158             : enum {
     159             :     kModeEnum_DrawPatchExtraMask        = 0xFF,
     160             :     kExplicitXfer_DrawPatchExtraValue   = 0xFF,
     161             :     kHasColors_DrawPatchExtraMask       = 0x100,
     162             :     kHasTexture_DrawPatchExtraMask      = 0x200,
     163             : };
     164             : 
     165             : enum {
     166             :     // if we store a zero for VCount, then read an int after the packedverb for the vcount
     167             :     kVCount_DrawVerticesMask            = (1 << 11) - 1,
     168             : 
     169             :     kVMode_DrawVerticesShift            = 11,
     170             :     kVMode_DrawVerticesMask             = 3 << kVMode_DrawVerticesShift,
     171             : 
     172             :     kXMode_DrawVerticesShift            = 13,
     173             :     kXMode_DrawVerticesMask             = 0xFF << kXMode_DrawVerticesShift,
     174             : 
     175             :     kHasTex_DrawVerticesMask            = 1 << 21,
     176             :     kHasColors_DrawVerticesMask         = 1 << 22,
     177             :     kHasIndices_DrawVerticesMask        = 1 << 23,
     178             : };
     179             : 
     180             : enum {
     181             :     kTextLength_DrawTextOnPathMask      = (1 << 16) - 1,
     182             :     kMatrixType_DrawTextOnPathShift     = 16,
     183             :     kMatrixType_DrawTextOnPathMask      = 0xF << kMatrixType_DrawTextOnPathShift,
     184             : };
     185             : 
     186             : enum {
     187             :     kHasPaint_DrawImageLatticeMask  = 1 << 0,
     188             :     kHasFlags_DrawImageLatticeMask  = 1 << 1,
     189             :     kXCount_DrawImageLatticeShift   = 2,        // bits  2:9  are xcount or FF means 32bits follow
     190             :     kYCount_DrawImageLatticeShift   = 10,       // bits 10:17 are ycount or FF means 32bits follow
     191             :     kCount_DrawImageLatticeMask     = 0xFF,     // sentinel for 32bits follow,
     192             :                                                 // thus max inline count is 254
     193             : };
     194             : 
     195             : ///////////////////////////////////////////////////////////////////////////////////////////////////
     196             : 
     197           0 : static inline bool fits_in(int value, int bits) {
     198           0 :     return value >= 0 && value < (1 << bits);
     199             : }
     200             : 
     201           0 : static inline void ASSERT_FITS_IN(int value, int bits) {
     202           0 :     SkASSERT(fits_in(value, bits));
     203           0 : }
     204             : 
     205           0 : static inline uint32_t pack_verb(SkPipeVerb verb, unsigned extra = 0) {
     206             :     //SkDebugf("pack [%d] %d\n", verb, extra);
     207           0 :     ASSERT_FITS_IN((unsigned)verb, 8);
     208           0 :     ASSERT_FITS_IN(extra, 24);
     209           0 :     return ((uint32_t)verb << 24) | extra;
     210             : }
     211             : 
     212           0 : static inline SkPipeVerb unpack_verb(uint32_t data) {
     213           0 :     return (SkPipeVerb)(data >> 24);
     214             : }
     215             : 
     216           0 : static inline unsigned unpack_verb_extra(uint32_t data) {
     217           0 :     return data & 0xFFFFFF;
     218             : }
     219             : 
     220             : #endif

Generated by: LCOV version 1.13