Make flattenables no longer depend on global static initializers.

Instead, force all builds to call InitializeFlattenables.

Remove the make_debugger script, which was created to force
rebuilding without global static initializers so that all flattenables
would be linked. It is no longer necessary since all flattenables
will be linked thanks to InitializeFlattenables, which now can (and
must) be called when global static initializers are turned on.

BUG=https://code.google.com/p/skia/issues/detail?id=903
BUG=https://code.google.com/p/skia/issues/detail?id=902

Review URL: https://codereview.appspot.com/6548044

git-svn-id: http://skia.googlecode.com/svn/trunk@5642 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
scroggo@google.com 2012-09-21 17:54:46 +00:00
parent 251a7667d2
commit a0c2bc2438
43 changed files with 3 additions and 157 deletions

View File

@ -1,12 +0,0 @@
# Used to recompile required skia libraries with static initializers turned
# off. This fixes a bug in which the linux compiler was incorrectly stripping
# required global static methods in an optimization effort.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CWD=$SCRIPT_DIR/../
DEFINES="skia_static_initializers=0"
export GYP_DEFINES="$DEFINES"
make clean -C $CWD
make -C $CWD debugger -j

View File

@ -15,22 +15,6 @@
class SkFlattenableReadBuffer;
class SkFlattenableWriteBuffer;
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#define SK_DEFINE_FLATTENABLE_REGISTRAR(flattenable) \
static SkFlattenable::Registrar g##flattenable##Reg(#flattenable, \
flattenable::CreateProc);
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
static SkFlattenable::Registrar g##flattenable##Reg(#flattenable, \
flattenable::CreateProc);
#define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable)
#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
#else
#define SK_DEFINE_FLATTENABLE_REGISTRAR(flattenable)
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
SkFlattenable::Registrar(#flattenable, flattenable::CreateProc);
@ -42,8 +26,6 @@ class SkFlattenableWriteBuffer;
#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \
}
#endif
#define SK_DECLARE_UNFLATTENABLE_OBJECT() \
virtual Factory getFactory() SK_OVERRIDE { return NULL; }; \
@ -93,9 +75,7 @@ protected:
virtual void flatten(SkFlattenableWriteBuffer&) const;
private:
#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
static void InitializeFlattenables();
#endif
friend class SkGraphics;
friend class SkFlattenableWriteBuffer;

View File

@ -38,8 +38,6 @@ void SkAnnotation::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writeFlattenable(fDataSet);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkAnnotation)
const char* SkAnnotationKeys::URL_Key() {
return "SkAnnotationKey_URL";
};

View File

@ -299,8 +299,6 @@ SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
return shader;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkBitmapProcShader)
///////////////////////////////////////////////////////////////////////////////
static const char* gTileModeName[] = {

View File

@ -155,5 +155,3 @@ void SkColorTable::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writeUInt(fFlags);
buffer.writeColorArray(fColors, fCount);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorTable)

View File

@ -165,6 +165,3 @@ void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count) {
} while (count > 0);
}
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkComposeShader)

View File

@ -141,8 +141,6 @@ SkData::SkData(SkFlattenableReadBuffer& buffer) {
buffer.readByteArray(const_cast<void*>(fPtr));
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkData)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@ -302,5 +300,3 @@ SkDataSet* SkDataSet::NewEmpty() {
gEmptySet->ref();
return gEmptySet;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDataSet)

View File

@ -90,7 +90,7 @@ void SkFlattenable::Register(const char name[], Factory factory) {
gCount += 1;
}
#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS && defined(SK_DEBUG)
#ifdef SK_DEBUG
static void report_no_entries(const char* functionName) {
if (!gCount) {
SkDebugf("%s has no registered name/factory pairs."
@ -101,7 +101,7 @@ static void report_no_entries(const char* functionName) {
#endif
SkFlattenable::Factory SkFlattenable::NameToFactory(const char name[]) {
#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS && defined(SK_DEBUG)
#ifdef SK_DEBUG
report_no_entries(__FUNCTION__);
#endif
const Pair* pairs = gPairs;
@ -114,7 +114,7 @@ SkFlattenable::Factory SkFlattenable::NameToFactory(const char name[]) {
}
const char* SkFlattenable::FactoryToName(Factory fact) {
#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS && defined(SK_DEBUG)
#ifdef SK_DEBUG
report_no_entries(__FUNCTION__);
#endif
const Pair* pairs = gPairs;

View File

@ -52,9 +52,7 @@ void SkGraphics::GetVersion(int32_t* major, int32_t* minor, int32_t* patch) {
#endif
void SkGraphics::Init() {
#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
SkFlattenable::InitializeFlattenables();
#endif
#ifdef BUILD_EMBOSS_TABLE
SkEmbossMask_BuildTable();
#endif

View File

@ -64,5 +64,3 @@ SkMallocPixelRef::SkMallocPixelRef(SkFlattenableReadBuffer& buffer)
this->setPreLocked(fStorage, fCTable);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkMallocPixelRef)

View File

@ -171,9 +171,3 @@ bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
// use bit-or so that we always call both, even if the first one succeeds
return fPE0->filterPath(dst, src, rec) | fPE1->filterPath(dst, src, rec);
}
///////////////////////////////////////////////////////////////////////////////
SK_DEFINE_FLATTENABLE_REGISTRAR(SkComposePathEffect)
SK_DEFINE_FLATTENABLE_REGISTRAR(SkSumPathEffect)

View File

@ -332,8 +332,6 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
return kColor_GradientType;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorShader)
///////////////////////////////////////////////////////////////////////////////
#include "SkEmptyShader.h"
@ -355,5 +353,3 @@ void SkEmptyShader::shadeSpan16(int x, int y, uint16_t span[], int count) {
void SkEmptyShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
SkDEBUGFAIL("should never get called, since setContext() returned false");
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkEmptyShader)

View File

@ -197,8 +197,3 @@ SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance,
}
return fAdvance;
}
///////////////////////////////////////////////////////////////////////////////
SK_DEFINE_FLATTENABLE_REGISTRAR(SkPath1DPathEffect)

View File

@ -76,8 +76,6 @@ Sk2DPathEffect::Sk2DPathEffect(SkFlattenableReadBuffer& buffer) {
fMatrixIsInvertible = fMatrix.invert(&fInverse);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(Sk2DPathEffect)
///////////////////////////////////////////////////////////////////////////////
bool SkLine2DPathEffect::filterPath(SkPath *dst, const SkPath &src, SkStrokeRec *rec) {
@ -110,8 +108,6 @@ void SkLine2DPathEffect::flatten(SkFlattenableWriteBuffer &buffer) const {
buffer.writeScalar(fWidth);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkLine2DPathEffect)
///////////////////////////////////////////////////////////////////////////////
SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p)
@ -131,7 +127,3 @@ void SkPath2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) {
dst->addPath(fPath, loc.fX, loc.fY);
}
///////////////////////////////////////////////////////////////////////////////
SK_DEFINE_FLATTENABLE_REGISTRAR(SkPath2DPathEffect)

View File

@ -230,5 +230,3 @@ void SkAvoidXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count, co
{
// override in subclass
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkAvoidXfermode)

View File

@ -25,5 +25,3 @@ bool SkBitmapSource::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&,
*result = fBitmap;
return true;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkBitmapSource)

View File

@ -289,5 +289,3 @@ GrGLProgramStage::StageKey GrGLBlendEffect::GenKey(const GrCustomStage& s, const
return static_cast<const GrBlendEffect&>(s).mode();
}
#endif
SK_DEFINE_FLATTENABLE_REGISTRAR(SkBlendImageFilter)

View File

@ -115,8 +115,3 @@ bool SkBlurDrawLooper::next(SkCanvas* canvas, SkPaint* paint) {
return false;
}
}
///////////////////////////////////////////////////////////////////////////////
SK_DEFINE_FLATTENABLE_REGISTRAR(SkBlurDrawLooper)

View File

@ -197,5 +197,3 @@ GrTexture* SkBlurImageFilter::onFilterImageGPU(GrTexture* src, const SkRect& rec
return NULL;
#endif
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkBlurImageFilter)

View File

@ -52,6 +52,3 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
*result = device.get()->accessBitmap(false);
return true;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorFilterImageFilter)

View File

@ -317,5 +317,3 @@ bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) {
}
return true;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorMatrixFilter)

View File

@ -137,6 +137,3 @@ void SkCornerPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
SkCornerPathEffect::SkCornerPathEffect(SkFlattenableReadBuffer& buffer) {
fRadius = buffer.readScalar();
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkCornerPathEffect)

View File

@ -256,7 +256,3 @@ SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED(
fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * fCount);
buffer.readScalarArray(fIntervals);
}
///////////////////////////////////////////////////////////////////////////////
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDashPathEffect)

View File

@ -80,8 +80,3 @@ SkDiscretePathEffect::SkDiscretePathEffect(SkFlattenableReadBuffer& buffer) {
fSegLength = buffer.readScalar();
fPerterb = buffer.readScalar();
}
///////////////////////////////////////////////////////////////////////////////
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDiscretePathEffect)

View File

@ -131,5 +131,3 @@ void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
buffer.writeScalar(fBlurRadius);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkEmbossMaskFilter)

View File

@ -245,7 +245,3 @@ SkLayerDrawLooper::SkLayerDrawLooper(SkFlattenableReadBuffer& buffer)
}
#endif
}
///////////////////////////////////////////////////////////////////////////////
SK_DEFINE_FLATTENABLE_REGISTRAR(SkLayerDrawLooper)

View File

@ -169,6 +169,3 @@ void SkLayerRasterizer::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writePoint(rec->fOffset);
}
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkLayerRasterizer)

View File

@ -339,5 +339,3 @@ bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
}
return true;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkMagnifierImageFilter)

View File

@ -175,5 +175,3 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
filterBorderPixels(src, result, bottom);
return true;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkMatrixConvolutionImageFilter)

View File

@ -489,6 +489,3 @@ GrTexture* SkErodeImageFilter::onFilterImageGPU(GrTexture* src, const SkRect& re
}
#endif
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDilateImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR(SkErodeImageFilter)

View File

@ -28,5 +28,3 @@ SkPixelXorXfermode::SkPixelXorXfermode(SkFlattenableReadBuffer& rb)
: INHERITED(rb) {
fOpColor = rb.readColor();
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkPixelXorXfermode)

View File

@ -85,6 +85,3 @@ void SkPaintShape::flatten(SkFlattenableWriteBuffer& buffer) const {
SkPaintShape::SkPaintShape(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
buffer.readPaint(&fPaint);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkRectShape)

View File

@ -81,5 +81,3 @@ GrTexture* SkSingleInputImageFilter::getInputResultAsTexture(GrTexture* src,
return resultTex;
}
#endif
SK_DEFINE_FLATTENABLE_REGISTRAR(SkSingleInputImageFilter)

View File

@ -44,5 +44,3 @@ bool SkStippleMaskFilter::filterMask(SkMask* dst,
return true;
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkStippleMaskFilter)

View File

@ -343,8 +343,3 @@ void SkDownSampleImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
SkDownSampleImageFilter::SkDownSampleImageFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
fScale = buffer.readScalar();
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkOffsetImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR(SkComposeImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR(SkMergeImageFilter)
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDownSampleImageFilter)

View File

@ -125,5 +125,3 @@ void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count)
memcpy(span, src, count << 1);
}
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkTransparentShader)

View File

@ -37,5 +37,3 @@ SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer)
fData = (SkData*)buffer.readFlattenable();
this->setPreLocked(const_cast<void*>(fData->data()), NULL);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDataPixelRef)

View File

@ -75,8 +75,6 @@ SkFlipPixelRef::SkFlipPixelRef(SkFlattenableReadBuffer& buffer)
buffer.readByteArray(fPage0);
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkFlipPixelRef)
///////////////////////////////////////////////////////////////////////////////
static void copyRect(const SkBitmap& dst, const SkIRect& rect,

View File

@ -71,8 +71,6 @@ SkImageRef_GlobalPool::SkImageRef_GlobalPool(SkFlattenableReadBuffer& buffer)
this->mutex()->release();
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkImageRef_GlobalPool)
///////////////////////////////////////////////////////////////////////////////
// global imagerefpool wrappers

View File

@ -7,8 +7,6 @@
#include "SkTypes.h"
#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#include "SkBitmapProcShader.h"
#include "SkFlipPixelRef.h"
#include "SkImageRef_ashmem.h"
@ -99,5 +97,3 @@ void SkFlattenable::InitializeFlattenables() {
SkTableColorFilter::InitializeFlattenables();
SkXfermode::InitializeFlattenables();
}
#endif

View File

@ -231,5 +231,3 @@ SkImageRef_ashmem::SkImageRef_ashmem(SkFlattenableReadBuffer& buffer)
}
this->useDefaultMutex(); // we don't need/want the shared imageref mutex
}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkImageRef_ashmem)

View File

@ -59,6 +59,3 @@ uint16_t SkCosineMapper::mapUnit16(uint16_t input)
SkCosineMapper::SkCosineMapper(SkFlattenableReadBuffer& rb)
: SkUnitMapper(rb) {}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkDiscreteMapper)
SK_DEFINE_FLATTENABLE_REGISTRAR(SkCosineMapper)

View File

@ -27,11 +27,6 @@ int random_int(GrRandom* r, int count) {
return (int)(r->nextF() * count);
}
// min is inclusive, max is exclusive
int random_int(GrRandom* r, int min, int max) {
return (int)(r->nextF() * (max-min)) + min;
}
bool random_bool(GrRandom* r) {
return r->nextF() > .5f;
}