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"
|
2016-11-18 22:19:54 +00:00
|
|
|
#include "SkBlendMode.h"
|
2014-12-03 18:40:13 +00:00
|
|
|
|
2014-12-17 21:37:13 +00:00
|
|
|
class GrProcOptInfo;
|
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.
|
|
|
|
#if defined(__GNUC__) || defined(__clang)
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC 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. */
|
2015-11-23 21:20:41 +00:00
|
|
|
static GrXferProcessor* CreateSrcOverXferProcessor(const GrCaps& caps,
|
2016-12-21 14:20:25 +00:00
|
|
|
const GrPipelineAnalysis&,
|
2015-11-23 21:20:41 +00:00
|
|
|
bool hasMixedSamples,
|
|
|
|
const GrXferProcessor::DstTexture*);
|
2017-02-08 19:41:05 +00:00
|
|
|
|
|
|
|
/** Returns a simple non-LCD porter duff blend XP with no optimizations or coverage. */
|
|
|
|
static sk_sp<GrXferProcessor> CreateNoCoverageXP(SkBlendMode);
|
|
|
|
|
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-02-14 15:28:22 +00:00
|
|
|
static bool WillSrcOverReadDst(const GrProcOptInfo& colorInput,
|
|
|
|
const GrProcOptInfo& coverageInput);
|
|
|
|
static bool IsSrcOverPreCoverageBlendedColorConstant(const GrProcOptInfo& colorInput,
|
|
|
|
GrColor* color);
|
2015-11-23 21:20:41 +00:00
|
|
|
|
2016-12-21 14:20:25 +00:00
|
|
|
static bool SrcOverWillNeedDstTexture(const GrCaps&, const GrPipelineAnalysis&);
|
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-02-14 15:28:22 +00:00
|
|
|
bool willReadsDst(const GrProcOptInfo&, const GrProcOptInfo&) const override;
|
|
|
|
|
2015-05-19 16:29:46 +00:00
|
|
|
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
|
2016-12-21 14:20:25 +00:00
|
|
|
const GrPipelineAnalysis&,
|
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
|
|
|
|
2017-02-14 15:28:22 +00:00
|
|
|
bool willReadDstInShader(const GrCaps&, ColorType, CoverageType) const override;
|
2015-02-06 15:02:37 +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
|
|
|
|
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-01-09 16:46:10 +00:00
|
|
|
#if defined(__GNUC__) || defined(__clang)
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif
|
2014-12-03 18:40:13 +00:00
|
|
|
|
|
|
|
#endif
|