aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyph.h
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-01-20 11:59:03 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-20 17:50:49 +0000
commit7c5a806bf67e1818b0272a2ae8d854ae1fd72e82 (patch)
treeeed446175857e8a27ac5f42cba1c84d737e97dc7 /src/core/SkGlyph.h
parentabddea0d8c05103dfb3ea63744f178b4ef4075c9 (diff)
Move from SkChunkAlloc to SkArenaAlloc for SkGlyphCache.
Change-Id: I221dd1c35898fe2703584f90d14192c8b546af40 Reviewed-on: https://skia-review.googlesource.com/7112 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkGlyph.h')
-rw-r--r--src/core/SkGlyph.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h
index 73f8704f64..06c1d76fb3 100644
--- a/src/core/SkGlyph.h
+++ b/src/core/SkGlyph.h
@@ -8,10 +8,12 @@
#ifndef SkGlyph_DEFINED
#define SkGlyph_DEFINED
+#include "SkArenaAlloc.h"
#include "SkChecksum.h"
-#include "SkTypes.h"
#include "SkFixed.h"
#include "SkMask.h"
+#include "SkTypes.h"
+
class SkPath;
class SkGlyphCache;
@@ -161,13 +163,17 @@ public:
fForceBW = 0;
}
+ static size_t BitsToBytes(size_t bits) {
+ return (bits + 7) >> 3;
+ }
+
/**
* Compute the rowbytes for the specified width and mask-format.
*/
static unsigned ComputeRowBytes(unsigned width, SkMask::Format format) {
unsigned rb = width;
if (SkMask::kBW_Format == format) {
- rb = (rb + 7) >> 3;
+ rb = BitsToBytes(rb);
} else if (SkMask::kARGB32_Format == format) {
rb <<= 2;
} else if (SkMask::kLCD16_Format == format) {
@@ -178,6 +184,26 @@ public:
return rb;
}
+ size_t allocImage(SkArenaAlloc* alloc) {
+ size_t allocSize;
+ if (SkMask::kBW_Format == fMaskFormat) {
+ allocSize = BitsToBytes(fWidth) * fHeight;
+ fImage = alloc->makeArrayDefault<char>(allocSize);
+ } else if (SkMask::kARGB32_Format == fMaskFormat) {
+ allocSize = fWidth * fHeight;
+ fImage = alloc->makeArrayDefault<uint32_t>(fWidth * fHeight);
+ allocSize *= sizeof(uint32_t);
+ } else if (SkMask::kLCD16_Format == fMaskFormat) {
+ allocSize = SkAlign2(fWidth) * fHeight;
+ fImage = alloc->makeArrayDefault<uint16_t>(allocSize);
+ allocSize *= sizeof(uint16_t);
+ } else {
+ allocSize = SkAlign4(fWidth) * fHeight;
+ fImage = alloc->makeArrayDefault<char>(allocSize);
+ }
+ return allocSize;
+ }
+
unsigned rowBytes() const {
return ComputeRowBytes(fWidth, (SkMask::Format)fMaskFormat);
}