2014-12-03 18:40:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrPorterDuffXferProcessor_DEFINED
|
|
|
|
#define GrPorterDuffXferProcessor_DEFINED
|
|
|
|
|
|
|
|
#include "GrTypes.h"
|
|
|
|
#include "GrXferProcessor.h"
|
|
|
|
#include "SkXfermode.h"
|
|
|
|
|
2014-12-17 21:37:13 +00:00
|
|
|
class GrProcOptInfo;
|
2014-12-03 18:40:13 +00:00
|
|
|
|
|
|
|
class GrPorterDuffXPFactory : public GrXPFactory {
|
|
|
|
public:
|
2014-12-03 19:41:54 +00:00
|
|
|
static GrXPFactory* Create(SkXfermode::Mode mode);
|
|
|
|
|
2014-12-03 18:40:13 +00:00
|
|
|
bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE;
|
|
|
|
|
2015-02-17 19:15:47 +00:00
|
|
|
bool canApplyCoverage(const GrProcOptInfo& /*colorPOI*/,
|
|
|
|
const GrProcOptInfo& /*coveragePOI*/) const SK_OVERRIDE {
|
|
|
|
return true;
|
|
|
|
}
|
2014-12-09 19:15:43 +00:00
|
|
|
|
2014-12-17 21:37:13 +00:00
|
|
|
bool canTweakAlphaForCoverage() const SK_OVERRIDE;
|
2014-12-09 19:15:43 +00:00
|
|
|
|
2014-12-18 20:44:55 +00:00
|
|
|
void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI,
|
|
|
|
GrXPFactory::InvariantOutput*) const SK_OVERRIDE;
|
2014-12-09 19:15:43 +00:00
|
|
|
|
2014-12-03 18:40:13 +00:00
|
|
|
private:
|
2014-12-05 20:58:28 +00:00
|
|
|
GrPorterDuffXPFactory(GrBlendCoeff src, GrBlendCoeff dst);
|
|
|
|
|
2015-02-17 19:15:47 +00:00
|
|
|
GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps,
|
|
|
|
const GrProcOptInfo& colorPOI,
|
2015-02-06 15:02:37 +00:00
|
|
|
const GrProcOptInfo& coveragePOI,
|
|
|
|
const GrDeviceCoordTexture* dstCopy) const SK_OVERRIDE;
|
|
|
|
|
2015-02-17 19:15:47 +00:00
|
|
|
bool willReadDstColor(const GrDrawTargetCaps& caps,
|
|
|
|
const GrProcOptInfo& colorPOI,
|
2015-02-13 17:00:33 +00:00
|
|
|
const GrProcOptInfo& coveragePOI) const SK_OVERRIDE;
|
2015-02-06 15:02:37 +00:00
|
|
|
|
2014-12-05 20:58:28 +00:00
|
|
|
bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE {
|
|
|
|
const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();
|
2014-12-09 19:15:43 +00:00
|
|
|
return (fSrcCoeff == xpf.fSrcCoeff && fDstCoeff == xpf.fDstCoeff);
|
2014-12-05 20:58:28 +00:00
|
|
|
}
|
2014-12-03 18:40:13 +00:00
|
|
|
|
2014-12-11 21:15:13 +00:00
|
|
|
GR_DECLARE_XP_FACTORY_TEST;
|
|
|
|
|
2014-12-09 19:15:43 +00:00
|
|
|
GrBlendCoeff fSrcCoeff;
|
|
|
|
GrBlendCoeff fDstCoeff;
|
2014-12-03 18:40:13 +00:00
|
|
|
|
|
|
|
typedef GrXPFactory INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|