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