ui/gfx: remove redundant erase operations and remove unused function

It removes erase operations for SkBitmaps
which touch whole inside pixels
since all pixels should be drawn fully.

Additionally, it removes a unused function, CreateSuperimposedBitmap().

BUG=NONE
TEST=gfx_unittests --gtest_filter="SkBitmapOperationsTest*"

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283814 0039d316-1c4b-4281-b951-d872f2087c98
parent 2126ceff
...@@ -27,7 +27,6 @@ SkBitmap SkBitmapOperations::CreateInvertedBitmap(const SkBitmap& image) { ...@@ -27,7 +27,6 @@ SkBitmap SkBitmapOperations::CreateInvertedBitmap(const SkBitmap& image) {
SkBitmap inverted; SkBitmap inverted;
inverted.allocN32Pixels(image.width(), image.height()); inverted.allocN32Pixels(image.width(), image.height());
inverted.eraseARGB(0, 0, 0, 0);
for (int y = 0; y < image.height(); ++y) { for (int y = 0; y < image.height(); ++y) {
uint32* image_row = image.getAddr32(0, y); uint32* image_row = image.getAddr32(0, y);
...@@ -43,35 +42,6 @@ SkBitmap SkBitmapOperations::CreateInvertedBitmap(const SkBitmap& image) { ...@@ -43,35 +42,6 @@ SkBitmap SkBitmapOperations::CreateInvertedBitmap(const SkBitmap& image) {
return inverted; return inverted;
} }
// static
SkBitmap SkBitmapOperations::CreateSuperimposedBitmap(const SkBitmap& first,
const SkBitmap& second) {
DCHECK(first.width() == second.width());
DCHECK(first.height() == second.height());
DCHECK(first.bytesPerPixel() == second.bytesPerPixel());
DCHECK(first.colorType() == kN32_SkColorType);
SkAutoLockPixels lock_first(first);
SkAutoLockPixels lock_second(second);
SkBitmap superimposed;
superimposed.allocN32Pixels(first.width(), first.height());
superimposed.eraseARGB(0, 0, 0, 0);
SkCanvas canvas(superimposed);
SkRect rect;
rect.fLeft = 0;
rect.fTop = 0;
rect.fRight = SkIntToScalar(first.width());
rect.fBottom = SkIntToScalar(first.height());
canvas.drawBitmapRect(first, NULL, rect);
canvas.drawBitmapRect(second, NULL, rect);
return superimposed;
}
// static // static
SkBitmap SkBitmapOperations::CreateBlendedBitmap(const SkBitmap& first, SkBitmap SkBitmapOperations::CreateBlendedBitmap(const SkBitmap& first,
const SkBitmap& second, const SkBitmap& second,
...@@ -95,7 +65,6 @@ SkBitmap SkBitmapOperations::CreateBlendedBitmap(const SkBitmap& first, ...@@ -95,7 +65,6 @@ SkBitmap SkBitmapOperations::CreateBlendedBitmap(const SkBitmap& first,
SkBitmap blended; SkBitmap blended;
blended.allocN32Pixels(first.width(), first.height()); blended.allocN32Pixels(first.width(), first.height());
blended.eraseARGB(0, 0, 0, 0);
double first_alpha = 1 - alpha; double first_alpha = 1 - alpha;
...@@ -135,7 +104,6 @@ SkBitmap SkBitmapOperations::CreateMaskedBitmap(const SkBitmap& rgb, ...@@ -135,7 +104,6 @@ SkBitmap SkBitmapOperations::CreateMaskedBitmap(const SkBitmap& rgb,
SkBitmap masked; SkBitmap masked;
masked.allocN32Pixels(rgb.width(), rgb.height()); masked.allocN32Pixels(rgb.width(), rgb.height());
masked.eraseARGB(0, 0, 0, 0);
SkAutoLockPixels lock_rgb(rgb); SkAutoLockPixels lock_rgb(rgb);
SkAutoLockPixels lock_alpha(alpha); SkAutoLockPixels lock_alpha(alpha);
...@@ -551,7 +519,6 @@ SkBitmap SkBitmapOperations::CreateHSLShiftedBitmap( ...@@ -551,7 +519,6 @@ SkBitmap SkBitmapOperations::CreateHSLShiftedBitmap(
SkBitmap shifted; SkBitmap shifted;
shifted.allocN32Pixels(bitmap.width(), bitmap.height()); shifted.allocN32Pixels(bitmap.width(), bitmap.height());
shifted.eraseARGB(0, 0, 0, 0);
SkAutoLockPixels lock_bitmap(bitmap); SkAutoLockPixels lock_bitmap(bitmap);
SkAutoLockPixels lock_shifted(shifted); SkAutoLockPixels lock_shifted(shifted);
...@@ -575,7 +542,6 @@ SkBitmap SkBitmapOperations::CreateTiledBitmap(const SkBitmap& source, ...@@ -575,7 +542,6 @@ SkBitmap SkBitmapOperations::CreateTiledBitmap(const SkBitmap& source,
SkBitmap cropped; SkBitmap cropped;
cropped.allocN32Pixels(dst_w, dst_h); cropped.allocN32Pixels(dst_w, dst_h);
cropped.eraseARGB(0, 0, 0, 0);
SkAutoLockPixels lock_source(source); SkAutoLockPixels lock_source(source);
SkAutoLockPixels lock_cropped(cropped); SkAutoLockPixels lock_cropped(cropped);
......
...@@ -32,12 +32,6 @@ class GFX_EXPORT SkBitmapOperations { ...@@ -32,12 +32,6 @@ class GFX_EXPORT SkBitmapOperations {
// (0, 240, 255). The alpha value is not inverted. // (0, 240, 255). The alpha value is not inverted.
static SkBitmap CreateInvertedBitmap(const SkBitmap& image); static SkBitmap CreateInvertedBitmap(const SkBitmap& image);
// Create a bitmap that is a superimposition of the second bitmap on top of
// the first. The provided bitmaps must use have the kARGB_8888_Config config
// and be of equal dimensions.
static SkBitmap CreateSuperimposedBitmap(const SkBitmap& first,
const SkBitmap& second);
// Create a bitmap that is a blend of two others. The alpha argument // Create a bitmap that is a blend of two others. The alpha argument
// specifies the opacity of the second bitmap. The provided bitmaps must // specifies the opacity of the second bitmap. The provided bitmaps must
// use have the kARGB_8888_Config config and be of equal dimensions. // use have the kARGB_8888_Config config and be of equal dimensions.
......
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