Simplify format_rowbyts calculation.
As per comment in change 114371.
Change-Id: I9724d5df205bb1430ebd3371677cce344372decc
Reviewed-on: https://skia-review.googlesource.com/115610
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkGlyph.cpp b/src/core/SkGlyph.cpp
index 3d9389c..2abe98a 100644
--- a/src/core/SkGlyph.cpp
+++ b/src/core/SkGlyph.cpp
@@ -39,24 +39,6 @@
return (bits + 7) >> 3;
}
-static size_t format_rowbytes(int width, SkMask::Format format) {
- switch (format) {
- case SkMask::kBW_Format:
- return bits_to_bytes(width);
- case SkMask::kA8_Format:
- case SkMask::k3D_Format:
- return width;
- case SkMask::kARGB32_Format:
- return width * sizeof(uint32_t);
- case SkMask::kLCD16_Format:
- return width * sizeof(uint16_t);
- default:
- SK_ABORT("Unknown mask format.");
- break;
- }
- return 0;
-}
-
static size_t format_alignment(SkMask::Format format) {
switch (format) {
case SkMask::kBW_Format:
@@ -74,6 +56,11 @@
return 0;
}
+static size_t format_rowbytes(int width, SkMask::Format format) {
+ return format == SkMask::kBW_Format ? bits_to_bytes(width)
+ : width * format_alignment(format);
+}
+
size_t SkGlyph::allocImage(SkArenaAlloc* alloc) {
auto size = this->computeImageSize();
auto format = static_cast<SkMask::Format>(fMaskFormat);