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
|
|
|
|
2015-11-20 23:12:59 +00:00
|
|
|
class GrPorterDuffXPFactory : public GrXPFactory {
|
2014-12-03 18:40:13 +00:00
|
|
|
public:
|
2015-11-20 23:12:59 +00:00
|
|
|
static GrXPFactory* Create(SkXfermode::Mode mode);
|
2014-12-03 19:41:54 +00:00
|
|
|
|
2015-09-15 16:31:40 +00:00
|
|
|
bool supportsRGBCoverage(GrColor /*knownColor*/, uint32_t /*knownColorFlags*/) const override {
|
|
|
|
return true;
|
|
|
|
}
|
2014-12-03 18:40:13 +00:00
|
|
|
|
2015-06-02 17:43:39 +00:00
|
|
|
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
|
|
|
|
GrXPFactory::InvariantBlendedColor*) const override;
|
2014-12-09 19:15:43 +00:00
|
|
|
|
2014-12-03 18:40:13 +00:00
|
|
|
private:
|
2015-11-20 23:12:59 +00:00
|
|
|
GrPorterDuffXPFactory(SkXfermode::Mode);
|
2014-12-05 20:58:28 +00:00
|
|
|
|
2015-05-19 16:29:46 +00:00
|
|
|
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
|
2015-02-17 19:15:47 +00:00
|
|
|
const GrProcOptInfo& colorPOI,
|
2015-02-06 15:02:37 +00:00
|
|
|
const GrProcOptInfo& coveragePOI,
|
2015-06-08 22:11:04 +00:00
|
|
|
bool hasMixedSamples,
|
2015-05-26 16:49:05 +00:00
|
|
|
const DstTexture*) const override;
|
2015-02-06 15:02:37 +00:00
|
|
|
|
2015-05-19 16:29:46 +00:00
|
|
|
bool willReadDstColor(const GrCaps& caps,
|
2015-02-17 19:15:47 +00:00
|
|
|
const GrProcOptInfo& colorPOI,
|
2015-06-08 22:11:04 +00:00
|
|
|
const GrProcOptInfo& coveragePOI,
|
|
|
|
bool hasMixedSamples) const override;
|
2015-02-06 15:02:37 +00:00
|
|
|
|
2015-03-26 01:17:31 +00:00
|
|
|
bool onIsEqual(const GrXPFactory& xpfBase) const override {
|
2015-11-20 23:12:59 +00:00
|
|
|
const GrPorterDuffXPFactory& xpf = xpfBase.cast<GrPorterDuffXPFactory>();
|
2015-05-27 22:08:33 +00:00
|
|
|
return fXfermode == xpf.fXfermode;
|
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;
|
2015-05-27 22:08:33 +00:00
|
|
|
static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, int* outSecondary);
|
2014-12-11 21:15:13 +00:00
|
|
|
|
2015-05-27 22:08:33 +00:00
|
|
|
SkXfermode::Mode fXfermode;
|
2014-12-03 18:40:13 +00:00
|
|
|
|
2015-05-27 22:08:33 +00:00
|
|
|
friend class GrPorterDuffTest; // for TestGetXPOutputTypes()
|
2014-12-03 18:40:13 +00:00
|
|
|
typedef GrXPFactory INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|