clip.copyToMask(&mask);
SkAutoMaskFreeImage amfi(mask.fImage);
- bm.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(),
- mask.fBounds.height(), mask.fRowBytes);
- bm.setPixels(mask.fImage);
+ bm.installPixels(SkImageInfo::MakeA8(mask.fBounds.width(),
+ mask.fBounds.height()),
+ mask.fImage, mask.fRowBytes, NULL, NULL);
SkPaint paint;
canvas->drawBitmap(bm,
static SkShader* make_bg_shader() {
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
- bm.allocPixels();
+ bm.allocN32Pixels(2, 2);
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCC,
0xCC, 0xCC);
static SkBitmap createBitmap(int n) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, n, n);
- bitmap.allocPixels();
+ bitmap.allocN32Pixels(n, n);
bitmap.eraseColor(SK_ColorGREEN);
SkCanvas canvas(bitmap);
#include "SkColorPriv.h"
-#if 0 // UNUSED
-static void reverseRedAndBlue(const SkBitmap& bm) {
- SkASSERT(bm.config() == SkBitmap::kARGB_8888_Config);
- uint8_t* p = (uint8_t*)bm.getPixels();
- uint8_t* stop = p + bm.getSize();
- while (p < stop) {
- // swap red/blue (to go from ARGB(int) to RGBA(memory) and premultiply
- unsigned scale = SkAlpha255To256(p[3]);
- unsigned r = p[2];
- unsigned b = p[0];
- p[0] = SkAlphaMul(r, scale);
- p[1] = SkAlphaMul(p[1], scale);
- p[2] = SkAlphaMul(b, scale);
- p += 4;
- }
-}
-#endif
-
void SampleWindow::saveToPdf()
{
fSaveToPdf = true;
kUnknown_SkColorType, // index8 -> none
};
-static SkColorType cycle_configs(SkColorType c) {
+static SkColorType cycle_colortypes(SkColorType c) {
return gColorTypeCycle[c];
}
if (USE_ARROWS_FOR_ZOOM) {
this->changeZoomLevel(-1.f / 32.f);
} else {
- this->setColorType(cycle_configs(this->getBitmap().colorType()));
+ this->setColorType(cycle_colortypes(this->getBitmap().colorType()));
this->updateTitle();
}
return true;
#define SCALAR_SIZE SkIntToScalar(INT_SIZE)
static void make_bitmap(SkBitmap* bitmap) {
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, INT_SIZE, INT_SIZE);
- bitmap->allocPixels();
+ bitmap->allocN32Pixels(INT_SIZE, INT_SIZE);
SkCanvas canvas(*bitmap);
canvas.drawColor(SK_ColorRED);
const int BIG_W = SkScalarRoundToInt(paint.measureText(gText, strlen(gText)));
- bm->setConfig(SkBitmap::kARGB_8888_Config, BIG_W, BIG_H);
- bm->allocPixels();
+ bm->allocN32Pixels(BIG_W, BIG_H);
bm->eraseColor(SK_ColorWHITE);
SkCanvas canvas(*bm);
SkBitmap bm;
SkColorTable* ctable = new SkColorTable(c, 256);
- bm.setConfig(SkBitmap::kIndex8_Config, 256, 256);
- bm.allocPixels(ctable);
+ bm.allocPixels(SkImageInfo::Make(256, 256, kIndex_8_SkColorType,
+ kPremul_SkAlphaType),
+ NULL, ctable);
ctable->unref();
bm.lockPixels();
SkShader* createChecker();
SkShader* createChecker() {
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
- bm.allocPixels();
+ bm.allocN32Pixels(2, 2);
bm.lockPixels();
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = SkPreMultiplyColor(0xFFFFFFFF);
*bm.getAddr32(0, 1) = *bm.getAddr32(1, 0) = SkPreMultiplyColor(0xFFCCCCCC);
static SkBitmap createBitmap(int n) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, n, n);
- bitmap.allocPixels();
+ bitmap.allocN32Pixels(n, n);
bitmap.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bitmap);
SkColor c = paint->getColor();
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 1);
- bm.allocPixels();
+ bm.allocN32Pixels(2, 1);
bm.lockPixels();
*bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c),
SkColorGetG(c), SkColorGetB(c));
}
static void make_bm(SkBitmap* bm) {
- bm->setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
- bm->allocPixels();
-#if 0
- bm->eraseColor(SK_ColorBLUE);
- return;
-#else
+ bm->allocN32Pixels(100, 100);
bm->eraseColor(SK_ColorTRANSPARENT);
-#endif
SkCanvas c(*bm);
draw_sweep(&c, bm->width(), bm->height(), 0);
SkColorTable* ctable = new SkColorTable(c, 256, kOpaque_SkAlphaType);
SkBitmap bm;
- bm.setConfig(SkBitmap::kIndex8_Config, 256, 32);
- bm.allocPixels(ctable);
+ bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType,
+ kPremul_SkAlphaType),
+ NULL, ctable);
ctable->unref();
bm.lockPixels();
static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) {
SkAutoLockPixels alp(*bm); // needed for ctable
bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
-#if 0
- SkColorTable* ctable = bm->getColorTable();
- if (ctable) {
- if (ctable->isOpaque() != isOpaque) {
- // how do we change a colortable? don't want to
- }
- }
-#endif
}
static void draw2(SkCanvas* canvas, const SkBitmap& bm) {
#include "SkStream.h"
-static void make_image(SkBitmap* bm, SkBitmap::Config config, int configIndex) {
+static void make_image(SkBitmap* bm, SkColorType ct, int configIndex) {
const int width = 98;
const int height = 100;
- SkBitmap device;
-
- device.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- device.allocPixels();
+ const SkImageInfo info = SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType);
+ SkBitmap device;
+ device.allocN32Pixels(width, height);
SkCanvas canvas(device);
SkPaint paint;
canvas.drawCircle(SkIntToScalar(width)/2, SkIntToScalar(height)/2,
SkIntToScalar(width)/2, paint);
- bm->setConfig(config, width, height);
- switch (config) {
- case SkBitmap::kARGB_8888_Config:
+ switch (ct) {
+ case kPMColor_SkColorType:
bm->swap(device);
break;
- case SkBitmap::kRGB_565_Config: {
- bm->allocPixels();
+ case kRGB_565_SkColorType: {
+ bm->allocPixels(info);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
*bm->getAddr16(x, y) = SkPixel32ToPixel16(*device.getAddr32(x, y));
}
break;
}
- case SkBitmap::kIndex8_Config: {
+ case kIndex_8_SkColorType: {
SkPMColor colors[256];
for (int i = 0; i < 256; i++) {
if (configIndex & 1) {
}
}
SkColorTable* ctable = new SkColorTable(colors, 256);
- bm->allocPixels(ctable);
+ bm->allocPixels(info, NULL, ctable);
ctable->unref();
-
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
*bm->getAddr8(x, y) = SkGetPackedR32(*device.getAddr32(x, y));
break;
}
default:
- break;
+ SkASSERT(0);
}
}
// configs to build the original bitmap in. Can be at most these 3
-static const SkBitmap::Config gConfigs[] = {
- SkBitmap::kARGB_8888_Config,
- SkBitmap::kRGB_565_Config,
- SkBitmap::kIndex8_Config, // opaque
- SkBitmap::kIndex8_Config // alpha
+static const SkColorType gColorTypes[] = {
+ kPMColor_SkColorType,
+ kRGB_565_SkColorType,
+ kIndex_8_SkColorType, // opaque
+ kIndex_8_SkColorType // alpha
};
static const char* const gConfigLabels[] = {
int fBitmapCount;
EncodeView() {
- #if 1
- fBitmapCount = SK_ARRAY_COUNT(gConfigs);
+ fBitmapCount = SK_ARRAY_COUNT(gColorTypes);
fBitmaps = new SkBitmap[fBitmapCount];
fEncodedPNGs = new SkAutoDataUnref[fBitmapCount];
fEncodedJPEGs = new SkAutoDataUnref[fBitmapCount];
for (int i = 0; i < fBitmapCount; i++) {
- make_image(&fBitmaps[i], gConfigs[i], i);
+ make_image(&fBitmaps[i], gColorTypes[i], i);
for (size_t j = 0; j < SK_ARRAY_COUNT(gTypes); j++) {
SkAutoTDelete<SkImageEncoder> codec(
}
}
}
- #else
- fBitmaps = NULL;
- fBitmapCount = 0;
- #endif
this->setBGColor(0xFFDDDDDD);
}
// SkColor colors[] = { 0xFFFDFDFD, 0xFFF4F4F4 };
SkColor colors[] = { 0xFFFFFFFF, 0xFFFFFFFF };
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
- bm.allocPixels();
+ bm.allocN32Pixels(2, 2);
bm.lockPixels();
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = SkPreMultiplyColor(colors[0]);
*bm.getAddr32(0, 1) = *bm.getAddr32(1, 0) = SkPreMultiplyColor(colors[1]);
#include "SkDither.h"
static void make_bm(SkBitmap* bm) {
- const SkColor colors[] = {
- SK_ColorRED, SK_ColorGREEN,
- SK_ColorBLUE, SK_ColorWHITE
+ const SkPMColor colors[] = {
+ SkPreMultiplyColor(SK_ColorRED), SkPreMultiplyColor(SK_ColorGREEN),
+ SkPreMultiplyColor(SK_ColorBLUE), SkPreMultiplyColor(SK_ColorWHITE)
};
SkColorTable* ctable = new SkColorTable(colors, 4);
- bm->setConfig(SkBitmap::kIndex8_Config, 2, 2);
- bm->allocPixels(ctable);
+ bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType,
+ kOpaque_SkAlphaType),
+ NULL, ctable);
ctable->unref();
*bm->getAddr8(0, 0) = 0;
static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm,
SkScalar x, SkScalar y, SkPaint* paint) {
-#if 1
canvas->drawBitmap(bm, x, y, paint);
return SkIntToScalar(bm.width()) * 5/4;
-#else
- SkAutoCanvasRestore acr(canvas, true);
- canvas->translate(x, y);
-
- SkScalar w = SkIntToScalar(bm.width());
- SkScalar h = SkIntToScalar(bm.height());
- SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
- paint->setShader(s)->unref();
- canvas->drawRect(SkRect::MakeWH(w, h), *paint);
- paint->setShader(NULL);
- return w * 5/4;
-#endif
}
static SkScalar draw_set(SkCanvas* c, const SkBitmap& bm, SkScalar x, SkPaint* p) {
p.setTextSize(SkIntToScalar(18));
SkString s;
s.append(" depth=");
- s.appendS32(fBitmaps[i].config() == SkBitmap::kRGB_565_Config ? 16 : 32);
+ s.appendS32(fBitmaps[i].colorType() == kRGB_565_SkColorType ? 16 : 32);
canvas->drawText(s.c_str(), s.size(), x + W + SkIntToScalar(4),
y + H/2, p);
}
return static_cast<SkDisplacementMapEffect::ChannelSelectorType>(R(4)+1);
}
-static void make_g_bitmap(SkBitmap& bitmap) {
- bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
- while (!bitmap.allocPixels()) {
- bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
+static bool valid_for_raster_canvas(const SkImageInfo& info) {
+ switch (info.colorType()) {
+ case kAlpha_8_SkColorType:
+ case kRGB_565_SkColorType:
+ return true;
+ case kPMColor_SkColorType:
+ return kPremul_SkAlphaType == info.alphaType() ||
+ kOpaque_SkAlphaType == info.alphaType();
+ default:
+ break;
}
- SkBitmapDevice device(bitmap);
- SkCanvas canvas(&device);
+ return false;
+}
+
+static SkColorType rand_colortype() {
+ return (SkColorType)R(kLastEnum_SkColorType + 1);
+}
+
+static void rand_bitmap_for_canvas(SkBitmap* bitmap) {
+ SkImageInfo info;
+ do {
+ info = SkImageInfo::Make(kBitmapSize, kBitmapSize, rand_colortype(),
+ kPremul_SkAlphaType);
+ } while (!valid_for_raster_canvas(info) || !bitmap->allocPixels(info));
+}
+
+static void make_g_bitmap(SkBitmap& bitmap) {
+ rand_bitmap_for_canvas(&bitmap);
+
+ SkCanvas canvas(bitmap);
canvas.clear(0x00000000);
SkPaint paint;
paint.setAntiAlias(true);
SkIntToScalar(kBitmapSize/4), paint);
}
-static bool valid_for_raster_canvas(const SkBitmap& bm) {
- SkImageInfo info;
- if (!bm.asImageInfo(&info)) {
- return false;
- }
- switch (info.fColorType) {
- case kAlpha_8_SkColorType:
- case kRGB_565_SkColorType:
- return true;
- case kPMColor_SkColorType:
- return kPremul_SkAlphaType == info.fAlphaType ||
- kOpaque_SkAlphaType == info.fAlphaType;
- default:
- break;
- }
- return false;
-}
-
static void make_checkerboard_bitmap(SkBitmap& bitmap) {
- bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
- while (valid_for_raster_canvas(bitmap) && !bitmap.allocPixels()) {
- bitmap.setConfig((SkBitmap::Config)R(SkBitmap::kConfigCount), kBitmapSize, kBitmapSize);
- }
- SkBitmapDevice device(bitmap);
- SkCanvas canvas(&device);
+ rand_bitmap_for_canvas(&bitmap);
+
+ SkCanvas canvas(bitmap);
canvas.clear(0x00000000);
SkPaint darkPaint;
darkPaint.setColor(0xFF804020);
status = pthread_create(&fMThreads[i], NULL, measure_proc, NULL);
SkASSERT(0 == status);
- fBitmaps[i].setConfig(SkBitmap::kRGB_565_Config, 320, 240);
- fBitmaps[i].allocPixels();
+ fBitmaps[i].allocPixels(SkImageInfo::Make(320, 240,
+ kRGB_565_SkColorType,
+ kOpaque_SkAlphaType));
status = pthread_create(&fDThreads[i], NULL, draw_proc, &fBitmaps[i]);
SkASSERT(0 == status);
}
static SkShader* make_bg_shader() {
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
- bm.allocPixels();
+ bm.allocN32Pixels(2, 2);
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
*bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCC, 0xCC, 0xCC);
static void test_chromium_9005() {
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, 800, 600);
- bm.allocPixels();
+ bm.allocN32Pixels(800, 600);
SkCanvas canvas(bm);
}
SkBitmap bm, bm2;
- bm.setConfig(SkBitmap::kARGB_8888_Config,
- WIDTH + MARGIN*2,
- HEIGHT + MARGIN*2);
- bm.allocPixels();
+ bm.allocN32Pixels(WIDTH + MARGIN*2, HEIGHT + MARGIN*2);
// this will erase our margin, which we want to always stay 0
bm.eraseColor(SK_ColorTRANSPARENT);
- bm2.setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT,
- bm.rowBytes());
- bm2.setPixels(bm.getAddr32(MARGIN, MARGIN));
+ bm2.installPixels(SkImageInfo::MakeN32Premul(WIDTH, HEIGHT),
+ bm.getAddr32(MARGIN, MARGIN), bm.rowBytes(),
+ NULL, NULL);
SkCanvas c2(bm2);
SkPaint paint;
SkBitmap mask;
int w = SkScalarRoundToInt(r.width());
int h = SkScalarRoundToInt(r.height());
- mask.setConfig(SkBitmap::kARGB_8888_Config, w, h);
- mask.allocPixels();
+ mask.allocN32Pixels(w, h);
mask.eraseColor(SK_ColorTRANSPARENT);
SkCanvas c(mask);
SkRect bounds = r;
static SkBitmap createBitmap(int n) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, n, n);
- bitmap.allocPixels();
+ bitmap.allocN32Pixels(n, n);
bitmap.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bitmap);
OvalTestView() {
fSize.set(SK_Scalar1, SK_Scalar1);
- fBitmap.setConfig(SkBitmap::kARGB_8888_Config, kILimit, kILimit);
- fBitmap.allocPixels();
+ fBitmap.allocN32Pixels(kILimit, kILimit);
fInsideColor = SkPreMultiplyColor(SK_ColorRED);
fOutsideColor = SkPreMultiplyColor(SK_ColorGREEN);
}
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 300, 200);
- bitmap.allocPixels();
+ bitmap.allocN32Pixels(300, 200);
SkCanvas canvas(bitmap);
SkPaint paint;
int height = 100;
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kA8_Config, width*2, height*2);
- bitmap.allocPixels();
+ bitmap.allocPixels(SkImageInfo::MakeA8(width*2, height*2));
bitmap.eraseColor(SK_ColorTRANSPARENT);
SkScalar dx = 20;
static void make_bitmap(SkBitmap* bm) {
const int W = 100;
const int H = 100;
- bm->setConfig(SkBitmap::kARGB_8888_Config, W, H);
- bm->allocPixels();
+ bm->allocN32Pixels(W, H);
SkPaint paint;
SkCanvas canvas(*bm);
int h = w;
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, w, h);
- bm.allocPixels();
+ bm.allocN32Pixels(w, h);
bm.eraseColor(0);
SkAutoLockPixels alp(bm);
#include "SkGradientShader.h"
#include "SkUnitMappers.h"
-static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
- bm->setConfig(config, w, h);
- bm->allocPixels();
+static void makebm(SkBitmap* bm, int w, int h) {
+ bm->allocN32Pixels(w, h);
bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm);
int w, int h) {
static SkBitmap bmp;
if (bmp.isNull()) {
- makebm(&bmp, SkBitmap::kARGB_8888_Config, w/2, h/4);
+ makebm(&bmp, w/2, h/4);
}
return SkShader::CreateBitmapShader(bmp, tx, ty);
}
fIndex = 0;
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, 1024, 768);
- bm.allocPixels();
+ bm.allocN32Pixels(1024, 768);
SkCanvas canvas(bm);
SkScalar s = SkIntToScalar(1024) / 640;
canvas.scale(s, s);
}
static void make_textstrip(SkBitmap* bm) {
- bm->setConfig(SkBitmap::kRGB_565_Config, 200, 18);
- bm->allocPixels();
+ bm->allocPixels(SkImageInfo::Make(200, 18, kRGB_565_SkColorType,
+ kOpaque_SkAlphaType));
bm->eraseColor(SK_ColorWHITE);
SkCanvas canvas(*bm);
#include "SkStream.h"
static void check_for_nonwhite(const SkBitmap& bm, int alpha) {
- if (bm.config() != SkBitmap::kRGB_565_Config) {
+ if (bm.colorType() != kRGB_565_SkColorType) {
return;
}
static SkBitmap make_bitmap() {
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config , 5, 5);
- bm.allocPixels();
+ bm.allocN32Pixels(5, 5);
for (int y = 0; y < bm.height(); y++) {
uint32_t* p = bm.getAddr32(0, y);
#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
-static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
- bm->setConfig(config, w, h);
- bm->allocPixels();
+static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
+ bm->allocPixels(SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType));
bm->eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(*bm);
paint->setFilterLevel(filter ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel);
}
-static const SkBitmap::Config gConfigs[] = {
- SkBitmap::kARGB_8888_Config,
- SkBitmap::kRGB_565_Config,
+static const SkColorType gColorTypes[] = {
+ kPMColor_SkColorType,
+ kRGB_565_SkColorType,
};
static const int gWidth = 32;
static const int gHeight = 32;
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
SkIntToScalar(2), SkIntToScalar(2)) {
fTextPicture = new SkPicture();
- for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
- makebm(&fTexture[i], gConfigs[i], gWidth, gHeight);
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
+ makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight);
}
}
fTextPicture->unref();
}
- SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)];
+ SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)];
protected:
// overrides from SkEventSink
y += SkIntToScalar(16);
- for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
for (size_t j = 0; j < SK_ARRAY_COUNT(gFilters); j++) {
x = SkIntToScalar(10);
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
SkColorTable* ctable = new SkColorTable(c, N);
SkBitmap bm;
- bm.setConfig(SkBitmap::kIndex8_Config, 1, 1);
- bm.allocPixels(ctable);
+ bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
+ kPremul_SkAlphaType),
+ NULL, ctable);
ctable->unref();
bm.lockPixels();
// Copy it to a bitmap which can be drawn, converting
// to premultiplied:
SkBitmap bm;
- bm.setConfig(SkBitmap::kARGB_8888_Config, fBitmap.width(),
- fBitmap.height());
- SkASSERT(fBitmap.config() == SkBitmap::kARGB_8888_Config);
- if (!bm.allocPixels()) {
+ if (!bm.allocN32Pixels(fBitmap.width(), fBitmap.height())) {
SkString errMsg("allocPixels failed");
canvas->drawText(errMsg.c_str(), errMsg.size(), 0, height, paint);
return;
static SkShader* make_shader0(SkIPoint* size) {
SkBitmap bm;
size->set(2, 2);
- bm.setConfig(SkBitmap::kARGB_8888_Config, size->fX, size->fY);
SkPMColor color0 = SkPreMultiplyARGB(0x80, 0x80, 0xff, 0x80);
SkPMColor color1 = SkPreMultiplyARGB(0x40, 0xff, 0x00, 0xff);
- bm.allocPixels();
+ bm.allocN32Pixels(size->fX, size->fY);
bm.eraseColor(color0);
bm.lockPixels();
uint32_t* pixels = (uint32_t*) bm.getPixels();
static void create_bitmap(SkBitmap* bitmap) {
const int W = 100;
const int H = 100;
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, W, H);
- bitmap->allocPixels();
+ bitmap->allocN32Pixels(W, H);
SkCanvas canvas(*bitmap);
canvas.drawColor(SK_ColorRED);
const static int W = 64;
const static int H = 64;
XfermodesBlurView() {
- fBG.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4, kOpaque_SkAlphaType);
- fBG.setPixels(gBG);
+ fBG.installPixels(SkImageInfo::Make(2, 2, kARGB_4444_SkColorType,
+ kPremul_SkAlphaType),
+ gBG, 4, NULL, NULL);
}
protected: