blob: 216fb62d43b164e74b1734f6d774e5fccffe34cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrCustomXfermodePriv_DEFINED
#define GrCustomXfermodePriv_DEFINED
#include "GrCoordTransform.h"
#include "GrDrawTargetCaps.h"
#include "GrFragmentProcessor.h"
#include "GrTextureAccess.h"
#include "GrXferProcessor.h"
#include "SkXfermode.h"
class GrGLCaps;
class GrGLFragmentProcessor;
class GrInvariantOutput;
class GrProcessorKeyBuilder;
class GrTexture;
///////////////////////////////////////////////////////////////////////////////
// Fragment Processor
///////////////////////////////////////////////////////////////////////////////
class GrCustomXferFP : public GrFragmentProcessor {
public:
GrCustomXferFP(SkXfermode::Mode mode, GrTexture* background);
void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
GrGLFragmentProcessor* createGLInstance() const override;
const char* name() const override { return "Custom Xfermode"; }
SkXfermode::Mode mode() const { return fMode; }
const GrTextureAccess& backgroundAccess() const { return fBackgroundAccess; }
private:
bool onIsEqual(const GrFragmentProcessor& other) const override;
void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
SkXfermode::Mode fMode;
GrCoordTransform fBackgroundTransform;
GrTextureAccess fBackgroundAccess;
typedef GrFragmentProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
// Xfer Processor
///////////////////////////////////////////////////////////////////////////////
class GrCustomXPFactory : public GrXPFactory {
public:
GrCustomXPFactory(SkXfermode::Mode mode);
bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const override {
return true;
}
bool canTweakAlphaForCoverage() const override {
return false;
}
void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
GrXPFactory::InvariantOutput*) const override;
private:
GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI,
const GrDeviceCoordTexture* dstCopy) const override;
bool willReadDstColor(const GrDrawTargetCaps& caps,
const GrProcOptInfo& colorPOI,
const GrProcOptInfo& coveragePOI) const override {
return true;
}
bool onIsEqual(const GrXPFactory& xpfBase) const override {
const GrCustomXPFactory& xpf = xpfBase.cast<GrCustomXPFactory>();
return fMode == xpf.fMode;
}
GR_DECLARE_XP_FACTORY_TEST;
SkXfermode::Mode fMode;
typedef GrXPFactory INHERITED;
};
#endif
|