Compose and YUV fragment processor clone implementations
Change-Id: If4d9f1aaf0e5939afb5ad5825d7198db18541926 Reviewed-on: https://skia-review.googlesource.com/27060 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
a4ce4b1f6b
commit
fb7c83a946
@ -50,9 +50,7 @@ public:
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
sk_sp<GrFragmentProcessor> clone() const override;
|
||||||
b->add32((int)fMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
SkBlendMode getMode() const { return fMode; }
|
SkBlendMode getMode() const { return fMode; }
|
||||||
|
|
||||||
@ -140,6 +138,10 @@ private:
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||||
|
b->add32((int)fMode);
|
||||||
|
}
|
||||||
|
|
||||||
bool onIsEqual(const GrFragmentProcessor& other) const override {
|
bool onIsEqual(const GrFragmentProcessor& other) const override {
|
||||||
const ComposeTwoFragmentProcessor& cs = other.cast<ComposeTwoFragmentProcessor>();
|
const ComposeTwoFragmentProcessor& cs = other.cast<ComposeTwoFragmentProcessor>();
|
||||||
return fMode == cs.fMode;
|
return fMode == cs.fMode;
|
||||||
@ -194,6 +196,16 @@ sk_sp<GrFragmentProcessor> ComposeTwoFragmentProcessor::TestCreate(GrProcessorTe
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
sk_sp<GrFragmentProcessor> ComposeTwoFragmentProcessor::clone() const {
|
||||||
|
auto src = this->childProcessor(0).clone();
|
||||||
|
auto dst = this->childProcessor(1).clone();
|
||||||
|
if (!src || !dst) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return sk_sp<GrFragmentProcessor>(
|
||||||
|
new ComposeTwoFragmentProcessor(std::move(src), std::move(dst), fMode));
|
||||||
|
}
|
||||||
|
|
||||||
GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() const{
|
GrGLSLFragmentProcessor* ComposeTwoFragmentProcessor::onCreateGLSLInstance() const{
|
||||||
return new GLComposeTwoFragmentProcessor;
|
return new GLComposeTwoFragmentProcessor;
|
||||||
}
|
}
|
||||||
@ -281,10 +293,7 @@ public:
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
sk_sp<GrFragmentProcessor> clone() const override;
|
||||||
GR_STATIC_ASSERT(((int)SkBlendMode::kLastMode & SK_MaxU16) == (int)SkBlendMode::kLastMode);
|
|
||||||
b->add32((int)fMode | (fChild << 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
SkBlendMode mode() const { return fMode; }
|
SkBlendMode mode() const { return fMode; }
|
||||||
|
|
||||||
@ -386,6 +395,11 @@ private:
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {
|
||||||
|
GR_STATIC_ASSERT(((int)SkBlendMode::kLastMode & SK_MaxU16) == (int)SkBlendMode::kLastMode);
|
||||||
|
b->add32((int)fMode | (fChild << 16));
|
||||||
|
}
|
||||||
|
|
||||||
bool onIsEqual(const GrFragmentProcessor& that) const override {
|
bool onIsEqual(const GrFragmentProcessor& that) const override {
|
||||||
return fMode == that.cast<ComposeOneFragmentProcessor>().fMode;
|
return fMode == that.cast<ComposeOneFragmentProcessor>().fMode;
|
||||||
}
|
}
|
||||||
@ -483,6 +497,15 @@ GrGLSLFragmentProcessor* ComposeOneFragmentProcessor::onCreateGLSLInstance() con
|
|||||||
return new GLComposeOneFragmentProcessor;
|
return new GLComposeOneFragmentProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sk_sp<GrFragmentProcessor> ComposeOneFragmentProcessor::clone() const {
|
||||||
|
auto child = this->childProcessor(0).clone();
|
||||||
|
if (!child) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return sk_sp<GrFragmentProcessor>(
|
||||||
|
new ComposeOneFragmentProcessor(std::move(child), fMode, fChild));
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// It may seems as though when the input FP is the dst and the mode is kDst (or same for src/kSrc)
|
// It may seems as though when the input FP is the dst and the mode is kDst (or same for src/kSrc)
|
||||||
|
@ -92,6 +92,10 @@ public:
|
|||||||
|
|
||||||
const char* name() const override { return "YUV to RGB"; }
|
const char* name() const override { return "YUV to RGB"; }
|
||||||
|
|
||||||
|
sk_sp<GrFragmentProcessor> clone() const override {
|
||||||
|
return sk_sp<GrFragmentProcessor>(new YUVtoRGBEffect(*this));
|
||||||
|
}
|
||||||
|
|
||||||
SkYUVColorSpace getColorSpace() const { return fColorSpace; }
|
SkYUVColorSpace getColorSpace() const { return fColorSpace; }
|
||||||
|
|
||||||
bool isNV12() const {
|
bool isNV12() const {
|
||||||
@ -175,6 +179,27 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YUVtoRGBEffect(const YUVtoRGBEffect& that)
|
||||||
|
: INHERITED(kPreservesOpaqueInput_OptimizationFlag)
|
||||||
|
, fYTransform(that.fYTransform)
|
||||||
|
, fYSampler(that.fYSampler)
|
||||||
|
, fUTransform(that.fUTransform)
|
||||||
|
, fUSampler(that.fUSampler)
|
||||||
|
, fVTransform(that.fVTransform)
|
||||||
|
, fVSampler(that.fVSampler)
|
||||||
|
, fColorSpace(that.fColorSpace)
|
||||||
|
, fNV12(that.fNV12) {
|
||||||
|
this->initClassID<YUVtoRGBEffect>();
|
||||||
|
this->addCoordTransform(&fYTransform);
|
||||||
|
this->addTextureSampler(&fYSampler);
|
||||||
|
this->addCoordTransform(&fUTransform);
|
||||||
|
this->addTextureSampler(&fUSampler);
|
||||||
|
if (!fNV12) {
|
||||||
|
this->addCoordTransform(&fVTransform);
|
||||||
|
this->addTextureSampler(&fVSampler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
|
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
|
||||||
return new GLSLProcessor;
|
return new GLSLProcessor;
|
||||||
}
|
}
|
||||||
@ -224,6 +249,14 @@ public:
|
|||||||
|
|
||||||
const char* name() const override { return "RGBToYUV"; }
|
const char* name() const override { return "RGBToYUV"; }
|
||||||
|
|
||||||
|
sk_sp<GrFragmentProcessor> clone() const override {
|
||||||
|
auto child = this->childProcessor(0).clone();
|
||||||
|
if (!child) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return Make(std::move(child), fColorSpace, fOutputChannels);
|
||||||
|
}
|
||||||
|
|
||||||
SkYUVColorSpace getColorSpace() const { return fColorSpace; }
|
SkYUVColorSpace getColorSpace() const { return fColorSpace; }
|
||||||
|
|
||||||
OutputChannels outputChannels() const { return fOutputChannels; }
|
OutputChannels outputChannels() const { return fOutputChannels; }
|
||||||
|
Loading…
Reference in New Issue
Block a user