summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-24 20:30:35 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-24 20:30:35 +0000
commita476d6bc629e75337f1052c9c70b3a993afed0e6 (patch)
tree0327947bc5a8345e5d47e47d413c1ae839220858 /skia
parent923e85f5dbb8fcea66b4d4a791331b186486ac7d (diff)
downloadchromium_src-a476d6bc629e75337f1052c9c70b3a993afed0e6.zip
chromium_src-a476d6bc629e75337f1052c9c70b3a993afed0e6.tar.gz
chromium_src-a476d6bc629e75337f1052c9c70b3a993afed0e6.tar.bz2
replace setIsOpaque (deprecated) with explicit SkAlphaType
BUG= R=enne@chromium.org, jam@chromium.org, jamesr@chromium.org, thakis@chromium.org Review URL: https://codereview.chromium.org/37233002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/bitmap_platform_device_android.cc12
-rw-r--r--skia/ext/bitmap_platform_device_linux.cc8
-rw-r--r--skia/ext/bitmap_platform_device_mac.cc9
-rw-r--r--skia/ext/bitmap_platform_device_win.cc8
-rw-r--r--skia/ext/image_operations.cc10
5 files changed, 21 insertions, 26 deletions
diff --git a/skia/ext/bitmap_platform_device_android.cc b/skia/ext/bitmap_platform_device_android.cc
index 32f447f..9d6051e 100644
--- a/skia/ext/bitmap_platform_device_android.cc
+++ b/skia/ext/bitmap_platform_device_android.cc
@@ -10,9 +10,9 @@ namespace skia {
BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (bitmap.allocPixels()) {
- bitmap.setIsOpaque(is_opaque);
// Follow the logic in SkCanvas::createDevice(), initialize the bitmap if it
// is not opaque.
if (!is_opaque)
@@ -35,13 +35,13 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
bool is_opaque,
uint8_t* data) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (data)
bitmap.setPixels(data);
else if (!bitmap.allocPixels())
return NULL;
- bitmap.setIsOpaque(is_opaque);
return new BitmapPlatformDevice(bitmap);
}
@@ -87,11 +87,11 @@ PlatformBitmap::~PlatformBitmap() {
}
bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
- bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap_.allocPixels())
return false;
- bitmap_.setIsOpaque(is_opaque);
surface_ = bitmap_.getPixels();
return true;
}
diff --git a/skia/ext/bitmap_platform_device_linux.cc b/skia/ext/bitmap_platform_device_linux.cc
index af26806..f259c6f 100644
--- a/skia/ext/bitmap_platform_device_linux.cc
+++ b/skia/ext/bitmap_platform_device_linux.cc
@@ -89,9 +89,9 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(int width, int height,
}
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height,
- cairo_image_surface_get_stride(surface));
+ cairo_image_surface_get_stride(surface),
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
bitmap.setPixels(cairo_image_surface_get_data(surface));
- bitmap.setIsOpaque(is_opaque);
// The device object will take ownership of the graphics context.
return new BitmapPlatformDevice
@@ -195,10 +195,10 @@ bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
// cairo drawing context tied to the bitmap. The SkBitmap's pixelRef can
// outlive the PlatformBitmap if additional copies are made.
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
- bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, stride);
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, stride,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap_.allocPixels()) // Using the default allocator.
return false;
- bitmap_.setIsOpaque(is_opaque);
cairo_surface_t* surf = cairo_image_surface_create_for_data(
reinterpret_cast<unsigned char*>(bitmap_.getPixels()),
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc
index 66298b2..8525cd3 100644
--- a/skia/ext/bitmap_platform_device_mac.cc
+++ b/skia/ext/bitmap_platform_device_mac.cc
@@ -127,7 +127,8 @@ 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);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
void* data;
if (context) {
@@ -139,8 +140,6 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
data = bitmap.getPixels();
}
- bitmap.setIsOpaque(is_opaque);
-
// If we were given data, then don't clobber it!
#ifndef NDEBUG
if (!context && is_opaque) {
@@ -285,13 +284,13 @@ 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);
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (!bitmap_.allocPixels())
return false;
if (!is_opaque)
bitmap_.eraseColor(0);
- bitmap_.setIsOpaque(is_opaque);
surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(),
bitmap_.height());
diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc
index 0088403..203281d 100644
--- a/skia/ext/bitmap_platform_device_win.cc
+++ b/skia/ext/bitmap_platform_device_win.cc
@@ -171,9 +171,9 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(
return NULL;
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
bitmap.setPixels(data);
- bitmap.setIsOpaque(is_opaque);
#ifndef NDEBUG
// If we were given data, then don't clobber it!
@@ -343,11 +343,11 @@ bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
HGDIOBJ stock_bitmap = SelectObject(surface_, hbitmap);
platform_extra_ = reinterpret_cast<intptr_t>(stock_bitmap);
- bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
// PlatformBitmapPixelRef takes ownership of |hbitmap|.
bitmap_.setPixelRef(
skia::AdoptRef(new PlatformBitmapPixelRef(hbitmap, data)).get());
- bitmap_.setIsOpaque(is_opaque);
bitmap_.lockPixels();
return true;
diff --git a/skia/ext/image_operations.cc b/skia/ext/image_operations.cc
index c61da0c..3bb765ff 100644
--- a/skia/ext/image_operations.cc
+++ b/skia/ext/image_operations.cc
@@ -394,7 +394,7 @@ SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
// Render into subpixels.
SkBitmap result;
result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(),
- dest_subset.height());
+ dest_subset.height(), 0, img.alphaType());
result.allocPixels(allocator, NULL);
if (!result.readyToDraw())
return img;
@@ -455,7 +455,6 @@ SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
src_row += h * row_words;
dst_row += result.rowBytes() / 4;
}
- result.setIsOpaque(img.isOpaque());
return result;
#else
return SkBitmap();
@@ -510,8 +509,8 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
// Convolve into the result.
SkBitmap result;
- result.setConfig(SkBitmap::kARGB_8888_Config,
- dest_subset.width(), dest_subset.height());
+ result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(),
+ dest_subset.height(), 0, source.alphaType());
result.allocPixels(allocator, NULL);
if (!result.readyToDraw())
return SkBitmap();
@@ -522,9 +521,6 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
static_cast<unsigned char*>(result.getPixels()),
true);
- // Preserve the "opaque" flag for use as an optimization later.
- result.setIsOpaque(source.isOpaque());
-
base::TimeDelta delta = base::TimeTicks::Now() - resize_start;
UMA_HISTOGRAM_TIMES("Image.ResampleMS", delta);