diff options
author | scroggo <scroggo@google.com> | 2015-12-18 06:56:01 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-18 06:56:01 -0800 |
commit | db7dc09e526e815ade242e3dcb066693c42c8bda (patch) | |
tree | 81c413bb1f8119f9ae0fe6ff727f609dfbd258af | |
parent | b81cecad379908160aebd0811616b011988c6df2 (diff) |
Remove SkImageMinRowBytes
As stated in the comments in crrev.com/1379193002, this method name is
misleading. It returns a larger number than the minimum rowbytes - it
increases to the next four-byte alignment. This has the effect that the
one place that calls it does not support 565 (which is not already
four-byte aligned), but does not serve any other purpose. Remove it and
the only call-site.
BUG=skia:4396
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1528383004
Review URL: https://codereview.chromium.org/1528383004
-rw-r--r-- | src/image/SkImagePriv.h | 8 | ||||
-rw-r--r-- | src/image/SkImage_Raster.cpp | 2 | ||||
-rw-r--r-- | tests/ImageFrom565Bitmap.cpp | 21 |
3 files changed, 22 insertions, 9 deletions
diff --git a/src/image/SkImagePriv.h b/src/image/SkImagePriv.h index b8f177905d..7518bbe808 100644 --- a/src/image/SkImagePriv.h +++ b/src/image/SkImagePriv.h @@ -40,14 +40,6 @@ enum ForceCopyMode { }; extern SkImage* SkNewImageFromRasterBitmap(const SkBitmap&, ForceCopyMode = kNo_ForceCopyMode); -static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { - size_t minRB = info.minRowBytes(); - if (kIndex_8_SkColorType != info.colorType()) { - minRB = SkAlign4(minRB); - } - return minRB; -} - // Given an image created from SkNewImageFromBitmap, return its pixelref. This // may be called to see if the surface and the image share the same pixelref, // in which case the surface may need to perform a copy-on-write. diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index 977dc01c4b..2b81da8915 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -48,7 +48,7 @@ public: return false; } - if (rowBytes < SkImageMinRowBytes(info)) { + if (rowBytes < info.minRowBytes()) { return false; } diff --git a/tests/ImageFrom565Bitmap.cpp b/tests/ImageFrom565Bitmap.cpp new file mode 100644 index 0000000000..d910a47560 --- /dev/null +++ b/tests/ImageFrom565Bitmap.cpp @@ -0,0 +1,21 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkBitmap.h" +#include "SkImageInfo.h" +#include "SkImage.h" +#include "Test.h" + +DEF_TEST(ImageFrom565Bitmap, r) { + SkBitmap bm; + bm.allocPixels(SkImageInfo::Make( + 5, 7, kRGB_565_SkColorType, kOpaque_SkAlphaType)); + SkAutoLockPixels autoLockPixels(bm); + bm.eraseColor(SK_ColorBLACK); + SkAutoTUnref<SkImage> img(SkImage::NewFromBitmap(bm)); + REPORTER_ASSERT(r, img.get() != nullptr); +} |