aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyph.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-03-21 11:13:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-21 15:44:58 +0000
commit5f3685b079de725032d526a7425c19c2e0f24444 (patch)
tree3401b152f74a19ea5144dd849490cfea8480e661 /src/core/SkGlyph.cpp
parent0262ea03f81c484ed4c287da55f1e0f2e65363b5 (diff)
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>
Diffstat (limited to 'src/core/SkGlyph.cpp')
-rw-r--r--src/core/SkGlyph.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/core/SkGlyph.cpp b/src/core/SkGlyph.cpp
index 3d9389ce4c..2abe98aa1e 100644
--- a/src/core/SkGlyph.cpp
+++ b/src/core/SkGlyph.cpp
@@ -39,24 +39,6 @@ static size_t bits_to_bytes(size_t bits) {
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 @@ static size_t format_alignment(SkMask::Format format) {
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);