• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkBlendMode.h"
12 #include "SkPM4f.h"
13 
14 class SkRasterPipeline;
15 
16 bool SkBlendMode_SupportsCoverageAsAlpha(SkBlendMode);
17 
SkBlendMode_CaresAboutRBOrder(SkBlendMode mode)18 static inline bool SkBlendMode_CaresAboutRBOrder(SkBlendMode mode) {
19     return (mode > SkBlendMode::kLastSeparableMode);
20 }
21 
22 void SkBlendMode_AppendStagesNoClamp(SkBlendMode, SkRasterPipeline*);
23 void SkBlendMode_AppendClampIfNeeded(SkBlendMode, SkRasterPipeline*);
24 
SkBlendMode_AppendStages(SkBlendMode mode,SkRasterPipeline * p)25 static inline void SkBlendMode_AppendStages(SkBlendMode mode, SkRasterPipeline* p) {
26     // Only plus clamps, so maybe append a clamping plus here instead of a second stage?
27     SkBlendMode_AppendStagesNoClamp(mode, p);
28     SkBlendMode_AppendClampIfNeeded(mode, p);
29 }
30 
31 enum class SkBlendModeCoeff {
32     kZero, /** 0 */
33     kOne,  /** 1 */
34     kSC,   /** src color */
35     kISC,  /** inverse src color (i.e. 1 - sc) */
36     kDC,   /** dst color */
37     kIDC,  /** inverse dst color (i.e. 1 - dc) */
38     kSA,   /** src alpha */
39     kISA,  /** inverse src alpha (i.e. 1 - sa) */
40     kDA,   /** dst alpha */
41     kIDA,  /** inverse dst alpha (i.e. 1 - da) */
42 
43     kCoeffCount
44 };
45 
46 bool SkBlendMode_AsCoeff(SkBlendMode mode, SkBlendModeCoeff* src, SkBlendModeCoeff* dst);
47 
48 SkPM4f SkBlendMode_Apply(SkBlendMode, const SkPM4f& src, const SkPM4f& dst);
49 
50 #if SK_SUPPORT_GPU
51 #include "GrXferProcessor.h"
52 const GrXPFactory* SkBlendMode_AsXPFactory(SkBlendMode);
53 #endif
54 
55 #endif
56