Skip to content

Commit

Permalink
setConfig is deprecated, use setInfo or allocPixels instead.
Browse files Browse the repository at this point in the history
kPNColor_SkColorType is now kN32_SkColorType

TBR=
BUG=skia:2706

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281044 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
reed@google.com committed Jul 2, 2014
1 parent 5ba8475 commit f47d8ca
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ class DesktopBackgroundControllerTest : public test::AshTestBase {
// Creates an image of size |size|.
gfx::ImageSkia CreateImage(int width, int height, SkColor color) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
bitmap.allocPixels();
bitmap.allocN32Pixels(width, height);
bitmap.eraseColor(color);
gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
return image;
Expand Down
3 changes: 1 addition & 2 deletions ash/desktop_background/wallpaper_resizer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ gfx::ImageSkia CreateTestImage(const gfx::Size& size) {
SkBitmap src;
int w = size.width();
int h = size.height();
src.setConfig(SkBitmap::kARGB_8888_Config, w, h);
src.allocPixels();
src.allocN32Pixels(w, h);

// Fill bitmap with data.
for (int y = 0; y < h; ++y) {
Expand Down
3 changes: 1 addition & 2 deletions ash/shell/app_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ class WindowTypeShelfItem : public app_list::AppListItem {

const int kIconSize = 128;
SkBitmap icon;
icon.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize);
icon.allocPixels();
icon.allocN32Pixels(kIconSize, kIconSize);
icon.eraseColor(kColors[static_cast<int>(type) % arraysize(kColors)]);
return gfx::ImageSkia::CreateFrom1xBitmap(icon);
}
Expand Down
3 changes: 1 addition & 2 deletions ash/shell/window_watcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ void WindowWatcher::OnWindowAdded(aura::Window* new_window) {
id_to_window_[id] = new_window;

SkBitmap icon_bitmap;
icon_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
icon_bitmap.allocPixels();
icon_bitmap.allocN32Pixels(16, 16);
icon_bitmap.eraseARGB(255,
image_count == 0 ? 255 : 0,
image_count == 1 ? 255 : 0,
Expand Down
3 changes: 1 addition & 2 deletions ash/system/chromeos/network/network_icon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ const SkBitmap GetEmptyBitmap(const gfx::Size pixel_size) {
return iter->second;

SkBitmap empty;
empty.setConfig(SkBitmap::kARGB_8888_Config, key.first, key.second);
empty.allocPixels();
empty.allocN32Pixels(key.first, key.second);
empty.eraseARGB(0, 0, 0, 0);
(*s_empty_bitmaps)[key] = empty;
return empty;
Expand Down
7 changes: 2 additions & 5 deletions athena/content/content_app_model_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ ShellExtensionSystem* GetShellExtensionSystem(

gfx::ImageSkia CreateFlatColorImage(SkColor color) {
SkBitmap bitmap;
bitmap.setConfig(
SkBitmap::kARGB_8888_Config,
extension_misc::EXTENSION_ICON_MEDIUM,
extension_misc::EXTENSION_ICON_MEDIUM);
bitmap.allocPixels();
bitmap.allocN32Pixels(extension_misc::EXTENSION_ICON_MEDIUM,
extension_misc::EXTENSION_ICON_MEDIUM);
bitmap.eraseColor(color);
return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
}
Expand Down
3 changes: 1 addition & 2 deletions athena/test/test_app_model_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class DummyItem : public app_list::AppListItem {
break;
}
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize);
bitmap.allocPixels();
bitmap.allocN32Pixels(kIconSize, kIconSize);
bitmap.eraseColor(color);
return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
}
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,7 @@ void GotFaviconData(HistoryMenuBridge::HistoryItem* item,
TEST_F(HistoryMenuBridgeTest, GotFaviconData) {
// Create a dummy bitmap.
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 25, 25);
bitmap.allocPixels();
bitmap.allocN32Pixels(25, 25);
bitmap.eraseARGB(255, 255, 0, 0);

// Set up the HistoryItem.
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/ui/cocoa/table_row_nsimage_cache_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ virtual int RowCount() const OVERRIDE {

SkBitmap MakeImage(int width, int height) {
SkBitmap image;
image.setConfig(SkBitmap::kARGB_8888_Config, width, height);
EXPECT_TRUE(image.allocPixels());
EXPECT_TRUE(image.allocN32Pixels(width, height));
image.eraseARGB(255, 255, 0, 0);
return image;
}
Expand Down
3 changes: 1 addition & 2 deletions components/search_provider_logos/logo_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ std::string EncodeBitmapAsPNGBase64(const SkBitmap& bitmap) {

SkBitmap MakeBitmap(int width, int height) {
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
bitmap.allocPixels();
bitmap.allocN32Pixels(width, height);
bitmap.eraseColor(SK_ColorBLUE);
return bitmap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,8 @@ class CompositingRenderWidgetHostViewBrowserTestTabCapture
media::SkCanvasVideoRenderer video_renderer;

SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::Make(video_frame->visible_rect().width(),
video_frame->visible_rect().height(),
kPMColor_SkColorType,
kPremul_SkAlphaType));
bitmap.allocN32Pixels(video_frame->visible_rect().width(),
video_frame->visible_rect().height());
bitmap.eraseColor(SK_ColorTRANSPARENT);
SkCanvas canvas(bitmap);

Expand Down
5 changes: 3 additions & 2 deletions content/shell/renderer/test_runner/TestPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ void TestPlugin::drawSceneSoftware(void* memory, size_t bytes) {
m_scene.backgroundColor[1],
m_scene.backgroundColor[2]);

const SkImageInfo info = SkImageInfo::MakeN32Premul(m_rect.width,
m_rect.height);
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, m_rect.width, m_rect.height);
bitmap.setPixels(memory);
bitmap.installPixels(info, memory, info.minRowBytes());
SkCanvas canvas(bitmap);
canvas.clear(backgroundColor);

Expand Down
6 changes: 2 additions & 4 deletions extensions/browser/extension_icon_image_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ namespace {
SkBitmap CreateBlankBitmapForScale(int size_dip, ui::ScaleFactor scale_factor) {
SkBitmap bitmap;
const float scale = ui::GetScaleForScaleFactor(scale_factor);
bitmap.setConfig(SkBitmap::kARGB_8888_Config,
static_cast<int>(size_dip * scale),
static_cast<int>(size_dip * scale));
bitmap.allocPixels();
bitmap.allocN32Pixels(static_cast<int>(size_dip * scale),
static_cast<int>(size_dip * scale));
bitmap.eraseColor(SkColorSetARGB(0, 0, 0, 0));
return bitmap;
}
Expand Down
8 changes: 0 additions & 8 deletions skia/config/SkUserConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,6 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
#define SK_SUPPORT_LEGACY_BITMAP_CONFIG
#endif

#ifndef SK_SUPPORT_LEGACY_N32_NAME
#define SK_SUPPORT_LEGACY_N32_NAME
#endif

#ifndef SK_SUPPORT_LEGACY_SETCONFIG
#define SK_SUPPORT_LEGACY_SETCONFIG
#endif

// ===== End Chrome-specific definitions =====

#endif
2 changes: 1 addition & 1 deletion skia/ext/bitmap_platform_device_cairo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ BitmapPlatformDevice::~BitmapPlatformDevice() {

SkBaseDevice* BitmapPlatformDevice::onCreateDevice(const SkImageInfo& info,
Usage /*usage*/) {
SkASSERT(info.colorType() == kPMColor_SkColorType);
SkASSERT(info.colorType() == kN32_SkColorType);
return BitmapPlatformDevice::Create(info.width(), info.height(),
info.isOpaque());
}
Expand Down
2 changes: 1 addition & 1 deletion skia/ext/bitmap_platform_device_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BitmapPlatformDevice::~BitmapPlatformDevice() {

SkBaseDevice* BitmapPlatformDevice::onCreateDevice(const SkImageInfo& info,
Usage /*usage*/) {
SkASSERT(info.colorType() == kPMColor_SkColorType);
SkASSERT(info.colorType() == kN32_SkColorType);
return BitmapPlatformDevice::Create(info.width(), info.height(),
info.isOpaque());
}
Expand Down
2 changes: 1 addition & 1 deletion skia/ext/bitmap_platform_device_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const SkBitmap& BitmapPlatformDevice::onAccessBitmap() {

SkBaseDevice* BitmapPlatformDevice::onCreateDevice(const SkImageInfo& info,
Usage /*usage*/) {
SkASSERT(info.colorType() == kPMColor_SkColorType);
SkASSERT(info.colorType() == kN32_SkColorType);
return BitmapPlatformDevice::CreateAndClear(info.width(), info.height(),
info.isOpaque());
}
Expand Down
6 changes: 1 addition & 5 deletions skia/ext/pixel_ref_utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ class TestDiscardableShader : public SkShader {
};

void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) {
const SkImageInfo info = {
size.width(), size.height(), kPMColor_SkColorType, kPremul_SkAlphaType
};

bitmap->allocPixels(info);
bitmap->allocN32Pixels(size.width(), size.height());
bitmap->pixelRef()->setImmutable();
bitmap->pixelRef()->setURI(uri);
}
Expand Down
8 changes: 1 addition & 7 deletions skia/ext/skia_utils_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ SkBitmap CGImageToSkBitmap(CGImageRef image, CGSize size, bool is_opaque) {
if (!image)
return 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;

void* data = bitmap.getPixels();
Expand Down
11 changes: 1 addition & 10 deletions skia/ext/vector_platform_device_emf_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,18 +693,9 @@ void VectorPlatformDeviceEmf::LoadClipRegion() {
LoadClippingRegionToDC(hdc_, clip_region_, t);
}

#ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
SkBaseDevice* VectorPlatformDeviceEmf::onCreateCompatibleDevice(
SkBitmap::Config config, int width, int height, bool isOpaque,
Usage /*usage*/) {
SkASSERT(config == SkBitmap::kARGB_8888_Config);
return VectorPlatformDeviceEmf::CreateDevice(width, height, isOpaque, NULL);
}
#endif

SkBaseDevice* VectorPlatformDeviceEmf::onCreateDevice(const SkImageInfo& info,
Usage /*usage*/) {
SkASSERT(info.colorType() == kPMColor_SkColorType);
SkASSERT(info.colorType() == kN32_SkColorType);
return VectorPlatformDeviceEmf::CreateDevice(
info.width(), info.height(), info.isOpaque(), NULL);
}
Expand Down
5 changes: 0 additions & 5 deletions skia/ext/vector_platform_device_emf_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ class VectorPlatformDeviceEmf : public SkBitmapDevice, public PlatformDevice {
void LoadClipRegion();

protected:
#ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config, int width,
int height, bool isOpaque,
Usage usage) OVERRIDE;
#endif
virtual SkBaseDevice* onCreateDevice(const SkImageInfo& info,
Usage usage) OVERRIDE;

Expand Down
2 changes: 1 addition & 1 deletion ui/app_list/cocoa/apps_grid_controller_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void SetMenuReadyForTesting(bool ready) {
SkBitmap bitmap;
const int kTestImageSize = 10;
const int kTargetImageSize = 48;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, kTestImageSize, kTestImageSize);
bitmap.setInfo(SkImageInfo::MakeN32Premul(kTestImageSize, kTestImageSize));
item_model->SetIcon(gfx::ImageSkia::CreateFrom1xBitmap(bitmap), false);
icon_size = [[button image] size];
// Icon should always be resized to 48x48.
Expand Down
3 changes: 1 addition & 2 deletions ui/message_center/cocoa/notification_controller_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ - (NSView*)listView {

// Message, image and no title: 2 lines.
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
bitmap.allocPixels();
bitmap.allocN32Pixels(2, 2);
bitmap.eraseColor(SK_ColorGREEN);
notification->set_title(ASCIIToUTF16(""));
notification->set_image(gfx::Image::CreateFrom1xBitmap(bitmap));
Expand Down

0 comments on commit f47d8ca

Please sign in to comment.