Eliminate some clutter in SkFlattenable

The Registrar class is unnecessary, as SkFlattenable factory
registration is now handled via initialization routines that can just
call the Register function directly.

Also, no need to lazily initialize gCount to 0, as initializing an int
to a constant value does not require dynamic initialization.  (C++
actually guarantees zero initialization of global ints anyway, but
existing practice in Skia appears to favor the explicit "= 0").

Relatedly, this requires removing the unused/unimplemented
SkLayerDrawLooper::MyRegistrar class.  And removing that allows Clang
to realize that SkLayerDrawLooper::fTopRec is unneeded too, so remove
that too to squelch the compiler warning/error.

This doesn't change any public API.
TBR=reed@google.com

Review URL: https://codereview.chromium.org/1361323002
This commit is contained in:
mdempsky 2015-09-24 15:04:45 -07:00 committed by Commit bot
parent 8db65a6d0c
commit 00d6e515e5
4 changed files with 3 additions and 24 deletions

View File

@ -43,8 +43,8 @@ class SkPrivateEffectInitializer;
}
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
flattenable::GetFlattenableType());
SkFlattenable::Register(#flattenable, flattenable::CreateProc, \
flattenable::GetFlattenableType());
#define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable) \
private: \
@ -102,13 +102,6 @@ public:
static void Register(const char name[], Factory, Type);
class Registrar {
public:
Registrar(const char name[], Factory factory, Type type) {
SkFlattenable::Register(name, factory, type);
}
};
/**
* Override this if your subclass needs to record data that it will need to recreate itself
* from its CreateProc (returned by getFactory()).

View File

@ -94,7 +94,6 @@ private:
LayerInfo fInfo;
};
Rec* fRecs;
Rec* fTopRec;
int fCount;
// state-machine during the init/next cycle
@ -111,11 +110,6 @@ private:
static void ApplyInfo(SkPaint* dst, const SkPaint& src, const LayerInfo&);
};
class MyRegistrar : public SkFlattenable::Registrar {
public:
MyRegistrar();
};
typedef SkDrawLooper INHERITED;
public:

View File

@ -56,19 +56,12 @@ struct Entry {
SkFlattenable::Type fType;
};
static int gCount;
static int gCount = 0;
static Entry gEntries[MAX_ENTRY_COUNT];
void SkFlattenable::Register(const char name[], Factory factory, SkFlattenable::Type type) {
SkASSERT(name);
SkASSERT(factory);
static bool gOnce = false;
if (!gOnce) {
gCount = 0;
gOnce = true;
}
SkASSERT(gCount < MAX_ENTRY_COUNT);
gEntries[gCount].fName = name;

View File

@ -23,7 +23,6 @@ SkLayerDrawLooper::LayerInfo::LayerInfo() {
SkLayerDrawLooper::SkLayerDrawLooper()
: fRecs(nullptr),
fTopRec(nullptr),
fCount(0) {
}