• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #ifndef GrBlendFragmentProcessor_DEFINED
9 #define GrBlendFragmentProcessor_DEFINED
10 
11 #include "include/core/SkBlendMode.h"
12 #include "include/core/SkRefCnt.h"
13 
14 class GrFragmentProcessor;
15 
16 namespace GrBlendFragmentProcessor {
17 
18 // TODO(skbug.com/10457): Standardize on a single blend behavior
19 enum class BlendBehavior {
20     // Picks "ComposeOne" or "ComposeTwo" automatically depending on presence of src/dst FPs.
21     kDefault = 0,
22 
23     // half(1) is passed as the input color to child FPs. No alpha channel trickery.
24     kComposeOneBehavior,
25 
26     // fInputColor.rgb1 is passed as the input color to child FPs. Alpha is manually blended.
27     kComposeTwoBehavior,
28 
29     // half(1) is passed to src; fInputColor is passed to dst. No alpha channel trickery.
30     kSkModeBehavior,
31 
32     kLastBlendBehavior = kSkModeBehavior,
33 };
34 
35 /** Blends src and dst inputs according to the blend mode.
36  *  If either input is null, fInputColor is used instead.
37  */
38 std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> src,
39                                           std::unique_ptr<GrFragmentProcessor> dst,
40                                           SkBlendMode mode,
41                                           BlendBehavior behavior = BlendBehavior::kDefault);
42 
43 }  // namespace GrBlendFragmentProcessor
44 
45 #endif
46