Home | History | Annotate | Download | only in codec
      1 /*
      2  * Copyright 2015 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 #include "SkTypes.h"
      8 
      9 /*
     10  *
     11  * Contains useful mask routines for SkMaskSwizzler
     12  *
     13  */
     14 class SkMasks {
     15 public:
     16 
     17     /*
     18      *
     19      * Input bit masks format
     20      *
     21      */
     22     struct InputMasks {
     23         uint32_t red;
     24         uint32_t green;
     25         uint32_t blue;
     26         uint32_t alpha;
     27     };
     28 
     29     /*
     30      *
     31      * Contains all of the information for a single mask
     32      *
     33      */
     34      struct MaskInfo {
     35         uint32_t mask;
     36         uint32_t shift;
     37         uint32_t size;
     38      };
     39 
     40     /*
     41      *
     42      * Create the masks object
     43      *
     44      */
     45     static SkMasks* CreateMasks(InputMasks masks, uint32_t bpp);
     46 
     47     /*
     48      *
     49      * Get a color component
     50      *
     51      */
     52     uint8_t getRed(uint32_t pixel);
     53     uint8_t getGreen(uint32_t pixel);
     54     uint8_t getBlue(uint32_t pixel);
     55     uint8_t getAlpha(uint32_t pixel);
     56 
     57     /*
     58      *
     59      * Getter for the alpha mask
     60      * The alpha mask may be used in other decoding modes
     61      *
     62      */
     63      uint32_t getAlphaMask() {
     64         return fAlpha.mask;
     65      }
     66 
     67 private:
     68 
     69     /*
     70      *
     71      * Constrcutor
     72      *
     73      */
     74     SkMasks(const MaskInfo red, const MaskInfo green, const MaskInfo blue,
     75             const MaskInfo alpha);
     76 
     77     const MaskInfo fRed;
     78     const MaskInfo fGreen;
     79     const MaskInfo fBlue;
     80     const MaskInfo fAlpha;
     81 };
     82