Start to unify signatures: return bool

Change-Id: If4a8e06f3a176697e3f5136dfc7ab1fbb347da70
Bug: skia:8937
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205120
Reviewed-by: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-03-30 14:27:53 -04:00 committed by Skia Commit-Bot
parent a6dd1ebd42
commit 2fdbeae327
15 changed files with 35 additions and 25 deletions

View File

@ -64,7 +64,7 @@ public:
*/
virtual bool asComponentTable(SkBitmap* table) const;
void appendStages(const SkStageRec& rec, bool shaderIsOpaque) const;
bool appendStages(const SkStageRec& rec, bool shaderIsOpaque) const;
enum Flags {
/** If set the filter methods will not change the alpha channel of the colors.
@ -196,7 +196,7 @@ private:
*/
virtual int privateComposedFilterCount() const { return 1; }
virtual void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const = 0;
virtual bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const = 0;
friend class SkComposeColorFilter;

View File

@ -49,7 +49,7 @@ private:
SK_FLATTENABLE_HOOKS(SkLumaColorFilter)
SkLumaColorFilter();
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
typedef SkColorFilter INHERITED;
};

View File

@ -44,7 +44,7 @@ private:
memcpy(fColors, colors, kNumColors * sizeof(SkPMColor));
}
void onAppendStages(const SkStageRec&, bool) const override;
bool onAppendStages(const SkStageRec&, bool) const override;
SkPMColor fColors[kNumColors];

View File

@ -44,8 +44,8 @@ std::unique_ptr<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(
}
#endif
void SkColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
this->onAppendStages(rec, shaderIsOpaque);
bool SkColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
return this->onAppendStages(rec, shaderIsOpaque);
}
SkColor SkColorFilter::filterColor(SkColor c) const {
@ -93,13 +93,13 @@ public:
return fOuter->getFlags() & fInner->getFlags();
}
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
bool innerIsOpaque = shaderIsOpaque;
if (!(fInner->getFlags() & kAlphaUnchanged_Flag)) {
innerIsOpaque = false;
}
fInner->appendStages(rec, shaderIsOpaque);
fOuter->appendStages(rec, innerIsOpaque);
return fInner->appendStages(rec, shaderIsOpaque) &&
fOuter->appendStages(rec, innerIsOpaque);
}
#if SK_SUPPORT_GPU
@ -210,7 +210,7 @@ public:
}
#endif
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
if (!shaderIsOpaque) {
rec.fPipeline->append(SkRasterPipeline::unpremul);
}
@ -222,6 +222,7 @@ public:
if (!shaderIsOpaque) {
rec.fPipeline->append(SkRasterPipeline::premul);
}
return true;
}
protected:
@ -278,7 +279,7 @@ public:
return f0 & f1;
}
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
// want cf0 * (1 - w) + cf1 * w == lerp(w)
// which means
// dr,dg,db,da <-- cf0
@ -304,6 +305,7 @@ public:
}
float* storage = rec.fAlloc->make<float>(fWeight);
p->append(SkRasterPipeline::lerp_1_float, storage);
return true;
}
#if SK_SUPPORT_GPU
@ -394,7 +396,7 @@ public:
}
#endif
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
if (fCpuFunction) {
struct CpuFuncCtx : public SkRasterPipeline_CallbackCtx {
SkRuntimeColorFilterFn cpuFn;
@ -440,6 +442,7 @@ public:
};
rec.fPipeline->append(SkRasterPipeline::callback, ctx);
}
return true;
}
protected:

View File

@ -36,7 +36,7 @@ void SkColorFilter_Mixer::flatten(SkWriteBuffer& buffer) const {
buffer.writeFlattenable(fMixer.get());
}
void SkColorFilter_Mixer::onAppendStages(const SkStageRec& rec,
bool SkColorFilter_Mixer::onAppendStages(const SkStageRec& rec,
bool shaderIsOpaque) const {
struct Storage {
float fOrig[4 * SkRasterPipeline_kMaxStride];
@ -71,7 +71,7 @@ void SkColorFilter_Mixer::onAppendStages(const SkStageRec& rec,
// 1st color in dr,dg,db,da
// 2nd color in r, g, b, a
(void) as_MB(fMixer)->appendStages(rec);
return as_MB(fMixer)->appendStages(rec);
}
#if SK_SUPPORT_GPU

View File

@ -33,7 +33,7 @@ public:
protected:
SkColorFilter_Mixer(SkReadBuffer&);
void flatten(SkWriteBuffer&) const override;
void onAppendStages(const SkStageRec&, bool shaderIsOpaque) const override;
bool onAppendStages(const SkStageRec&, bool shaderIsOpaque) const override;
private:
SK_FLATTENABLE_HOOKS(SkColorFilter_Mixer)

View File

@ -66,7 +66,7 @@ bool SkColorMatrixFilterRowMajor255::asColorMatrix(SkScalar matrix[20]) const {
return true;
}
void SkColorMatrixFilterRowMajor255::onAppendStages(const SkStageRec& rec,
bool SkColorMatrixFilterRowMajor255::onAppendStages(const SkStageRec& rec,
bool shaderIsOpaque) const {
const bool willStayOpaque = shaderIsOpaque && (fFlags & kAlphaUnchanged_Flag);
@ -76,6 +76,7 @@ void SkColorMatrixFilterRowMajor255::onAppendStages(const SkStageRec& rec,
if ( true) { p->append(SkRasterPipeline::clamp_0); }
if ( true) { p->append(SkRasterPipeline::clamp_1); }
if (!willStayOpaque) { p->append(SkRasterPipeline::premul); }
return true;
}
#if SK_SUPPORT_GPU

View File

@ -33,7 +33,7 @@ protected:
private:
SK_FLATTENABLE_HOOKS(SkColorMatrixFilterRowMajor255)
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
SkScalar fMatrix[20];
float fTranspose[20]; // for Sk4s

View File

@ -61,13 +61,14 @@ sk_sp<SkFlattenable> SkModeColorFilter::CreateProc(SkReadBuffer& buffer) {
return SkColorFilter::MakeModeFilter(color, mode);
}
void SkModeColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
bool SkModeColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
rec.fPipeline->append(SkRasterPipeline::move_src_dst);
SkColor4f color = SkColor4f::FromColor(fColor);
SkColorSpaceXformSteps(sk_srgb_singleton(), kUnpremul_SkAlphaType,
rec.fDstCS, kUnpremul_SkAlphaType).apply(color.vec());
rec.fPipeline->append_constant_color(rec.fAlloc, color.premul().vec());
SkBlendMode_AppendStages(fMode, rec.fPipeline);
return true;
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -30,7 +30,7 @@ protected:
void flatten(SkWriteBuffer&) const override;
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
private:
SK_FLATTENABLE_HOOKS(SkModeColorFilter)

View File

@ -40,7 +40,7 @@ public:
GrRecordingContext*, const GrColorSpaceInfo&) const override;
#endif
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
protected:
void flatten(SkWriteBuffer&) const override;
@ -55,7 +55,7 @@ private:
typedef SkColorFilter INHERITED;
};
void SkHighContrast_Filter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
bool SkHighContrast_Filter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
SkRasterPipeline* p = rec.fPipeline;
SkArenaAlloc* alloc = rec.fAlloc;
@ -125,6 +125,7 @@ void SkHighContrast_Filter::onAppendStages(const SkStageRec& rec, bool shaderIsO
if (!shaderIsOpaque) {
p->append(SkRasterPipeline::premul);
}
return true;
}
void SkHighContrast_Filter::flatten(SkWriteBuffer& buffer) const {

View File

@ -18,10 +18,11 @@
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#endif
void SkLumaColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
bool SkLumaColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const {
rec.fPipeline->append(SkRasterPipeline::luminance_to_alpha);
rec.fPipeline->append(SkRasterPipeline::clamp_0);
rec.fPipeline->append(SkRasterPipeline::clamp_1);
return true;
}
sk_sp<SkColorFilter> SkLumaColorFilter::Make() {

View File

@ -41,7 +41,7 @@ void main(inout half4 color) {
)";
#endif
void SkOverdrawColorFilter::onAppendStages(const SkStageRec& rec, bool shader_is_opaque) const {
bool SkOverdrawColorFilter::onAppendStages(const SkStageRec& rec, bool shader_is_opaque) const {
struct Ctx : public SkRasterPipeline_CallbackCtx {
const SkPMColor* colors;
};
@ -60,6 +60,7 @@ void SkOverdrawColorFilter::onAppendStages(const SkStageRec& rec, bool shader_is
}
};
rec.fPipeline->append(SkRasterPipeline::callback, ctx);
return true;
}
void SkOverdrawColorFilter::flatten(SkWriteBuffer& buffer) const {

View File

@ -99,7 +99,7 @@ public:
kB_Flag = 1 << 3,
};
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
const uint8_t *r = gIdentityTable,
*g = gIdentityTable,
*b = gIdentityTable,
@ -122,6 +122,7 @@ public:
if (!definitelyOpaque) {
p->append(SkRasterPipeline::premul);
}
return true;
}
protected:

View File

@ -47,8 +47,9 @@ public:
protected:
void flatten(SkWriteBuffer&) const override {}
void onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override {
rec.fPipeline->append(SkRasterPipeline::gauss_a_to_rgba);
return true;
}
private:
SK_FLATTENABLE_HOOKS(SkGaussianColorFilter)