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 SkBlendModePriv_DEFINED 9 #define SkBlendModePriv_DEFINED 10 11 #include "include/core/SkBlendMode.h" 12 #include "include/core/SkColor.h" 13 #include "include/private/SkColorData.h" 14 15 class SkRasterPipeline; 16 class SkPaint; 17 18 /** 19 * Sentinel value for SkBlendMode enum. 20 * 21 * Will never be a valid enum value, but will be storable in a byte. 22 */ 23 constexpr uint8_t kCustom_SkBlendMode = 0xFF; 24 25 bool SkBlendMode_SupportsCoverageAsAlpha(SkBlendMode); 26 SkBlendMode_CaresAboutRBOrder(SkBlendMode mode)27static inline bool SkBlendMode_CaresAboutRBOrder(SkBlendMode mode) { 28 return (mode > SkBlendMode::kLastSeparableMode); 29 } 30 31 bool SkBlendMode_ShouldPreScaleCoverage(SkBlendMode, bool rgb_coverage); 32 void SkBlendMode_AppendStages(SkBlendMode, SkRasterPipeline*); 33 34 SkPMColor4f SkBlendMode_Apply(SkBlendMode, const SkPMColor4f& src, const SkPMColor4f& dst); 35 36 enum class SkBlendFastPath { 37 kNormal, // draw normally 38 kSrcOver, //< draw as if in srcover mode 39 kSkipDrawing //< draw nothing 40 }; 41 42 /** 43 * Given a paint, determine whether the paint's blend mode can be 44 * replaced with kSrcOver or not drawn at all. This can inform drawing optimizations. 45 */ 46 SkBlendFastPath CheckFastPath(const SkPaint&, bool dstIsOpaque); 47 48 #endif 49