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
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkBlendMode.h"
|
|
|
|
#include "include/gpu/GrTypes.h"
|
|
|
|
#include "src/gpu/GrXferProcessor.h"
|
2014-12-03 18:40:13 +00:00
|
|
|
|
2017-01-09 16:46:10 +00:00
|
|
|
// See the comment above GrXPFactory's definition about this warning suppression.
|
2017-12-04 19:01:30 +00:00
|
|
|
#if defined(__GNUC__)
|
2017-01-09 16:46:10 +00:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
|
|
|
#endif
|
2017-12-04 19:01:30 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
|
|
|
|
#endif
|
2015-11-20 23:12:59 +00:00
|
|
|
class GrPorterDuffXPFactory : public GrXPFactory {
|
2014-12-03 18:40:13 +00:00
|
|
|
public:
|
2017-01-09 16:46:10 +00:00
|
|
|
static const GrXPFactory* Get(SkBlendMode blendMode);
|
2014-12-03 19:41:54 +00:00
|
|
|
|
2015-12-21 21:12:54 +00:00
|
|
|
/** Because src-over is so common we special case it for performance reasons. If this returns
|
|
|
|
null then the SimpleSrcOverXP() below should be used. */
|
2017-04-10 14:54:25 +00:00
|
|
|
static sk_sp<const GrXferProcessor> MakeSrcOverXferProcessor(const GrProcessorAnalysisColor&,
|
|
|
|
GrProcessorAnalysisCoverage,
|
|
|
|
bool hasMixedSamples,
|
|
|
|
const GrCaps&);
|
2017-02-08 19:41:05 +00:00
|
|
|
|
|
|
|
/** Returns a simple non-LCD porter duff blend XP with no optimizations or coverage. */
|
2017-04-10 14:54:25 +00:00
|
|
|
static sk_sp<const GrXferProcessor> MakeNoCoverageXP(SkBlendMode);
|
2017-02-08 19:41:05 +00:00
|
|
|
|
2015-12-21 21:12:54 +00:00
|
|
|
/** This XP implements non-LCD src-over using hw blend with no optimizations. It is returned
|
|
|
|
by reference because it is global and its ref-cnting methods are not thread safe. */
|
|
|
|
static const GrXferProcessor& SimpleSrcOverXP();
|
2015-11-23 21:20:41 +00:00
|
|
|
|
2017-03-30 12:21:32 +00:00
|
|
|
static AnalysisProperties SrcOverAnalysisProperties(const GrProcessorAnalysisColor&,
|
|
|
|
const GrProcessorAnalysisCoverage&,
|
2019-03-15 14:15:29 +00:00
|
|
|
const GrCaps&,
|
|
|
|
GrClampType);
|
2015-11-23 21:20:41 +00:00
|
|
|
|
2014-12-03 18:40:13 +00:00
|
|
|
private:
|
2017-01-09 16:46:10 +00:00
|
|
|
constexpr GrPorterDuffXPFactory(SkBlendMode);
|
2014-12-05 20:58:28 +00:00
|
|
|
|
2017-04-10 14:54:25 +00:00
|
|
|
sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
|
|
|
|
GrProcessorAnalysisCoverage,
|
|
|
|
bool hasMixedSamples,
|
2019-03-15 14:15:29 +00:00
|
|
|
const GrCaps&,
|
|
|
|
GrClampType) const override;
|
2015-02-06 15:02:37 +00:00
|
|
|
|
2017-03-30 12:21:32 +00:00
|
|
|
AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
|
|
|
|
const GrProcessorAnalysisCoverage&,
|
2019-03-15 14:15:29 +00:00
|
|
|
const GrCaps&,
|
|
|
|
GrClampType) const override;
|
2017-03-13 14:36:40 +00:00
|
|
|
|
2017-07-06 14:09:38 +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
|
|
|
|
2017-01-09 16:46:10 +00:00
|
|
|
SkBlendMode fBlendMode;
|
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;
|
|
|
|
};
|
2017-12-04 19:01:30 +00:00
|
|
|
#if defined(__GNUC__)
|
2017-01-09 16:46:10 +00:00
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif
|
2017-12-04 19:01:30 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
#endif
|
2014-12-03 18:40:13 +00:00
|
|
|
|
|
|
|
#endif
|