blob: 73c21f718de65f868c38bc2194d6e75dab9f157f [file] [log] [blame]
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrFPArgs_DEFINED
#define GrFPArgs_DEFINED
#include "include/core/SkMatrix.h"
class GrColorInfo;
class GrRecordingContext;
class SkMatrixProvider;
struct GrFPArgs {
GrFPArgs(GrRecordingContext* context,
const SkMatrixProvider& matrixProvider,
const GrColorInfo* dstColorInfo)
: fContext(context)
, fMatrixProvider(matrixProvider)
, fDstColorInfo(dstColorInfo) {
SkASSERT(fContext);
}
class WithPreLocalMatrix;
GrFPArgs withNewMatrixProvider(const SkMatrixProvider& provider) const {
GrFPArgs newArgs(fContext, provider, fDstColorInfo);
newArgs.fInputColorIsOpaque = fInputColorIsOpaque;
newArgs.fPreLocalMatrix = fPreLocalMatrix;
return newArgs;
}
GrRecordingContext* fContext;
const SkMatrixProvider& fMatrixProvider;
const SkMatrix* fPreLocalMatrix = nullptr;
// Make this SkAlphaType?
bool fInputColorIsOpaque = false;
const GrColorInfo* fDstColorInfo;
};
class GrFPArgs::WithPreLocalMatrix final : public GrFPArgs {
public:
WithPreLocalMatrix(const GrFPArgs& args, const SkMatrix& lm) : INHERITED(args) {
if (!lm.isIdentity()) {
if (fPreLocalMatrix) {
fStorage.setConcat(lm, *fPreLocalMatrix);
fPreLocalMatrix = fStorage.isIdentity() ? nullptr : &fStorage;
} else {
fPreLocalMatrix = &lm;
}
}
}
private:
WithPreLocalMatrix(const WithPreLocalMatrix&) = delete;
WithPreLocalMatrix& operator=(const WithPreLocalMatrix&) = delete;
SkMatrix fStorage;
using INHERITED = GrFPArgs;
};
#endif