Home | History | Annotate | Download | only in core
      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 SkPM4f_DEFINED
      9 #define SkPM4f_DEFINED
     10 
     11 #include "SkColorPriv.h"
     12 
     13 /*
     14  *  The float values are 0...1 premultiplied
     15  */
     16 struct SkPM4f {
     17     enum {
     18         A = SK_A32_SHIFT/8,
     19         R = SK_R32_SHIFT/8,
     20         G = SK_G32_SHIFT/8,
     21         B = SK_B32_SHIFT/8,
     22     };
     23     float fVec[4];
     24 
     25     float a() const { return fVec[A]; }
     26 
     27     SkColor4f unpremul() const;
     28 
     29     static SkPM4f FromPMColor(SkPMColor);
     30 
     31     // half-float routines
     32     void toF16(uint16_t[4]) const;
     33     uint64_t toF16() const; // 4 float16 values packed into uint64_t
     34     static SkPM4f FromF16(const uint16_t[4]);
     35 
     36 #ifdef SK_DEBUG
     37     void assertIsUnit() const;
     38 #else
     39     void assertIsUnit() const {}
     40 #endif
     41 };
     42 
     43 typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst);
     44 
     45 
     46 #endif
     47