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

          Line data    Source code
       1             : 
       2             : /*
       3             :  * Copyright 2008 The Android Open Source Project
       4             :  *
       5             :  * Use of this source code is governed by a BSD-style license that can be
       6             :  * found in the LICENSE file.
       7             :  */
       8             : 
       9             : 
      10             : 
      11             : 
      12             : 
      13             : #ifndef SkUnPreMultiply_DEFINED
      14             : #define SkUnPreMultiply_DEFINED
      15             : 
      16             : #include "SkColor.h"
      17             : 
      18             : class SK_API SkUnPreMultiply {
      19             : public:
      20             :     typedef uint32_t Scale;
      21             : 
      22             :     // index this table with alpha [0..255]
      23           0 :     static const Scale* GetScaleTable() {
      24           0 :         return gTable;
      25             :     }
      26             : 
      27           0 :     static Scale GetScale(U8CPU alpha) {
      28           0 :         SkASSERT(alpha <= 255);
      29           0 :         return gTable[alpha];
      30             :     }
      31             : 
      32             :     /** Usage:
      33             : 
      34             :         const Scale* table = SkUnPreMultiply::GetScaleTable();
      35             : 
      36             :         for (...) {
      37             :             unsigned a = ...
      38             :             SkUnPreMultiply::Scale scale = table[a];
      39             : 
      40             :             red = SkUnPreMultiply::ApplyScale(scale, red);
      41             :             ...
      42             :             // now red is unpremultiplied
      43             :         }
      44             :     */
      45           0 :     static U8CPU ApplyScale(Scale scale, U8CPU component) {
      46           0 :         SkASSERT(component <= 255);
      47           0 :         return (scale * component + (1 << 23)) >> 24;
      48             :     }
      49             : 
      50             :     static SkColor PMColorToColor(SkPMColor c);
      51             : 
      52             :     static uint32_t UnPreMultiplyPreservingByteOrder(SkPMColor c);
      53             : 
      54             : private:
      55             :     static const uint32_t gTable[256];
      56             : };
      57             : 
      58             : #endif

Generated by: LCOV version 1.13