2 * Copyright 2006 The Android Open Source Project
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkXfermodePriv_DEFINED
9 #define SkXfermodePriv_DEFINED
11 #include "include/core/SkBlendMode.h"
12 #include "include/core/SkColor.h"
13 #include "include/core/SkRefCnt.h"
15 class GrFragmentProcessor;
18 class SkRasterPipeline;
21 class SkXfermode : public SkRefCnt {
23 virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
24 const SkAlpha aa[]) const = 0;
26 /** Return an SkXfermode object for the specified mode.
28 static sk_sp<SkXfermode> Make(SkBlendMode);
31 * Skia maintains global xfermode objects corresponding to each BlendMode. This returns a
32 * ptr to that global xfermode (or null if the mode is srcover). Thus the caller may use
33 * the returned ptr, but it should leave its refcnt untouched.
35 static SkXfermode* Peek(SkBlendMode mode) {
36 sk_sp<SkXfermode> xfer = Make(mode);
38 SkASSERT(SkBlendMode::kSrcOver == mode);
41 SkASSERT(!xfer->unique());
45 enum SrcColorOpacity {
46 // The src color is known to be opaque (alpha == 255)
47 kOpaque_SrcColorOpacity = 0,
48 // The src color is known to be fully transparent (color == 0)
49 kTransparentBlack_SrcColorOpacity = 1,
50 // The src alpha is known to be fully transparent (alpha == 0)
51 kTransparentAlpha_SrcColorOpacity = 2,
52 // The src color opacity is unknown
53 kUnknown_SrcColorOpacity = 3
56 static bool IsOpaque(SkBlendMode, SrcColorOpacity);