Skip to content

Commit

Permalink
SkBitmap::Config is no more, use SkColorType
Browse files Browse the repository at this point in the history
When this lands, we can remove SkBitmap::Config entirely from Skia
TBR=kmadhusu@chromium.org

mac_chromium_rel failure is unrelated to this CL (and passes locally)
NOTRY=True

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282431 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
reed@google.com committed Jul 10, 2014
1 parent 9973446 commit bf27a7e
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ SkColor ComputeAverageColor(const SkBitmap& bitmap) {
ADD_FAILURE() << "Bitmap has no pixelref.";
return SkColorSetARGB(0, 0, 0, 0);
}
if (bitmap.config() == SkBitmap::kNo_Config) {
if (bitmap.colorType() == kUnknown_SkColorType) {
ADD_FAILURE() << "Bitmap has not been configured.";
return SkColorSetARGB(0, 0, 0, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/convert_web_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ scoped_refptr<Extension> ConvertWebAppToExtension(
}
for (size_t i = 0; i < web_app.icons.size(); ++i) {
// Skip unfetched bitmaps.
if (web_app.icons[i].data.config() == SkBitmap::kNo_Config)
if (web_app.icons[i].data.colorType() == kUnknown_SkColorType)
continue;

base::FilePath icon_file = icons_dir.AppendASCII(
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/thumbnails/content_analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void ApplyGaussianGradientMagnitudeFilter(SkBitmap* input_bitmap,
SkAutoLockPixels source_lock(*input_bitmap);
DCHECK(input_bitmap);
DCHECK(input_bitmap->getPixels());
DCHECK_EQ(SkBitmap::kA8_Config, input_bitmap->config());
DCHECK_EQ(kAlpha_8_SkColorType, input_bitmap->colorType());

// To perform computations we will need one intermediate buffer. It can
// very well be just another bitmap.
Expand Down Expand Up @@ -383,7 +383,7 @@ void ExtractImageProfileInformation(const SkBitmap& input_bitmap,
DCHECK(rows);
DCHECK(columns);
DCHECK(input_bitmap.getPixels());
DCHECK_EQ(SkBitmap::kA8_Config, input_bitmap.config());
DCHECK_EQ(kAlpha_8_SkColorType, input_bitmap.colorType());
DCHECK_GE(area.x(), 0);
DCHECK_GE(area.y(), 0);
DCHECK_LE(area.right(), input_bitmap.width());
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/thumbnails/content_analysis_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace {
unsigned long ImagePixelSum(const SkBitmap& bitmap, const gfx::Rect& rect) {
// Get the sum of pixel values in the rectangle. Applicable only to
// monochrome bitmaps.
DCHECK_EQ(SkBitmap::kA8_Config, bitmap.config());
DCHECK_EQ(kAlpha_8_SkColorType, bitmap.colorType());
unsigned long total = 0;
for (int r = rect.y(); r < rect.bottom(); ++r) {
const uint8* row_data = static_cast<const uint8*>(
Expand Down
18 changes: 9 additions & 9 deletions chrome/browser/ui/app_list/fast_show_pickler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@ bool FormatToColorType(ImageFormat format, SkColorType* out) {
return true;
}

bool ConfigToFormat(SkBitmap::Config config, ImageFormat* out) {
switch (config) {
case SkBitmap::kNo_Config:
bool ColorTypeToFormat(SkColorType colorType, ImageFormat* out) {
switch (colorType) {
case kUnknown_SkColorType:
*out = NONE;
break;
case SkBitmap::kA8_Config:
case kAlpha_8_SkColorType:
*out = A8;
break;
case SkBitmap::kIndex8_Config:
case kIndex_8_SkColorType:
*out = INDEX_8;
break;
case SkBitmap::kRGB_565_Config:
case kRGB_565_SkColorType:
*out = RGB_565;
break;
case SkBitmap::kARGB_4444_Config:
case kARGB_4444_SkColorType:
*out = ARGB_4444;
break;
case SkBitmap::kARGB_8888_Config:
case kN32_SkColorType:
*out = ARGB_8888;
break;
default: return false;
Expand All @@ -84,7 +84,7 @@ bool PickleImage(Pickle* pickle, const gfx::ImageSkia& image) {
pickle->WriteInt(it->pixel_width());
pickle->WriteInt(it->pixel_height());
ImageFormat format = NONE;
if (!ConfigToFormat(it->sk_bitmap().config(), &format))
if (!ColorTypeToFormat(it->sk_bitmap().colorType(), &format))
return false;
pickle->WriteInt(static_cast<int>(format));
int size = static_cast<int>(it->sk_bitmap().getSafeSize());
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/web_applications/web_app_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool AddGfxImageToIconFamily(IconFamilyHandle icon_family,
// have all the representations desired here for mac, from the kDesiredSizes
// array in web_app.cc.
SkBitmap bitmap = image.AsBitmap();
if (bitmap.config() != SkBitmap::kARGB_8888_Config ||
if (bitmap.colorType() != kN32_SkColorType ||
bitmap.width() != bitmap.height()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> {

void EncodeOnWorker(const SkBitmap& bitmap) {
std::vector<unsigned char> data;
// Paint |bitmap| to a kA8_Config SkBitmap
// Paint |bitmap| to a kAlpha_8_SkColorType SkBitmap
SkBitmap a8Bitmap;
a8Bitmap.allocPixels(SkImageInfo::MakeA8(bitmap.width(), bitmap.height()));
SkCanvas canvas(a8Bitmap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void RenderVideoFrame(const SkBitmap& input,
DVLOG(1) << "input unacceptable (size="
<< input.getSize()
<< ", ready=" << input.readyToDraw()
<< ", config=" << input.config() << ')';
<< ", colorType=" << input.colorType() << ')';
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class CompositingRenderWidgetHostViewBrowserTestTabCapture
expected_copy_from_compositing_surface_bitmap_;
EXPECT_EQ(expected_bitmap.width(), bitmap.width());
EXPECT_EQ(expected_bitmap.height(), bitmap.height());
EXPECT_EQ(expected_bitmap.config(), bitmap.config());
EXPECT_EQ(expected_bitmap.colorType(), bitmap.colorType());
SkAutoLockPixels expected_bitmap_lock(expected_bitmap);
SkAutoLockPixels bitmap_lock(bitmap);
int fails = 0;
Expand Down
2 changes: 1 addition & 1 deletion content/common/common_param_traits_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TEST(IPCMessageTest, Bitmap) {
PickleIterator iter(msg);
EXPECT_TRUE(IPC::ParamTraits<SkBitmap>::Read(&msg, &iter, &output));

EXPECT_EQ(bitmap.config(), output.config());
EXPECT_EQ(bitmap.colorType(), output.colorType());
EXPECT_EQ(bitmap.width(), output.width());
EXPECT_EQ(bitmap.height(), output.height());
EXPECT_EQ(bitmap.rowBytes(), output.rowBytes());
Expand Down
2 changes: 1 addition & 1 deletion content/renderer/webclipboard_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void WebClipboardImpl::writeImage(const WebImage& image,
if (!image.isNull()) {
const SkBitmap& bitmap = image.getSkBitmap();
// WriteBitmapFromPixels expects 32-bit data.
DCHECK_EQ(bitmap.config(), SkBitmap::kARGB_8888_Config);
DCHECK_EQ(bitmap.colorType(), kN32_SkColorType);

SkAutoLockPixels locked(bitmap);
void *pixels = bitmap.getPixels();
Expand Down
2 changes: 1 addition & 1 deletion printing/emf_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ bool Emf::Record::SafePlayback(Emf::EnumerationContext* context) const {
DCHECK(bitmap.get());
if (bitmap.get()) {
SkAutoLockPixels lock(*bitmap.get());
DCHECK_EQ(bitmap->config(), SkBitmap::kARGB_8888_Config);
DCHECK_EQ(bitmap->colorType(), kN32_SkColorType);
const uint32_t* pixels =
static_cast<const uint32_t*>(bitmap->getPixels());
if (pixels == NULL) {
Expand Down
4 changes: 0 additions & 4 deletions skia/config/SkUserConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,6 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
#define SK_SUPPORT_LEGACY_GETTOPDEVICE
#endif

#ifndef SK_SUPPORT_LEGACY_BITMAP_CONFIG
#define SK_SUPPORT_LEGACY_BITMAP_CONFIG
#endif

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

#endif
2 changes: 1 addition & 1 deletion skia/ext/image_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
(method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD));

SkAutoLockPixels locker(source);
if (!source.readyToDraw() || source.config() != SkBitmap::kARGB_8888_Config)
if (!source.readyToDraw() || source.colorType() != kN32_SkColorType)
return SkBitmap();

ResizeFilter filter(method, source.width(), source.height(),
Expand Down
4 changes: 2 additions & 2 deletions skia/ext/platform_canvas_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ TEST(PlatformBitmapTest, PlatformBitmap) {
EXPECT_EQ(kHeight, platform_bitmap->GetBitmap().height());
EXPECT_LE(static_cast<size_t>(platform_bitmap->GetBitmap().width()*4),
platform_bitmap->GetBitmap().rowBytes());
EXPECT_EQ(SkBitmap::kARGB_8888_Config, // Same for all platforms.
platform_bitmap->GetBitmap().config());
EXPECT_EQ(kN32_SkColorType, // Same for all platforms.
platform_bitmap->GetBitmap().colorType());
EXPECT_TRUE(platform_bitmap->GetBitmap().lockPixelsAreWritable());
EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->isLocked());
EXPECT_EQ(1, platform_bitmap->GetBitmap().pixelRef()->getRefCnt());
Expand Down

0 comments on commit bf27a7e

Please sign in to comment.