use sk_bzero instead of bzero, since it isn't always available.
git-svn-id: http://skia.googlecode.com/svn/trunk@244 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
4b7577b042
commit
4516f4786f
@ -3,7 +3,7 @@
|
||||
static void computeOuterProduct(SkScalar op[4],
|
||||
const SkPoint pts0[3], const SkPoint& ave0,
|
||||
const SkPoint pts1[3], const SkPoint& ave1) {
|
||||
bzero(op, 4 * sizeof(op[0]));
|
||||
sk_bzero(op, 4 * sizeof(op[0]));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
SkScalar x0 = pts0[i].fX - ave0.fX;
|
||||
SkScalar y0 = pts0[i].fY - ave0.fY;
|
||||
|
@ -31,7 +31,7 @@ static SkDScalar SkDScalar_setMul(SkScalar a, SkScalar b) {
|
||||
static void computeOuterProduct(SkScalar op[4],
|
||||
const SkPoint pts0[3], const SkPoint& ave0,
|
||||
const SkPoint pts1[3], const SkPoint& ave1) {
|
||||
bzero(op, 4 * sizeof(op[0]));
|
||||
sk_bzero(op, 4 * sizeof(op[0]));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
SkScalar x0 = pts0[i].fX - ave0.fX;
|
||||
SkScalar y0 = pts0[i].fY - ave0.fY;
|
||||
|
@ -17,7 +17,7 @@ static void computeOuterProduct(SkMatrix* matrix,
|
||||
const SkPoint pts0[3], const SkPoint& ave0,
|
||||
const SkPoint pts1[3], const SkPoint& ave1) {
|
||||
SkDScalar tmp[4];
|
||||
bzero(tmp, sizeof(tmp));
|
||||
sk_bzero(tmp, sizeof(tmp));
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
SkScalar x0 = pts0[i].fX - ave0.fX;
|
||||
|
@ -65,6 +65,11 @@ extern void* sk_realloc_throw(void* buffer, size_t size);
|
||||
*/
|
||||
extern void sk_free(void*);
|
||||
|
||||
// bzero is safer than memset, but we can't rely on it, so... sk_bzero()
|
||||
static inline void sk_bzero(void* buffer, size_t size) {
|
||||
memset(buffer, 0, size);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SK_INIT_TO_AVOID_WARNING = 0
|
||||
|
@ -52,7 +52,7 @@ static SkShader* make_shader1(const SkIPoint& size) {
|
||||
|
||||
class Patch {
|
||||
public:
|
||||
Patch() { bzero(fPts, sizeof(fPts)); }
|
||||
Patch() { sk_bzero(fPts, sizeof(fPts)); }
|
||||
~Patch() {}
|
||||
|
||||
void setPatch(const SkPoint pts[12]) {
|
||||
|
@ -84,12 +84,12 @@ struct SkBitmap::MipMap : SkNoncopyable {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkBitmap::SkBitmap() {
|
||||
bzero(this, sizeof(*this));
|
||||
sk_bzero(this, sizeof(*this));
|
||||
}
|
||||
|
||||
SkBitmap::SkBitmap(const SkBitmap& src) {
|
||||
SkDEBUGCODE(src.validate();)
|
||||
bzero(this, sizeof(*this));
|
||||
sk_bzero(this, sizeof(*this));
|
||||
*this = src;
|
||||
SkDEBUGCODE(this->validate();)
|
||||
}
|
||||
@ -153,7 +153,7 @@ void SkBitmap::swap(SkBitmap& other) {
|
||||
|
||||
void SkBitmap::reset() {
|
||||
this->freePixels();
|
||||
bzero(this, sizeof(*this));
|
||||
sk_bzero(this, sizeof(*this));
|
||||
}
|
||||
|
||||
int SkBitmap::ComputeBytesPerPixel(SkBitmap::Config config) {
|
||||
@ -1319,7 +1319,7 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
|
||||
SkBitmap::RLEPixels::RLEPixels(int width, int height) {
|
||||
fHeight = height;
|
||||
fYPtrs = (uint8_t**)sk_malloc_throw(height * sizeof(uint8_t*));
|
||||
bzero(fYPtrs, height * sizeof(uint8_t*));
|
||||
sk_bzero(fYPtrs, height * sizeof(uint8_t*));
|
||||
}
|
||||
|
||||
SkBitmap::RLEPixels::~RLEPixels() {
|
||||
|
@ -687,7 +687,7 @@ bool ConvertPointsToVertices(size_t numPts, const SkPoint *pts, Vertex *vta) {
|
||||
|
||||
// Clear everything.
|
||||
DebugPrintf("Zeroing vertices\n");
|
||||
bzero(vta, numPts * sizeof(*vta));
|
||||
sk_bzero(vta, numPts * sizeof(*vta));
|
||||
|
||||
// Initialize vertices.
|
||||
DebugPrintf("Initializing vertices\n");
|
||||
|
@ -151,7 +151,7 @@ SkDraw::SkDraw(const SkDraw& src) {
|
||||
typedef void (*BitmapXferProc)(void* pixels, size_t bytes, uint32_t data);
|
||||
|
||||
static void D_Clear_BitmapXferProc(void* pixels, size_t bytes, uint32_t) {
|
||||
bzero(pixels, bytes);
|
||||
sk_bzero(pixels, bytes);
|
||||
}
|
||||
|
||||
static void D_Dst_BitmapXferProc(void*, size_t, uint32_t data) {}
|
||||
|
@ -397,7 +397,7 @@ bool SkMatrix::setRectToRect(const SkRect& src, const SkRect& dst,
|
||||
}
|
||||
|
||||
if (dst.isEmpty()) {
|
||||
bzero(fMat, 8 * sizeof(SkScalar));
|
||||
sk_bzero(fMat, 8 * sizeof(SkScalar));
|
||||
this->setTypeMask(kScale_Mask | kRectStaysRect_Mask);
|
||||
} else {
|
||||
SkScalar tx, sx = SkScalarDiv(dst.width(), src.width());
|
||||
|
@ -246,7 +246,7 @@ void SkRefCntPlayback::setCount(int count) {
|
||||
|
||||
fCount = count;
|
||||
fArray = SkNEW_ARRAY(SkRefCnt*, count);
|
||||
bzero(fArray, count * sizeof(SkRefCnt*));
|
||||
sk_bzero(fArray, count * sizeof(SkRefCnt*));
|
||||
}
|
||||
|
||||
SkRefCnt* SkRefCntPlayback::set(int index, SkRefCnt* obj) {
|
||||
|
@ -67,7 +67,7 @@ void SkRect::set(const SkPoint pts[], int count)
|
||||
SkASSERT((pts && count > 0) || count == 0);
|
||||
|
||||
if (count <= 0) {
|
||||
bzero(this, sizeof(SkRect));
|
||||
sk_bzero(this, sizeof(SkRect));
|
||||
} else {
|
||||
#ifdef SK_SCALAR_SLOW_COMPARES
|
||||
int32_t l, t, r, b;
|
||||
|
@ -334,7 +334,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
|
||||
|
||||
glyph->toMask(&mask);
|
||||
mask.fFormat = SkMask::kA8_Format;
|
||||
bzero(glyph->fImage, mask.computeImageSize());
|
||||
sk_bzero(glyph->fImage, mask.computeImageSize());
|
||||
|
||||
if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, NULL,
|
||||
fMaskFilter, &mask,
|
||||
@ -364,7 +364,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
|
||||
bm.setConfig(config, glyph->fWidth, glyph->fHeight,
|
||||
glyph->rowBytes());
|
||||
bm.setPixels(glyph->fImage);
|
||||
bzero(glyph->fImage, bm.height() * bm.rowBytes());
|
||||
sk_bzero(glyph->fImage, bm.height() * bm.rowBytes());
|
||||
|
||||
draw.fClip = &clip;
|
||||
draw.fMatrix = &matrix;
|
||||
@ -400,7 +400,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
|
||||
}
|
||||
|
||||
// clean out our glyph, since it may be larger than dstM
|
||||
//bzero(dst, height * dstRB);
|
||||
//sk_bzero(dst, height * dstRB);
|
||||
|
||||
while (--height >= 0) {
|
||||
memcpy(dst, src, width);
|
||||
@ -576,10 +576,10 @@ protected:
|
||||
virtual void generateFontMetrics(SkPaint::FontMetrics* mx,
|
||||
SkPaint::FontMetrics* my) {
|
||||
if (mx) {
|
||||
bzero(mx, sizeof(*mx));
|
||||
sk_bzero(mx, sizeof(*mx));
|
||||
}
|
||||
if (my) {
|
||||
bzero(my, sizeof(*my));
|
||||
sk_bzero(my, sizeof(*my));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -120,7 +120,7 @@ void SkGL::Ortho(float left, float right, float bottom, float top,
|
||||
|
||||
float mat[16];
|
||||
|
||||
bzero(mat, sizeof(mat));
|
||||
sk_bzero(mat, sizeof(mat));
|
||||
|
||||
mat[0] = 2 / (right - left);
|
||||
mat[5] = 2 / (top - bottom);
|
||||
|
@ -193,12 +193,12 @@ struct SkGLMatrix {
|
||||
SkGLScalar fMat[16];
|
||||
|
||||
void reset() {
|
||||
bzero(fMat, sizeof(fMat));
|
||||
sk_bzero(fMat, sizeof(fMat));
|
||||
fMat[0] = fMat[5] = fMat[10] = fMat[15] = SK_GLScalar1;
|
||||
}
|
||||
|
||||
void set(const SkMatrix& m) {
|
||||
bzero(fMat, sizeof(fMat));
|
||||
sk_bzero(fMat, sizeof(fMat));
|
||||
fMat[0] = SkScalarToGL(m[SkMatrix::kMScaleX]);
|
||||
fMat[4] = SkScalarToGL(m[SkMatrix::kMSkewX]);
|
||||
fMat[12] = SkScalarToGL(m[SkMatrix::kMTransX]);
|
||||
|
@ -127,7 +127,7 @@ SkGLTextCache::Strike::addGlyphAndBind(const SkGlyph& glyph,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkGLTextCache::SkGLTextCache() {
|
||||
bzero(fStrikeList, sizeof(fStrikeList));
|
||||
sk_bzero(fStrikeList, sizeof(fStrikeList));
|
||||
}
|
||||
|
||||
SkGLTextCache::~SkGLTextCache() {
|
||||
@ -146,7 +146,7 @@ void SkGLTextCache::deleteAllStrikes(bool texturesAreValid) {
|
||||
strike = next;
|
||||
}
|
||||
}
|
||||
bzero(fStrikeList, sizeof(fStrikeList));
|
||||
sk_bzero(fStrikeList, sizeof(fStrikeList));
|
||||
}
|
||||
|
||||
SkGLTextCache::Strike* SkGLTextCache::findGlyph(const SkGlyph& glyph,
|
||||
|
@ -23,7 +23,7 @@ SkTextureCache::SkTextureCache(size_t countMax, size_t sizeMax)
|
||||
fTexCountMax(countMax), fTexSizeMax(sizeMax),
|
||||
fTexCount(0), fTexSize(0) {
|
||||
|
||||
bzero(fHash, sizeof(fHash));
|
||||
sk_bzero(fHash, sizeof(fHash));
|
||||
this->validate();
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ void SkTextureCache::deleteAllCaches(bool texturesAreValid) {
|
||||
}
|
||||
|
||||
fSorted.reset();
|
||||
bzero(fHash, sizeof(fHash));
|
||||
sk_bzero(fHash, sizeof(fHash));
|
||||
|
||||
fTexCount = 0;
|
||||
fTexSize = 0;
|
||||
|
@ -107,7 +107,7 @@ static bool getFrame(PVJpgDecoderInterface* codec, SkBitmap* bitmap,
|
||||
TPvJpgDecFrame frame;
|
||||
uint8* ptrs[3];
|
||||
int32 widths[3], heights[3];
|
||||
bzero(ptrs, sizeof(ptrs));
|
||||
sk_bzero(ptrs, sizeof(ptrs));
|
||||
frame.ptr = ptrs;
|
||||
frame.iWidth = widths;
|
||||
frame.iHeight = heights;
|
||||
|
@ -156,7 +156,7 @@ SkFaceRec::SkFaceRec(SkStream* strm, uint32_t fontID)
|
||||
: fSkStream(strm), fFontID(fontID) {
|
||||
// SkDEBUGF(("SkFaceRec: opening %s (%p)\n", key.c_str(), strm));
|
||||
|
||||
bzero(&fFTStream, sizeof(fFTStream));
|
||||
sk_bzero(&fFTStream, sizeof(fFTStream));
|
||||
fFTStream.size = fSkStream->getLength();
|
||||
fFTStream.descriptor.pointer = fSkStream;
|
||||
fFTStream.read = sk_stream_read;
|
||||
@ -754,10 +754,10 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
|
||||
if (this->setupSize()) {
|
||||
ERROR:
|
||||
if (mx) {
|
||||
bzero(mx, sizeof(SkPaint::FontMetrics));
|
||||
sk_bzero(mx, sizeof(SkPaint::FontMetrics));
|
||||
}
|
||||
if (my) {
|
||||
bzero(my, sizeof(SkPaint::FontMetrics));
|
||||
sk_bzero(my, sizeof(SkPaint::FontMetrics));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ void SkScalerContext_Mac::generateImage(const SkGlyph& glyph)
|
||||
SkAutoMutexAcquire ac(gFTMutex);
|
||||
SkASSERT(fLayout);
|
||||
|
||||
bzero(glyph.fImage, glyph.fHeight * glyph.rowBytes());
|
||||
sk_bzero(glyph.fImage, glyph.fHeight * glyph.rowBytes());
|
||||
CGContextRef contextRef = ::CGBitmapContextCreate(glyph.fImage,
|
||||
glyph.fWidth, glyph.fHeight, 8,
|
||||
glyph.rowBytes(), fGrayColorSpace,
|
||||
|
@ -9,7 +9,7 @@ Reporter::Reporter() {
|
||||
void Reporter::resetReporting() {
|
||||
fCurrTest = NULL;
|
||||
fTestCount = 0;
|
||||
bzero(fResultCount, sizeof(fResultCount));
|
||||
sk_bzero(fResultCount, sizeof(fResultCount));
|
||||
}
|
||||
|
||||
void Reporter::startTest(Test* test) {
|
||||
|
Loading…
Reference in New Issue
Block a user