aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkRefCnt.h18
-rw-r--r--samplecode/SampleDrawLooper.cpp24
-rw-r--r--samplecode/SampleFontScalerTest.cpp22
-rw-r--r--samplecode/SampleMovie.cpp12
-rw-r--r--samplecode/SamplePatch.cpp70
-rw-r--r--samplecode/SampleShaders.cpp34
-rw-r--r--samplecode/SampleText.cpp134
-rw-r--r--samplecode/SampleTextEffects.cpp64
-rw-r--r--samplecode/SampleTypeface.cpp22
-rw-r--r--samplecode/SampleVertices.cpp72
-rw-r--r--src/animator/SkDrawExtraPathEffect.cpp38
-rw-r--r--src/animator/SkDrawPaint.cpp46
-rw-r--r--src/core/SkBitmap.cpp8
-rw-r--r--src/core/SkBlitter.cpp584
-rw-r--r--src/core/SkBlitter_4444.cpp111
-rw-r--r--src/core/SkBlitter_A8.cpp233
-rw-r--r--src/core/SkBlitter_ARGB32.cpp26
-rw-r--r--src/core/SkCanvas.cpp4
-rw-r--r--src/core/SkComposeShader.cpp108
-rw-r--r--src/core/SkDraw.cpp9
-rw-r--r--src/core/SkFlattenable.cpp28
-rw-r--r--src/core/SkMallocPixelRef.cpp5
-rw-r--r--src/core/SkPaint.cpp97
-rw-r--r--src/core/SkPicture.cpp32
-rw-r--r--src/core/SkPicturePlayback.cpp146
-rw-r--r--src/core/SkPictureRecord.cpp78
-rw-r--r--src/core/SkScalerContext.cpp52
-rw-r--r--src/core/SkSpriteBlitter_ARGB32.cpp64
-rw-r--r--src/effects/SkBlurDrawLooper.cpp8
-rw-r--r--src/effects/SkGradientShader.cpp4
-rw-r--r--src/effects/SkLayerRasterizer.cpp42
-rw-r--r--src/images/SkImageDecoder.cpp6
-rw-r--r--src/images/SkImageRef.cpp10
-rw-r--r--src/pdf/SkPDFPage.cpp4
-rw-r--r--src/pdf/SkPDFTypes.cpp4
-rw-r--r--src/utils/SkDumpCanvas.cpp16
-rw-r--r--src/utils/SkProxyCanvas.cpp6
-rw-r--r--tests/Test.cpp2
38 files changed, 1063 insertions, 1180 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index be6ad0eeec..f109ead4c7 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -62,24 +62,6 @@ public:
SkDELETE(this);
}
}
-
- /** Helper version of ref(), that first checks to see if this is not null.
- If this is null, then do nothing.
- */
- void safeRef() const {
- if (this) {
- this->ref();
- }
- }
-
- /** Helper version of unref(), that first checks to see if this is not null.
- If this is null, then do nothing.
- */
- void safeUnref() const {
- if (this) {
- this->unref();
- }
- }
private:
mutable int32_t fRefCnt;
diff --git a/samplecode/SampleDrawLooper.cpp b/samplecode/SampleDrawLooper.cpp
index 7ea7b75b07..7cf53b2106 100644
--- a/samplecode/SampleDrawLooper.cpp
+++ b/samplecode/SampleDrawLooper.cpp
@@ -27,9 +27,9 @@ public:
{ SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 },
{ 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), 3 }
};
-
+
fLooper = new SkLayerDrawLooper;
-
+
for (int i = 0; i < SK_ARRAY_COUNT(gParams); i++) {
SkPaint* paint = fLooper->addLayer(gParams[i].fOffset,
gParams[i].fOffset);
@@ -45,11 +45,11 @@ public:
}
}
}
-
+
virtual ~LooperView() {
- fLooper->safeUnref();
+ SkSafeUnref(fLooper);
}
-
+
protected:
// overrides from SkEventSink
virtual bool onQuery(SkEvent* evt) {
@@ -59,18 +59,18 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFFDDDDDD);
// canvas->drawColor(SK_ColorWHITE);
}
-
+
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
-
+
SkPaint paint;
paint.setLooper(fLooper);
-
+
canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
SkIntToScalar(30), paint);
@@ -80,16 +80,16 @@ protected:
canvas->drawText("Looper", 6, SkIntToScalar(230), SkIntToScalar(100),
paint);
}
-
+
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
this->inval(NULL);
return this->INHERITED::onFindClickHandler(x, y);
}
-
+
virtual bool onClick(Click* click) {
return this->INHERITED::onClick(click);
}
-
+
private:
typedef SkView INHERITED;
};
diff --git a/samplecode/SampleFontScalerTest.cpp b/samplecode/SampleFontScalerTest.cpp
index d597a9adfb..de70292520 100644
--- a/samplecode/SampleFontScalerTest.cpp
+++ b/samplecode/SampleFontScalerTest.cpp
@@ -39,10 +39,10 @@ public:
gFaces[i].fStyle);
}
}
-
+
virtual ~FontScalerTestView() {
for (int i = 0; i < gFaceCount; i++) {
- fFaces[i]->safeUnref();
+ SkSafeUnref(fFaces[i]);
}
}
@@ -55,14 +55,14 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFFDDDDDD);
}
-
+
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
-
+
SkPaint paint;
// test handling of obscene cubic values (currently broken)
@@ -72,19 +72,19 @@ protected:
pts[1].set(-7.18397061e+15, -1.53091184e+13);
pts[2].set(-1.30077315e+16, -2.77196141e+13);
pts[3].set(-1.30077315e+16, -2.77196162e+13);
-
+
SkPath path;
path.moveTo(pts[0]);
path.cubicTo(pts[1], pts[2], pts[3]);
canvas->drawPath(path, paint);
}
-
+
canvas->translate(200, 20);
canvas->rotate(30);
paint.setAntiAlias(true);
- paint.setTypeface(SkTypeface::CreateFromName("Times Roman", SkTypeface::kNormal))->safeUnref();
-
+ SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromName("Times Roman", SkTypeface::kNormal)));
+
// const char* text = "abcdefghijklmnopqrstuvwxyz";
const char* text = "HnHnHnHnHnHnHnHnH";
size_t textLen = strlen(text);
@@ -99,7 +99,7 @@ protected:
r.set(0, 0, x, y*20);
canvas->drawRect(r, p);
}
-
+
int index = 0;
for (int ps = 9; ps <= 24; ps++) {
textLen = strlen(text);
@@ -109,7 +109,7 @@ protected:
index += 1;
}
}
-
+
private:
typedef SkView INHERITED;
};
diff --git a/samplecode/SampleMovie.cpp b/samplecode/SampleMovie.cpp
index ed1a844ced..af34198191 100644
--- a/samplecode/SampleMovie.cpp
+++ b/samplecode/SampleMovie.cpp
@@ -11,9 +11,9 @@ public:
AnimGifView() {
fMovie = SkMovie::DecodeFile("/skimages/dollarblk.gif");
}
-
+
virtual ~AnimGifView() {
- fMovie->safeUnref();
+ SkSafeUnref(fMovie);
}
protected:
@@ -25,14 +25,14 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFFDDDDDD);
}
-
+
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
-
+
if (fMovie) {
if (fMovie->duration()) {
fMovie->setTime(SkTime::GetMSecs() % fMovie->duration());
@@ -44,7 +44,7 @@ protected:
this->inval(NULL);
}
}
-
+
private:
SkRect fClip;
SkIPoint* fPoints;
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index fb70dbaf97..4203391c18 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -23,17 +23,17 @@
static void drawtriangle(SkCanvas* canvas, const SkPaint& paint,
const SkPoint pts[3]) {
SkPath path;
-
+
path.moveTo(pts[0]);
path.lineTo(pts[1]);
path.lineTo(pts[2]);
-
+
canvas->drawPath(path, paint);
}
static SkShader* make_shader0(SkIPoint* size) {
SkBitmap bm;
-
+
// SkImageDecoder::DecodeFile("/skimages/progressivejpg.jpg", &bm);
SkImageDecoder::DecodeFile("/skimages/logo.png", &bm);
size->set(bm.width(), bm.height());
@@ -54,7 +54,7 @@ class Patch {
public:
Patch() { sk_bzero(fPts, sizeof(fPts)); }
~Patch() {}
-
+
void setPatch(const SkPoint pts[12]) {
memcpy(fPts, pts, 12 * sizeof(SkPoint));
fPts[12] = pts[0]; // the last shall be first
@@ -63,7 +63,7 @@ public:
void draw(SkCanvas*, const SkPaint&, int segsU, int segsV,
bool doTextures, bool doColors);
-
+
private:
SkPoint fPts[13];
int fW, fH;
@@ -89,12 +89,12 @@ static void eval_sheet(const SkPoint edge[], int nu, int nv, int iu, int iv,
SkScalar u = SkIntToScalar(iu) / nu;
SkScalar v = SkIntToScalar(iv) / nv;
-
+
SkScalar uv = SkScalarMul(u, v);
SkScalar Uv = SkScalarMul(SK_Scalar1 - u, v);
SkScalar uV = SkScalarMul(u, SK_Scalar1 - v);
SkScalar UV = SkScalarMul(SK_Scalar1 - u, SK_Scalar1 - v);
-
+
SkScalar x0 = SkScalarMul(UV, edge[TL].fX) + SkScalarMul(uV, edge[TR].fX) +
SkScalarMul(Uv, edge[BL].fX) + SkScalarMul(uv, edge[BR].fX);
SkScalar y0 = SkScalarMul(UV, edge[TL].fY) + SkScalarMul(uV, edge[TR].fY) +
@@ -123,7 +123,7 @@ static int ScalarTo255(SkScalar v) {
static SkColor make_color(SkScalar s, SkScalar t) {
int cs = ScalarTo255(s);
- int ct = ScalarTo255(t);
+ int ct = ScalarTo255(t);
return SkColorSetARGB(0xFF, cs, 0, 0) + SkColorSetARGB(0, 0, ct, 0);
}
@@ -139,22 +139,22 @@ void Patch::draw(SkCanvas* canvas, const SkPaint& paint, int nu, int nv,
SkPoint* edge1 = edge0 + nu;
SkPoint* edge2 = edge1 + nv;
SkPoint* edge3 = edge2 + nu;
-
+
// evaluate the edge points
eval_patch_edge(fPts + 0, edge0, nu);
eval_patch_edge(fPts + 3, edge1, nv);
eval_patch_edge(fPts + 6, edge2, nu);
eval_patch_edge(fPts + 9, edge3, nv);
edge3[nv] = edge0[0]; // the last shall be first
-
+
for (i = 0; i < npts; i++) {
// canvas->drawLine(edge0[i].fX, edge0[i].fY, edge0[i+1].fX, edge0[i+1].fY, paint);
}
-
+
int row, vertCount = (nu + 1) * (nv + 1);
SkAutoTMalloc<SkPoint> vertStorage(vertCount);
SkPoint* verts = vertStorage.get();
-
+
// first row
memcpy(verts, edge0, (nu + 1) * sizeof(SkPoint));
// rows
@@ -172,9 +172,9 @@ void Patch::draw(SkCanvas* canvas, const SkPaint& paint, int nu, int nv,
for (i = 0; i <= nu; i++) {
last[i] = edge2[nu - i];
}
-
+
// canvas->drawPoints(verts, vertCount, paint);
-
+
int stripCount = (nu + 1) * 2;
SkAutoTMalloc<SkPoint> stripStorage(stripCount * 2);
SkAutoTMalloc<SkColor> colorStorage(stripCount);
@@ -226,8 +226,8 @@ class PatchView : public SkView {
SkShader* fShader1;
SkIPoint fSize0, fSize1;
SkPoint fPts[12];
-
-public:
+
+public:
PatchView() {
fShader0 = make_shader0(&fSize0);
fSize1 = fSize0;
@@ -251,12 +251,12 @@ public:
fPts[10].set(S*0, T*3);
fPts[11].set(S*0, T*2);
}
-
+
virtual ~PatchView() {
- fShader0->safeUnref();
- fShader1->safeUnref();
+ SkSafeUnref(fShader0);
+ SkSafeUnref(fShader1);
}
-
+
protected:
// overrides from SkEventSink
virtual bool onQuery(SkEvent* evt) {
@@ -268,22 +268,22 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorGRAY);
}
-
+
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
-
+
SkPaint paint;
paint.setDither(true);
paint.setFilterBitmap(true);
-
+
canvas->translate(SkIntToScalar(20), 0);
Patch patch;
-
+
paint.setShader(fShader0);
if (fSize0.fX == 0) {
fSize0.fX = 1;
@@ -292,33 +292,33 @@ protected:
fSize0.fY = 1;
}
patch.setBounds(fSize0.fX, fSize0.fY);
-
- patch.setPatch(fPts);
+
+ patch.setPatch(fPts);
drawpatches(canvas, paint, 10, 10, &patch);
-
+
paint.setShader(NULL);
paint.setAntiAlias(true);
paint.setStrokeWidth(SkIntToScalar(5));
canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fPts, paint);
-
+
canvas->translate(0, SkIntToScalar(300));
-
+
paint.setAntiAlias(false);
paint.setShader(fShader1);
patch.setBounds(fSize1.fX, fSize1.fY);
drawpatches(canvas, paint, 10, 10, &patch);
}
-
+
class PtClick : public Click {
public:
int fIndex;
PtClick(SkView* view, int index) : Click(view), fIndex(index) {}
};
-
+
static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) {
return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5);
}
-
+
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
for (int i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
if (hittest(fPts[i], x, y)) {
@@ -327,13 +327,13 @@ protected:
}
return this->INHERITED::onFindClickHandler(x, y);
}
-
+
virtual bool onClick(Click* click) {
fPts[((PtClick*)click)->fIndex].set(click->fCurr.fX, click->fCurr.fY);
this->inval(NULL);
return true;
}
-
+
private:
typedef SkView INHERITED;
};
diff --git a/samplecode/SampleShaders.cpp b/samplecode/SampleShaders.cpp
index 115f9f5bce..86c8b17e82 100644
--- a/samplecode/SampleShaders.cpp
+++ b/samplecode/SampleShaders.cpp
@@ -36,7 +36,7 @@ static SkShader* make_bitmapfade(const SkBitmap& bm)
shaderA->unref();
shaderB->unref();
mode->unref();
-
+
return shader;
}
@@ -51,19 +51,19 @@ public:
SkPoint pts[2];
SkColor colors[2];
-
+
pts[0].set(0, 0);
pts[1].set(SkIntToScalar(100), 0);
colors[0] = SK_ColorRED;
colors[1] = SK_ColorBLUE;
SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
-
+
pts[0].set(0, 0);
pts[1].set(0, SkIntToScalar(100));
colors[0] = SK_ColorBLACK;
colors[1] = SkColorSetARGB(0x80, 0, 0, 0);
SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
-
+
SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode);
fShader = new SkComposeShader(shaderA, shaderB, mode);
@@ -73,9 +73,9 @@ public:
}
virtual ~ShaderView()
{
- fShader->safeUnref();
+ SkSafeUnref(fShader);
}
-
+
protected:
// overrides from SkEventSink
virtual bool onQuery(SkEvent* evt) {
@@ -85,21 +85,21 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas)
{
// canvas->drawColor(0xFFDDDDDD);
canvas->drawColor(SK_ColorWHITE);
}
-
+
virtual void onDraw(SkCanvas* canvas)
{
this->drawBG(canvas);
-
+
canvas->drawBitmap(fBitmap, 0, 0);
-
+
canvas->translate(SkIntToScalar(20), SkIntToScalar(120));
-
+
SkPaint paint;
SkRect r;
@@ -120,22 +120,22 @@ protected:
canvas->drawRect(r, paint);
paint.setShader(make_bitmapfade(fBitmap))->unref();
canvas->drawRect(r, paint);
-
+
paint.setShader(new SkTransparentShader)->unref();
canvas->drawRect(r, paint);
}
-
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
+
+ virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
{
this->inval(NULL);
return this->INHERITED::onFindClickHandler(x, y);
}
-
- virtual bool onClick(Click* click)
+
+ virtual bool onClick(Click* click)
{
return this->INHERITED::onClick(click);
}
-
+
private:
typedef SkView INHERITED;
};
diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp
index abd88be113..b1bb6cbc9f 100644
--- a/samplecode/SampleText.cpp
+++ b/samplecode/SampleText.cpp
@@ -63,7 +63,7 @@ public:
{
int c = srcRows[1][1];
float f = c / 255.f;
-
+
if (c >= 0)
{
f = sqrtf(f);
@@ -96,7 +96,7 @@ static void test_typefaceCache()
SkTypeface* t1 = SkTypeface::CreateFromName(NULL, SkTypeface::kNormal);
SkTypeface* t2 = SkTypeface::CreateFromName("arial", SkTypeface::kNormal);
SkTypeface* t3 = SkTypeface::CreateFromName("helvetica", SkTypeface::kItalic);
-
+
SkASSERT(t0 == t1);
SkASSERT(t0 == t2);
SkASSERT(t0 == t3);
@@ -109,7 +109,7 @@ static void test_breakText()
const char* text = "sdfkljAKLDFJKEWkldfjlk#$%&sdfs.dsj";
size_t length = strlen(text);
SkScalar width = paint.measureText(text, length);
-
+
SkScalar mm = 0;
SkScalar nn = 0;
for (SkScalar w = 0; w <= width; w += SK_Scalar1)
@@ -117,10 +117,10 @@ static void test_breakText()
SkScalar m;
size_t n = paint.breakText(text, length, w, &m,
SkPaint::kBackward_TextBufferDirection);
-
+
SkASSERT(n <= length);
SkASSERT(m <= width);
-
+
if (n == 0)
SkASSERT(m == 0);
else
@@ -152,7 +152,7 @@ public:
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&);
-
+
// overrides for SkFlattenable
virtual Factory getFactory() { return Create; }
virtual void flatten(SkFlattenableWriteBuffer& b)
@@ -160,7 +160,7 @@ public:
// this->INHERITED::flatten(b); How can we know if this is legal????
b.write32(SkScalarToFixed(fExp));
}
-
+
private:
SkScalar fExp; // user's value
uint8_t fTable[256]; // cache
@@ -175,7 +175,7 @@ private:
{
return SkNEW_ARGS(SkPowerMode, (b));
}
-
+
typedef SkXfermode INHERITED;
};
@@ -183,7 +183,7 @@ void SkPowerMode::init(SkScalar e)
{
fExp = e;
float ee = SkScalarToFloat(e);
-
+
printf("------ %g\n", ee);
for (int i = 0; i < 256; i++)
{
@@ -231,7 +231,7 @@ static const struct {
static int count_char_points(const SkPaint& paint, char c)
{
SkPath path;
-
+
paint.getTextPath(&c, 1, 0, 0, &path);
return path.getPoints(NULL, 0);
}
@@ -264,7 +264,7 @@ static void make_badrgn(SkRegion* rgn, int insetAmount)
{
SkRect16 r, bounds;
int i;
-
+
rgn->setEmpty();
bounds.setEmpty();
@@ -281,7 +281,7 @@ static void make_badrgn(SkRegion* rgn, int insetAmount)
for (i = 0; i < SK_ARRAY_COUNT(badrects); i++)
{
- r.set(badrects[i].x, badrects[i].y, badrects[i].x + badrects[i].width, badrects[i].y + badrects[i].height);
+ r.set(badrects[i].x, badrects[i].y, badrects[i].x + badrects[i].width, badrects[i].y + badrects[i].height);
SkASSERT(rgn->contains(r));
}
}
@@ -291,7 +291,7 @@ static void draw_rgn(const SkRegion& rgn, SkCanvas* canvas, const SkPaint& paint
{
SkRect r;
SkRegion::Iterator iter(rgn);
-
+
for (; !iter.done(); iter.next())
{
r.set(iter.rect());
@@ -304,11 +304,11 @@ static void test_break(SkCanvas* canvas, const char text[], size_t length,
SkScalar clickX)
{
SkPaint linePaint;
-
+
linePaint.setAntiAlias(true);
-
+
SkScalar measured;
-
+
if (paint.breakText(text, length, clickX - x, &measured, SkPaint::kForward_TextBufferDirection))
{
linePaint.setColor(SK_ColorRED);
@@ -331,20 +331,20 @@ static void test_poly()
SkIntToScalar(5), SkIntToScalar(3),
SkIntToScalar(2), SkIntToScalar(3)
};
-
+
static const SkPoint src[] = {
SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(1), SkIntToScalar(0),
SkIntToScalar(1), SkIntToScalar(1),
SkIntToScalar(0), SkIntToScalar(1)
};
-
+
SkMatrix matrix;
-
+
if (matrix.setPolyToPoly(src, dst, 4))
{
SkPoint pt = { SK_Scalar1/2, SK_Scalar1/2 };
- matrix.mapPoints(&pt, 1);
+ matrix.mapPoints(&pt, 1);
printf("---- x = %g y = %g\n", SkScalarToFloat(pt.fX), SkScalarToFloat(pt.fY));
}
else
@@ -424,25 +424,25 @@ public:
printf("--- ave reduction = %g%%\n", 100. * (gOld - gNew) / gOld);
}
-
+
if (true)
{
SkPoint pts[] = { SkIntToScalar(20), 0, SkIntToScalar(256+20), 0 };
SkColor colors[] = { SkColorSetARGB(0, 255, 255, 255), SkColorSetARGB(255, 255, 255, 255) };
fGradient = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
}
-
+
fClickX = 0;
- test_breakText();
+ test_breakText();
test_typefaceCache();
// test_poly();
}
-
+
virtual ~TextSpeedView()
{
fGradient->unref();
- fMF->safeUnref();
+ SkSafeUnref(fMF);
}
protected:
@@ -456,36 +456,36 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas)
{
// canvas->drawColor(0xFFDDDDDD);
canvas->drawColor(SK_ColorWHITE);
// canvas->drawColor(SK_ColorBLACK);
}
-
+
static void make_textstrip(SkBitmap* bm)
{
bm->setConfig(SkBitmap::kRGB_565_Config, 200, 18);
bm->allocPixels();
bm->eraseColor(SK_ColorWHITE);
-
+
SkCanvas canvas(*bm);
SkPaint paint;
const char* s = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit";
-
+
paint.setFlags(paint.getFlags() | SkPaint::kAntiAlias_Flag
| SkPaint::kDevKernText_Flag);
paint.setTextSize(SkIntToScalar(14));
canvas.drawText(s, strlen(s), SkIntToScalar(8), SkIntToScalar(14), paint);
}
-
+
static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand)
{
for (size_t i = 0; i < n; i++)
pts[i].set(rand->nextUScalar1() * 640, rand->nextUScalar1() * 480);
}
-
+
virtual void onDraw(SkCanvas* canvas)
{
inval(NULL);
@@ -494,22 +494,22 @@ protected:
canvas->translate(SkIntToScalar(480), 0);
canvas->rotate(SkIntToScalar(90));
}
-
+
this->drawBG(canvas);
-
+
if (false)
{
SkPaint p;
-
+
p.setAntiAlias(true);
p.setSubpixelText(true);
// p.setLinearText(true);
-
+
SkScalar size = SkIntToScalar(6);
SkMSec dur = 0;
const int LOOP = 16;
const int TIMES = 10;
-
+
for (int times = 0; times < TIMES; times++)
{
SkMSec now = SkTime::GetMSecs();
@@ -522,12 +522,12 @@ protected:
dur += SkTime::GetMSecs() - now;
SkGraphics::SetFontCacheUsed(0);
}
-
+
printf("----- duration = %g\n", dur * 1.0 / TIMES);
this->inval(NULL);
return;
}
-
+
if (false)
{
SkPaint p;
@@ -552,7 +552,7 @@ protected:
}
}
}
-
+
if (false)
{
SkPaint p;
@@ -569,11 +569,11 @@ protected:
#endif
return;
}
-
+
if (false)
{
SkBitmap bm;
-
+
make_textstrip(&bm);
canvas->translate(0, SkIntToScalar(50));
for (int i = 0; i < 10; i++)
@@ -582,16 +582,16 @@ protected:
SkPowerMode mode(SkFloatToScalar(1 / gamma));
SkPaint p;
p.setXfermode(&mode);
-
+
canvas->drawBitmap(bm, 0, SkIntToScalar(i) * bm.height(), &p);
}
return;
}
-
+
if (false)
{
SkPaint paint;
-
+
paint.setAntiAlias(true);
paint.setDevKernText(true);
SkMSec now = SkTime::GetMSecs();
@@ -609,9 +609,9 @@ protected:
SkRegion rgn;
SkPath path;
SkPaint paint;
-
+
// make_badrgn(&rgn, -2);
-
+
if (false)
{
paint.setColor(SK_ColorBLUE);
@@ -619,7 +619,7 @@ protected:
}
paint.setColor(SK_ColorRED);
draw_rgn(rgn, canvas, paint);
-
+
rgn.getBoundaryPath(&path);
paint.setARGB(0x80, 0, 0, 0xFF);
canvas->drawPath(path, paint);
@@ -630,13 +630,13 @@ protected:
{
SkRect r = { SkIntToScalar(50), SkIntToScalar(50), SkIntToScalar(300), SkIntToScalar(300) };
SkPaint p;
-
+
p.setStyle(SkPaint::kStroke_Style);
p.setAlpha(0x80);
p.setStrokeWidth(SkIntToScalar(20));
canvas->drawRect(r, p);
}
-
+
if (false)
{
SkPaint p;
@@ -648,7 +648,7 @@ protected:
canvas->drawRect(r, p);
return;
}
-
+
if (false)
{
Sk64 aa, bb;
@@ -661,19 +661,19 @@ protected:
b = a >> 16;
// SkFixed c = aa.addGetFixed(bb);
-
+
printf("%d %d\n", (int)a, a >> 32);
-
+
SkBitmap bm;
SkPaint paint;
SkScalar scale = SkFloatToScalar(0.5625f);
SkScalar x = SkIntToScalar(100);
SkScalar y = SkIntToScalar(100);
-
+
//paint.setFilterType(SkPaint::kBilinear_FilterType);
-
+
SkImageDecoder::DecodeFile("/app_web_browser.png", &bm);
-
+
// canvas->drawBitmap(bm, x, y, paint);
x += SkIntToScalar(100);
canvas->save();
@@ -691,7 +691,7 @@ protected:
canvas->restore();
return;
}
-
+
SkAutoCanvasRestore restore(canvas, false);
{
SkRect r;
@@ -704,7 +704,7 @@ protected:
int index = fHints % SK_ARRAY_COUNT(gHints);
index = 1;
// const char* style = gHints[index].fName;
-
+
// canvas->translate(0, SkIntToScalar(50));
// canvas->drawText(style, strlen(style), SkIntToScalar(20), SkIntToScalar(20), paint);
@@ -712,20 +712,20 @@ protected:
SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromFile("/skimages/samplefont.ttf")));
paint.setAntiAlias(true);
paint.setFlags(paint.getFlags() | gHints[index].fFlags);
-
+
SkMSec now = 0;
if (REPEAT_COUNT > 1)
now = SkTime::GetMSecs();
SkRect clip;
clip.set(SkIntToScalar(25), SkIntToScalar(34), SkIntToScalar(88), SkIntToScalar(155));
-
+
if (0) {
canvas->clipRect(clip);
}
if (0) {
- SkPath clipPath;
+ SkPath clipPath;
clipPath.addOval(clip);
canvas->clipPath(clipPath);
}
@@ -736,7 +736,7 @@ protected:
#ifdef TEST_CLICKX
{
SkPaint p;
-
+
p.setColor(SK_ColorGREEN);
p.setAntiAlias(true);
canvas->drawLine(fClickX, 0, fClickX, SkIntToScalar(1000), p);
@@ -758,26 +758,26 @@ protected:
// SkGraphics::SetFontCacheUsed(0);
}
}
-
+
if (REPEAT_COUNT > 1)
{
printf("--------- FPS = %g\n", REPEAT_COUNT * 1000. / (SkTime::GetMSecs() - now));
this->inval(NULL);
}
}
-
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
+
+ virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
{
fClickX = x;
this->inval(NULL);
return this->INHERITED::onFindClickHandler(x, y);
}
-
- virtual bool onClick(Click* click)
+
+ virtual bool onClick(Click* click)
{
return this->INHERITED::onClick(click);
}
-
+
private:
int fHints;
SkScalar fClickX;
diff --git a/samplecode/SampleTextEffects.cpp b/samplecode/SampleTextEffects.cpp
index b71f5b4c03..77a3bd795a 100644
--- a/samplecode/SampleTextEffects.cpp
+++ b/samplecode/SampleTextEffects.cpp
@@ -16,9 +16,9 @@ static inline SkPMColor rgb2gray(SkPMColor c)
unsigned r = SkGetPackedR32(c);
unsigned g = SkGetPackedG32(c);
unsigned b = SkGetPackedB32(c);
-
+
unsigned x = r * 5 + g * 7 + b * 4 >> 4;
-
+
return SkPackARGB32(0, x, x, x) | (c & (SK_A32_MASK << SK_A32_SHIFT));
}
@@ -44,7 +44,7 @@ public:
for (int i = 0; i < count; i++)
result[i] = src[i] & mask;
}
-
+
private:
SkPMColor fMask;
};
@@ -82,7 +82,7 @@ static void r1(SkLayerRasterizer* rast, SkPaint& p)
p.setStrokeWidth(SK_Scalar1*2);
rast->addLayer(p);
}
-
+
static void r2(SkLayerRasterizer* rast, SkPaint& p)
{
p.setStyle(SkPaint::kStrokeAndFill_Style);
@@ -134,7 +134,7 @@ static void r5(SkLayerRasterizer* rast, SkPaint& p)
static void r6(SkLayerRasterizer* rast, SkPaint& p)
{
rast->addLayer(p);
-
+
p.setAntiAlias(false);
SkLayerRasterizer* rast2 = new SkLayerRasterizer;
r5(rast2, p);
@@ -153,7 +153,7 @@ public:
virtual void flatten(SkFlattenableWriteBuffer& buffer)
{
this->INHERITED::flatten(buffer);
-
+
buffer.writeScalar(fRadius);
}
virtual Factory getFactory() { return CreateProc; }
@@ -163,7 +163,7 @@ protected:
{
dst->addCircle(loc.fX, loc.fY, fRadius);
}
-
+
Dot2DPathEffect(SkFlattenableReadBuffer& buffer) : Sk2DPathEffect(buffer)
{
fRadius = buffer.readScalar();
@@ -191,7 +191,7 @@ static void r7(SkLayerRasterizer* rast, SkPaint& p)
static void r8(SkLayerRasterizer* rast, SkPaint& p)
{
rast->addLayer(p);
-
+
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
@@ -220,7 +220,7 @@ public:
}
return false;
}
-
+
virtual Factory getFactory() { return CreateProc; }
virtual void flatten(SkFlattenableWriteBuffer& buffer)
{
@@ -239,17 +239,17 @@ protected:
src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf,
SkIntToScalar(v) + SK_ScalarHalf);
this->getMatrix().mapPoints(dstP, src, 2);
-
+
dst->moveTo(dstP[0]);
dst->lineTo(dstP[1]);
}
}
-
+
Line2DPathEffect(SkFlattenableReadBuffer& buffer) : Sk2DPathEffect(buffer)
{
fWidth = buffer.readScalar();
}
-
+
private:
SkScalar fWidth;
@@ -264,7 +264,7 @@ private:
static void r9(SkLayerRasterizer* rast, SkPaint& p)
{
rast->addLayer(p);
-
+
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
@@ -302,7 +302,7 @@ static unsigned color_dist16(uint16_t a, uint16_t b)
unsigned dr = SkAbs32(SkPacked16ToR32(a) - SkPacked16ToR32(b));
unsigned dg = SkAbs32(SkPacked16ToG32(a) - SkPacked16ToG32(b));
unsigned db = SkAbs32(SkPacked16ToB32(a) - SkPacked16ToB32(b));
-
+
return SkMax32(dr, SkMax32(dg, db));
}
@@ -317,7 +317,7 @@ static unsigned scale_dist(unsigned dist, unsigned scale)
}
static void apply_shader(SkPaint* paint, int index)
-{
+{
raster_proc proc = gRastProcs[index];
if (proc)
{
@@ -331,7 +331,7 @@ static void apply_shader(SkPaint* paint, int index)
#if 0
SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 };
- paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir, SK_Scalar1/4, SkIntToScalar(4), SkIntToScalar(3)))->unref();
+ paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir, SK_Scalar1/4, SkIntToScalar(4), SkIntToScalar(3)))->unref();
#endif
paint->setColor(SK_ColorBLUE);
}
@@ -345,10 +345,10 @@ public:
{
fFace = SkTypeface::CreateFromFile("/Users/reed/Downloads/p052024l.pfb");
}
-
+
virtual ~TextEffectView()
{
- fFace->safeUnref();
+ SkSafeUnref(fFace);
}
protected:
@@ -362,22 +362,22 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas)
{
// canvas->drawColor(0xFFDDDDDD);
canvas->drawColor(SK_ColorWHITE);
}
-
+
virtual void onDraw(SkCanvas* canvas)
{
this->drawBG(canvas);
-
+
canvas->save();
// canvas->scale(SK_Scalar1*2, SK_Scalar1*2, 0, 0);
SkPaint paint;
-
+
paint.setAntiAlias(true);
paint.setTextSize(SkIntToScalar(56));
paint.setTypeface(SkTypeface::CreateFromName("sans-serif",
@@ -389,11 +389,11 @@ protected:
SkString str("TextEffects");
paint.setTypeface(fFace);
-
+
for (int i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++)
{
apply_shader(&paint, i);
-
+
// paint.setMaskFilter(NULL);
// paint.setColor(SK_ColorBLACK);
@@ -403,7 +403,7 @@ protected:
gLightingColors[index].fMul,
gLightingColors[index].fAdd))->unref();
#endif
-
+
canvas->drawText(str.c_str(), str.size(), x, y, paint);
if (0)
@@ -417,7 +417,7 @@ protected:
}
canvas->restore();
-
+
if (0)
{
SkPoint pts[] = { 0, 0, 0, SkIntToScalar(150) };
@@ -428,7 +428,7 @@ protected:
paint.setShader(s);
canvas->drawRectCoords(0, 0, SkIntToScalar(120), SkIntToScalar(150), paint);
}
-
+
if (0)
{
SkAvoidXfermode mode(SK_ColorWHITE, 0xFF,
@@ -442,20 +442,20 @@ protected:
canvas->drawOval(r, paint);
}
}
-
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
+
+ virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
{
gRastIndex = (gRastIndex + 1) % SK_ARRAY_COUNT(gRastProcs);
this->inval(NULL);
return this->INHERITED::onFindClickHandler(x, y);
}
-
- virtual bool onClick(Click* click)
+
+ virtual bool onClick(Click* click)
{
return this->INHERITED::onClick(click);
}
-
+
private:
typedef SkView INHERITED;
};
diff --git a/samplecode/SampleTypeface.cpp b/samplecode/SampleTypeface.cpp
index fa2f5463a5..96082af5f6 100644
--- a/samplecode/SampleTypeface.cpp
+++ b/samplecode/SampleTypeface.cpp
@@ -70,10 +70,10 @@ public:
gFaces[i].fStyle);
}
}
-
+
virtual ~TypefaceView() {
for (int i = 0; i < gFaceCount; i++) {
- fFaces[i]->safeUnref();
+ SkSafeUnref(fFaces[i]);
}
}
@@ -86,11 +86,11 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas) {
canvas->drawColor(0xFFDDDDDD);
}
-
+
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
@@ -105,17 +105,17 @@ protected:
const char* text = "Hamburgefons";
const size_t textLen = strlen(text);
-
+
SkScalar x = SkIntToScalar(10);
SkScalar dy = paint.getFontMetrics(NULL);
SkScalar y = dy;
-
+
for (int i = 0; i < gFaceCount; i++) {
paint.setTypeface(fFaces[i]);
canvas->drawText(text, textLen, x, y, paint);
y += dy;
}
-
+
SkRect r;
if (false) {
r.set(10, 10, 100, 100);
@@ -132,7 +132,7 @@ protected:
paint.setStyle(SkPaint::kFill_Style);
canvas->drawRect(r, paint);
}
-
+
if (false) {
SkScalar rad = 90;
SkScalar angle = 210;
@@ -142,12 +142,12 @@ protected:
SkPath path;
path.arcTo(r, angle, -(angle + 90), true);
path.close();
-
+
paint.setColor(SK_ColorRED);
canvas->drawRect(path.getBounds(), paint);
paint.setColor(SK_ColorBLUE);
canvas->drawPath(path, paint);
-
+
paint.setColor(SK_ColorGREEN);
SkPoint pts[100];
int count = path.getPoints(pts, 100);
@@ -155,7 +155,7 @@ protected:
canvas->drawPoints(SkCanvas::kPoints_PointMode, count, pts, paint);
}
}
-
+
private:
typedef SkView INHERITED;
};
diff --git a/samplecode/SampleVertices.cpp b/samplecode/SampleVertices.cpp
index 96fa0daab6..7f5aa9665b 100644
--- a/samplecode/SampleVertices.cpp
+++ b/samplecode/SampleVertices.cpp
@@ -21,7 +21,7 @@
static SkShader* make_shader0(SkIPoint* size) {
SkBitmap bm;
-
+
SkImageDecoder::DecodeFile("/skimages/logo.png", &bm);
size->set(bm.width(), bm.height());
return SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
@@ -39,25 +39,25 @@ class VerticesView : public SkView {
SkShader* fShader0;
SkShader* fShader1;
-public:
+public:
VerticesView() {
SkIPoint size;
-
+
fShader0 = make_shader0(&size);
fShader1 = make_shader1(size);
make_strip(&fRecs[0], size.fX, size.fY);
make_fan(&fRecs[1], size.fX, size.fY);
make_tris(&fRecs[2]);
-
+
fScale = SK_Scalar1;
}
-
+
virtual ~VerticesView() {
- fShader0->safeUnref();
- fShader1->safeUnref();
+ SkSafeUnref(fShader0);
+ SkSafeUnref(fShader1);
}
-
+
protected:
// overrides from SkEventSink
virtual bool onQuery(SkEvent* evt) {
@@ -69,65 +69,65 @@ protected:
}
return this->INHERITED::onQuery(evt);
}
-
+
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorGRAY);
}
-
+
SkScalar fScale;
-
+
virtual void onDraw(SkCanvas* canvas) {
this->drawBG(canvas);
-
+
SkPaint paint;
paint.setDither(true);
paint.setFilterBitmap(true);
-
+
for (int i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
canvas->save();
-
+
paint.setShader(NULL);
canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
NULL, NULL, NULL, 0, paint);
-
+
canvas->translate(SkIntToScalar(250), 0);
-
+
paint.setShader(fShader0);
canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
NULL, NULL, NULL, 0, paint);
canvas->translate(SkIntToScalar(250), 0);
-
+
paint.setShader(fShader1);
canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
fRecs[i].fVerts, fRecs[i].fTexs,
NULL, NULL, NULL, 0, paint);
canvas->restore();
-
+
canvas->translate(0, SkIntToScalar(250));
}
}
-
+
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
return new Click(this);
}
-
+
virtual bool onClick(Click* click) {
// fCurrX = click->fICurr.fX;
// fCurrY = click->fICurr.fY;
this->inval(NULL);
return true;
}
-
+
private:
struct Rec {
SkCanvas::VertexMode fMode;
int fCount;
SkPoint* fVerts;
SkPoint* fTexs;
-
+
Rec() : fCount(0), fVerts(NULL), fTexs(NULL) {}
~Rec() { delete[] fVerts; delete[] fTexs; }
};
@@ -135,11 +135,11 @@ private:
void make_tris(Rec* rec) {
int n = 10;
SkRandom rand;
-
+
rec->fMode = SkCanvas::kTriangles_VertexMode;
rec->fCount = n * 3;
rec->fVerts = new SkPoint[rec->fCount];
-
+
for (int i = 0; i < n; i++) {
SkPoint* v = &rec->fVerts[i*3];
for (int j = 0; j < 3; j++) {
@@ -147,17 +147,17 @@ private:
}
}
}
-
+
void make_fan(Rec* rec, int texWidth, int texHeight) {
const SkScalar tx = SkIntToScalar(texWidth);
const SkScalar ty = SkIntToScalar(texHeight);
const int n = 24;
-
+
rec->fMode = SkCanvas::kTriangleFan_VertexMode;
rec->fCount = n + 2;
rec->fVerts = new SkPoint[rec->fCount];
rec->fTexs = new SkPoint[rec->fCount];
-
+
SkPoint* v = rec->fVerts;
SkPoint* t = rec->fTexs;
@@ -171,47 +171,47 @@ private:
}
v[n+1] = v[1];
t[n+1].set(tx, ty);
-
+
SkMatrix m;
m.setScale(SkIntToScalar(100), SkIntToScalar(100));
m.postTranslate(SkIntToScalar(110), SkIntToScalar(110));
m.mapPoints(v, rec->fCount);
}
-
+
void make_strip(Rec* rec, int texWidth, int texHeight) {
const SkScalar tx = SkIntToScalar(texWidth);
const SkScalar ty = SkIntToScalar(texHeight);
const int n = 24;
-
+
rec->fMode = SkCanvas::kTriangleStrip_VertexMode;
rec->fCount = 2 * (n + 1);
rec->fVerts = new SkPoint[rec->fCount];
rec->fTexs = new SkPoint[rec->fCount];
-
+
SkPoint* v = rec->fVerts;
SkPoint* t = rec->fTexs;
-
+
for (int i = 0; i < n; i++) {
SkScalar cos;
SkScalar sin = SkScalarSinCos(SK_ScalarPI * 2 * i / n, &cos);
v[i*2 + 0].set(cos/2, sin/2);
v[i*2 + 1].set(cos, sin);
-
+
t[i*2 + 0].set(tx * i / n, ty);
t[i*2 + 1].set(tx * i / n, 0);
}
v[2*n + 0] = v[0];
v[2*n + 1] = v[1];
-
+
t[2*n + 0].set(tx, ty);
t[2*n + 1].set(tx, 0);
-
+
SkMatrix m;
m.setScale(SkIntToScalar(100), SkIntToScalar(100));
m.postTranslate(SkIntToScalar(110), SkIntToScalar(110));
m.mapPoints(v, rec->fCount);
}
-
+
Rec fRecs[3];
typedef SkView INHERITED;
diff --git a/src/animator/SkDrawExtraPathEffect.cpp b/src/animator/SkDrawExtraPathEffect.cpp
index 4cca73832f..76b55c68d1 100644
--- a/src/animator/SkDrawExtraPathEffect.cpp
+++ b/src/animator/SkDrawExtraPathEffect.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -70,7 +70,7 @@ class SkDrawComposePathEffect : public SkDrawPathEffect {
virtual ~SkDrawComposePathEffect();
virtual bool add(SkAnimateMaker& , SkDisplayable* );
virtual SkPathEffect* getPathEffect();
- virtual bool isPaint() const;
+ virtual bool isPaint() const;
private:
SkDrawPathEffect* effect1;
SkDrawPathEffect* effect2;
@@ -127,7 +127,7 @@ protected:
m.reset();
if (fDraw->addMatrix) {
SkDrawMatrix* matrix;
- if (fDraw->addMatrix->getType() == SkType_Matrix)
+ if (fDraw->addMatrix->getType() == SkType_Matrix)
matrix = (SkDrawMatrix*) fDraw->addMatrix;
else {
SkApply* apply = (SkApply*) fDraw->addMatrix;
@@ -185,12 +185,12 @@ const SkMemberInfo SkDrawShapePathEffect::fInfo[] = {
DEFINE_GET_MEMBER(SkDrawShapePathEffect);
-SkDrawShapePathEffect::SkDrawShapePathEffect() :
+SkDrawShapePathEffect::SkDrawShapePathEffect() :
addPath(NULL), addMatrix(NULL), path(NULL), fPathEffect(NULL) {
}
SkDrawShapePathEffect::~SkDrawShapePathEffect() {
- fPathEffect->safeUnref();
+ SkSafeUnref(fPathEffect);
}
bool SkDrawShapePathEffect::add(SkAnimateMaker& , SkDisplayable* child) {
@@ -234,7 +234,7 @@ void SkDrawShape1DPathEffect::onEndElement(SkAnimateMaker& maker) {
class SkShape2DPathEffect : public Sk2DPathEffect {
public:
- SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker,
+ SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker,
const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(maker) {
}
@@ -265,7 +265,7 @@ protected:
goto clearCallBack;
if (fDraw->matrix) {
SkDrawMatrix* matrix;
- if (fDraw->matrix->getType() == SkType_Matrix)
+ if (fDraw->matrix->getType() == SkType_Matrix)
matrix = (SkDrawMatrix*) fDraw->matrix;
else {
SkApply* apply = (SkApply*) fDraw->matrix;
@@ -301,7 +301,7 @@ private:
}
return true;
}
-
+
SkPoint fLoc;
SkRect fUVBounds;
int32_t fU;
@@ -418,13 +418,13 @@ const char kDrawCornerPathEffectName[] = "pathEffect:corner";
class SkExtraPathEffects : public SkExtras {
public:
- SkExtraPathEffects(SkAnimator* animator) :
+ SkExtraPathEffects(SkAnimator* animator) :
skDrawShape1DPathEffectType(SkType_Unknown),
skDrawShape2DPathEffectType(SkType_Unknown),
skDrawComposePathEffectType(SkType_Unknown),
skDrawCornerPathEffectType(SkType_Unknown) {
}
-
+
virtual SkDisplayable* createInstance(SkDisplayTypes type) {
SkDisplayable* result = NULL;
if (skDrawShape1DPathEffectType == type)
@@ -439,8 +439,8 @@ public:
}
virtual bool definesType(SkDisplayTypes type) {
- return type == skDrawShape1DPathEffectType ||
- type == skDrawShape2DPathEffectType ||
+ return type == skDrawShape1DPathEffectType ||
+ type == skDrawShape2DPathEffectType ||
type == skDrawComposePathEffectType ||
type == skDrawCornerPathEffectType;
}
diff --git a/src/animator/SkDrawPaint.cpp b/src/animator/SkDrawPaint.cpp
index 0c23771240..f21a15a10e 100644
--- a/src/animator/SkDrawPaint.cpp
+++ b/src/animator/SkDrawPaint.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -77,11 +77,11 @@ DEFINE_GET_MEMBER(SkDrawPaint);
SkDrawPaint::SkDrawPaint() : antiAlias(-1), color(NULL), fakeBold(-1), filterBitmap(-1),
linearText(-1), maskFilter((SkDrawMaskFilter*) -1), pathEffect((SkDrawPathEffect*) -1),
shader((SkDrawShader*) -1), strikeThru(-1), stroke(-1),
- strokeCap((SkPaint::Cap) -1), strokeJoin((SkPaint::Join) -1), strokeMiter(SK_ScalarNaN),
+ strokeCap((SkPaint::Cap) -1), strokeJoin((SkPaint::Join) -1), strokeMiter(SK_ScalarNaN),
strokeWidth(SK_ScalarNaN), style((SkPaint::Style) -1),
- textAlign((SkPaint::Align) -1), textScaleX(SK_ScalarNaN), textSize(SK_ScalarNaN),
+ textAlign((SkPaint::Align) -1), textScaleX(SK_ScalarNaN), textSize(SK_ScalarNaN),
textSkewX(SK_ScalarNaN), typeface((SkDrawTypeface*) -1),
- underline(-1), xfermode((SkXfermode::Mode) -1), fOwnsColor(false), fOwnsMaskFilter(false),
+ underline(-1), xfermode((SkXfermode::Mode) -1), fOwnsColor(false), fOwnsMaskFilter(false),
fOwnsPathEffect(false), fOwnsShader(false), fOwnsTypeface(false) {
}
@@ -102,7 +102,7 @@ bool SkDrawPaint::add(SkAnimateMaker& maker, SkDisplayable* child) {
SkASSERT(child && child->isPaintPart());
SkPaintPart* part = (SkPaintPart*) child;
if (part->add())
- maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint);
+ maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint);
return true;
}
@@ -154,8 +154,8 @@ void SkDrawPaint::dump(SkAnimateMaker* maker) {
dumpChildren(maker, closedYet);
}
#endif
-
-void SkDrawPaint::executeFunction(SkDisplayable* target, int index,
+
+void SkDrawPaint::executeFunction(SkDisplayable* target, int index,
SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
SkScriptValue* scriptValue) {
if (scriptValue == NULL)
@@ -169,9 +169,9 @@ void SkDrawPaint::executeFunction(SkDisplayable* target, int index,
setupPaint(&paint);
scriptValue->fType = SkType_Float;
SkASSERT(parameters[0].fType == SkType_String);
- scriptValue->fOperand.fScalar = paint.measureText(parameters[0].fOperand.fString->c_str(),
- parameters[0].fOperand.fString->size());
-// SkDebugf("measureText: %s = %g\n", parameters[0].fOperand.fString->c_str(),
+ scriptValue->fOperand.fScalar = paint.measureText(parameters[0].fOperand.fString->c_str(),
+ parameters[0].fOperand.fString->size());
+// SkDebugf("measureText: %s = %g\n", parameters[0].fOperand.fString->c_str(),
// scriptValue->fOperand.fScalar / 65536.0f);
} break;
default:
@@ -195,7 +195,7 @@ bool SkDrawPaint::getProperty(int index, SkScriptValue* value) const {
case SK_PROPERTY(descent):
value->fOperand.fScalar = metrics.fDescent;
break;
- // should consider returning fLeading as well (or roll it into ascent/descent somehow
+ // should consider returning fLeading as well (or roll it into ascent/descent somehow
default:
SkASSERT(0);
return false;
@@ -217,7 +217,7 @@ bool SkDrawPaint::resolveIDs(SkAnimateMaker& maker, SkDisplayable* origDisp, SkA
return true;
if (fOwnsTypeface && maker.resolveID(typeface, original->typeface) == false)
return true;
- return false; // succeeded
+ return false; // succeeded
}
void SkDrawPaint::setupPaint(SkPaint* paint) const {
@@ -239,15 +239,15 @@ void SkDrawPaint::setupPaint(SkPaint* paint) const {
if (maskFilter == NULL)
paint->setMaskFilter(NULL);
else if (maskFilter != (SkDrawMaskFilter*) -1)
- paint->setMaskFilter(maskFilter->getMaskFilter())->safeUnref();
+ SkSafeUnref(paint->setMaskFilter(maskFilter->getMaskFilter()));
if (pathEffect == NULL)
paint->setPathEffect(NULL);
else if (pathEffect != (SkDrawPathEffect*) -1)
- paint->setPathEffect(pathEffect->getPathEffect())->safeUnref();
+ SkSafeUnref(paint->setPathEffect(pathEffect->getPathEffect()));
if (shader == NULL)
paint->setShader(NULL);
else if (shader != (SkDrawShader*) -1)
- paint->setShader(shader->getShader())->safeUnref();
+ SkSafeUnref(paint->setShader(shader->getShader()));
if (strikeThru != -1)
paint->setStrikeThruText(SkToBool(strikeThru));
if (strokeCap != (SkPaint::Cap) -1)
@@ -269,7 +269,7 @@ void SkDrawPaint::setupPaint(SkPaint* paint) const {
if (typeface == NULL)
paint->setTypeface(NULL);
else if (typeface != (SkDrawTypeface*) -1)
- paint->setTypeface(typeface->getTypeface())->safeUnref();
+ SkSafeUnref(paint->setTypeface(typeface->getTypeface()));
if (underline != -1)
paint->setUnderlineText(SkToBool(underline));
if (xfermode != (SkXfermode::Mode) -1)
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 8266dfecc0..3e26639d0e 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -116,7 +116,7 @@ SkBitmap& SkBitmap::operator=(const SkBitmap& src) {
*/
if (NULL == fPixelRef) {
// leave fPixels as it is
- fColorTable->safeRef(); // ref the user's ctable if present
+ SkSafeRef(fColorTable); // ref the user's ctable if present
} else { // we have a pixelref, so pixels/ctable reflect it
// ignore the values from the memcpy
fPixels = NULL;
@@ -311,7 +311,7 @@ SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) {
this->freePixels();
SkASSERT(NULL == fPixelRef);
- pr->safeRef();
+ SkSafeRef(pr);
fPixelRef = pr;
}
fPixelRefOffset = offset;
@@ -1135,7 +1135,7 @@ static bool GetBitmapAlpha(const SkBitmap& src, uint8_t SK_RESTRICT alpha[],
}
return false;
}
-
+
if (SkBitmap::kA8_Config == config && !src.isOpaque()) {
const uint8_t* s = src.getAddr8(0, 0);
while (--h >= 0) {
@@ -1351,7 +1351,7 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
size_t offset = buffer.readU32();
SkPixelRef::Factory fact = deserialize_factory(buffer);
SkPixelRef* pr = fact(buffer);
- this->setPixelRef(pr, offset)->safeUnref();
+ SkSafeUnref(this->setPixelRef(pr, offset));
break;
}
case SERIALIZE_PIXELTYPE_RAW_WITH_CTABLE:
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index 930f9bf74c..cd3cb1bd10 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -27,70 +27,62 @@
SkBlitter::~SkBlitter() {}
-const SkBitmap* SkBlitter::justAnOpaqueColor(uint32_t* value)
-{
+const SkBitmap* SkBlitter::justAnOpaqueColor(uint32_t* value) {
return NULL;
}
-void SkBlitter::blitH(int x, int y, int width)
-{
+void SkBlitter::blitH(int x, int y, int width) {
SkASSERT(!"unimplemented");
}
-void SkBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
-{
+void SkBlitter::blitAntiH(int x, int y, const SkAlpha antialias[],
+ const int16_t runs[]) {
SkASSERT(!"unimplemented");
}
-void SkBlitter::blitV(int x, int y, int height, SkAlpha alpha)
-{
- if (alpha == 255)
+void SkBlitter::blitV(int x, int y, int height, SkAlpha alpha) {
+ if (alpha == 255) {
this->blitRect(x, y, 1, height);
- else
- {
+ } else {
int16_t runs[2];
runs[0] = 1;
runs[1] = 0;
- while (--height >= 0)
+ while (--height >= 0) {
this->blitAntiH(x, y++, &alpha, runs);
+ }
}
}
-void SkBlitter::blitRect(int x, int y, int width, int height)
-{
- while (--height >= 0)
+void SkBlitter::blitRect(int x, int y, int width, int height) {
+ while (--height >= 0) {
this->blitH(x, y++, width);
+ }
}
//////////////////////////////////////////////////////////////////////////////
-static inline void bits_to_runs(SkBlitter* blitter, int x, int y, const uint8_t bits[],
- U8CPU left_mask, int rowBytes, U8CPU right_mask)
-{
+static inline void bits_to_runs(SkBlitter* blitter, int x, int y,
+ const uint8_t bits[],
+ U8CPU left_mask, int rowBytes,
+ U8CPU right_mask) {
int inFill = 0;
int pos = 0;
- while (--rowBytes >= 0)
- {
+ while (--rowBytes >= 0) {
unsigned b = *bits++ & left_mask;
- if (rowBytes == 0)
+ if (rowBytes == 0) {
b &= right_mask;
+ }
- for (unsigned test = 0x80; test != 0; test >>= 1)
- {
- if (b & test)
- {
- if (!inFill)
- {
+ for (unsigned test = 0x80; test != 0; test >>= 1) {
+ if (b & test) {
+ if (!inFill) {
pos = x;
inFill = true;
}
- }
- else
- {
- if (inFill)
- {
+ } else {
+ if (inFill) {
blitter->blitH(pos, y, x - pos);
inFill = false;
}
@@ -101,16 +93,15 @@ static inline void bits_to_runs(SkBlitter* blitter, int x, int y, const uint8_t
}
// final cleanup
- if (inFill)
+ if (inFill) {
blitter->blitH(pos, y, x - pos);
+ }
}
-void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
-{
+void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
SkASSERT(mask.fBounds.contains(clip));
- if (mask.fFormat == SkMask::kBW_Format)
- {
+ if (mask.fFormat == SkMask::kBW_Format) {
int cx = clip.fLeft;
int cy = clip.fTop;
int maskLeft = mask.fBounds.fLeft;
@@ -119,17 +110,13 @@ void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
const uint8_t* bits = mask.getAddr1(cx, cy);
- if (cx == maskLeft && clip.fRight == mask.fBounds.fRight)
- {
- while (--height >= 0)
- {
+ if (cx == maskLeft && clip.fRight == mask.fBounds.fRight) {
+ while (--height >= 0) {
bits_to_runs(this, cx, cy, bits, 0xFF, mask_rowBytes, 0xFF);
bits += mask_rowBytes;
cy += 1;
}
- }
- else
- {
+ } else {
int left_edge = cx - maskLeft;
SkASSERT(left_edge >= 0);
int rite_edge = clip.fRight - maskLeft;
@@ -140,42 +127,35 @@ void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3);
// check for empty right mask, so we don't read off the end (or go slower than we need to)
- if (rite_mask == 0)
- {
+ if (rite_mask == 0) {
SkASSERT(full_runs >= 0);
full_runs -= 1;
rite_mask = 0xFF;
}
- if (left_mask == 0xFF)
+ if (left_mask == 0xFF) {
full_runs -= 1;
+ }
// back up manually so we can keep in sync with our byte-aligned src
// have cx reflect our actual starting x-coord
cx -= left_edge & 7;
- if (full_runs < 0)
- {
+ if (full_runs < 0) {
SkASSERT((left_mask & rite_mask) != 0);
- while (--height >= 0)
- {
+ while (--height >= 0) {
bits_to_runs(this, cx, cy, bits, left_mask, 1, rite_mask);
bits += mask_rowBytes;
cy += 1;
}
- }
- else
- {
- while (--height >= 0)
- {
+ } else {
+ while (--height >= 0) {
bits_to_runs(this, cx, cy, bits, left_mask, full_runs + 2, rite_mask);
bits += mask_rowBytes;
cy += 1;
}
}
}
- }
- else
- {
+ } else {
int width = clip.width();
SkAutoSTMalloc<64, int16_t> runStorage(width + 1);
int16_t* runs = runStorage.get();
@@ -186,8 +166,7 @@ void SkBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
int height = clip.height();
int y = clip.fTop;
- while (--height >= 0)
- {
+ while (--height >= 0) {
this->blitAntiH(clip.fLeft, y, aa, runs);
aa += mask.fRowBytes;
y += 1;
@@ -201,9 +180,9 @@ void SkBlitter::blitMaskRegion(const SkMask& mask, const SkRegion& clip) {
if (clip.quickReject(mask.fBounds)) {
return;
}
-
+
SkRegion::Cliperator clipper(clip, mask.fBounds);
-
+
while (!clipper.done()) {
const SkIRect& cr = clipper.rect();
this->blitMask(mask, cr);
@@ -213,7 +192,7 @@ void SkBlitter::blitMaskRegion(const SkMask& mask, const SkRegion& clip) {
void SkBlitter::blitRectRegion(const SkIRect& rect, const SkRegion& clip) {
SkRegion::Cliperator clipper(clip, rect);
-
+
while (!clipper.done()) {
const SkIRect& cr = clipper.rect();
this->blitRect(cr.fLeft, cr.fTop, cr.width(), cr.height());
@@ -223,7 +202,7 @@ void SkBlitter::blitRectRegion(const SkIRect& rect, const SkRegion& clip) {
void SkBlitter::blitRegion(const SkRegion& clip) {
SkRegion::Iterator iter(clip);
-
+
while (!iter.done()) {
const SkIRect& cr = iter.rect();
this->blitRect(cr.fLeft, cr.fTop, cr.width(), cr.height());
@@ -231,99 +210,88 @@ void SkBlitter::blitRegion(const SkRegion& clip) {
}
}
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-void SkNullBlitter::blitH(int x, int y, int width)
-{
-}
+void SkNullBlitter::blitH(int x, int y, int width) {}
-void SkNullBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
-{
-}
+void SkNullBlitter::blitAntiH(int x, int y, const SkAlpha antialias[],
+ const int16_t runs[]) {}
-void SkNullBlitter::blitV(int x, int y, int height, SkAlpha alpha)
-{
-}
+void SkNullBlitter::blitV(int x, int y, int height, SkAlpha alpha) {}
-void SkNullBlitter::blitRect(int x, int y, int width, int height)
-{
-}
+void SkNullBlitter::blitRect(int x, int y, int width, int height) {}
-void SkNullBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
-{
-}
+void SkNullBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {}
-const SkBitmap* SkNullBlitter::justAnOpaqueColor(uint32_t* value)
-{
+const SkBitmap* SkNullBlitter::justAnOpaqueColor(uint32_t* value) {
return NULL;
}
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-static int compute_anti_width(const int16_t runs[])
-{
+static int compute_anti_width(const int16_t runs[]) {
int width = 0;
-
- for (;;)
- {
+
+ for (;;) {
int count = runs[0];
-
+
SkASSERT(count >= 0);
- if (count == 0)
+ if (count == 0) {
break;
+ }
width += count;
runs += count;
-
+
SkASSERT(width < 20000);
}
return width;
}
-static inline bool y_in_rect(int y, const SkIRect& rect)
-{
+static inline bool y_in_rect(int y, const SkIRect& rect) {
return (unsigned)(y - rect.fTop) < (unsigned)rect.height();
}
-static inline bool x_in_rect(int x, const SkIRect& rect)
-{
+static inline bool x_in_rect(int x, const SkIRect& rect) {
return (unsigned)(x - rect.fLeft) < (unsigned)rect.width();
}
-void SkRectClipBlitter::blitH(int left, int y, int width)
-{
+void SkRectClipBlitter::blitH(int left, int y, int width) {
SkASSERT(width > 0);
- if (!y_in_rect(y, fClipRect))
+ if (!y_in_rect(y, fClipRect)) {
return;
+ }
int right = left + width;
- if (left < fClipRect.fLeft)
+ if (left < fClipRect.fLeft) {
left = fClipRect.fLeft;
- if (right > fClipRect.fRight)
+ }
+ if (right > fClipRect.fRight) {
right = fClipRect.fRight;
+ }
width = right - left;
- if (width > 0)
+ if (width > 0) {
fBlitter->blitH(left, y, width);
+ }
}
-void SkRectClipBlitter::blitAntiH(int left, int y, const SkAlpha aa[], const int16_t runs[])
-{
- if (!y_in_rect(y, fClipRect) || left >= fClipRect.fRight)
+void SkRectClipBlitter::blitAntiH(int left, int y, const SkAlpha aa[],
+ const int16_t runs[]) {
+ if (!y_in_rect(y, fClipRect) || left >= fClipRect.fRight) {
return;
+ }
int x0 = left;
int x1 = left + compute_anti_width(runs);
- if (x1 <= fClipRect.fLeft)
+ if (x1 <= fClipRect.fLeft) {
return;
+ }
SkASSERT(x0 < x1);
- if (x0 < fClipRect.fLeft)
- {
+ if (x0 < fClipRect.fLeft) {
int dx = fClipRect.fLeft - x0;
SkAlphaRuns::BreakAt((int16_t*)runs, (uint8_t*)aa, dx);
runs += dx;
@@ -332,8 +300,7 @@ void SkRectClipBlitter::blitAntiH(int left, int y, const SkAlpha aa[], const int
}
SkASSERT(x0 < x1 && runs[x1 - x0] == 0);
- if (x1 > fClipRect.fRight)
- {
+ if (x1 > fClipRect.fRight) {
x1 = fClipRect.fRight;
SkAlphaRuns::BreakAt((int16_t*)runs, (uint8_t*)aa, x1 - x0);
((int16_t*)runs)[x1 - x0] = 0;
@@ -345,95 +312,91 @@ void SkRectClipBlitter::blitAntiH(int left, int y, const SkAlpha aa[], const int
fBlitter->blitAntiH(x0, y, aa, runs);
}
-void SkRectClipBlitter::blitV(int x, int y, int height, SkAlpha alpha)
-{
+void SkRectClipBlitter::blitV(int x, int y, int height, SkAlpha alpha) {
SkASSERT(height > 0);
- if (!x_in_rect(x, fClipRect))
+ if (!x_in_rect(x, fClipRect)) {
return;
+ }
int y0 = y;
int y1 = y + height;
- if (y0 < fClipRect.fTop)
+ if (y0 < fClipRect.fTop) {
y0 = fClipRect.fTop;
- if (y1 > fClipRect.fBottom)
+ }
+ if (y1 > fClipRect.fBottom) {
y1 = fClipRect.fBottom;
+ }
- if (y0 < y1)
+ if (y0 < y1) {
fBlitter->blitV(x, y0, y1 - y0, alpha);
+ }
}
-void SkRectClipBlitter::blitRect(int left, int y, int width, int height)
-{
+void SkRectClipBlitter::blitRect(int left, int y, int width, int height) {
SkIRect r;
r.set(left, y, left + width, y + height);
- if (r.intersect(fClipRect))
+ if (r.intersect(fClipRect)) {
fBlitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
+ }
}
-void SkRectClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
-{
+void SkRectClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
SkASSERT(mask.fBounds.contains(clip));
SkIRect r = clip;
- if (r.intersect(fClipRect))
+ if (r.intersect(fClipRect)) {
fBlitter->blitMask(mask, r);
+ }
}
-const SkBitmap* SkRectClipBlitter::justAnOpaqueColor(uint32_t* value)
-{
+const SkBitmap* SkRectClipBlitter::justAnOpaqueColor(uint32_t* value) {
return fBlitter->justAnOpaqueColor(value);
}
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-void SkRgnClipBlitter::blitH(int x, int y, int width)
-{
+void SkRgnClipBlitter::blitH(int x, int y, int width) {
SkRegion::Spanerator span(*fRgn, y, x, x + width);
int left, right;
- while (span.next(&left, &right))
- {
+ while (span.next(&left, &right)) {
SkASSERT(left < right);
fBlitter->blitH(left, y, right - left);
}
}
-void SkRgnClipBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t runs[])
-{
+void SkRgnClipBlitter::blitAntiH(int x, int y, const SkAlpha aa[],
+ const int16_t runs[]) {
int width = compute_anti_width(runs);
SkRegion::Spanerator span(*fRgn, y, x, x + width);
int left, right;
SkDEBUGCODE(const SkIRect& bounds = fRgn->getBounds();)
-
+
int prevRite = x;
- while (span.next(&left, &right))
- {
+ while (span.next(&left, &right)) {
SkASSERT(x <= left);
SkASSERT(left < right);
SkASSERT(left >= bounds.fLeft && right <= bounds.fRight);
-
+
SkAlphaRuns::Break((int16_t*)runs, (uint8_t*)aa, left - x, right - left);
// now zero before left
- if (left > prevRite)
- {
+ if (left > prevRite) {
int index = prevRite - x;
((uint8_t*)aa)[index] = 0; // skip runs after right
((int16_t*)runs)[index] = SkToS16(left - prevRite);
}
-
+
prevRite = right;
}
-
- if (prevRite > x)
- {
+
+ if (prevRite > x) {
((int16_t*)runs)[prevRite - x] = 0;
-
+
if (x < 0) {
int skip = runs[0];
SkASSERT(skip >= -x);
@@ -445,15 +408,13 @@ void SkRgnClipBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t
}
}
-void SkRgnClipBlitter::blitV(int x, int y, int height, SkAlpha alpha)
-{
+void SkRgnClipBlitter::blitV(int x, int y, int height, SkAlpha alpha) {
SkIRect bounds;
bounds.set(x, y, x + 1, y + height);
SkRegion::Cliperator iter(*fRgn, bounds);
- while (!iter.done())
- {
+ while (!iter.done()) {
const SkIRect& r = iter.rect();
SkASSERT(bounds.contains(r));
@@ -462,15 +423,13 @@ void SkRgnClipBlitter::blitV(int x, int y, int height, SkAlpha alpha)
}
}
-void SkRgnClipBlitter::blitRect(int x, int y, int width, int height)
-{
+void SkRgnClipBlitter::blitRect(int x, int y, int width, int height) {
SkIRect bounds;
bounds.set(x, y, x + width, y + height);
SkRegion::Cliperator iter(*fRgn, bounds);
- while (!iter.done())
- {
+ while (!iter.done()) {
const SkIRect& r = iter.rect();
SkASSERT(bounds.contains(r));
@@ -479,47 +438,38 @@ void SkRgnClipBlitter::blitRect(int x, int y, int width, int height)
}
}
-void SkRgnClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip)
-{
+void SkRgnClipBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
SkASSERT(mask.fBounds.contains(clip));
SkRegion::Cliperator iter(*fRgn, clip);
const SkIRect& r = iter.rect();
SkBlitter* blitter = fBlitter;
- while (!iter.done())
- {
+ while (!iter.done()) {
blitter->blitMask(mask, r);
iter.next();
}
}
-const SkBitmap* SkRgnClipBlitter::justAnOpaqueColor(uint32_t* value)
-{
+const SkBitmap* SkRgnClipBlitter::justAnOpaqueColor(uint32_t* value) {
return fBlitter->justAnOpaqueColor(value);
}
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip, const SkIRect* ir)
-{
- if (clip)
- {
+SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip,
+ const SkIRect* ir) {
+ if (clip) {
const SkIRect& clipR = clip->getBounds();
- if (clip->isEmpty() || (ir && !SkIRect::Intersects(clipR, *ir)))
+ if (clip->isEmpty() || (ir && !SkIRect::Intersects(clipR, *ir))) {
blitter = &fNullBlitter;
- else if (clip->isRect())
- {
- if (ir == NULL || !clipR.contains(*ir))
- {
+ } else if (clip->isRect()) {
+ if (ir == NULL || !clipR.contains(*ir)) {
fRectBlitter.init(blitter, clipR);
blitter = &fRectBlitter;
}
- }
- else
- {
+ } else {
fRgnBlitter.init(blitter, clip);
blitter = &fRgnBlitter;
}
@@ -527,44 +477,43 @@ SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip, con
return blitter;
}
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
#include "SkColorShader.h"
#include "SkColorPriv.h"
class Sk3DShader : public SkShader {
public:
- Sk3DShader(SkShader* proxy) : fProxy(proxy)
- {
- proxy->safeRef();
+ Sk3DShader(SkShader* proxy) : fProxy(proxy) {
+ SkSafeRef(proxy);
fMask = NULL;
}
- virtual ~Sk3DShader()
- {
- fProxy->safeUnref();
+
+ virtual ~Sk3DShader() {
+ SkSafeUnref(fProxy);
}
+
void setMask(const SkMask* mask) { fMask = mask; }
- virtual bool setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
- {
- if (fProxy)
+ virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
+ const SkMatrix& matrix) {
+ if (fProxy) {
return fProxy->setContext(device, paint, matrix);
- else
- {
+ } else {
fPMColor = SkPreMultiplyColor(paint.getColor());
return this->INHERITED::setContext(device, paint, matrix);
}
}
- virtual void shadeSpan(int x, int y, SkPMColor span[], int count)
- {
- if (fProxy)
+
+ virtual void shadeSpan(int x, int y, SkPMColor span[], int count) {
+ if (fProxy) {
fProxy->shadeSpan(x, y, span, count);
+ }
- if (fMask == NULL)
- {
- if (fProxy == NULL)
+ if (fMask == NULL) {
+ if (fProxy == NULL) {
sk_memset32(span, fPMColor, count);
+ }
return;
}
@@ -576,15 +525,11 @@ public:
const uint8_t* mulp = alpha + size;
const uint8_t* addp = mulp + size;
- if (fProxy)
- {
- for (int i = 0; i < count; i++)
- {
- if (alpha[i])
- {
+ if (fProxy) {
+ for (int i = 0; i < count; i++) {
+ if (alpha[i]) {
SkPMColor c = span[i];
- if (c)
- {
+ if (c) {
unsigned a = SkGetPackedA32(c);
unsigned r = SkGetPackedR32(c);
unsigned g = SkGetPackedG32(c);
@@ -599,73 +544,65 @@ public:
span[i] = SkPackARGB32(a, r, g, b);
}
- }
- else
+ } else {
span[i] = 0;
+ }
}
- }
- else // color
- {
+ } else { // color
unsigned a = SkGetPackedA32(fPMColor);
unsigned r = SkGetPackedR32(fPMColor);
unsigned g = SkGetPackedG32(fPMColor);
unsigned b = SkGetPackedB32(fPMColor);
- for (int i = 0; i < count; i++)
- {
- if (alpha[i])
- {
+ for (int i = 0; i < count; i++) {
+ if (alpha[i]) {
unsigned mul = SkAlpha255To256(mulp[i]);
unsigned add = addp[i];
span[i] = SkPackARGB32( a,
- SkFastMin32(SkAlphaMul(r, mul) + add, a),
- SkFastMin32(SkAlphaMul(g, mul) + add, a),
- SkFastMin32(SkAlphaMul(b, mul) + add, a));
- }
- else
+ SkFastMin32(SkAlphaMul(r, mul) + add, a),
+ SkFastMin32(SkAlphaMul(g, mul) + add, a),
+ SkFastMin32(SkAlphaMul(b, mul) + add, a));
+ } else {
span[i] = 0;
+ }
}
}
}
-
- virtual void beginSession()
- {
+
+ virtual void beginSession() {
this->INHERITED::beginSession();
- if (fProxy)
+ if (fProxy) {
fProxy->beginSession();
+ }
}
-
- virtual void endSession()
- {
- if (fProxy)
+
+ virtual void endSession() {
+ if (fProxy) {
fProxy->endSession();
+ }
this->INHERITED::endSession();
}
protected:
Sk3DShader(SkFlattenableReadBuffer& buffer) :
- INHERITED(buffer)
- {
+ INHERITED(buffer) {
fProxy = static_cast<SkShader*>(buffer.readFlattenable());
fPMColor = buffer.readU32();
fMask = NULL;
}
-
- virtual void flatten(SkFlattenableWriteBuffer& buffer)
- {
+
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fProxy);
buffer.write32(fPMColor);
}
-
- virtual Factory getFactory()
- {
+
+ virtual Factory getFactory() {
return CreateProc;
}
private:
- static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer)
- {
+ static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
return SkNEW_ARGS(Sk3DShader, (buffer));
}
@@ -679,36 +616,34 @@ private:
class Sk3DBlitter : public SkBlitter {
public:
Sk3DBlitter(SkBlitter* proxy, Sk3DShader* shader, void (*killProc)(void*))
- : fProxy(proxy), f3DShader(shader), fKillProc(killProc)
- {
+ : fProxy(proxy), f3DShader(shader), fKillProc(killProc) {
shader->ref();
}
- virtual ~Sk3DBlitter()
- {
+
+ virtual ~Sk3DBlitter() {
f3DShader->unref();
fKillProc(fProxy);
}
- virtual void blitH(int x, int y, int width)
- {
+ virtual void blitH(int x, int y, int width) {
fProxy->blitH(x, y, width);
}
- virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
- {
+
+ virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
+ const int16_t runs[]) {
fProxy->blitAntiH(x, y, antialias, runs);
}
- virtual void blitV(int x, int y, int height, SkAlpha alpha)
- {
+
+ virtual void blitV(int x, int y, int height, SkAlpha alpha) {
fProxy->blitV(x, y, height, alpha);
}
- virtual void blitRect(int x, int y, int width, int height)
- {
+
+ virtual void blitRect(int x, int y, int width, int height) {
fProxy->blitRect(x, y, width, height);
}
- virtual void blitMask(const SkMask& mask, const SkIRect& clip)
- {
- if (mask.fFormat == SkMask::k3D_Format)
- {
+
+ virtual void blitMask(const SkMask& mask, const SkIRect& clip) {
+ if (mask.fFormat == SkMask::k3D_Format) {
f3DShader->setMask(&mask);
((SkMask*)&mask)->fFormat = SkMask::kA8_Format;
@@ -716,18 +651,18 @@ public:
((SkMask*)&mask)->fFormat = SkMask::k3D_Format;
f3DShader->setMask(NULL);
- }
- else
+ } else {
fProxy->blitMask(mask, clip);
+ }
}
+
private:
SkBlitter* fProxy;
Sk3DShader* f3DShader;
void (*fKillProc)(void*);
};
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
#include "SkCoreBlitters.h"
@@ -739,6 +674,7 @@ public:
fXfer = fPaint->getXfermode();
SkSafeRef(fXfer);
}
+
~SkAutoRestoreShaderXfer() {
fPaint->setShader(fShader);
SkSafeUnref(fShader);
@@ -763,34 +699,34 @@ private:
class SkAutoCallProc {
public:
typedef void (*Proc)(void*);
+
SkAutoCallProc(void* obj, Proc proc)
- : fObj(obj), fProc(proc)
- {
- }
- ~SkAutoCallProc()
- {
- if (fObj && fProc)
+ : fObj(obj), fProc(proc) {}
+
+ ~SkAutoCallProc() {
+ if (fObj && fProc) {
fProc(fObj);
+ }
}
+
void* get() const { return fObj; }
- void* detach()
- {
+
+ void* detach() {
void* obj = fObj;
fObj = NULL;
return obj;
}
+
private:
void* fObj;
Proc fProc;
};
-static void destroy_blitter(void* blitter)
-{
+static void destroy_blitter(void* blitter) {
((SkBlitter*)blitter)->~SkBlitter();
}
-static void delete_blitter(void* blitter)
-{
+static void delete_blitter(void* blitter) {
SkDELETE((SkBlitter*)blitter);
}
@@ -804,7 +740,7 @@ static bool just_solid_color(const SkPaint& paint) {
}
return false;
}
-
+
/** By analyzing the paint (with an xfermode), we may decide we can take
special action. This enum lists our possible actions
*/
@@ -817,7 +753,7 @@ enum XferInterp {
static XferInterp interpret_xfermode(const SkPaint& paint, SkXfermode* xfer,
SkBitmap::Config deviceConfig) {
SkXfermode::Mode mode;
-
+
if (SkXfermode::IsMode(xfer, &mode)) {
switch (mode) {
case SkXfermode::kSrc_Mode:
@@ -855,16 +791,14 @@ static XferInterp interpret_xfermode(const SkPaint& paint, SkXfermode* xfer,
SkBlitter* SkBlitter::Choose(const SkBitmap& device,
const SkMatrix& matrix,
const SkPaint& paint,
- void* storage, size_t storageSize)
-{
+ void* storage, size_t storageSize) {
SkASSERT(storageSize == 0 || storage != NULL);
SkBlitter* blitter = NULL;
// which check, in case we're being called by a client with a dummy device
// (e.g. they have a bounder that always aborts the draw)
- if (SkBitmap::kNo_Config == device.getConfig())
- {
+ if (SkBitmap::kNo_Config == device.getConfig()) {
SK_PLACEMENT_NEW(blitter, SkNullBlitter, storage, storageSize);
return blitter;
}
@@ -873,8 +807,8 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
SkShader* shader = paint.getShader();
Sk3DShader* shader3D = NULL;
- if (paint.getMaskFilter() != NULL && paint.getMaskFilter()->getFormat() == SkMask::k3D_Format)
- {
+ if (paint.getMaskFilter() != NULL &&
+ paint.getMaskFilter()->getFormat() == SkMask::k3D_Format) {
shader3D = SkNEW_ARGS(Sk3DShader, (shader));
restorePaint.setShader(shader3D)->unref();
shader = shader3D;
@@ -900,58 +834,66 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
shader = SkNEW(SkColorShader);
restorePaint.setShader(shader)->unref();
}
-
- if (paint.getColorFilter() != NULL)
- {
+
+ if (paint.getColorFilter() != NULL) {
SkASSERT(shader);
shader = SkNEW_ARGS(SkFilterShader, (shader, paint.getColorFilter()));
restorePaint.setShader(shader)->unref();
// blitters should ignore the presence/absence of a filter, since
// if there is one, the shader will take care of it.
}
-
+
if (shader && !shader->setContext(device, paint, matrix)) {
return SkNEW(SkNullBlitter);
}
switch (device.getConfig()) {
- case SkBitmap::kA1_Config:
- SK_PLACEMENT_NEW_ARGS(blitter, SkA1_Blitter, storage, storageSize, (device, paint));
- break;
-
- case SkBitmap::kA8_Config:
- if (shader)
- SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Shader_Blitter, storage, storageSize, (device, paint));
- else
- SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Blitter, storage, storageSize, (device, paint));
- break;
-
- case SkBitmap::kARGB_4444_Config:
- blitter = SkBlitter_ChooseD4444(device, paint, storage, storageSize);
- break;
-
- case SkBitmap::kRGB_565_Config:
- blitter = SkBlitter_ChooseD565(device, paint, storage, storageSize);
- break;
-
- case SkBitmap::kARGB_8888_Config:
- if (shader)
- SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Shader_Blitter, storage, storageSize, (device, paint));
- else if (paint.getColor() == SK_ColorBLACK)
- SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Black_Blitter, storage, storageSize, (device, paint));
- else if (paint.getAlpha() == 0xFF)
- SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Opaque_Blitter, storage, storageSize, (device, paint));
- else
- SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Blitter, storage, storageSize, (device, paint));
- break;
-
- default:
- SkASSERT(!"unsupported device config");
- SK_PLACEMENT_NEW(blitter, SkNullBlitter, storage, storageSize);
+ case SkBitmap::kA1_Config:
+ SK_PLACEMENT_NEW_ARGS(blitter, SkA1_Blitter,
+ storage, storageSize, (device, paint));
+ break;
+
+ case SkBitmap::kA8_Config:
+ if (shader) {
+ SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Shader_Blitter,
+ storage, storageSize, (device, paint));
+ } else {
+ SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Blitter,
+ storage, storageSize, (device, paint));
+ }
+ break;
+
+ case SkBitmap::kARGB_4444_Config:
+ blitter = SkBlitter_ChooseD4444(device, paint, storage, storageSize);
+ break;
+
+ case SkBitmap::kRGB_565_Config:
+ blitter = SkBlitter_ChooseD565(device, paint, storage, storageSize);
+ break;
+
+ case SkBitmap::kARGB_8888_Config:
+ if (shader) {
+ SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Shader_Blitter,
+ storage, storageSize, (device, paint));
+ } else if (paint.getColor() == SK_ColorBLACK) {
+ SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Black_Blitter,
+ storage, storageSize, (device, paint));
+ } else if (paint.getAlpha() == 0xFF) {
+ SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Opaque_Blitter,
+ storage, storageSize, (device, paint));
+ } else {
+ SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Blitter,
+ storage, storageSize, (device, paint));
+ }
+ break;
+
+ default:
+ SkASSERT(!"unsupported device config");
+ SK_PLACEMENT_NEW(blitter, SkNullBlitter, storage, storageSize);
+ break;
}
- if (shader3D)
- {
+ if (shader3D) {
void (*proc)(void*) = ((void*)storage == (void*)blitter) ? destroy_blitter : delete_blitter;
SkAutoCallProc tmp(blitter, proc);
@@ -961,12 +903,12 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
return blitter;
}
-//////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
const uint16_t gMask_0F0F = 0xF0F;
const uint32_t gMask_00FF00FF = 0xFF00FF;
-//////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
SkShaderBlitter::SkShaderBlitter(const SkBitmap& device, const SkPaint& paint)
: INHERITED(device) {
diff --git a/src/core/SkBlitter_4444.cpp b/src/core/SkBlitter_4444.cpp
index 81bbc48cbb..e1c519a313 100644
--- a/src/core/SkBlitter_4444.cpp
+++ b/src/core/SkBlitter_4444.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
- ** Licensed under the Apache License, Version 2.0 (the "License");
- ** you may not use this file except in compliance with the License.
- ** You may obtain a copy of the License at
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
**
- ** http://www.apache.org/licenses/LICENSE-2.0
+ ** http://www.apache.org/licenses/LICENSE-2.0
**
- ** Unless required by applicable law or agreed to in writing, software
- ** distributed under the License is distributed on an "AS IS" BASIS,
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ** See the License for the specific language governing permissions and
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -23,13 +23,13 @@
#include "SkUtils.h"
#include "SkXfermode.h"
-inline SkPMColor SkBlendARGB4444(SkPMColor16 src, SkPMColor16 dst, U8CPU aa)
-{
+static inline SkPMColor SkBlendARGB4444(SkPMColor16 src, SkPMColor16 dst,
+ U8CPU aa) {
SkASSERT((unsigned)aa <= 255);
-
+
unsigned src_scale = SkAlpha255To256(aa) >> 4;
unsigned dst_scale = SkAlpha15To16(15 - SkAlphaMul4(SkGetPackedA4444(src), src_scale));
-
+
uint32_t src32 = SkExpand_4444(src) * src_scale;
uint32_t dst32 = SkExpand_4444(dst) * dst_scale;
return SkCompact_4444((src32 + dst32) >> 4);
@@ -46,16 +46,16 @@ public:
virtual void blitRect(int x, int y, int width, int height);
virtual void blitMask(const SkMask&, const SkIRect&);
virtual const SkBitmap* justAnOpaqueColor(uint32_t*);
-
+
protected:
SkPMColor16 fPMColor16, fPMColor16Other;
SkPMColor16 fRawColor16, fRawColor16Other;
uint8_t fScale16;
-
+
private:
// illegal
SkARGB4444_Blitter& operator=(const SkARGB4444_Blitter&);
-
+
typedef SkRasterBlitter INHERITED;
};
@@ -81,7 +81,7 @@ SkARGB4444_Blitter::SkARGB4444_Blitter(const SkBitmap& device, const SkPaint& pa
} else {
fRawColor16Other = fRawColor16;
}
-
+
#if 0 /// don't think this assertion is true, but need it be?
// our dithered color will be the same or more opaque than the original
@@ -146,19 +146,19 @@ static void src_over_4444x(SkPMColor16 dst[], uint32_t color,
void SkARGB4444_Blitter::blitH(int x, int y, int width)
{
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
-
+
if (0 == fScale16) {
return;
}
-
+
SkPMColor16* device = fDevice.getAddr16(x, y);
SkPMColor16 color = fPMColor16;
SkPMColor16 other = fPMColor16Other;
-
+
if ((x ^ y) & 1) {
SkTSwap<SkPMColor16>(color, other);
}
-
+
if (16 == fScale16) {
sk_dither_memset16(device, color, other, width);
}
@@ -174,12 +174,12 @@ void SkARGB4444_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
if (0 == alpha || 0 == fScale16) {
return;
}
-
+
SkPMColor16* device = fDevice.getAddr16(x, y);
SkPMColor16 color = fPMColor16;
SkPMColor16 other = fPMColor16Other;
unsigned rb = fDevice.rowBytes();
-
+
if ((x ^ y) & 1) {
SkTSwap<SkPMColor16>(color, other);
}
@@ -211,19 +211,19 @@ void SkARGB4444_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
void SkARGB4444_Blitter::blitRect(int x, int y, int width, int height)
{
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= fDevice.height());
-
+
if (0 == fScale16) {
return;
}
-
+
SkPMColor16* device = fDevice.getAddr16(x, y);
SkPMColor16 color = fPMColor16;
SkPMColor16 other = fPMColor16Other;
-
+
if ((x ^ y) & 1) {
SkTSwap<SkPMColor16>(color, other);
}
-
+
if (16 == fScale16) {
while (--height >= 0) {
sk_dither_memset16(device, color, other, width);
@@ -248,22 +248,22 @@ void SkARGB4444_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], cons
if (0 == fScale16) {
return;
}
-
+
SkPMColor16* device = fDevice.getAddr16(x, y);
SkPMColor16 color = fPMColor16;
SkPMColor16 other = fPMColor16Other;
-
+
if ((x ^ y) & 1) {
SkTSwap<SkPMColor16>(color, other);
}
-
+
for (;;) {
int count = runs[0];
SkASSERT(count >= 0);
if (count <= 0) {
return;
}
-
+
unsigned aa = antialias[0];
if (aa) {
if (0xFF == aa) {
@@ -338,11 +338,11 @@ if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ4(dst[7], dst_scale); } \
void SkARGB4444_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
{
SkASSERT(mask.fBounds.contains(clip));
-
+
if (0 == fScale16) {
return;
}
-
+
if (mask.fFormat == SkMask::kBW_Format) {
if (16 == fScale16) {
SkARGB4444_BlitBW(fDevice, mask, clip, fPMColor16);
@@ -351,18 +351,18 @@ void SkARGB4444_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
}
return;
}
-
+
int x = clip.fLeft;
int y = clip.fTop;
int width = clip.width();
int height = clip.height();
-
+
SkPMColor16* device = fDevice.getAddr16(x, y);
const uint8_t* alpha = mask.getAddr(x, y);
SkPMColor16 srcColor = fPMColor16;
unsigned devRB = fDevice.rowBytes() - (width << 1);
unsigned maskRB = mask.fRowBytes - width;
-
+
do {
int w = width;
do {
@@ -384,15 +384,17 @@ class SkARGB4444_Shader_Blitter : public SkShaderBlitter {
SkPMColor* fBuffer;
uint8_t* fAAExpand;
public:
+
SkARGB4444_Shader_Blitter(const SkBitmap& device, const SkPaint& paint)
: INHERITED(device, paint)
{
const int width = device.width();
fBuffer = (SkPMColor*)sk_malloc_throw(width * sizeof(SkPMColor) + width);
fAAExpand = (uint8_t*)(fBuffer + width);
-
- (fXfermode = paint.getXfermode())->safeRef();
-
+
+ fXfermode = paint.getXfermode();
+ SkSafeRef(fXfermode);
+
unsigned flags = 0;
if (!(fShader->getFlags() & SkShader::kOpaqueAlpha_Flag)) {
flags |= SkBlitRow::kSrcPixelAlpha_Flag;
@@ -405,41 +407,39 @@ SkARGB4444_Shader_Blitter(const SkBitmap& device, const SkPaint& paint)
SkBitmap::kARGB_4444_Config);
}
-virtual ~SkARGB4444_Shader_Blitter()
-{
- fXfermode->safeUnref();
+virtual ~SkARGB4444_Shader_Blitter() {
+ SkSafeUnref(fXfermode);
sk_free(fBuffer);
}
-virtual void blitH(int x, int y, int width)
-{
+virtual void blitH(int x, int y, int width) {
SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
-
- SkPMColor16* device = fDevice.getAddr16(x, y);
+
+ SkPMColor16* device = fDevice.getAddr16(x, y);
SkPMColor* span = fBuffer;
-
+
fShader->shadeSpan(x, y, span, width);
if (fXfermode) {
fXfermode->xfer4444(device, span, width, NULL);
- }
- else {
+ } else {
fOpaqueProc(device, span, width, 0xFF, x, y);
}
}
-virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
-{
+virtual void blitAntiH(int x, int y, const SkAlpha antialias[],
+ const int16_t runs[]) {
SkPMColor* SK_RESTRICT span = fBuffer;
uint8_t* SK_RESTRICT aaExpand = fAAExpand;
SkPMColor16* device = fDevice.getAddr16(x, y);
SkShader* shader = fShader;
SkXfermode* xfer = fXfermode;
-
+
if (NULL != xfer) {
for (;;) {
int count = *runs;
- if (count <= 0)
+ if (count <= 0) {
break;
+ }
int aa = *antialias;
if (aa) {
shader->shadeSpan(x, y, span, count);
@@ -458,12 +458,13 @@ virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t ru
runs += count;
antialias += count;
x += count;
- }
+ }
} else { // no xfermode
for (;;) {
int count = *runs;
- if (count <= 0)
+ if (count <= 0) {
break;
+ }
int aa = *antialias;
if (aa) {
fShader->shadeSpan(x, y, span, count);
@@ -477,7 +478,7 @@ virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t ru
runs += count;
antialias += count;
x += count;
- }
+ }
}
}
diff --git a/src/core/SkBlitter_A8.cpp b/src/core/SkBlitter_A8.cpp
index 18b088160e..f2d73e3a6c 100644
--- a/src/core/SkBlitter_A8.cpp
+++ b/src/core/SkBlitter_A8.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -21,71 +21,64 @@
#include "SkXfermode.h"
SkA8_Blitter::SkA8_Blitter(const SkBitmap& device, const SkPaint& paint)
- : INHERITED(device)
-{
+ : INHERITED(device) {
fSrcA = SkColorGetA(paint.getColor());
}
-const SkBitmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value)
-{
- if (255 == fSrcA)
- {
+const SkBitmap* SkA8_Blitter::justAnOpaqueColor(uint32_t* value) {
+ if (255 == fSrcA) {
*value = 255;
return &fDevice;
}
return NULL;
}
-void SkA8_Blitter::blitH(int x, int y, int width)
-{
- SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width());
+void SkA8_Blitter::blitH(int x, int y, int width) {
+ SkASSERT(x >= 0 && y >= 0 &&
+ (unsigned)(x + width) <= (unsigned)fDevice.width());
- if (fSrcA == 0)
+ if (fSrcA == 0) {
return;
+ }
uint8_t* device = fDevice.getAddr8(x, y);
- if (fSrcA == 255)
- {
+ if (fSrcA == 255) {
memset(device, 0xFF, width);
- }
- else
- {
+ } else {
unsigned scale = 256 - SkAlpha255To256(fSrcA);
unsigned srcA = fSrcA;
- for (int i = 0; i < width; i++)
- {
+ for (int i = 0; i < width; i++) {
device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
}
}
}
-void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
-{
- if (fSrcA == 0)
+void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
+ const int16_t runs[]) {
+ if (fSrcA == 0) {
return;
+ }
uint8_t* device = fDevice.getAddr8(x, y);
unsigned srcA = fSrcA;
- for (;;)
- {
+ for (;;) {
int count = runs[0];
SkASSERT(count >= 0);
- if (count == 0)
+ if (count == 0) {
return;
+ }
unsigned aa = antialias[0];
- if (aa == 255 && srcA == 255)
+ if (aa == 255 && srcA == 255) {
memset(device, 0xFF, count);
- else
- {
+ } else {
unsigned sa = SkAlphaMul(srcA, SkAlpha255To256(aa));
unsigned scale = 256 - sa;
- for (int i = 0; i < count; i++)
- {
+ for (int i = 0; i < count; i++) {
device[i] = SkToU8(sa + SkAlphaMul(device[i], scale));
}
}
@@ -110,14 +103,14 @@ void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int1
} while (0)
#define SK_BLITBWMASK_NAME SkA8_BlitBW
-#define SK_BLITBWMASK_ARGS
+#define SK_BLITBWMASK_ARGS
#define SK_BLITBWMASK_BLIT8(mask, dst) solid_8_pixels(mask, dst)
#define SK_BLITBWMASK_GETADDR getAddr8
#define SK_BLITBWMASK_DEVTYPE uint8_t
#include "SkBlitBWMaskTemplate.h"
-static inline void blend_8_pixels(U8CPU bw, uint8_t dst[], U8CPU sa, unsigned dst_scale)
-{
+static inline void blend_8_pixels(U8CPU bw, uint8_t dst[], U8CPU sa,
+ unsigned dst_scale) {
if (bw & 0x80) dst[0] = SkToU8(sa + SkAlphaMul(dst[0], dst_scale));
if (bw & 0x40) dst[1] = SkToU8(sa + SkAlphaMul(dst[1], dst_scale));
if (bw & 0x20) dst[2] = SkToU8(sa + SkAlphaMul(dst[2], dst_scale));
@@ -135,17 +128,18 @@ static inline void blend_8_pixels(U8CPU bw, uint8_t dst[], U8CPU sa, unsigned ds
#define SK_BLITBWMASK_DEVTYPE uint8_t
#include "SkBlitBWMaskTemplate.h"
-void SkA8_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
-{
- if (fSrcA == 0)
+void SkA8_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
+ if (fSrcA == 0) {
return;
+ }
- if (mask.fFormat == SkMask::kBW_Format)
- {
- if (fSrcA == 0xFF)
+ if (mask.fFormat == SkMask::kBW_Format) {
+ if (fSrcA == 0xFF) {
SkA8_BlitBW(fDevice, mask, clip);
- else
- SkA8_BlendBW(fDevice, mask, clip, fSrcA, SkAlpha255To256(255 - fSrcA));
+ } else {
+ SkA8_BlendBW(fDevice, mask, clip, fSrcA,
+ SkAlpha255To256(255 - fSrcA));
+ }
return;
}
@@ -157,28 +151,24 @@ void SkA8_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
const uint8_t* alpha = mask.getAddr(x, y);
unsigned srcA = fSrcA;
- while (--height >= 0)
- {
- for (int i = width - 1; i >= 0; --i)
- {
+ while (--height >= 0) {
+ for (int i = width - 1; i >= 0; --i) {
unsigned sa;
// scale our src by the alpha value
{
int aa = alpha[i];
- if (aa == 0)
+ if (aa == 0) {
continue;
-
- if (aa == 255)
- {
- if (srcA == 255)
- {
+ }
+ if (aa == 255) {
+ if (srcA == 255) {
device[i] = 0xFF;
continue;
}
sa = srcA;
- }
- else
+ } else {
sa = SkAlphaMul(srcA, SkAlpha255To256(aa));
+ }
}
int scale = 256 - SkAlpha255To256(sa);
@@ -189,63 +179,54 @@ void SkA8_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
}
}
-///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
-void SkA8_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
-{
- if (fSrcA == 0)
+void SkA8_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
+ if (fSrcA == 0) {
return;
+ }
unsigned sa = SkAlphaMul(fSrcA, SkAlpha255To256(alpha));
uint8_t* device = fDevice.getAddr8(x, y);
int rowBytes = fDevice.rowBytes();
- if (sa == 0xFF)
- {
- for (int i = 0; i < height; i++)
- {
+ if (sa == 0xFF) {
+ for (int i = 0; i < height; i++) {
*device = SkToU8(sa);
device += rowBytes;
}
- }
- else
- {
+ } else {
unsigned scale = 256 - SkAlpha255To256(sa);
- for (int i = 0; i < height; i++)
- {
+ for (int i = 0; i < height; i++) {
*device = SkToU8(sa + SkAlphaMul(*device, scale));
device += rowBytes;
}
}
}
-void SkA8_Blitter::blitRect(int x, int y, int width, int height)
-{
- SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width() && (unsigned)(y + height) <= (unsigned)fDevice.height());
+void SkA8_Blitter::blitRect(int x, int y, int width, int height) {
+ SkASSERT(x >= 0 && y >= 0 &&
+ (unsigned)(x + width) <= (unsigned)fDevice.width() &&
+ (unsigned)(y + height) <= (unsigned)fDevice.height());
- if (fSrcA == 0)
+ if (fSrcA == 0) {
return;
+ }
uint8_t* device = fDevice.getAddr8(x, y);
unsigned srcA = fSrcA;
- if (srcA == 255)
- {
- while (--height >= 0)
- {
+ if (srcA == 255) {
+ while (--height >= 0) {
memset(device, 0xFF, width);
device += fDevice.rowBytes();
}
- }
- else
- {
+ } else {
unsigned scale = 256 - SkAlpha255To256(srcA);
- while (--height >= 0)
- {
- for (int i = 0; i < width; i++)
- {
+ while (--height >= 0) {
+ for (int i = 0; i < width; i++) {
device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
}
device += fDevice.rowBytes();
@@ -256,10 +237,8 @@ void SkA8_Blitter::blitRect(int x, int y, int width, int height)
///////////////////////////////////////////////////////////////////////
SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint)
- : INHERITED(device, paint)
-{
- if ((fXfermode = paint.getXfermode()) != NULL)
- {
+ : INHERITED(device, paint) {
+ if ((fXfermode = paint.getXfermode()) != NULL) {
fXfermode->ref();
SkASSERT(fShader);
}
@@ -269,33 +248,27 @@ SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint&
fAAExpand = (uint8_t*)(fBuffer + width);
}
-SkA8_Shader_Blitter::~SkA8_Shader_Blitter()
-{
- fXfermode->safeUnref();
+SkA8_Shader_Blitter::~SkA8_Shader_Blitter() {
+ SkSafeUnref(fXfermode);
sk_free(fBuffer);
}
-void SkA8_Shader_Blitter::blitH(int x, int y, int width)
-{
- SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width());
+void SkA8_Shader_Blitter::blitH(int x, int y, int width) {
+ SkASSERT(x >= 0 && y >= 0 &&
+ (unsigned)(x + width) <= (unsigned)fDevice.width());
uint8_t* device = fDevice.getAddr8(x, y);
- if ((fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) && fXfermode == NULL)
- {
+ if ((fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) && !fXfermode) {
memset(device, 0xFF, width);
- }
- else
- {
+ } else {
SkPMColor* span = fBuffer;
fShader->shadeSpan(x, y, span, width);
- if (fXfermode)
+ if (fXfermode) {
fXfermode->xferA8(device, span, width, NULL);
- else
- {
- for (int i = width - 1; i >= 0; --i)
- {
+ } else {
+ for (int i = width - 1; i >= 0; --i) {
unsigned srcA = SkGetPackedA32(span[i]);
unsigned scale = 256 - SkAlpha255To256(srcA);
@@ -305,8 +278,7 @@ void SkA8_Shader_Blitter::blitH(int x, int y, int width)
}
}
-static inline uint8_t aa_blend8(SkPMColor src, U8CPU da, int aa)
-{
+static inline uint8_t aa_blend8(SkPMColor src, U8CPU da, int aa) {
SkASSERT((unsigned)aa <= 255);
int src_scale = SkAlpha255To256(aa);
@@ -316,8 +288,8 @@ static inline uint8_t aa_blend8(SkPMColor src, U8CPU da, int aa)
return SkToU8((sa * src_scale + da * dst_scale) >> 8);
}
-void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
-{
+void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
+ const int16_t runs[]) {
SkShader* shader = fShader;
SkXfermode* mode = fXfermode;
uint8_t* aaExpand = fAAExpand;
@@ -325,28 +297,24 @@ void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], con
uint8_t* device = fDevice.getAddr8(x, y);
int opaque = fShader->getFlags() & SkShader::kOpaqueAlpha_Flag;
- for (;;)
- {
+ for (;;) {
int count = *runs;
- if (count == 0)
+ if (count == 0) {
break;
+ }
int aa = *antialias;
- if (aa)
- {
- if (opaque && aa == 255 && mode == NULL)
+ if (aa) {
+ if (opaque && aa == 255 && mode == NULL) {
memset(device, 0xFF, count);
- else
- {
+ } else {
shader->shadeSpan(x, y, span, count);
- if (mode)
- {
+ if (mode) {
memset(aaExpand, aa, count);
mode->xferA8(device, span, count, aaExpand);
- }
- else
- {
- for (int i = count - 1; i >= 0; --i)
+ } else {
+ for (int i = count - 1; i >= 0; --i) {
device[i] = aa_blend8(span[i], device[i], aa);
+ }
}
}
}
@@ -354,17 +322,15 @@ void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], con
runs += count;
antialias += count;
x += count;
- }
+ }
}
-void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
-{
- if (mask.fFormat == SkMask::kBW_Format)
- {
+void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
+ if (mask.fFormat == SkMask::kBW_Format) {
this->INHERITED::blitMask(mask, clip);
return;
}
-
+
int x = clip.fLeft;
int y = clip.fTop;
int width = clip.width();
@@ -374,11 +340,10 @@ void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
SkPMColor* span = fBuffer;
- while (--height >= 0)
- {
+ while (--height >= 0) {
fShader->shadeSpan(x, y, span, width);
fXfermode->xferA8(device, span, width, alpha);
-
+
y += 1;
device += fDevice.rowBytes();
alpha += mask.fRowBytes;
diff --git a/src/core/SkBlitter_ARGB32.cpp b/src/core/SkBlitter_ARGB32.cpp
index 88b9491e4c..a775adb551 100644
--- a/src/core/SkBlitter_ARGB32.cpp
+++ b/src/core/SkBlitter_ARGB32.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -53,7 +53,7 @@ static void SkARGB32_Blit32(const SkBitmap& device, const SkMask& mask,
int y = clip.fTop;
int width = clip.width();
int height = clip.height();
-
+
SkPMColor* dstRow = device.getAddr32(x, y);
const SkPMColor* srcRow = reinterpret_cast<const SkPMColor*>(mask.getAddr(x, y));
@@ -448,7 +448,7 @@ SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device,
}
SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() {
- fXfermode->safeUnref();
+ SkSafeUnref(fXfermode);
sk_free(fBuffer);
}
@@ -501,7 +501,7 @@ void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
runs += count;
antialias += count;
x += count;
- }
+ }
} else if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) {
for (;;) {
int count = *runs;
@@ -522,7 +522,7 @@ void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
runs += count;
antialias += count;
x += count;
- }
+ }
} else { // no xfermode but the shader not opaque
for (;;) {
int count = *runs;
@@ -542,6 +542,6 @@ void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
runs += count;
antialias += count;
x += count;
- }
+ }
}
}
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 79915f8903..faf030c81e 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -197,7 +197,7 @@ public:
}
fFilter = prev->fFilter;
- fFilter->safeRef();
+ SkSafeRef(fFilter);
fTopLayer = prev->fTopLayer;
} else { // no prev
@@ -214,7 +214,7 @@ public:
inc_rec();
}
~MCRec() {
- fFilter->safeUnref();
+ SkSafeUnref(fFilter);
SkDELETE(fLayer);
dec_rec();
}
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index 7e566a3d2e..62bb2d6fdc 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -20,40 +20,36 @@
#include "SkColorPriv.h"
#include "SkXfermode.h"
-//////////////////////////////////////////////////////////////////////////////////////
-
-SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode)
-{
+///////////////////////////////////////////////////////////////////////////////
+
+SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) {
fShaderA = sA; sA->ref();
fShaderB = sB; sB->ref();
// mode may be null
- fMode = mode; mode->safeRef();
+ fMode = mode;
+ SkSafeRef(mode);
}
SkComposeShader::SkComposeShader(SkFlattenableReadBuffer& buffer) :
- INHERITED(buffer)
-{
+ INHERITED(buffer) {
fShaderA = static_cast<SkShader*>(buffer.readFlattenable());
fShaderB = static_cast<SkShader*>(buffer.readFlattenable());
fMode = static_cast<SkXfermode*>(buffer.readFlattenable());
}
-SkComposeShader::~SkComposeShader()
-{
- fMode->safeUnref(); // may be null
+SkComposeShader::~SkComposeShader() {
+ SkSafeUnref(fMode);
fShaderB->unref();
fShaderA->unref();
}
-void SkComposeShader::beginSession()
-{
+void SkComposeShader::beginSession() {
this->INHERITED::beginSession();
fShaderA->beginSession();
fShaderB->beginSession();
}
-void SkComposeShader::endSession()
-{
+void SkComposeShader::endSession() {
fShaderA->endSession();
fShaderB->endSession();
this->INHERITED::endSession();
@@ -61,14 +57,13 @@ void SkComposeShader::endSession()
class SkAutoAlphaRestore {
public:
- SkAutoAlphaRestore(SkPaint* paint, uint8_t newAlpha)
- {
+ SkAutoAlphaRestore(SkPaint* paint, uint8_t newAlpha) {
fAlpha = paint->getAlpha();
fPaint = paint;
paint->setAlpha(newAlpha);
}
- ~SkAutoAlphaRestore()
- {
+
+ ~SkAutoAlphaRestore() {
fPaint->setAlpha(fAlpha);
}
private:
@@ -76,8 +71,7 @@ private:
uint8_t fAlpha;
};
-void SkComposeShader::flatten(SkFlattenableWriteBuffer& buffer)
-{
+void SkComposeShader::flatten(SkFlattenableWriteBuffer& buffer) {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fShaderA);
buffer.writeFlattenable(fShaderB);
@@ -90,19 +84,19 @@ void SkComposeShader::flatten(SkFlattenableWriteBuffer& buffer)
*/
bool SkComposeShader::setContext(const SkBitmap& device,
const SkPaint& paint,
- const SkMatrix& matrix)
-{
- if (!this->INHERITED::setContext(device, paint, matrix))
+ const SkMatrix& matrix) {
+ if (!this->INHERITED::setContext(device, paint, matrix)) {
return false;
+ }
// we preconcat our localMatrix (if any) with the device matrix
// before calling our sub-shaders
SkMatrix tmpM;
-
+
(void)this->getLocalMatrix(&tmpM);
tmpM.setConcat(matrix, tmpM);
-
+
SkAutoAlphaRestore restore(const_cast<SkPaint*>(&paint), 0xFF);
return fShaderA->setContext(device, paint, tmpM) &&
@@ -113,58 +107,56 @@ bool SkComposeShader::setContext(const SkBitmap& device,
// take up too much stack-space (each element is 4 bytes)
#define TMP_COLOR_COUNT 64
-void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count)
-{
+void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count) {
SkShader* shaderA = fShaderA;
SkShader* shaderB = fShaderB;
SkXfermode* mode = fMode;
unsigned scale = SkAlpha255To256(this->getPaintAlpha());
-
+
SkPMColor tmp[TMP_COLOR_COUNT];
- if (NULL == mode) // implied SRC_OVER
- {
+ if (NULL == mode) { // implied SRC_OVER
// TODO: when we have a good test-case, should use SkBlitRow::Proc32
// for these loops
do {
int n = count;
- if (n > TMP_COLOR_COUNT)
+ if (n > TMP_COLOR_COUNT) {
n = TMP_COLOR_COUNT;
-
+ }
+
shaderA->shadeSpan(x, y, result, n);
shaderB->shadeSpan(x, y, tmp, n);
- if (256 == scale)
- {
- for (int i = 0; i < n; i++)
+ if (256 == scale) {
+ for (int i = 0; i < n; i++) {
result[i] = SkPMSrcOver(tmp[i], result[i]);
+ }
+ } else {
+ for (int i = 0; i < n; i++) {
+ result[i] = SkAlphaMulQ(SkPMSrcOver(tmp[i], result[i]),
+ scale);
+ }
}
- else
- {
- for (int i = 0; i < n; i++)
- result[i] = SkAlphaMulQ(SkPMSrcOver(tmp[i], result[i]), scale);
- }
-
+
result += n;
x += n;
count -= n;
} while (count > 0);
- }
- else // use mode for the composition
- {
+ } else { // use mode for the composition
do {
int n = count;
- if (n > TMP_COLOR_COUNT)
+ if (n > TMP_COLOR_COUNT) {
n = TMP_COLOR_COUNT;
-
+ }
+
shaderA->shadeSpan(x, y, result, n);
shaderB->shadeSpan(x, y, tmp, n);
mode->xfer32(result, tmp, n, NULL);
- if (256 == scale)
- {
- for (int i = 0; i < n; i++)
+ if (256 == scale) {
+ for (int i = 0; i < n; i++) {
result[i] = SkAlphaMulQ(result[i], scale);
+ }
}
result += n;
@@ -173,4 +165,4 @@ void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count)
} while (count > 0);
}
}
-
+
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 541860c12a..8378e7370d 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -76,6 +76,7 @@ public:
fBlitter = SkBlitter::Choose(device, matrix, paint,
fStorage, sizeof(fStorage));
}
+
~SkAutoBlitterChoose();
SkBlitter* operator->() { return fBlitter; }
@@ -99,16 +100,17 @@ public:
SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint* paint)
: fPaint((SkPaint*)paint) {
fPrevShader = paint->getShader();
- fPrevShader->safeRef();
+ SkSafeRef(fPrevShader);
fPaint->setShader(SkShader::CreateBitmapShader( src,
SkShader::kClamp_TileMode, SkShader::kClamp_TileMode,
fStorage, sizeof(fStorage)));
}
+
~SkAutoBitmapShaderInstall() {
SkShader* shader = fPaint->getShader();
fPaint->setShader(fPrevShader);
- fPrevShader->safeUnref();
+ SkSafeUnref(fPrevShader);
if ((void*)shader == (void*)fStorage) {
shader->~SkShader();
@@ -116,6 +118,7 @@ public:
SkDELETE(shader);
}
}
+
private:
SkPaint* fPaint;
SkShader* fPrevShader;
@@ -129,9 +132,11 @@ public:
fStyle = paint.getStyle(); // record the old
fPaint.setStyle(style); // change it to the specified style
}
+
~SkAutoPaintStyleRestore() {
fPaint.setStyle(fStyle); // restore the old
}
+
private:
SkPaint& fPaint;
SkPaint::Style fStyle;
diff --git a/src/core/SkFlattenable.cpp b/src/core/SkFlattenable.cpp
index 355851924b..dcdaa92d35 100644
--- a/src/core/SkFlattenable.cpp
+++ b/src/core/SkFlattenable.cpp
@@ -15,10 +15,10 @@ void SkFlattenable::flatten(SkFlattenableWriteBuffer&)
SkFlattenableReadBuffer::SkFlattenableReadBuffer() {
fRCArray = NULL;
fRCCount = 0;
-
+
fTFArray = NULL;
fTFCount = 0;
-
+
fFactoryArray = NULL;
fFactoryCount = 0;
}
@@ -27,10 +27,10 @@ SkFlattenableReadBuffer::SkFlattenableReadBuffer(const void* data) :
INHERITED(data, 1024 * 1024) {
fRCArray = NULL;
fRCCount = 0;
-
+
fTFArray = NULL;
fTFCount = 0;
-
+
fFactoryArray = NULL;
fFactoryCount = 0;
}
@@ -39,10 +39,10 @@ SkFlattenableReadBuffer::SkFlattenableReadBuffer(const void* data, size_t size)
: INHERITED(data, size) {
fRCArray = NULL;
fRCCount = 0;
-
+
fTFArray = NULL;
fTFCount = 0;
-
+
fFactoryArray = NULL;
fFactoryCount = 0;
}
@@ -72,7 +72,7 @@ SkRefCnt* SkFlattenableReadBuffer::readRefCnt() {
SkFlattenable* SkFlattenableReadBuffer::readFlattenable() {
SkFlattenable::Factory factory = NULL;
-
+
if (fFactoryCount > 0) {
uint32_t index = this->readU32();
if (index > 0) {
@@ -123,9 +123,9 @@ SkFlattenableWriteBuffer::SkFlattenableWriteBuffer(size_t minSize) :
}
SkFlattenableWriteBuffer::~SkFlattenableWriteBuffer() {
- fRCRecorder->safeUnref();
- fTFRecorder->safeUnref();
- fFactoryRecorder->safeUnref();
+ SkSafeUnref(fRCRecorder);
+ SkSafeUnref(fTFRecorder);
+ SkSafeUnref(fFactoryRecorder);
}
SkRefCntRecorder* SkFlattenableWriteBuffer::setRefCntRecorder(
@@ -173,7 +173,7 @@ void SkFlattenableWriteBuffer::writeFlattenable(SkFlattenable* flattenable) {
} else {
this->writeFunctionPtr((void*)factory);
}
-
+
if (factory) {
// make room for the size of the flatttened object
(void)this->reserve(sizeof(uint32_t));
@@ -223,15 +223,15 @@ static Pair gPairs[MAX_PAIR_COUNT];
void SkFlattenable::Register(const char name[], Factory factory) {
SkASSERT(name);
SkASSERT(factory);
-
+
static bool gOnce;
if (!gOnce) {
gCount = 0;
gOnce = true;
}
-
+
SkASSERT(gCount < MAX_PAIR_COUNT);
-
+
gPairs[gCount].fName = name;
gPairs[gCount].fFactory = factory;
gCount += 1;
diff --git a/src/core/SkMallocPixelRef.cpp b/src/core/SkMallocPixelRef.cpp
index 726baca4d1..7b97f169da 100644
--- a/src/core/SkMallocPixelRef.cpp
+++ b/src/core/SkMallocPixelRef.cpp
@@ -10,7 +10,7 @@ SkMallocPixelRef::SkMallocPixelRef(void* storage, size_t size,
fStorage = storage;
fSize = size;
fCTable = ctable;
- ctable->safeRef();
+ SkSafeRef(ctable);
}
SkMallocPixelRef::~SkMallocPixelRef() {
@@ -40,7 +40,8 @@ void SkMallocPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
}
}
-SkMallocPixelRef::SkMallocPixelRef(SkFlattenableReadBuffer& buffer) : INHERITED(buffer, NULL) {
+SkMallocPixelRef::SkMallocPixelRef(SkFlattenableReadBuffer& buffer)
+ : INHERITED(buffer, NULL) {
fSize = buffer.readU32();
fStorage = sk_malloc_throw(fSize);
buffer.read(fStorage, fSize);
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 1c65a7df33..0fb225442f 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -71,49 +71,49 @@ SkPaint::SkPaint(const SkPaint& src)
{
memcpy(this, &src, sizeof(src));
- fTypeface->safeRef();
- fPathEffect->safeRef();
- fShader->safeRef();
- fXfermode->safeRef();
- fMaskFilter->safeRef();
- fColorFilter->safeRef();
- fRasterizer->safeRef();
- fLooper->safeRef();
+ SkSafeRef(fTypeface);
+ SkSafeRef(fPathEffect);
+ SkSafeRef(fShader);
+ SkSafeRef(fXfermode);
+ SkSafeRef(fMaskFilter);
+ SkSafeRef(fColorFilter);
+ SkSafeRef(fRasterizer);
+ SkSafeRef(fLooper);
}
SkPaint::~SkPaint()
{
- fTypeface->safeUnref();
- fPathEffect->safeUnref();
- fShader->safeUnref();
- fXfermode->safeUnref();
- fMaskFilter->safeUnref();
- fColorFilter->safeUnref();
- fRasterizer->safeUnref();
- fLooper->safeUnref();
+ SkSafeUnref(fTypeface);
+ SkSafeUnref(fPathEffect);
+ SkSafeUnref(fShader);
+ SkSafeUnref(fXfermode);
+ SkSafeUnref(fMaskFilter);
+ SkSafeUnref(fColorFilter);
+ SkSafeUnref(fRasterizer);
+ SkSafeUnref(fLooper);
}
SkPaint& SkPaint::operator=(const SkPaint& src)
{
SkASSERT(&src);
- src.fTypeface->safeRef();
- src.fPathEffect->safeRef();
- src.fShader->safeRef();
- src.fXfermode->safeRef();
- src.fMaskFilter->safeRef();
- src.fColorFilter->safeRef();
- src.fRasterizer->safeRef();
- src.fLooper->safeRef();
-
- fTypeface->safeUnref();
- fPathEffect->safeUnref();
- fShader->safeUnref();
- fXfermode->safeUnref();
- fMaskFilter->safeUnref();
- fColorFilter->safeUnref();
- fRasterizer->safeUnref();
- fLooper->safeUnref();
+ SkSafeRef(src.fTypeface);
+ SkSafeRef(src.fPathEffect);
+ SkSafeRef(src.fShader);
+ SkSafeRef(src.fXfermode);
+ SkSafeRef(src.fMaskFilter);
+ SkSafeRef(src.fColorFilter);
+ SkSafeRef(src.fRasterizer);
+ SkSafeRef(src.fLooper);
+
+ SkSafeUnref(fTypeface);
+ SkSafeUnref(fPathEffect);
+ SkSafeUnref(fShader);
+ SkSafeUnref(fXfermode);
+ SkSafeUnref(fMaskFilter);
+ SkSafeUnref(fColorFilter);
+ SkSafeUnref(fRasterizer);
+ SkSafeUnref(fLooper);
memcpy(this, &src, sizeof(src));
@@ -1511,13 +1511,13 @@ void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) {
}
if (flatFlags & kHasEffects_FlatFlag) {
- this->setPathEffect((SkPathEffect*) buffer.readFlattenable())->safeUnref();
- this->setShader((SkShader*) buffer.readFlattenable())->safeUnref();
- this->setXfermode((SkXfermode*) buffer.readFlattenable())->safeUnref();
- this->setMaskFilter((SkMaskFilter*) buffer.readFlattenable())->safeUnref();
- this->setColorFilter((SkColorFilter*) buffer.readFlattenable())->safeUnref();
- this->setRasterizer((SkRasterizer*) buffer.readFlattenable())->safeUnref();
- this->setLooper((SkDrawLooper*) buffer.readFlattenable())->safeUnref();
+ SkSafeUnref(this->setPathEffect((SkPathEffect*) buffer.readFlattenable()));
+ SkSafeUnref(this->setShader((SkShader*) buffer.readFlattenable()));
+ SkSafeUnref(this->setXfermode((SkXfermode*) buffer.readFlattenable()));
+ SkSafeUnref(this->setMaskFilter((SkMaskFilter*) buffer.readFlattenable()));
+ SkSafeUnref(this->setColorFilter((SkColorFilter*) buffer.readFlattenable()));
+ SkSafeUnref(this->setRasterizer((SkRasterizer*) buffer.readFlattenable()));
+ SkSafeUnref(this->setLooper((SkDrawLooper*) buffer.readFlattenable()));
} else {
this->setPathEffect(NULL);
this->setShader(NULL);
@@ -1531,20 +1531,17 @@ void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) {
///////////////////////////////////////////////////////////////////////////////
-SkShader* SkPaint::setShader(SkShader* shader)
-{
+SkShader* SkPaint::setShader(SkShader* shader) {
SkRefCnt_SafeAssign(fShader, shader);
return shader;
}
-SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter)
-{
+SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter) {
SkRefCnt_SafeAssign(fColorFilter, filter);
return filter;
}
-SkXfermode* SkPaint::setXfermode(SkXfermode* mode)
-{
+SkXfermode* SkPaint::setXfermode(SkXfermode* mode) {
SkRefCnt_SafeAssign(fXfermode, mode);
return mode;
}
@@ -1555,19 +1552,17 @@ SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) {
return fXfermode;
}
-SkPathEffect* SkPaint::setPathEffect(SkPathEffect* effect)
-{
+SkPathEffect* SkPaint::setPathEffect(SkPathEffect* effect) {
SkRefCnt_SafeAssign(fPathEffect, effect);
return effect;
}
-SkMaskFilter* SkPaint::setMaskFilter(SkMaskFilter* filter)
-{
+SkMaskFilter* SkPaint::setMaskFilter(SkMaskFilter* filter) {
SkRefCnt_SafeAssign(fMaskFilter, filter);
return filter;
}
-////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
bool SkPaint::getFillPath(const SkPath& src, SkPath* dst) const
{
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 343ca2b4b2..c199caebd6 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2007, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -37,7 +37,7 @@
#ifdef SK_DEBUG
-// enable SK_DEBUG_TRACE to trace DrawType elements when
+// enable SK_DEBUG_TRACE to trace DrawType elements when
// recorded and played back
// #define SK_DEBUG_TRACE
// enable SK_DEBUG_SIZE to see the size of picture components
@@ -77,12 +77,12 @@ const char* DrawTypeToString(DrawType drawType) {
case SCALE: return "SCALE";
case SKEW: return "SKEW";
case TRANSLATE: return "TRANSLATE";
- default:
- SkDebugf("DrawType error 0x%08x\n", drawType);
- SkASSERT(0);
+ default:
+ SkDebugf("DrawType error 0x%08x\n", drawType);
+ SkASSERT(0);
break;
}
- SkASSERT(0);
+ SkASSERT(0);
return NULL;
}
#endif
@@ -133,7 +133,7 @@ SkPicture::SkPicture(const SkPicture& src) : SkRefCnt() {
}
SkPicture::~SkPicture() {
- fRecord->safeUnref();
+ SkSafeUnref(fRecord);
SkDELETE(fPlayback);
}
@@ -166,7 +166,7 @@ SkCanvas* SkPicture::beginRecording(int width, int height,
SkBitmap bm;
bm.setConfig(SkBitmap::kNo_Config, width, height);
fRecord->setBitmapDevice(bm);
-
+
return fRecord;
}
@@ -217,7 +217,7 @@ SkPicture::SkPicture(SkStream* stream) : SkRefCnt() {
void SkPicture::serialize(SkWStream* stream) const {
SkPicturePlayback* playback = fPlayback;
-
+
if (NULL == playback && fRecord) {
playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
}
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index f488565b41..0232cc0a88 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -14,7 +14,7 @@ SkPicturePlayback::SkPicturePlayback() {
SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
#ifdef SK_DEBUG_SIZE
- size_t overallBytes, bitmapBytes, matricesBytes,
+ size_t overallBytes, bitmapBytes, matricesBytes,
paintBytes, pathBytes, pictureBytes, regionBytes;
int bitmaps = record.bitmaps(&bitmapBytes);
int matrices = record.matrices(&matricesBytes);
@@ -42,7 +42,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
SkDebugf("rects size %zd (rects:%d) ", record.fRectBytes, record.fRectWrites);
if (record.fTextWrites != 0)
SkDebugf("text size %zd (text strings:%d) ", record.fTextBytes, record.fTextWrites);
-
+
SkDebugf("\n");
#endif
#ifdef SK_DEBUG_DUMP
@@ -55,27 +55,27 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
init();
if (writer.size() == 0)
return;
-
+
{
size_t size = writer.size();
void* buffer = sk_malloc_throw(size);
writer.flatten(buffer);
fReader.setMemory(buffer, size); // fReader owns buffer now
}
-
+
// copy over the refcnt dictionary to our reader
//
fRCPlayback.reset(&record.fRCRecorder);
fRCPlayback.setupBuffer(fReader);
-
+
fTFPlayback.reset(&record.fTFRecorder);
fTFPlayback.setupBuffer(fReader);
-
+
const SkTDArray<const SkFlatBitmap* >& bitmaps = record.getBitmaps();
fBitmapCount = bitmaps.count();
if (fBitmapCount > 0) {
fBitmaps = SkNEW_ARRAY(SkBitmap, fBitmapCount);
- for (const SkFlatBitmap** flatBitmapPtr = bitmaps.begin();
+ for (const SkFlatBitmap** flatBitmapPtr = bitmaps.begin();
flatBitmapPtr != bitmaps.end(); flatBitmapPtr++) {
const SkFlatBitmap* flatBitmap = *flatBitmapPtr;
int index = flatBitmap->index() - 1;
@@ -87,7 +87,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
fMatrixCount = matrices.count();
if (fMatrixCount > 0) {
fMatrices = SkNEW_ARRAY(SkMatrix, fMatrixCount);
- for (const SkFlatMatrix** matrixPtr = matrices.begin();
+ for (const SkFlatMatrix** matrixPtr = matrices.begin();
matrixPtr != matrices.end(); matrixPtr++) {
const SkFlatMatrix* flatMatrix = *matrixPtr;
flatMatrix->unflatten(&fMatrices[flatMatrix->index() - 1]);
@@ -98,7 +98,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
fPaintCount = paints.count();
if (fPaintCount > 0) {
fPaints = SkNEW_ARRAY(SkPaint, fPaintCount);
- for (const SkFlatPaint** flatPaintPtr = paints.begin();
+ for (const SkFlatPaint** flatPaintPtr = paints.begin();
flatPaintPtr != paints.end(); flatPaintPtr++) {
const SkFlatPaint* flatPaint = *flatPaintPtr;
int index = flatPaint->index() - 1;
@@ -108,7 +108,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
}
fPathHeap = record.fPathHeap;
- fPathHeap->safeRef();
+ SkSafeRef(fPathHeap);
const SkTDArray<SkPicture* >& pictures = record.getPictureRefs();
fPictureCount = pictures.count();
@@ -119,7 +119,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
fPictureRefs[i]->ref();
}
}
-
+
const SkTDArray<SkShape* >& shapes = record.getShapes();
fShapeCount = shapes.count();
if (fShapeCount > 0) {
@@ -130,18 +130,18 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record) {
fShapes[i] = s;
}
}
-
+
const SkTDArray<const SkFlatRegion* >& regions = record.getRegions();
fRegionCount = regions.count();
if (fRegionCount > 0) {
fRegions = SkNEW_ARRAY(SkRegion, fRegionCount);
- for (const SkFlatRegion** flatRegionPtr = regions.begin();
+ for (const SkFlatRegion** flatRegionPtr = regions.begin();
flatRegionPtr != regions.end(); flatRegionPtr++) {
const SkFlatRegion* flatRegion = *flatRegionPtr;
flatRegion->unflatten(&fRegions[flatRegion->index() - 1]);
}
}
-
+
#ifdef SK_DEBUG_SIZE
int overall = fPlayback->size(&overallBytes);
bitmaps = fPlayback->bitmaps(&bitmapBytes);
@@ -194,7 +194,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src) {
}
fPathHeap = src.fPathHeap;
- fPathHeap->safeRef();
+ SkSafeRef(fPathHeap);
fPictureCount = src.fPictureCount;
fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
@@ -202,7 +202,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src) {
fPictureRefs[i] = src.fPictureRefs[i];
fPictureRefs[i]->ref();
}
-
+
fShapeCount = src.fShapeCount;
fShapes = SkNEW_ARRAY(SkShape*, fShapeCount);
for (int i = 0; i < fShapeCount; i++) {
@@ -210,7 +210,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src) {
SkSafeRef(s);
fShapes[i] = s;
}
-
+
fRegionCount = src.fRegionCount;
fRegions = SkNEW_ARRAY(SkRegion, fRegionCount);
for (i = 0; i < fRegionCount; i++) {
@@ -226,9 +226,9 @@ void SkPicturePlayback::init() {
fPictureRefs = NULL;
fShapes = NULL;
fRegions = NULL;
- fBitmapCount = fMatrixCount = fPaintCount = fPictureCount =
+ fBitmapCount = fMatrixCount = fPaintCount = fPictureCount =
fRegionCount = fShapeCount = 0;
-
+
fFactoryPlayback = NULL;
}
@@ -239,19 +239,19 @@ SkPicturePlayback::~SkPicturePlayback() {
SkDELETE_ARRAY(fMatrices);
SkDELETE_ARRAY(fPaints);
SkDELETE_ARRAY(fRegions);
-
- fPathHeap->safeUnref();
-
+
+ SkSafeUnref(fPathHeap);
+
for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i]->unref();
}
SkDELETE_ARRAY(fPictureRefs);
-
+
for (int i = 0; i < fShapeCount; i++) {
SkSafeUnref(fShapes[i]);
}
SkDELETE_ARRAY(fShapes);
-
+
SkDELETE(fFactoryPlayback);
}
@@ -299,13 +299,13 @@ static void writeTagSize(SkWStream* stream, uint32_t tag,
static void writeFactories(SkWStream* stream, const SkFactoryRecorder& rec) {
int count = rec.count();
-
+
writeTagSize(stream, PICT_FACTORY_TAG, count);
-
+
SkAutoSTMalloc<16, SkFlattenable::Factory> storage(count);
SkFlattenable::Factory* array = (SkFlattenable::Factory*)storage.get();
rec.get(array);
-
+
for (int i = 0; i < count; i++) {
const char* name = SkFlattenable::FactoryToName(array[i]);
// SkDebugf("---- write factories [%d] %p <%s>\n", i, array[i], name);
@@ -321,13 +321,13 @@ static void writeFactories(SkWStream* stream, const SkFactoryRecorder& rec) {
static void writeTypefaces(SkWStream* stream, const SkRefCntRecorder& rec) {
int count = rec.count();
-
+
writeTagSize(stream, PICT_TYPEFACE_TAG, count);
-
+
SkAutoSTMalloc<16, SkTypeface*> storage(count);
SkTypeface** array = (SkTypeface**)storage.get();
rec.get((SkRefCnt**)array);
-
+
for (int i = 0; i < count; i++) {
array[i]->serialize(stream);
}
@@ -336,7 +336,7 @@ static void writeTypefaces(SkWStream* stream, const SkRefCntRecorder& rec) {
void SkPicturePlayback::serialize(SkWStream* stream) const {
writeTagSize(stream, PICT_READER_TAG, fReader.size());
stream->write(fReader.base(), fReader.size());
-
+
SkRefCntRecorder typefaceRecorder;
SkFactoryRecorder factRecorder;
@@ -347,7 +347,7 @@ void SkPicturePlayback::serialize(SkWStream* stream) const {
buffer.setFactoryRecorder(&factRecorder);
int i;
-
+
writeTagSize(buffer, PICT_BITMAP_TAG, fBitmapCount);
for (i = 0; i < fBitmapCount; i++) {
fBitmaps[i].flatten(buffer);
@@ -360,7 +360,7 @@ void SkPicturePlayback::serialize(SkWStream* stream) const {
for (i = 0; i < fPaintCount; i++) {
fPaints[i].flatten(buffer);
}
-
+
{
int count = fPathHeap ? fPathHeap->count() : 0;
writeTagSize(buffer, PICT_PATH_TAG, count);
@@ -368,7 +368,7 @@ void SkPicturePlayback::serialize(SkWStream* stream) const {
fPathHeap->flatten(buffer);
}
}
-
+
writeTagSize(buffer, PICT_REGION_TAG, fRegionCount);
for (i = 0; i < fRegionCount; i++) {
uint32_t size = fRegions[i].flatten(NULL);
@@ -377,7 +377,7 @@ void SkPicturePlayback::serialize(SkWStream* stream) const {
fRegions[i].flatten(storage.get());
buffer.writePad(storage.get(), size);
}
-
+
writeTagSize(buffer, PICT_SHAPE_TAG, fShapeCount);
for (i = 0; i < fShapeCount; i++) {
buffer.writeFlattenable(fShapes[i]);
@@ -392,7 +392,7 @@ void SkPicturePlayback::serialize(SkWStream* stream) const {
for (i = 0; i < fPictureCount; i++) {
fPictureRefs[i]->serialize(stream);
}
-
+
writeTagSize(stream, PICT_ARRAYS_TAG, buffer.size());
buffer.writeToStream(stream);
}
@@ -419,14 +419,14 @@ SkPicturePlayback::SkPicturePlayback(SkStream* stream) {
this->init();
int i;
-
+
{
size_t size = readTagSize(stream, PICT_READER_TAG);
void* storage = sk_malloc_throw(size);
stream->read(storage, size);
fReader.setMemory(storage, size);
}
-
+
int factoryCount = readTagSize(stream, PICT_FACTORY_TAG);
fFactoryPlayback = SkNEW_ARGS(SkFactoryPlayback, (factoryCount));
for (i = 0; i < factoryCount; i++) {
@@ -437,19 +437,19 @@ SkPicturePlayback::SkPicturePlayback(SkStream* stream) {
// SkDebugf("--- factory playback [%d] <%s>\n", i, str.c_str());
fFactoryPlayback->base()[i] = SkFlattenable::NameToFactory(str.c_str());
}
-
+
int typefaceCount = readTagSize(stream, PICT_TYPEFACE_TAG);
fTFPlayback.setCount(typefaceCount);
for (i = 0; i < typefaceCount; i++) {
fTFPlayback.set(i, SkTypeface::Deserialize(stream))->unref();
- }
+ }
fPictureCount = readTagSize(stream, PICT_PICTURE_TAG);
fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
for (i = 0; i < fPictureCount; i++) {
fPictureRefs[i] = SkNEW_ARGS(SkPicture, (stream));
}
-
+
/*
Now read the arrays chunk, and parse using a read buffer
*/
@@ -470,20 +470,20 @@ SkPicturePlayback::SkPicturePlayback(SkStream* stream) {
fMatrixCount = readTagSize(buffer, PICT_MATRIX_TAG);
fMatrices = SkNEW_ARRAY(SkMatrix, fMatrixCount);
buffer.read(fMatrices, fMatrixCount * sizeof(SkMatrix));
-
+
fPaintCount = readTagSize(buffer, PICT_PAINT_TAG);
fPaints = SkNEW_ARRAY(SkPaint, fPaintCount);
for (i = 0; i < fPaintCount; i++) {
fPaints[i].unflatten(buffer);
}
-
+
{
int count = readTagSize(buffer, PICT_PATH_TAG);
if (count > 0) {
fPathHeap = SkNEW_ARGS(SkPathHeap, (buffer));
}
}
-
+
fRegionCount = readTagSize(buffer, PICT_REGION_TAG);
fRegions = SkNEW_ARRAY(SkRegion, fRegionCount);
for (i = 0; i < fRegionCount; i++) {
@@ -506,12 +506,12 @@ SkPicturePlayback::SkPicturePlayback(SkStream* stream) {
struct SkipClipRec {
int fCount;
size_t fSize;
-
+
SkipClipRec() {
fCount = 0;
fSize = 0;
}
-
+
void recordSkip(size_t bytes) {
fCount += 1;
fSize += bytes;
@@ -523,7 +523,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
#ifdef ENABLE_TIME_DRAW
SkAutoTime at("SkPicture::draw", 50);
#endif
-
+
#ifdef SPEW_CLIP_SKIPPING
SkipClipRec skipRect, skipRegion, skipPath;
#endif
@@ -537,7 +537,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
const SkPath& path = getPath();
SkRegion::Op op = (SkRegion::Op) getInt();
size_t offsetToRestore = getInt();
- // HACK (false) until I can handle op==kReplace
+ // HACK (false) until I can handle op==kReplace
if (!canvas.clipPath(path, op)) {
#ifdef SPEW_CLIP_SKIPPING
skipPath.recordSkip(offsetToRestore - fReader.offset());
@@ -642,7 +642,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
} break;
case DRAW_RECT: {
const SkPaint& paint = *getPaint();
- canvas.drawRect(*fReader.skipRect(), paint);
+ canvas.drawRect(*fReader.skipRect(), paint);
} break;
case DRAW_SHAPE: {
SkShape* shape = getShape();
@@ -652,10 +652,10 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
} break;
case DRAW_SPRITE: {
const SkPaint* paint = getPaint();
- const SkBitmap& bitmap = getBitmap();
+ const SkBitmap& bitmap = getBitmap();
int left = getInt();
int top = getInt();
- canvas.drawSprite(bitmap, left, top, paint);
+ canvas.drawSprite(bitmap, left, top, paint);
} break;
case DRAW_TEXT: {
const SkPaint& paint = *getPaint();
@@ -683,7 +683,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
getText(&text);
const SkPath& path = getPath();
const SkMatrix* matrix = getMatrix();
- canvas.drawTextOnPath(text.text(), text.length(), path,
+ canvas.drawTextOnPath(text.text(), text.length(), path,
matrix, paint);
} break;
case DRAW_VERTICES: {
@@ -749,7 +749,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
SkASSERT(0);
}
}
-
+
#ifdef SPEW_CLIP_SKIPPING
{
size_t size = skipRect.fSize + skipPath.fSize + skipRegion.fSize;
@@ -768,7 +768,7 @@ void SkPicturePlayback::abort() {
///////////////////////////////////////////////////////////////////////////////
#if 0
-uint32_t SkPicturePlayback::flatten(void* storage) const {
+uint32_t SkPicturePlayback::flatten(void* storage) const {
SkWBuffer buffer(storage);
buffer.write32(fBitmapCount);
int index;
@@ -849,7 +849,7 @@ void SkPicturePlayback::unflatten(const void* storage) {
const void* local = buffer.skip(size);
fPaths[index].unflatten(local);
}
-
+
#if 0
fPictureCount = buffer.readU32();
fPictures = new SkPicture[fPictureCount];
@@ -859,7 +859,7 @@ void SkPicturePlayback::unflatten(const void* storage) {
fPictures[index].unflatten(local);
}
#endif
-
+
fRegionCount = buffer.readU32();
fRegions = new SkRegion[fRegionCount];
for (index = 0; index < fRegionCount; index++) {
@@ -876,14 +876,14 @@ void SkPicturePlayback::unflatten(const void* storage) {
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_DEBUG_SIZE
-int SkPicturePlayback::size(size_t* sizePtr) {
+int SkPicturePlayback::size(size_t* sizePtr) {
int objects = bitmaps(sizePtr);
objects += paints(sizePtr);
objects += paths(sizePtr);
objects += pictures(sizePtr);
objects += regions(sizePtr);
*sizePtr = fReader.size();
- return objects;
+ return objects;
}
int SkPicturePlayback::bitmaps(size_t* size) {
@@ -1110,7 +1110,7 @@ int SkPicturePlayback::dumpInt(char* bufferPtr, char* buffer, char* name) {
int SkPicturePlayback::dumpRect(char* bufferPtr, char* buffer, char* name) {
const SkRect* rect = fReader.skipRect();
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
- "%s:{l:%g t:%g r:%g b:%g}, ", name, SkScalarToFloat(rect.fLeft),
+ "%s:{l:%g t:%g r:%g b:%g}, ", name, SkScalarToFloat(rect.fLeft),
SkScalarToFloat(rect.fTop),
SkScalarToFloat(rect.fRight), SkScalarToFloat(rect.fBottom));
}
@@ -1119,7 +1119,7 @@ int SkPicturePlayback::dumpPoint(char* bufferPtr, char* buffer, char* name) {
SkPoint pt;
getPoint(&pt);
return snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
- "%s:{x:%g y:%g}, ", name, SkScalarToFloat(pt.fX),
+ "%s:{x:%g y:%g}, ", name, SkScalarToFloat(pt.fX),
SkScalarToFloat(pt.fY));
}
@@ -1131,7 +1131,7 @@ void SkPicturePlayback::dumpPointArray(char** bufferPtrPtr, char* buffer, int co
"count:%d {", count);
for (int index = 0; index < count; index++)
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
- "{x:%g y:%g}, ", SkScalarToFloat(pts[index].fX),
+ "{x:%g y:%g}, ", SkScalarToFloat(pts[index].fX),
SkScalarToFloat(pts[index].fY));
bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - buffer),
"} ");
@@ -1341,10 +1341,10 @@ void SkPicturePlayback::dump() const {
dumpBitmap(bitmap);
}
if (fBitmapCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"Bitmaps bitmaps = {");
for (index = 0; index < fBitmapCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"bitmap%p, ", &fBitmaps[index]);
if (fBitmapCount > 0)
SkDebugf("%s0};\n", pBuffer);
@@ -1357,10 +1357,10 @@ void SkPicturePlayback::dump() const {
}
bufferPtr = pBuffer;
if (fMatrixCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"Matrices matrices = {");
for (index = 0; index < fMatrixCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"matrix%p, ", &fMatrices[index]);
if (fMatrixCount > 0)
SkDebugf("%s0};\n", pBuffer);
@@ -1373,10 +1373,10 @@ void SkPicturePlayback::dump() const {
}
bufferPtr = pBuffer;
if (fPaintCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"Paints paints = {");
for (index = 0; index < fPaintCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"paint%p, ", &fPaints[index]);
if (fPaintCount > 0)
SkDebugf("%s0};\n", pBuffer);
@@ -1387,10 +1387,10 @@ void SkPicturePlayback::dump() const {
}
bufferPtr = pBuffer;
if (fPathCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"Paths paths = {");
for (index = 0; index < fPathCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"path%p, ", &fPaths[index]);
if (fPathCount > 0)
SkDebugf("%s0};\n", pBuffer);
@@ -1400,10 +1400,10 @@ void SkPicturePlayback::dump() const {
}
bufferPtr = pBuffer;
if (fPictureCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"Pictures pictures = {");
for (index = 0; index < fPictureCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"picture%p, ", fPictureRefs[index]);
if (fPictureCount > 0)
SkDebugf("%s0};\n", pBuffer);
@@ -1414,10 +1414,10 @@ void SkPicturePlayback::dump() const {
}
bufferPtr = pBuffer;
if (fRegionCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"Regions regions = {");
for (index = 0; index < fRegionCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
+ bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
"region%p, ", &fRegions[index]);
if (fRegionCount > 0)
SkDebugf("%s0};\n", pBuffer);
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 9844a480cd..00e4b600ef 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -15,7 +15,7 @@ SkPictureRecord::SkPictureRecord(uint32_t flags) :
fRestoreOffsetStack.setReserve(32);
fRestoreOffsetStack.push(0);
-
+
fPathHeap = NULL; // lazy allocate
}
@@ -28,9 +28,9 @@ SkPictureRecord::~SkPictureRecord() {
int SkPictureRecord::save(SaveFlags flags) {
addDraw(SAVE);
addInt(flags);
-
+
fRestoreOffsetStack.push(0);
-
+
validate();
return this->INHERITED::save(flags);
}
@@ -84,7 +84,7 @@ bool SkPictureRecord::translate(SkScalar dx, SkScalar dy) {
}
bool SkPictureRecord::scale(SkScalar sx, SkScalar sy) {
- addDraw(SCALE);
+ addDraw(SCALE);
addScalar(sx);
addScalar(sy);
validate();
@@ -92,14 +92,14 @@ bool SkPictureRecord::scale(SkScalar sx, SkScalar sy) {
}
bool SkPictureRecord::rotate(SkScalar degrees) {
- addDraw(ROTATE);
- addScalar(degrees);
+ addDraw(ROTATE);
+ addScalar(degrees);
validate();
return this->INHERITED::rotate(degrees);
}
bool SkPictureRecord::skew(SkScalar sx, SkScalar sy) {
- addDraw(SKEW);
+ addDraw(SKEW);
addScalar(sx);
addScalar(sy);
validate();
@@ -126,7 +126,7 @@ bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op) {
addDraw(CLIP_RECT);
addRect(rect);
addInt(op);
-
+
size_t offset = fWriter.size();
addInt(fRestoreOffsetStack.top());
fRestoreOffsetStack.top() = offset;
@@ -139,13 +139,13 @@ bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op) {
addDraw(CLIP_PATH);
addPath(path);
addInt(op);
-
+
size_t offset = fWriter.size();
addInt(fRestoreOffsetStack.top());
fRestoreOffsetStack.top() = offset;
-
+
validate();
-
+
if (fRecordFlags & SkPicture::kUsePathBoundsForClip_RecordingFlag) {
return this->INHERITED::clipRect(path.getBounds(), op);
} else {
@@ -154,14 +154,14 @@ bool SkPictureRecord::clipPath(const SkPath& path, SkRegion::Op op) {
}
bool SkPictureRecord::clipRegion(const SkRegion& region, SkRegion::Op op) {
- addDraw(CLIP_REGION);
+ addDraw(CLIP_REGION);
addRegion(region);
addInt(op);
-
+
size_t offset = fWriter.size();
addInt(fRestoreOffsetStack.top());
fRestoreOffsetStack.top() = offset;
-
+
validate();
return this->INHERITED::clipRegion(region, op);
}
@@ -250,10 +250,10 @@ void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint,
addScalar(bounds.fBottom);
}
-void SkPictureRecord::drawText(const void* text, size_t byteLength, SkScalar x,
+void SkPictureRecord::drawText(const void* text, size_t byteLength, SkScalar x,
SkScalar y, const SkPaint& paint) {
bool fast = paint.canComputeFastBounds();
-
+
addDraw(fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT);
addPaint(paint);
addText(text, byteLength);
@@ -265,7 +265,7 @@ void SkPictureRecord::drawText(const void* text, size_t byteLength, SkScalar x,
validate();
}
-void SkPictureRecord::drawPosText(const void* text, size_t byteLength,
+void SkPictureRecord::drawPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkPaint& paint) {
size_t points = paint.countText(text, byteLength);
if (0 == points)
@@ -282,7 +282,7 @@ void SkPictureRecord::drawPosText(const void* text, size_t byteLength,
}
}
}
-
+
bool fast = canUseDrawH && paint.canComputeFastBounds();
if (fast) {
@@ -303,7 +303,7 @@ void SkPictureRecord::drawPosText(const void* text, size_t byteLength,
}
addScalar(pos[0].fY);
SkScalar* xptr = (SkScalar*)fWriter.reserve(points * sizeof(SkScalar));
- for (size_t index = 0; index < points; index++)
+ for (size_t index = 0; index < points; index++)
*xptr++ = pos[index].fX;
}
else {
@@ -322,14 +322,14 @@ void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength,
size_t points = paint.countText(text, byteLength);
if (0 == points)
return;
-
+
bool fast = paint.canComputeFastBounds();
addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : DRAW_POS_TEXT_H);
addPaint(paint);
addText(text, byteLength);
addInt(points);
-
+
#ifdef SK_DEBUG_SIZE
size_t start = fWriter.size();
#endif
@@ -345,8 +345,8 @@ void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength,
validate();
}
-void SkPictureRecord::drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix,
+void SkPictureRecord::drawTextOnPath(const void* text, size_t byteLength,
+ const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) {
addDraw(DRAW_TEXT_ON_PATH);
addPaint(paint);
@@ -417,9 +417,9 @@ void SkPictureRecord::drawData(const void* data, size_t length) {
}
///////////////////////////////////////////////////////////////////////////////
-
+
void SkPictureRecord::reset() {
- fPathHeap->safeUnref();
+ SkSafeUnref(fPathHeap);
fPathHeap = NULL;
fBitmaps.reset();
@@ -430,10 +430,10 @@ void SkPictureRecord::reset() {
fShapes.safeUnrefAll();
fWriter.reset();
fHeap.reset();
-
+
fRestoreOffsetStack.setCount(1);
fRestoreOffsetStack.top() = 0;
-
+
fRCRecorder.reset();
fTFRecorder.reset();
}
@@ -486,7 +486,7 @@ void SkPictureRecord::addPoint(const SkPoint& point) {
fPointWrites++;
#endif
}
-
+
void SkPictureRecord::addPoints(const SkPoint pts[], int count) {
fWriter.writeMul4(pts, count * sizeof(SkPoint));
#ifdef SK_DEBUG_SIZE
@@ -539,7 +539,7 @@ void SkPictureRecord::addText(const void* text, size_t byteLength) {
int SkPictureRecord::find(SkTDArray<const SkFlatBitmap* >& bitmaps, const SkBitmap& bitmap) {
SkFlatBitmap* flat = SkFlatBitmap::Flatten(&fHeap, bitmap, fBitmapIndex,
&fRCRecorder);
- int index = SkTSearch<SkFlatData>((const SkFlatData**) bitmaps.begin(),
+ int index = SkTSearch<SkFlatData>((const SkFlatData**) bitmaps.begin(),
bitmaps.count(), (SkFlatData*) flat, sizeof(flat), &SkFlatData::Compare);
if (index >= 0) {
(void)fHeap.unalloc(flat);
@@ -554,7 +554,7 @@ int SkPictureRecord::find(SkTDArray<const SkFlatMatrix* >& matrices, const SkMat
if (matrix == NULL)
return 0;
SkFlatMatrix* flat = SkFlatMatrix::Flatten(&fHeap, *matrix, fMatrixIndex);
- int index = SkTSearch<SkFlatData>((const SkFlatData**) matrices.begin(),
+ int index = SkTSearch<SkFlatData>((const SkFlatData**) matrices.begin(),
matrices.count(), (SkFlatData*) flat, sizeof(flat), &SkFlatData::Compare);
if (index >= 0) {
(void)fHeap.unalloc(flat);
@@ -569,10 +569,10 @@ int SkPictureRecord::find(SkTDArray<const SkFlatPaint* >& paints, const SkPaint*
if (paint == NULL) {
return 0;
}
-
+
SkFlatPaint* flat = SkFlatPaint::Flatten(&fHeap, *paint, fPaintIndex,
&fRCRecorder, &fTFRecorder);
- int index = SkTSearch<SkFlatData>((const SkFlatData**) paints.begin(),
+ int index = SkTSearch<SkFlatData>((const SkFlatData**) paints.begin(),
paints.count(), (SkFlatData*) flat, sizeof(flat), &SkFlatData::Compare);
if (index >= 0) {
(void)fHeap.unalloc(flat);
@@ -586,7 +586,7 @@ int SkPictureRecord::find(SkTDArray<const SkFlatPaint* >& paints, const SkPaint*
int SkPictureRecord::find(SkTDArray<const SkFlatRegion* >& regions, const SkRegion& region) {
SkFlatRegion* flat = SkFlatRegion::Flatten(&fHeap, region, fRegionIndex);
- int index = SkTSearch<SkFlatData>((const SkFlatData**) regions.begin(),
+ int index = SkTSearch<SkFlatData>((const SkFlatData**) regions.begin(),
regions.count(), (SkFlatData*) flat, sizeof(flat), &SkFlatData::Compare);
if (index >= 0) {
(void)fHeap.unalloc(flat);
@@ -610,7 +610,7 @@ void SkPictureRecord::dumpMatrices() {
void SkPictureRecord::dumpPaints() {
int count = fPaints.count();
- for (int index = 0; index < count; index++)
+ for (int index = 0; index < count; index++)
fPaints[index]->dump();
}
#endif
@@ -638,7 +638,7 @@ size_t SkPictureRecord::size() const {
int SkPictureRecord::bitmaps(size_t* size) const {
size_t result = 0;
int count = fBitmaps.count();
- for (int index = 0; index < count; index++)
+ for (int index = 0; index < count; index++)
result += sizeof(fBitmaps[index]) + fBitmaps[index]->size();
*size = result;
return count;
@@ -653,7 +653,7 @@ int SkPictureRecord::matrices(size_t* size) const {
int SkPictureRecord::paints(size_t* size) const {
size_t result = 0;
int count = fPaints.count();
- for (int index = 0; index < count; index++)
+ for (int index = 0; index < count; index++)
result += sizeof(fPaints[index]) + fPaints[index]->size();
*size = result;
return count;
@@ -662,7 +662,7 @@ int SkPictureRecord::paints(size_t* size) const {
int SkPictureRecord::paths(size_t* size) const {
size_t result = 0;
int count = fPaths.count();
- for (int index = 0; index < count; index++)
+ for (int index = 0; index < count; index++)
result += sizeof(fPaths[index]) + fPaths[index]->size();
*size = result;
return count;
@@ -671,7 +671,7 @@ int SkPictureRecord::paths(size_t* size) const {
int SkPictureRecord::regions(size_t* size) const {
size_t result = 0;
int count = fRegions.count();
- for (int index = 0; index < count; index++)
+ for (int index = 0; index < count; index++)
result += sizeof(fRegions[index]) + fRegions[index]->size();
*size = result;
return count;
@@ -708,7 +708,7 @@ void SkPictureRecord::validateMatrices() const {
for (int index = 0; index < count; index++) {
const SkFlatMatrix* matrix = fMatrices[index];
SkASSERT(matrix);
- matrix->validate();
+ matrix->validate();
}
}
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 983f1addcc..f98969cec5 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -173,9 +173,9 @@ SkScalerContext::SkScalerContext(const SkDescriptor* desc)
SkScalerContext::~SkScalerContext() {
SkDELETE(fNextContext);
- fPathEffect->safeUnref();
- fMaskFilter->safeUnref();
- fRasterizer->safeUnref();
+ SkSafeUnref(fPathEffect);
+ SkSafeUnref(fMaskFilter);
+ SkSafeUnref(fRasterizer);
}
static SkScalerContext* allocNextContext(const SkScalerContext::Rec& rec) {
@@ -309,7 +309,7 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
glyph->fMaskFormat = 0;
return;
}
-
+
if (fRec.fFrameWidth > 0 || fPathEffect != NULL || fRasterizer != NULL) {
SkPath devPath, fillPath;
SkMatrix fillToDevMatrix;
@@ -333,7 +333,7 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
// just use devPath
SkIRect ir;
devPath.getBounds().roundOut(&ir);
-
+
if (ir.isEmpty() || !ir.is16Bit()) {
goto SK_ERROR;
}
@@ -366,7 +366,7 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
}
}
return;
-
+
SK_ERROR:
// draw nothing 'cause we failed
glyph->fLeft = 0;
@@ -410,11 +410,11 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
if (fRasterizer) {
SkMask mask;
-
+
glyph->toMask(&mask);
mask.fFormat = SkMask::kA8_Format;
sk_bzero(glyph->fImage, mask.computeImageSize());
-
+
if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, NULL,
fMaskFilter, &mask,
SkMask::kJustRenderImage_CreateMode)) {
@@ -472,7 +472,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
int height = SkFastMin32(origGlyph.fHeight, dstM.fBounds.height());
int dstRB = origGlyph.rowBytes();
int srcRB = dstM.fRowBytes;
-
+
const uint8_t* src = (const uint8_t*)dstM.fImage;
uint8_t* dst = (uint8_t*)origGlyph.fImage;
@@ -492,7 +492,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
SkMask::FreeImage(dstM.fImage);
}
}
-
+
// check to see if we should filter the alpha channel
if (NULL == fMaskFilter &&
@@ -504,7 +504,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
{
uint8_t* dst = (uint8_t*)origGlyph.fImage;
unsigned rowBytes = origGlyph.rowBytes();
-
+
for (int y = origGlyph.fHeight - 1; y >= 0; --y)
{
for (int x = origGlyph.fWidth - 1; x >= 0; --x)
@@ -536,7 +536,7 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath, Sk
SkPath path;
this->getGlyphContext(glyph)->generatePath(glyph, &path);
-
+
if (fRec.fFrameWidth > 0 || fPathEffect != NULL)
{
// need the path in user-space, with only the point-size applied
@@ -573,14 +573,14 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath, Sk
stroker.strokePath(localPath, &outline);
localPath.swap(outline);
}
-
+
// now return stuff to the caller
if (fillToDevMatrix)
*fillToDevMatrix = matrix;
-
+
if (devPath)
localPath.transform(matrix, devPath);
-
+
if (fillPath)
fillPath->swap(localPath);
}
@@ -588,7 +588,7 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath, Sk
{
if (fillToDevMatrix)
fillToDevMatrix->reset();
-
+
if (devPath)
{
if (fillPath == NULL)
@@ -596,11 +596,11 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath, Sk
else
*devPath = path;
}
-
+
if (fillPath)
fillPath->swap(path);
}
-
+
if (devPath)
devPath->updateBoundsCache();
if (fillPath)
diff --git a/src/core/SkSpriteBlitter_ARGB32.cpp b/src/core/SkSpriteBlitter_ARGB32.cpp
index 01ee9f1f69..df9e2a1651 100644
--- a/src/core/SkSpriteBlitter_ARGB32.cpp
+++ b/src/core/SkSpriteBlitter_ARGB32.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -41,7 +41,7 @@ public:
fProc32 = SkBlitRow::Factory32(flags32);
fAlpha = alpha;
}
-
+
virtual void blitRect(int x, int y, int width, int height) {
SkASSERT(width > 0 && height > 0);
SK_RESTRICT uint32_t* dst = fDevice->getAddr32(x, y);
@@ -62,7 +62,7 @@ public:
private:
SkBlitRow::Proc32 fProc32;
U8CPU fAlpha;
-
+
typedef SkSpriteBlitter INHERITED;
};
@@ -73,11 +73,11 @@ public:
Sprite_D32_XferFilter(const SkBitmap& source, const SkPaint& paint)
: SkSpriteBlitter(source) {
fColorFilter = paint.getColorFilter();
- fColorFilter->safeRef();
-
+ SkSafeRef(fColorFilter);
+
fXfermode = paint.getXfermode();
- fXfermode->safeRef();
-
+ SkSafeRef(fXfermode);
+
fBufferSize = 0;
fBuffer = NULL;
@@ -88,21 +88,21 @@ public:
if (!source.isOpaque()) {
flags32 |= SkBlitRow::kSrcPixelAlpha_Flag32;
}
-
+
fProc32 = SkBlitRow::Factory32(flags32);
fAlpha = paint.getAlpha();
}
-
+
virtual ~Sprite_D32_XferFilter() {
delete[] fBuffer;
- fXfermode->safeUnref();
- fColorFilter->safeUnref();
+ SkSafeUnref(fXfermode);
+ SkSafeUnref(fColorFilter);
}
-
+
virtual void setup(const SkBitmap& device, int left, int top,
const SkPaint& paint) {
this->INHERITED::setup(device, left, top, paint);
-
+
int width = device.width();
if (width > fBufferSize) {
fBufferSize = width;
@@ -142,12 +142,12 @@ public:
do {
const SkPMColor* tmp = src;
-
+
if (NULL != colorFilter) {
colorFilter->filterSpan(src, width, fBuffer);
tmp = fBuffer;
}
-
+
if (NULL != xfermode) {
xfermode->xfer32(dst, tmp, width, NULL);
} else {
@@ -158,7 +158,7 @@ public:
src = (const SK_RESTRICT uint32_t*)((const char*)src + srcRB);
} while (--height != 0);
}
-
+
private:
typedef Sprite_D32_XferFilter INHERITED;
};
@@ -166,7 +166,7 @@ private:
static void fillbuffer(SK_RESTRICT SkPMColor dst[],
const SK_RESTRICT SkPMColor16 src[], int count) {
SkASSERT(count > 0);
-
+
do {
*dst++ = SkPixel4444ToPixel32(*src++);
} while (--count != 0);
@@ -176,7 +176,7 @@ class Sprite_D32_S4444_XferFilter : public Sprite_D32_XferFilter {
public:
Sprite_D32_S4444_XferFilter(const SkBitmap& source, const SkPaint& paint)
: Sprite_D32_XferFilter(source, paint) {}
-
+
virtual void blitRect(int x, int y, int width, int height) {
SkASSERT(width > 0 && height > 0);
SK_RESTRICT SkPMColor* dst = fDevice->getAddr32(x, y);
@@ -190,7 +190,7 @@ public:
do {
fillbuffer(buffer, src, width);
-
+
if (NULL != colorFilter) {
colorFilter->filterSpan(buffer, width, buffer);
}
@@ -199,12 +199,12 @@ public:
} else {
fProc32(dst, buffer, width, fAlpha);
}
-
+
dst = (SK_RESTRICT SkPMColor*)((char*)dst + dstRB);
src = (const SK_RESTRICT SkPMColor16*)((const char*)src + srcRB);
} while (--height != 0);
}
-
+
private:
typedef Sprite_D32_XferFilter INHERITED;
};
@@ -223,7 +223,7 @@ static void src_row(SK_RESTRICT SkPMColor dst[],
class Sprite_D32_S4444_Opaque : public SkSpriteBlitter {
public:
Sprite_D32_S4444_Opaque(const SkBitmap& source) : SkSpriteBlitter(source) {}
-
+
virtual void blitRect(int x, int y, int width, int height) {
SkASSERT(width > 0 && height > 0);
SK_RESTRICT SkPMColor* dst = fDevice->getAddr32(x, y);
@@ -231,7 +231,7 @@ public:
y - fTop);
unsigned dstRB = fDevice->rowBytes();
unsigned srcRB = fSource->rowBytes();
-
+
do {
src_row(dst, src, width);
dst = (SK_RESTRICT SkPMColor*)((char*)dst + dstRB);
@@ -252,7 +252,7 @@ static void srcover_row(SK_RESTRICT SkPMColor dst[],
class Sprite_D32_S4444 : public SkSpriteBlitter {
public:
Sprite_D32_S4444(const SkBitmap& source) : SkSpriteBlitter(source) {}
-
+
virtual void blitRect(int x, int y, int width, int height) {
SkASSERT(width > 0 && height > 0);
SK_RESTRICT SkPMColor* dst = fDevice->getAddr32(x, y);
@@ -260,7 +260,7 @@ public:
y - fTop);
unsigned dstRB = fDevice->rowBytes();
unsigned srcRB = fSource->rowBytes();
-
+
do {
srcover_row(dst, src, width);
dst = (SK_RESTRICT SkPMColor*)((char*)dst + dstRB);
diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp
index 2af60971c3..a3c4eacb6f 100644
--- a/src/effects/SkBlurDrawLooper.cpp
+++ b/src/effects/SkBlurDrawLooper.cpp
@@ -11,12 +11,12 @@ SkBlurDrawLooper::SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy,
SkASSERT(flags <= kAll_BlurFlag);
if (radius > 0)
{
- uint32_t blurFlags = flags & kIgnoreTransform_BlurFlag ?
- SkBlurMaskFilter::kIgnoreTransform_BlurFlag :
+ uint32_t blurFlags = flags & kIgnoreTransform_BlurFlag ?
+ SkBlurMaskFilter::kIgnoreTransform_BlurFlag :
SkBlurMaskFilter::kNone_BlurFlag;
fBlur = SkBlurMaskFilter::Create(radius,
- SkBlurMaskFilter::kNormal_BlurStyle,
+ SkBlurMaskFilter::kNormal_BlurStyle,
blurFlags);
}
else
@@ -34,7 +34,7 @@ SkBlurDrawLooper::SkBlurDrawLooper(SkFlattenableReadBuffer& buffer)
SkBlurDrawLooper::~SkBlurDrawLooper()
{
- fBlur->safeUnref();
+ SkSafeUnref(fBlur);
}
void SkBlurDrawLooper::flatten(SkFlattenableWriteBuffer& buffer)
diff --git a/src/effects/SkGradientShader.cpp b/src/effects/SkGradientShader.cpp
index 81a8d683f1..64a78c7f0e 100644
--- a/src/effects/SkGradientShader.cpp
+++ b/src/effects/SkGradientShader.cpp
@@ -169,7 +169,7 @@ Gradient_Shader::Gradient_Shader(const SkColor colors[], const SkScalar pos[],
fCacheAlpha = 256; // init to a value that paint.getAlpha() can't return
fMapper = mapper;
- mapper->safeRef();
+ SkSafeRef(mapper);
SkASSERT((unsigned)mode < SkShader::kTileModeCount);
SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs));
@@ -321,7 +321,7 @@ Gradient_Shader::~Gradient_Shader() {
if (fOrigColors != fStorage) {
sk_free(fOrigColors);
}
- fMapper->safeUnref();
+ SkSafeUnref(fMapper);
}
void Gradient_Shader::flatten(SkFlattenableWriteBuffer& buffer) {
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp
index 5aa883dfa2..168fbe91ea 100644
--- a/src/effects/SkLayerRasterizer.cpp
+++ b/src/effects/SkLayerRasterizer.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -59,7 +59,7 @@ static bool compute_bounds(const SkDeque& layers, const SkPath& path, const SkMa
SkLayerRasterizer_Rec* rec;
bounds->set(SK_MaxS32, SK_MaxS32, SK_MinS32, SK_MinS32);
-
+
while ((rec = (SkLayerRasterizer_Rec*)iter.next()) != NULL)
{
const SkPaint& paint = rec->fPaint;
@@ -117,13 +117,13 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
}
if (SkMask::kJustComputeBounds_CreateMode != mode)
- {
+ {
SkBitmap device;
SkDraw draw;
SkMatrix translatedMatrix; // this translates us to our local pixels
SkMatrix drawMatrix; // this translates the path by each layer's offset
SkRegion rectClip;
-
+
rectClip.setRect(0, 0, mask->fBounds.width(), mask->fBounds.height());
translatedMatrix = matrix;
@@ -138,7 +138,7 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
draw.fClip = &rectClip;
// we set the matrixproc in the loop, as the matrix changes each time (potentially)
draw.fBounder = NULL;
-
+
SkDeque::Iter iter(fLayers);
SkLayerRasterizer_Rec* rec;
@@ -158,7 +158,7 @@ static void paint_read(SkPaint* paint, SkFlattenableReadBuffer& buffer)
paint->setAntiAlias(buffer.readBool());
paint->setStyle((SkPaint::Style)buffer.readU8());
paint->setAlpha(buffer.readU8());
-
+
if (paint->getStyle() != SkPaint::kFill_Style)
{
paint->setStrokeWidth(buffer.readScalar());
@@ -167,10 +167,10 @@ static void paint_read(SkPaint* paint, SkFlattenableReadBuffer& buffer)
paint->setStrokeJoin((SkPaint::Join)buffer.readU8());
}
- paint->setMaskFilter((SkMaskFilter*)buffer.readFlattenable())->safeUnref();
- paint->setPathEffect((SkPathEffect*)buffer.readFlattenable())->safeUnref();
- paint->setRasterizer((SkRasterizer*)buffer.readFlattenable())->safeUnref();
- paint->setXfermode((SkXfermode*)buffer.readFlattenable())->safeUnref();
+ SkSafeUnref(paint->setMaskFilter((SkMaskFilter*)buffer.readFlattenable()));
+ SkSafeUnref(paint->setPathEffect((SkPathEffect*)buffer.readFlattenable()));
+ SkSafeUnref(paint->setRasterizer((SkRasterizer*)buffer.readFlattenable()));
+ SkSafeUnref(paint->setXfermode((SkXfermode*)buffer.readFlattenable()));
}
static void paint_write(const SkPaint& paint, SkFlattenableWriteBuffer& buffer)
@@ -178,7 +178,7 @@ static void paint_write(const SkPaint& paint, SkFlattenableWriteBuffer& buffer)
buffer.writeBool(paint.isAntiAlias());
buffer.write8(paint.getStyle());
buffer.write8(paint.getAlpha());
-
+
if (paint.getStyle() != SkPaint::kFill_Style)
{
buffer.writeScalar(paint.getStrokeWidth());
@@ -186,7 +186,7 @@ static void paint_write(const SkPaint& paint, SkFlattenableWriteBuffer& buffer)
buffer.write8(paint.getStrokeCap());
buffer.write8(paint.getStrokeJoin());
}
-
+
buffer.writeFlattenable(paint.getMaskFilter());
buffer.writeFlattenable(paint.getPathEffect());
buffer.writeFlattenable(paint.getRasterizer());
@@ -197,11 +197,11 @@ SkLayerRasterizer::SkLayerRasterizer(SkFlattenableReadBuffer& buffer)
: SkRasterizer(buffer), fLayers(sizeof(SkLayerRasterizer_Rec))
{
int count = buffer.readS32();
-
+
for (int i = 0; i < count; i++)
{
SkLayerRasterizer_Rec* rec = (SkLayerRasterizer_Rec*)fLayers.push_back();
-
+
#if 0
new (&rec->fPaint) SkPaint(buffer);
#else
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index 768d671d6a..347a6da58c 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -42,9 +42,9 @@ SkImageDecoder::SkImageDecoder()
}
SkImageDecoder::~SkImageDecoder() {
- fPeeker->safeUnref();
- fChooser->safeUnref();
- fAllocator->safeUnref();
+ SkSafeUnref(fPeeker);
+ SkSafeUnref(fChooser);
+ SkSafeUnref(fAllocator);
}
SkImageDecoder::Format SkImageDecoder::getFormat() const {
diff --git a/src/images/SkImageRef.cpp b/src/images/SkImageRef.cpp
index 60e01c672b..16c2820b92 100644
--- a/src/images/SkImageRef.cpp
+++ b/src/images/SkImageRef.cpp
@@ -40,16 +40,16 @@ SkImageRef::~SkImageRef() {
#endif
fStream->unref();
- fFactory->safeUnref();
+ SkSafeUnref(fFactory);
}
bool SkImageRef::getInfo(SkBitmap* bitmap) {
SkAutoMutexAcquire ac(gImageRefMutex);
-
+
if (!this->prepareBitmap(SkImageDecoder::kDecodeBounds_Mode)) {
return false;
}
-
+
SkASSERT(SkBitmap::kNo_Config != fBitmap.config());
if (bitmap) {
bitmap->setConfig(fBitmap.config(), fBitmap.width(), fBitmap.height());
@@ -77,7 +77,7 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) {
if (fErrorInDecoding) {
return false;
}
-
+
/* As soon as we really know our config, we record it, so that on
subsequent calls to the codec, we are sure we will always get the same
result.
@@ -85,7 +85,7 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) {
if (SkBitmap::kNo_Config != fBitmap.config()) {
fConfig = fBitmap.config();
}
-
+
if (NULL != fBitmap.getPixels() ||
(SkBitmap::kNo_Config != fBitmap.config() &&
SkImageDecoder::kDecodeBounds_Mode == mode)) {
diff --git a/src/pdf/SkPDFPage.cpp b/src/pdf/SkPDFPage.cpp
index 98d7682436..1c470c7d01 100644
--- a/src/pdf/SkPDFPage.cpp
+++ b/src/pdf/SkPDFPage.cpp
@@ -73,7 +73,7 @@ void SkPDFPage::generatePageTree(const SkTDArray<SkPDFPage*>& pages,
SkTDArray<SkPDFDict*> curNodes;
curNodes.setReserve(pages.count());
for (int i = 0; i < pages.count(); i++) {
- pages[i]->safeRef();
+ SkSafeRef(pages[i]);
curNodes.push(pages[i]);
}
@@ -107,7 +107,7 @@ void SkPDFPage::generatePageTree(const SkTDArray<SkPDFPage*>& pages,
pageTree->push(curNodes[i]); // Transfer reference.
catalog->addObject(curNodes[i], false);
} else {
- curNodes[i]->safeUnref();
+ SkSafeUnref(curNodes[i]);
}
}
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index cc1735e98a..209a2cf527 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -323,8 +323,8 @@ SkPDFObject* SkPDFDict::insert(const char key[], SkPDFObject* value) {
void SkPDFDict::clear() {
for (int i = 0; i < fValue.count(); i++) {
- fValue[i].key->safeUnref();
- fValue[i].value->safeUnref();
+ SkSafeUnref(fValue[i].key);
+ SkSafeUnref(fValue[i].value);
}
fValue.reset();
}
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 4ff7a50fc8..223a4f704f 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -1,5 +1,5 @@
#include "SkDumpCanvas.h"
-#include "SkPicture.h"
+#include "SkPicture.h"
#include "SkPixelRef.h"
#include "SkString.h"
#include <stdarg.h>
@@ -105,7 +105,7 @@ static const char* toString(SkBitmap::Config config) {
static void toString(const SkBitmap& bm, SkString* str) {
str->printf("bitmap:[%d %d] %s", bm.width(), bm.height(),
toString(bm.config()));
-
+
SkPixelRef* pr = bm.pixelRef();
if (NULL == pr) {
// show null or the explicit pixel address (rare)
@@ -140,7 +140,7 @@ static void toString(const void* text, size_t len, SkPaint::TextEncoding enc,
///////////////////////////////////////////////////////////////////////////////
SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : fNestLevel(0) {
- dumper->safeRef();
+ SkSafeRef(dumper);
fDumper = dumper;
static const int WIDE_OPEN = 16384;
@@ -151,7 +151,7 @@ SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : fNestLevel(0) {
}
SkDumpCanvas::~SkDumpCanvas() {
- fDumper->safeUnref();
+ SkSafeUnref(fDumper);
}
void SkDumpCanvas::dump(Verb verb, const SkPaint* paint,
@@ -163,7 +163,7 @@ void SkDumpCanvas::dump(Verb verb, const SkPaint* paint,
va_start(args, format);
vsnprintf(buffer, BUFFER_SIZE, format, args);
va_end(args);
-
+
if (fDumper) {
fDumper->dump(this, verb, buffer, paint);
}
@@ -420,7 +420,7 @@ void SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb,
tab.append("\t");
}
msg.printf("%s%s", tab.c_str(), str);
-
+
if (p) {
msg.appendf(" color:0x%08X flags:%X", p->getColor(), p->getFlags());
appendFlattenable(&msg, p->getShader(), "shader");
@@ -429,13 +429,13 @@ void SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb,
appendFlattenable(&msg, p->getMaskFilter(), "maskFilter");
appendFlattenable(&msg, p->getPathEffect(), "pathEffect");
appendFlattenable(&msg, p->getColorFilter(), "filter");
-
+
if (SkDumpCanvas::kDrawText_Verb == verb) {
msg.appendf(" textSize:%g", SkScalarToFloat(p->getTextSize()));
appendPtr(&msg, p->getTypeface(), "typeface");
}
}
-
+
fProc(msg.c_str(), fRefcon);
}
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index d462d01b12..4336181bf0 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -1,13 +1,13 @@
#include "SkProxyCanvas.h"
SkProxyCanvas::SkProxyCanvas(SkCanvas* proxy) : fProxy(proxy) {
- fProxy->safeRef();
+ SkSafeRef(fProxy);
}
SkProxyCanvas::~SkProxyCanvas() {
- fProxy->safeUnref();
+ SkSafeUnref(fProxy);
}
-
+
void SkProxyCanvas::setProxy(SkCanvas* proxy) {
SkRefCnt_SafeAssign(fProxy, proxy);
}
diff --git a/tests/Test.cpp b/tests/Test.cpp
index 4bbe83a33d..2bcd3e0441 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -42,7 +42,7 @@ void Reporter::endTest(Test* test) {
Test::Test() : fReporter(NULL) {}
Test::~Test() {
- fReporter->safeUnref();
+ SkSafeUnref(fReporter);
}
void Test::setReporter(Reporter* r) {