Defining new color constat for transparent color

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

git-svn-id: http://skia.googlecode.com/svn/trunk@6696 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
junov@google.com 2012-12-06 21:47:40 +00:00
parent 4eeda37a74
commit dbfac8a723
46 changed files with 74 additions and 72 deletions

View File

@ -46,7 +46,7 @@ enum benchModes {
static void erase(SkBitmap& bm) { static void erase(SkBitmap& bm) {
if (bm.config() == SkBitmap::kA8_Config) { if (bm.config() == SkBitmap::kA8_Config) {
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
} else { } else {
bm.eraseColor(SK_ColorWHITE); bm.eraseColor(SK_ColorWHITE);
} }

View File

@ -12,7 +12,7 @@
SkRasterWidget::SkRasterWidget(SkDebugger *debugger) : QWidget() { SkRasterWidget::SkRasterWidget(SkDebugger *debugger) : QWidget() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 800, 800); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 800, 800);
fBitmap.allocPixels(); fBitmap.allocPixels();
fBitmap.eraseColor(0); fBitmap.eraseColor(SK_ColorTRANSPARENT);
fDevice = new SkDevice(fBitmap); fDevice = new SkDevice(fBitmap);
fDebugger = debugger; fDebugger = debugger;
fCanvas = new SkCanvas(fDevice); fCanvas = new SkCanvas(fDevice);

View File

@ -101,7 +101,7 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
canvas->restore(); canvas->restore();
} }
i = 0; i = 0;
canvas->clear(0); canvas->clear(SK_ColorTRANSPARENT);
canvas->resetMatrix(); canvas->resetMatrix();
SkRect rect = SkRect::MakeWH(SkIntToScalar(fWidth), SkRect rect = SkRect::MakeWH(SkIntToScalar(fWidth),
SkIntToScalar(fHeight)); SkIntToScalar(fHeight));

View File

@ -999,7 +999,7 @@ void CreateSweep(SkBitmap* sweep, SkScalar rectWidth) {
const int pixelCol = 100; const int pixelCol = 100;
sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow); sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow);
sweep->allocPixels(); sweep->allocPixels();
sweep->eraseColor(0); sweep->eraseColor(SK_ColorTRANSPARENT);
sweep->lockPixels(); sweep->lockPixels();
void* pixels = sweep->getPixels(); void* pixels = sweep->getPixels();
create_sweep((uint8_t*) pixels, pixelRow, pixelCol, rectWidth); create_sweep((uint8_t*) pixels, pixelRow, pixelCol, rectWidth);
@ -1011,7 +1011,7 @@ void CreateHorz(SkBitmap* sweep) {
const int pixelCol = 100; const int pixelCol = 100;
sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow); sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow);
sweep->allocPixels(); sweep->allocPixels();
sweep->eraseColor(0); sweep->eraseColor(SK_ColorTRANSPARENT);
sweep->lockPixels(); sweep->lockPixels();
void* pixels = sweep->getPixels(); void* pixels = sweep->getPixels();
create_horz((uint8_t*) pixels, pixelRow, pixelCol); create_horz((uint8_t*) pixels, pixelRow, pixelCol);
@ -1023,7 +1023,7 @@ void CreateVert(SkBitmap* sweep) {
const int pixelCol = 100; const int pixelCol = 100;
sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow); sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow);
sweep->allocPixels(); sweep->allocPixels();
sweep->eraseColor(0); sweep->eraseColor(SK_ColorTRANSPARENT);
sweep->lockPixels(); sweep->lockPixels();
void* pixels = sweep->getPixels(); void* pixels = sweep->getPixels();
create_vert((uint8_t*) pixels, pixelRow, pixelCol); create_vert((uint8_t*) pixels, pixelRow, pixelCol);
@ -1035,7 +1035,7 @@ void CreateAngle(SkBitmap* sweep, SkScalar angle) {
const int pixelCol = 150; const int pixelCol = 150;
sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow); sweep->setConfig(SkBitmap::kA8_Config, pixelCol, pixelRow);
sweep->allocPixels(); sweep->allocPixels();
sweep->eraseColor(0); sweep->eraseColor(SK_ColorTRANSPARENT);
sweep->lockPixels(); sweep->lockPixels();
void* pixels = sweep->getPixels(); void* pixels = sweep->getPixels();
create_angle((uint8_t*) pixels, pixelRow, pixelCol, angle); create_angle((uint8_t*) pixels, pixelRow, pixelCol, angle);

View File

@ -29,7 +29,7 @@ static SkCanvas* MakeCanvas(const SkIRect& bounds) {
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()); bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height());
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas* canvas = new SkCanvas(bm); SkCanvas* canvas = new SkCanvas(bm);
canvas->translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); canvas->translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));

View File

@ -19,7 +19,7 @@ static SkBitmap make_bm() {
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, WW, HH); bm.setConfig(SkBitmap::kARGB_8888_Config, WW, HH);
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
return bm; return bm;
} }

View File

@ -34,7 +34,7 @@ static SkBitmap make_chessbm(int w, int h) {
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
bm->setConfig(config, w, h); bm->setConfig(config, w, h);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);

View File

@ -41,7 +41,7 @@ static void draw_fatpath(SkCanvas* canvas, SkSurface* surface,
const SkPath paths[], int count) { const SkPath paths[], int count) {
SkPaint paint; SkPaint paint;
surface->getCanvas()->clear(0); surface->getCanvas()->clear(SK_ColorTRANSPARENT);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
surface->getCanvas()->drawPath(paths[i], paint); surface->getCanvas()->drawPath(paths[i], paint);
} }

View File

@ -371,7 +371,7 @@ public:
SkBitmap* bitmap) { SkBitmap* bitmap) {
bitmap->setConfig(gRec.fConfig, size.width(), size.height()); bitmap->setConfig(gRec.fConfig, size.width(), size.height());
bitmap->allocPixels(); bitmap->allocPixels();
bitmap->eraseColor(0); bitmap->eraseColor(SK_ColorTRANSPARENT);
} }
static void installFilter(SkCanvas* canvas) { static void installFilter(SkCanvas* canvas) {

View File

@ -116,7 +116,7 @@ static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()); bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height());
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas c(bm); SkCanvas c(bm);
draw_path(&c, r, NULL); draw_path(&c, r, NULL);
@ -133,7 +133,7 @@ static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height()); bm.setConfig(SkBitmap::kARGB_8888_Config, bounds.width(), bounds.height());
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas c(bm); SkCanvas c(bm);
draw_path(&c, r, NULL); draw_path(&c, r, NULL);

View File

@ -34,7 +34,7 @@ static void make_bitmap(SkBitmap* bitmap, GrContext* ctx, SkIRect* center) {
SkCanvas canvas(dev); SkCanvas canvas(dev);
dev->unref(); dev->unref();
canvas.clear(0); canvas.clear(SK_ColorTRANSPARENT);
SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize)); SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize));
const SkScalar strokeWidth = SkIntToScalar(6); const SkScalar strokeWidth = SkIntToScalar(6);

View File

@ -15,7 +15,7 @@ namespace skiagm {
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
bm->setConfig(config, w, h); bm->setConfig(config, w, h);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkScalar s = SkIntToScalar(SkMin32(w, h)); SkScalar s = SkIntToScalar(SkMin32(w, h));

View File

@ -14,7 +14,7 @@ namespace skiagm {
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
bm->setConfig(config, w, h); bm->setConfig(config, w, h);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkScalar s = SkIntToScalar(SkMin32(w, h)); SkScalar s = SkIntToScalar(SkMin32(w, h));

View File

@ -14,7 +14,7 @@ namespace skiagm {
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
bm->setConfig(config, w, h); bm->setConfig(config, w, h);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkScalar s = SkIntToScalar(SkMin32(w, h)); SkScalar s = SkIntToScalar(SkMin32(w, h));

View File

@ -15,7 +15,7 @@ static void make_bm0(SkBitmap* bm) {
int H = 120; int H = 120;
bm->setConfig(SkBitmap::kARGB_8888_Config, W, H); bm->setConfig(SkBitmap::kARGB_8888_Config, W, H);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkPaint paint; SkPaint paint;
@ -34,7 +34,7 @@ static void make_bm1(SkBitmap* bm) {
int H = 120; int H = 120;
bm->setConfig(SkBitmap::kARGB_8888_Config, W, H); bm->setConfig(SkBitmap::kARGB_8888_Config, W, H);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkPaint paint; SkPaint paint;

View File

@ -22,7 +22,7 @@
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
bm->setConfig(config, w, h); bm->setConfig(config, w, h);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} }; SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h)} };

View File

@ -15,7 +15,7 @@ namespace skiagm {
static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst) { static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst) {
src->setConfig(SkBitmap::kARGB_8888_Config, w, h); src->setConfig(SkBitmap::kARGB_8888_Config, w, h);
src->allocPixels(); src->allocPixels();
src->eraseColor(0); src->eraseColor(SK_ColorTRANSPARENT);
SkPaint p; SkPaint p;
p.setAntiAlias(true); p.setAntiAlias(true);
@ -33,7 +33,7 @@ static void make_bitmaps(int w, int h, SkBitmap* src, SkBitmap* dst) {
dst->setConfig(SkBitmap::kARGB_8888_Config, w, h); dst->setConfig(SkBitmap::kARGB_8888_Config, w, h);
dst->allocPixels(); dst->allocPixels();
dst->eraseColor(0); dst->eraseColor(SK_ColorTRANSPARENT);
{ {
SkCanvas c(*dst); SkCanvas c(*dst);

View File

@ -73,18 +73,20 @@ static inline SkColor SkColorSetA(SkColor c, U8CPU a) {
// common colors // common colors
#define SK_ColorBLACK 0xFF000000 //!< black SkColor value #define SK_ColorTRANSPARENT 0x00000000 //!< transparent SkColor value
#define SK_ColorDKGRAY 0xFF444444 //!< dark gray SkColor value
#define SK_ColorGRAY 0xFF888888 //!< gray SkColor value
#define SK_ColorLTGRAY 0xFFCCCCCC //!< light gray SkColor value
#define SK_ColorWHITE 0xFFFFFFFF //!< white SkColor value
#define SK_ColorRED 0xFFFF0000 //!< red SkColor value #define SK_ColorBLACK 0xFF000000 //!< black SkColor value
#define SK_ColorGREEN 0xFF00FF00 //!< green SkColor value #define SK_ColorDKGRAY 0xFF444444 //!< dark gray SkColor value
#define SK_ColorBLUE 0xFF0000FF //!< blue SkColor value #define SK_ColorGRAY 0xFF888888 //!< gray SkColor value
#define SK_ColorYELLOW 0xFFFFFF00 //!< yellow SkColor value #define SK_ColorLTGRAY 0xFFCCCCCC //!< light gray SkColor value
#define SK_ColorCYAN 0xFF00FFFF //!< cyan SkColor value #define SK_ColorWHITE 0xFFFFFFFF //!< white SkColor value
#define SK_ColorMAGENTA 0xFFFF00FF //!< magenta SkColor value
#define SK_ColorRED 0xFFFF0000 //!< red SkColor value
#define SK_ColorGREEN 0xFF00FF00 //!< green SkColor value
#define SK_ColorBLUE 0xFF0000FF //!< blue SkColor value
#define SK_ColorYELLOW 0xFFFFFF00 //!< yellow SkColor value
#define SK_ColorCYAN 0xFF00FFFF //!< cyan SkColor value
#define SK_ColorMAGENTA 0xFFFF00FF //!< magenta SkColor value
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

View File

@ -468,7 +468,7 @@ static void testpdf() {
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kA8_Config, 64, 64); bm.setConfig(SkBitmap::kA8_Config, 64, 64);
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bm); SkCanvas canvas(bm);

View File

@ -101,7 +101,7 @@ static SkBitmap createBitmap(int n) {
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, n, n); bitmap.setConfig(SkBitmap::kARGB_8888_Config, n, n);
bitmap.allocPixels(); bitmap.allocPixels();
bitmap.eraseColor(0); bitmap.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bitmap); SkCanvas canvas(bitmap);
SkRect r; SkRect r;

View File

@ -76,7 +76,7 @@ static void make_bm(SkBitmap* bm) {
bm->eraseColor(SK_ColorBLUE); bm->eraseColor(SK_ColorBLUE);
return; return;
#else #else
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
#endif #endif
SkCanvas c(*bm); SkCanvas c(*bm);

View File

@ -21,7 +21,7 @@
#define WIRE_FRAME_SIZE 1.5f #define WIRE_FRAME_SIZE 1.5f
static void erase(SkSurface* surface) { static void erase(SkSurface* surface) {
surface->getCanvas()->clear(0); surface->getCanvas()->clear(SK_ColorTRANSPARENT);
} }
static SkShader* createChecker() { static SkShader* createChecker() {

View File

@ -232,7 +232,7 @@ protected:
HEIGHT + MARGIN*2); HEIGHT + MARGIN*2);
bm.allocPixels(); bm.allocPixels();
// this will erase our margin, which we want to always stay 0 // this will erase our margin, which we want to always stay 0
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
bm2.setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT, bm2.setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT,
bm.rowBytes()); bm.rowBytes());
@ -243,7 +243,7 @@ protected:
paint.setAntiAlias(fDoAA); paint.setAntiAlias(fDoAA);
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
bm2.eraseColor(0); bm2.eraseColor(SK_ColorTRANSPARENT);
gProcs[fProcIndex].fProc(&c2, paint, bm); gProcs[fProcIndex].fProc(&c2, paint, bm);
canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), NULL); canvas->drawBitmap(bm2, SkIntToScalar(10), SkIntToScalar(10), NULL);

View File

@ -38,7 +38,7 @@ protected:
int h = SkScalarRound(r.height()); int h = SkScalarRound(r.height());
mask.setConfig(SkBitmap::kARGB_8888_Config, w, h); mask.setConfig(SkBitmap::kARGB_8888_Config, w, h);
mask.allocPixels(); mask.allocPixels();
mask.eraseColor(0); mask.eraseColor(SK_ColorTRANSPARENT);
SkCanvas c(mask); SkCanvas c(mask);
SkRect bounds = r; SkRect bounds = r;
bounds.offset(-bounds.fLeft, -bounds.fTop); bounds.offset(-bounds.fLeft, -bounds.fTop);

View File

@ -16,7 +16,7 @@ static SkBitmap createBitmap(int n) {
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, n, n); bitmap.setConfig(SkBitmap::kARGB_8888_Config, n, n);
bitmap.allocPixels(); bitmap.allocPixels();
bitmap.eraseColor(0); bitmap.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bitmap); SkCanvas canvas(bitmap);
SkRect r; SkRect r;
@ -83,7 +83,7 @@ protected:
SkAutoCanvasRestore acr(canvas, true); SkAutoCanvasRestore acr(canvas, true);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
bg.eraseColor(0); bg.eraseColor(SK_ColorTRANSPARENT);
SkCanvas c(bg); SkCanvas c(bg);
c.scale(SK_Scalar1 / (1 << i), SK_Scalar1 / (1 << i)); c.scale(SK_Scalar1 / (1 << i), SK_Scalar1 / (1 << i));
c.drawBitmap(bitmap, 0, 0, NULL); c.drawBitmap(bitmap, 0, 0, NULL);

View File

@ -45,7 +45,7 @@ protected:
SkCanvas canvas(fBitmap); SkCanvas canvas(fBitmap);
SkPaint p; SkPaint p;
fBitmap.eraseColor(0); fBitmap.eraseColor(SK_ColorTRANSPARENT);
canvas.drawOval(SkRect::MakeSize(fSize), p); canvas.drawOval(SkRect::MakeSize(fSize), p);
} }

View File

@ -120,7 +120,7 @@ public:
fBitmaps[i].setConfig(gConfigs[i], WIDTH, HEIGHT); fBitmaps[i].setConfig(gConfigs[i], WIDTH, HEIGHT);
SkFlipPixelRef* pr = new SkFlipPixelRef(gConfigs[i], WIDTH, HEIGHT); SkFlipPixelRef* pr = new SkFlipPixelRef(gConfigs[i], WIDTH, HEIGHT);
fBitmaps[i].setPixelRef(pr)->unref(); fBitmaps[i].setPixelRef(pr)->unref();
fBitmaps[i].eraseColor(0); fBitmaps[i].eraseColor(SK_ColorTRANSPARENT);
status = pthread_create(&fThreads[i], &attr, draw_proc, &fBitmaps[i]); status = pthread_create(&fThreads[i], &attr, draw_proc, &fBitmaps[i]);
SkASSERT(0 == status); SkASSERT(0 == status);

View File

@ -22,7 +22,7 @@ static void test_strokerect(SkCanvas* canvas) {
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kA8_Config, width*2, height*2); bitmap.setConfig(SkBitmap::kA8_Config, width*2, height*2);
bitmap.allocPixels(); bitmap.allocPixels();
bitmap.eraseColor(0); bitmap.eraseColor(SK_ColorTRANSPARENT);
SkScalar dx = 20; SkScalar dx = 20;
SkScalar dy = 20; SkScalar dy = 20;
@ -41,12 +41,12 @@ static void test_strokerect(SkCanvas* canvas) {
paint.setStrokeWidth(1); paint.setStrokeWidth(1);
// use the rect // use the rect
c.clear(0); c.clear(SK_ColorTRANSPARENT);
c.drawRect(r, paint); c.drawRect(r, paint);
canvas->drawBitmap(bitmap, 0, 0, NULL); canvas->drawBitmap(bitmap, 0, 0, NULL);
// use the path // use the path
c.clear(0); c.clear(SK_ColorTRANSPARENT);
c.drawPath(path, paint); c.drawPath(path, paint);
canvas->drawBitmap(bitmap, SkIntToScalar(2*width), 0, NULL); canvas->drawBitmap(bitmap, SkIntToScalar(2*width), 0, NULL);
} }

View File

@ -14,7 +14,7 @@
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
bm->setConfig(config, w, h); bm->setConfig(config, w, h);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkScalar s = SkIntToScalar(w < h ? w : h); SkScalar s = SkIntToScalar(w < h ? w : h);

View File

@ -48,7 +48,7 @@ static void lettersToBitmap(SkBitmap* dst, const char chars[],
SkBitmap src; SkBitmap src;
src.setConfig(config, w, h); src.setConfig(config, w, h);
src.allocPixels(); src.allocPixels();
src.eraseColor(0); src.eraseColor(SK_ColorTRANSPARENT);
{ {
SkCanvas canvas(src); SkCanvas canvas(src);
paint.setAntiAlias(true); paint.setAntiAlias(true);

View File

@ -26,7 +26,7 @@
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
bm->setConfig(config, w, h); bm->setConfig(config, w, h);
bm->allocPixels(); bm->allocPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm); SkCanvas canvas(*bm);
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } }; SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } };

View File

@ -1023,7 +1023,7 @@ bool SkBitmap::copyTo(SkBitmap* dst, Config dstConfig, Allocator* alloc) const {
} else { } else {
// if the src has alpha, we have to clear the dst first // if the src has alpha, we have to clear the dst first
if (!src->isOpaque()) { if (!src->isOpaque()) {
tmpDst.eraseColor(0); tmpDst.eraseColor(SK_ColorTRANSPARENT);
} }
SkCanvas canvas(tmpDst); SkCanvas canvas(tmpDst);

View File

@ -44,7 +44,7 @@ SkDevice::SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque
fBitmap.allocPixels(); fBitmap.allocPixels();
fBitmap.setIsOpaque(isOpaque); fBitmap.setIsOpaque(isOpaque);
if (!isOpaque) { if (!isOpaque) {
fBitmap.eraseColor(0); fBitmap.eraseColor(SK_ColorTRANSPARENT);
} }
} }

View File

@ -74,7 +74,7 @@ struct SkScalerContextRec {
* paint and device gamma to be effectively 1.0. * paint and device gamma to be effectively 1.0.
*/ */
void ignorePreBlend() { void ignorePreBlend() {
setLuminanceColor(0x00000000); setLuminanceColor(SK_ColorTRANSPARENT);
setPaintGamma(SK_Scalar1); setPaintGamma(SK_Scalar1);
setDeviceGamma(SK_Scalar1); setDeviceGamma(SK_Scalar1);
setContrast(0); setContrast(0);

View File

@ -59,12 +59,12 @@ enum {
// a sub region of a larger source image. // a sub region of a larger source image.
#define COLOR_BLEED_TOLERANCE SkFloatToScalar(0.001f) #define COLOR_BLEED_TOLERANCE SkFloatToScalar(0.001f)
#define DO_DEFERRED_CLEAR() \ #define DO_DEFERRED_CLEAR() \
do { \ do { \
if (fNeedClear) { \ if (fNeedClear) { \
this->clear(0x0); \ this->clear(SK_ColorTRANSPARENT); \
} \ } \
} while (false) \ } while (false) \
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -103,7 +103,7 @@ SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, SkPixelRef* pr, si
fWeOwnThePixels = true; fWeOwnThePixels = true;
if (!isOpaque) { if (!isOpaque) {
fBitmap.eraseColor(0); fBitmap.eraseColor(SK_ColorTRANSPARENT);
} }
} }

View File

@ -78,7 +78,7 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
} }
bm->lockPixels(); bm->lockPixels();
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
// use the same colorspace, so we don't change the pixels at all // use the same colorspace, so we don't change the pixels at all
CGColorSpaceRef cs = CGImageGetColorSpace(image); CGColorSpaceRef cs = CGImageGetColorSpace(image);

View File

@ -127,7 +127,7 @@ bool SkImageDecoder_WIC::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
//Copy the pixels into the bitmap. //Copy the pixels into the bitmap.
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
SkAutoLockPixels alp(*bm); SkAutoLockPixels alp(*bm);
bm->eraseColor(0); bm->eraseColor(SK_ColorTRANSPARENT);
const int stride = bm->rowBytes(); const int stride = bm->rowBytes();
hr = piBitmapSourceConverted->CopyPixels( hr = piBitmapSourceConverted->CopyPixels(
NULL, //Get all the pixels NULL, //Get all the pixels

View File

@ -16,7 +16,7 @@ static void test_nodraw(skiatest::Reporter* reporter) {
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); bm.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bm); SkCanvas canvas(bm);
SkRect r = SkRect::MakeWH(SkIntToScalar(10), SkIntToScalar(10)); SkRect r = SkRect::MakeWH(SkIntToScalar(10), SkIntToScalar(10));

View File

@ -20,7 +20,7 @@ static void test_giantClip() {
bm.setConfig(SkBitmap::kARGB_8888_Config, 64919, 1); bm.setConfig(SkBitmap::kARGB_8888_Config, 64919, 1);
bm.allocPixels(); bm.allocPixels();
SkCanvas canvas(bm); SkCanvas canvas(bm);
canvas.clear(0); canvas.clear(SK_ColorTRANSPARENT);
SkPath path; SkPath path;
path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(33, 1); path.moveTo(0, 0); path.lineTo(1, 0); path.lineTo(33, 1);

View File

@ -36,7 +36,7 @@ static void test_wacky_bitmapshader(skiatest::Reporter* reporter,
SkBitmap dev; SkBitmap dev;
dev.setConfig(SkBitmap::kARGB_8888_Config, 0x56F, 0x4f6); dev.setConfig(SkBitmap::kARGB_8888_Config, 0x56F, 0x4f6);
dev.allocPixels(); dev.allocPixels();
dev.eraseColor(0); // necessary, so we know if we draw to it dev.eraseColor(SK_ColorTRANSPARENT); // necessary, so we know if we draw to it
SkMatrix matrix; SkMatrix matrix;

View File

@ -210,7 +210,7 @@ static void test_giantaa(skiatest::Reporter* reporter) {
const int W = 400; const int W = 400;
const int H = 400; const int H = 400;
SkAutoTUnref<SkCanvas> canvas(new_canvas(33000, 10)); SkAutoTUnref<SkCanvas> canvas(new_canvas(33000, 10));
canvas.get()->clear(0); canvas.get()->clear(SK_ColorTRANSPARENT);
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); paint.setAntiAlias(true);

View File

@ -28,7 +28,7 @@ static void drawAndTest(skiatest::Reporter* reporter, const SkPath& path,
// explicitly specify a trim rowbytes, so we have no padding on each row // explicitly specify a trim rowbytes, so we have no padding on each row
bm.setConfig(SkBitmap::kARGB_8888_Config, DIMENSION, DIMENSION, DIMENSION*4); bm.setConfig(SkBitmap::kARGB_8888_Config, DIMENSION, DIMENSION, DIMENSION*4);
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bm); SkCanvas canvas(bm);
SkPaint p(paint); SkPaint p(paint);

View File

@ -32,7 +32,7 @@ static void testDrawingAfterEndRecording(SkCanvas* canvas) {
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
bm.allocPixels(); bm.allocPixels();
bm.eraseColor(0); bm.eraseColor(SK_ColorTRANSPARENT);
SkShader* shader = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode, SkShader* shader = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode); SkShader::kClamp_TileMode);

View File

@ -41,7 +41,7 @@ static void test_drawBitmap(skiatest::Reporter* reporter) {
SkBitmap dst; SkBitmap dst;
dst.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); dst.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
dst.allocPixels(); dst.allocPixels();
dst.eraseColor(0); dst.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(dst); SkCanvas canvas(dst);
SkPaint paint; SkPaint paint;
@ -54,7 +54,7 @@ static void test_drawBitmap(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5));
// reverify we are clear again // reverify we are clear again
dst.eraseColor(0); dst.eraseColor(SK_ColorTRANSPARENT);
REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5)); REPORTER_ASSERT(reporter, 0 == *dst.getAddr32(5, 5));
// if the bitmap is clipped out, we don't draw it // if the bitmap is clipped out, we don't draw it

View File

@ -88,6 +88,6 @@ namespace sk_tools {
void setup_bitmap(SkBitmap* bitmap, int width, int height) { void setup_bitmap(SkBitmap* bitmap, int width, int height) {
bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
bitmap->allocPixels(); bitmap->allocPixels();
bitmap->eraseColor(0); bitmap->eraseColor(SK_ColorTRANSPARENT);
} }
} }