Commit 20259ae2 authored by reed@google.com's avatar reed@google.com

stop calling deprecated setConfig

BUG=

Review URL: https://codereview.chromium.org/331283002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277985 0039d316-1c4b-4281-b951-d872f2087c98
parent 1d33d766
......@@ -277,7 +277,7 @@ void AnalysisCanvas::drawVertices(SkCanvas::VertexMode,
// by any pixels
static SkBitmap MakeEmptyBitmap(int width, int height) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kNo_Config, width, height);
bitmap.setInfo(SkImageInfo::MakeUnknown(width, height));
return bitmap;
}
......
......@@ -101,8 +101,7 @@ TEST(AnalysisCanvasTest, ComplexActions) {
// Draw bitmap test.
SolidColorFill(canvas);
SkBitmap secondBitmap;
secondBitmap.setConfig(SkBitmap::kARGB_8888_Config, 255, 255);
secondBitmap.allocPixels();
secondBitmap.allocN32Pixels(255, 255);
canvas.drawBitmap(secondBitmap, 0, 0);
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
......
......@@ -103,8 +103,7 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
SkBitmap bitmap;
// TODO: verify that the CG Context's pixels will have tight rowbytes or pass in the correct
// rowbytes for the case when context != NULL.
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
bitmap.setInfo(SkImageInfo::MakeN32(width, height, is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType));
void* data;
if (context) {
......@@ -272,9 +271,7 @@ bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
if (RasterDeviceTooBigToAllocate(width, height))
return false;
bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4,
is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap_.allocPixels())
if (!bitmap_.allocN32Pixels(width, height, is_opaque))
return false;
if (!is_opaque)
......
......@@ -10,9 +10,7 @@ namespace skia {
BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (bitmap.allocPixels()) {
if (bitmap.allocN32Pixels(width, height, is_opaque)) {
// Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it
// is not opaque.
if (!is_opaque)
......@@ -35,8 +33,8 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque,
uint8_t* data) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
bitmap.setInfo(SkImageInfo::MakeN32(width, height,
is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType));
if (data)
bitmap.setPixels(data);
else if (!bitmap.allocPixels())
......@@ -87,9 +85,7 @@ PlatformBitmap::~PlatformBitmap() {
}
bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap_.allocPixels())
if (!bitmap_.allocN32Pixels(width, height, is_opaque))
return false;
surface_ = bitmap_.getPixels();
......
......@@ -237,15 +237,9 @@ void VerifySIMD(unsigned int source_width,
// Allocate input and output skia bitmap.
SkBitmap source, result_c, result_sse;
source.setConfig(SkBitmap::kARGB_8888_Config,
source_width, source_height);
source.allocPixels();
result_c.setConfig(SkBitmap::kARGB_8888_Config,
dest_width, dest_height);
result_c.allocPixels();
result_sse.setConfig(SkBitmap::kARGB_8888_Config,
dest_width, dest_height);
result_sse.allocPixels();
source.allocN32Pixels(source_width, source_height);
result_c.allocN32Pixels(dest_width, dest_height);
result_sse.allocN32Pixels(dest_width, dest_height);
// Randomize source bitmap for testing.
unsigned char* src_ptr = static_cast<unsigned char*>(source.getPixels());
......
......@@ -393,8 +393,8 @@ SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
// Render into subpixels.
SkBitmap result;
result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(),
dest_subset.height(), 0, img.alphaType());
result.setInfo(SkImageInfo::MakeN32(dest_subset.width(), dest_subset.height(),
img.alphaType()));
result.allocPixels(allocator, NULL);
if (!result.readyToDraw())
return img;
......@@ -509,8 +509,7 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
// Convolve into the result.
SkBitmap result;
result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(),
dest_subset.height(), 0, source.alphaType());
result.setInfo(SkImageInfo::MakeN32(dest_subset.width(), dest_subset.height(), source.alphaType()));
result.allocPixels(allocator, NULL);
if (!result.readyToDraw())
return SkBitmap();
......
......@@ -229,9 +229,7 @@ bool Benchmark::ParseArgs(const base::CommandLine* command_line) {
// actual benchmark.
bool Benchmark::Run() const {
SkBitmap source;
source.setConfig(SkBitmap::kARGB_8888_Config,
source_.width(), source_.height());
source.allocPixels();
source.allocN32Pixels(source_.width(), source_.height());
source.eraseARGB(0, 0, 0, 0);
SkBitmap dest;
......
......@@ -111,8 +111,7 @@ bool ColorsClose(uint32_t a, uint32_t b) {
}
void FillDataToBitmap(int w, int h, SkBitmap* bmp) {
bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h);
bmp->allocPixels();
bmp->allocN32Pixels(w, h);
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
......@@ -140,8 +139,7 @@ void DrawGridToBitmap(int w, int h,
ASSERT_GT(grid_width, 0);
ASSERT_NE(background_color, grid_color);
bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h);
bmp->allocPixels();
bmp->allocN32Pixels(w, h);
for (int y = 0; y < h; ++y) {
bool y_on_grid = ((y % grid_pitch) < grid_width);
......@@ -166,8 +164,7 @@ void DrawCheckerToBitmap(int w, int h,
ASSERT_GT(rect_h, 0);
ASSERT_NE(color1, color2);
bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h);
bmp->allocPixels();
bmp->allocN32Pixels(w, h);
for (int y = 0; y < h; ++y) {
bool y_bit = (((y / rect_h) & 0x1) == 0);
......@@ -464,8 +461,7 @@ TEST(ImageOperations, HalveSubset) {
TEST(ImageOperations, InvalidParams) {
// Make our source bitmap.
SkBitmap src;
src.setConfig(SkBitmap::kA8_Config, 16, 34);
src.allocPixels();
src.allocPixels(SkImageInfo::MakeA8(16, 34));
// Scale it, don't die.
SkBitmap full_results = skia::ImageOperations::Resize(
......@@ -667,8 +663,7 @@ TEST(ImageOperations, ScaleUp) {
const int dst_w = 9;
const int dst_h = 9;
SkBitmap src;
src.setConfig(SkBitmap::kARGB_8888_Config, src_w, src_h);
src.allocPixels();
src.allocN32Pixels(src_w, src_h);
for (int src_y = 0; src_y < src_h; ++src_y) {
for (int src_x = 0; src_x < src_w; ++src_x) {
......
......@@ -361,8 +361,7 @@ void PixelRefUtils::GatherDiscardablePixelRefs(
DiscardablePixelRefSet pixel_ref_set(pixel_refs);
SkBitmap empty_bitmap;
empty_bitmap.setConfig(
SkBitmap::kNo_Config, picture->width(), picture->height());
empty_bitmap.setInfo(SkImageInfo::MakeUnknown(picture->width(), picture->height()));
GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set);
SkNoSaveLayerCanvas canvas(&device);
......
......@@ -27,13 +27,7 @@ SkBitmap NSImageOrNSImageRepToSkBitmapWithColorSpace(
DCHECK((image != 0) ^ (image_rep != 0));
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config,
size.width,
size.height,
0,
is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap.allocPixels())
if (!bitmap.allocN32Pixels(size.width, size.height, is_opaque))
return bitmap; // Return |bitmap| which should respond true to isNull().
......@@ -381,9 +375,8 @@ CGContextRef SkiaBitLocker::cgContext() {
bitmap_ = deviceBits;
bitmap_.lockPixels();
} else {
bitmap_.setConfig(
SkBitmap::kARGB_8888_Config, deviceBits.width(), deviceBits.height());
bitmap_.allocPixels();
if (!bitmap_.allocN32Pixels(deviceBits.width(), deviceBits.height()))
return 0;
bitmap_.eraseColor(0);
}
base::ScopedCFTypeRef<CGColorSpaceRef> colorSpace(
......
......@@ -43,13 +43,11 @@ class SkiaUtilsMacTest : public testing::Test {
SkBitmap SkiaUtilsMacTest::CreateSkBitmap(int width, int height,
bool isred, bool tfbit) {
SkBitmap bitmap;
SkColorType ct = tfbit ? kN32_SkColorType : kARGB_4444_SkColorType;
SkImageInfo info = SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType);
if (tfbit)
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
else
bitmap.setConfig(SkBitmap::kARGB_4444_Config, width, height);
bitmap.allocPixels();
SkBitmap bitmap;
bitmap.allocPixels(info);
if (isred)
bitmap.eraseARGB(0xff, 0xff, 0, 0);
......@@ -123,9 +121,9 @@ void SkiaUtilsMacTest::RunBitLockerTest(BitLockerTest test) {
EXPECT_EQ(storageSize, sizeof(original) / sizeof(original[0]));
unsigned bits[storageSize];
memcpy(bits, original, sizeof(original));
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
bitmap.setPixels(bits);
bitmap.installPixels(info, bits, info.minRowBytes());
SkCanvas canvas(bitmap);
if (test & TestTranslate)
......
......@@ -81,20 +81,16 @@ SkBaseDevice* VectorPlatformDeviceEmf::create(HDC dc, int width, int height) {
// VectorPlatformDeviceEmf has no way to detect this, so the HBITMAP
// could be released while SkBitmap still has a reference to it. Be
// cautious.
if (width == bitmap_data.bmWidth &&
height == bitmap_data.bmHeight) {
bitmap.setConfig(SkBitmap::kARGB_8888_Config,
bitmap_data.bmWidth,
bitmap_data.bmHeight,
if (width == bitmap_data.bmWidth && height == bitmap_data.bmHeight) {
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
succeeded = bitmap.installPixels(info, bitmap_data.bmBits,
bitmap_data.bmWidthBytes);
bitmap.setPixels(bitmap_data.bmBits);
succeeded = true;
}
}
}
if (!succeeded)
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
bitmap.setInfo(SkImageInfo::MakeUnknown(width, height));
return new VectorPlatformDeviceEmf(dc, bitmap);
}
......
......@@ -15,7 +15,7 @@ namespace skia {
static inline SkBitmap makeABitmap(int width, int height) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kNo_Config, width, height);
bitmap.setInfo(SkImageInfo::MakeUnknown(width, height));
return bitmap;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment