SkXfermode no longer needs to e a flattenable
SkArithmeticMode is unreachable, so delete it Bug: skia: Change-Id: Ibe4c48fcf756280569c4b302da8d96bd4e21b717 Reviewed-on: https://skia-review.googlesource.com/19394 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
f449ded72a
commit
8d3f4433d8
@ -20,7 +20,6 @@ skia_effects_sources = [
|
||||
"$_src/effects/SkAlphaThresholdFilter.cpp",
|
||||
"$_src/effects/SkArcToPathEffect.cpp",
|
||||
"$_src/effects/SkArithmeticImageFilter.cpp",
|
||||
"$_src/effects/SkArithmeticMode.cpp",
|
||||
"$_src/effects/SkBlurMask.cpp",
|
||||
"$_src/effects/SkBlurMask.h",
|
||||
"$_src/effects/SkBlurMaskFilter.cpp",
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
kSkRasterizer_Type,
|
||||
kSkShaderBase_Type,
|
||||
kSkUnused_Type, // used to be SkUnitMapper
|
||||
kSkXfermode_Type,
|
||||
kSkUnused_Xfermode_Type,
|
||||
kSkNormalSource_Type,
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,6 @@ void SkFlattenable::PrivateInitializer::InitCore() {
|
||||
SkColorFilter::InitializeFlattenables();
|
||||
SkPathEffect::InitializeFlattenables();
|
||||
SkShaderBase::InitializeFlattenables();
|
||||
SkXfermode::InitializeFlattenables();
|
||||
|
||||
// Drawable
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRecordedDrawable)
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "SkShaderBase.h"
|
||||
#include "SkTHash.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
#include "SkXfermodePriv.h"
|
||||
|
||||
class SkBitmap;
|
||||
class SkImage;
|
||||
@ -152,7 +151,6 @@ public:
|
||||
sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEffect>(); }
|
||||
sk_sp<SkRasterizer> readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
|
||||
sk_sp<SkShader> readShader() { return this->readFlattenable<SkShaderBase>(); }
|
||||
sk_sp<SkXfermode> readXfermode() { return this->readFlattenable<SkXfermode>(); }
|
||||
|
||||
// binary data and arrays
|
||||
virtual bool readByteArray(void* value, size_t size);
|
||||
|
@ -679,18 +679,6 @@ const GrXPFactory* SkXfermode::asXPFactory() const {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sk_sp<SkFlattenable> SkProcCoeffXfermode::CreateProc(SkReadBuffer& buffer) {
|
||||
uint32_t mode32 = buffer.read32();
|
||||
if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcs))) {
|
||||
return nullptr;
|
||||
}
|
||||
return SkXfermode::Make((SkBlendMode)mode32);
|
||||
}
|
||||
|
||||
void SkProcCoeffXfermode::flatten(SkWriteBuffer& buffer) const {
|
||||
buffer.write32((int)fMode);
|
||||
}
|
||||
|
||||
bool SkProcCoeffXfermode::asMode(SkBlendMode* mode) const {
|
||||
if (mode) {
|
||||
*mode = fMode;
|
||||
@ -758,16 +746,6 @@ const char* SkBlendMode_Name(SkBlendMode mode) {
|
||||
static_assert(SK_ARRAY_COUNT(gModeStrings) == (size_t)SkBlendMode::kLastMode + 1, "mode_count");
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void SkProcCoeffXfermode::toString(SkString* str) const {
|
||||
str->append("SkProcCoeffXfermode: ");
|
||||
|
||||
str->append("mode: ");
|
||||
str->append(SkBlendMode_Name(fMode));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
sk_sp<SkXfermode> SkXfermode::Make(SkBlendMode mode) {
|
||||
if ((unsigned)mode > (unsigned)SkBlendMode::kLastMode) {
|
||||
// report error
|
||||
@ -805,10 +783,6 @@ SkXfermodeProc SkXfermode::GetProc(SkBlendMode mode) {
|
||||
return proc;
|
||||
}
|
||||
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkXfermode::IsOpaque(SkBlendMode mode, SrcColorOpacity opacityType) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
class GrFragmentProcessor;
|
||||
class GrTexture;
|
||||
@ -18,23 +18,7 @@ class GrXPFactory;
|
||||
class SkRasterPipeline;
|
||||
class SkString;
|
||||
|
||||
struct SkArithmeticParams;
|
||||
|
||||
struct SkPM4f;
|
||||
typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst);
|
||||
|
||||
/** \class SkXfermode
|
||||
*
|
||||
* SkXfermode is the base class for objects that are called to implement custom
|
||||
* "transfer-modes" in the drawing pipeline. The static function Create(Modes)
|
||||
* can be called to return an instance of any of the predefined subclasses as
|
||||
* specified in the Modes enum. When an SkXfermode is assigned to an SkPaint,
|
||||
* then objects drawn with that paint have the xfermode applied.
|
||||
*
|
||||
* All subclasses are required to be reentrant-safe : it must be legal to share
|
||||
* the same instance between several threads.
|
||||
*/
|
||||
class SK_API SkXfermode : public SkFlattenable {
|
||||
class SkXfermode : public SkRefCnt {
|
||||
public:
|
||||
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]) const = 0;
|
||||
@ -103,16 +87,11 @@ public:
|
||||
virtual const GrXPFactory* asXPFactory() const;
|
||||
#endif
|
||||
|
||||
SK_TO_STRING_PUREVIRT()
|
||||
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
|
||||
SK_DEFINE_FLATTENABLE_TYPE(SkXfermode)
|
||||
|
||||
protected:
|
||||
SkXfermode() {}
|
||||
virtual ~SkXfermode() {}
|
||||
|
||||
private:
|
||||
|
||||
typedef SkFlattenable INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,12 +30,7 @@ public:
|
||||
const GrXPFactory* asXPFactory() const override;
|
||||
#endif
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
|
||||
|
||||
protected:
|
||||
void flatten(SkWriteBuffer& buffer) const override;
|
||||
|
||||
SkBlendMode getMode() const { return fMode; }
|
||||
|
||||
SkXfermodeProc getProc() const { return fProc; }
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "SkArithmeticImageFilter.h"
|
||||
#include "SkArithmeticModePriv.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkNx.h"
|
||||
#include "SkReadBuffer.h"
|
||||
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkArithmeticModePriv.h"
|
||||
#include "SkReadBuffer.h"
|
||||
|
||||
// This class only exists to unflatten instances that were serialized into old pictures as part of
|
||||
// SkXfermodeImageFilter before the advent of SkBlendMode. Those image filters will now be
|
||||
// transformed to SkArithmeticImageFilter which does not use this class in its implementation.
|
||||
class SkArithmeticMode_scalar : public SkXfermode {
|
||||
public:
|
||||
SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
|
||||
bool enforcePMColor) {
|
||||
fK[0] = k1;
|
||||
fK[1] = k2;
|
||||
fK[2] = k3;
|
||||
fK[3] = k4;
|
||||
fEnforcePMColor = enforcePMColor;
|
||||
}
|
||||
|
||||
void xfer32(SkPMColor[], const SkPMColor[], int count, const SkAlpha[]) const override {
|
||||
SkFAIL("This should never be called.");
|
||||
}
|
||||
|
||||
SK_TO_STRING_OVERRIDE()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
|
||||
|
||||
private:
|
||||
void flatten(SkWriteBuffer& buffer) const override { SkFAIL("This shouild never be called."); }
|
||||
|
||||
SkScalar fK[4];
|
||||
bool fEnforcePMColor;
|
||||
|
||||
friend class SkArithmeticMode;
|
||||
|
||||
typedef SkXfermode INHERITED;
|
||||
};
|
||||
|
||||
sk_sp<SkFlattenable> SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) {
|
||||
const SkScalar k1 = buffer.readScalar();
|
||||
const SkScalar k2 = buffer.readScalar();
|
||||
const SkScalar k3 = buffer.readScalar();
|
||||
const SkScalar k4 = buffer.readScalar();
|
||||
const bool enforcePMColor = buffer.readBool();
|
||||
return SkArithmeticMode::Make(k1, k2, k3, k4, enforcePMColor);
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_TO_STRING
|
||||
void SkArithmeticMode_scalar::toString(SkString* str) const {
|
||||
SkFAIL("This should never be called.");
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sk_sp<SkXfermode> SkArithmeticMode::Make(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
|
||||
bool enforcePMColor) {
|
||||
if (SkScalarNearlyZero(k1) && SkScalarNearlyEqual(k2, SK_Scalar1) &&
|
||||
SkScalarNearlyZero(k3) && SkScalarNearlyZero(k4)) {
|
||||
return SkXfermode::Make(SkBlendMode::kSrc);
|
||||
} else if (SkScalarNearlyZero(k1) && SkScalarNearlyZero(k2) &&
|
||||
SkScalarNearlyEqual(k3, SK_Scalar1) && SkScalarNearlyZero(k4)) {
|
||||
return SkXfermode::Make(SkBlendMode::kDst);
|
||||
}
|
||||
return sk_make_sp<SkArithmeticMode_scalar>(k1, k2, k3, k4, enforcePMColor);
|
||||
}
|
||||
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkArithmeticModePriv_DEFINED
|
||||
#define SkArithmeticModePriv_DEFINED
|
||||
|
||||
#include "SkScalar.h"
|
||||
#include "SkXfermodePriv.h"
|
||||
|
||||
class SkXfermode;
|
||||
|
||||
// This only exists to unflatten instances that were serialized into old pictures as part of
|
||||
// SkXfermodeImageFilter before the advent of SkBlendMode.
|
||||
class SK_API SkArithmeticMode {
|
||||
public:
|
||||
/**
|
||||
* result = clamp[k1 * src * dst + k2 * src + k3 * dst + k4]
|
||||
*
|
||||
* k1=k2=k3=0, k4=1.0 results in returning opaque white
|
||||
* k1=k3=k4=0, k2=1.0 results in returning the src
|
||||
* k1=k2=k4=0, k3=1.0 results in returning the dst
|
||||
*/
|
||||
static sk_sp<SkXfermode> Make(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
|
||||
bool enforcePMColor = true);
|
||||
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
|
||||
|
||||
private:
|
||||
SkArithmeticMode(); // can't be instantiated
|
||||
};
|
||||
|
||||
#endif
|
@ -16,6 +16,7 @@
|
||||
#include "SkString.h"
|
||||
#include "SkStringUtils.h"
|
||||
#include "SkUnPreMultiply.h"
|
||||
#include "SkXfermodePriv.h"
|
||||
|
||||
SkLayerDrawLooper::LayerInfo::LayerInfo() {
|
||||
fPaintBits = 0; // ignore our paint fields
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "SkXfermodeImageFilter.h"
|
||||
#include "SkArithmeticImageFilter.h"
|
||||
#include "SkArithmeticModePriv.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkReadBuffer.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "Sk1DPathEffect.h"
|
||||
#include "Sk2DPathEffect.h"
|
||||
#include "SkAlphaThresholdFilter.h"
|
||||
#include "../../src/effects/SkArithmeticModePriv.h"
|
||||
#include "SkArcToPathEffect.h"
|
||||
#include "SkBitmapSourceDeserializer.h"
|
||||
#include "SkBlurImageFilter.h"
|
||||
@ -81,7 +80,6 @@ void SkFlattenable::PrivateInitializer::InitEffects() {
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilterRowMajor255)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLumaColorFilter)
|
||||
SkAlphaThresholdFilter::InitializeFlattenables();
|
||||
SkArithmeticMode::InitializeFlattenables();
|
||||
SkTableColorFilter::InitializeFlattenables();
|
||||
SkOverdrawColorFilter::InitializeFlattenables();
|
||||
SkHighContrastFilter::InitializeFlattenables();
|
||||
|
Loading…
Reference in New Issue
Block a user