diff options
author | 2018-02-09 13:26:46 -0500 | |
---|---|---|
committer | 2018-02-09 20:38:32 +0000 | |
commit | 7fcfb621998648ba018e3b89e2cab3135bd46a1f (patch) | |
tree | ce43ae14602539ef7b541e91cc1372c1ee4b4e0e /src/core/SkImageInfo.cpp | |
parent | 47cf048abecb5064b9e851ea01f75b23797c1611 (diff) |
move a bunch of helpers from SkImageInfo.h into priv
Bug: skia:
Change-Id: I8c91cfdb89e4f22448d1201d391556fe43d86dca
Reviewed-on: https://skia-review.googlesource.com/105289
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Reviewed-by: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src/core/SkImageInfo.cpp')
-rw-r--r-- | src/core/SkImageInfo.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp index a3d352f05f..b684cdfcf4 100644 --- a/src/core/SkImageInfo.cpp +++ b/src/core/SkImageInfo.cpp @@ -5,11 +5,28 @@ * found in the LICENSE file. */ -#include "SkImageInfo.h" +#include "SkImageInfoPriv.h" #include "SkSafeMath.h" #include "SkReadBuffer.h" #include "SkWriteBuffer.h" +int SkColorTypeBytesPerPixel(SkColorType ct) { + switch (ct) { + case kUnknown_SkColorType: return 0; + case kAlpha_8_SkColorType: return 1; + case kRGB_565_SkColorType: return 2; + case kARGB_4444_SkColorType: return 2; + case kRGBA_8888_SkColorType: return 4; + case kBGRA_8888_SkColorType: return 4; + case kRGB_888x_SkColorType: return 4; + case kRGBA_1010102_SkColorType: return 4; + case kRGB_101010x_SkColorType: return 4; + case kGray_8_SkColorType: return 1; + case kRGBA_F16_SkColorType: return 8; + } + return 0; +} + // These values must be constant over revisions, though they can be renamed to reflect if/when // they are deprecated. enum Stored_SkColorType { @@ -64,6 +81,16 @@ static SkColorType stored_to_live(unsigned stored) { /////////////////////////////////////////////////////////////////////////////////////////////////// +int SkImageInfo::bytesPerPixel() const { return SkColorTypeBytesPerPixel(fColorType); } + +int SkImageInfo::shiftPerPixel() const { return SkColorTypeShiftPerPixel(fColorType); } + +size_t SkImageInfo::computeOffset(int x, int y, size_t rowBytes) const { + SkASSERT((unsigned)x < (unsigned)fWidth); + SkASSERT((unsigned)y < (unsigned)fHeight); + return SkColorTypeComputeOffset(fColorType, x, y, rowBytes); +} + size_t SkImageInfo::computeByteSize(size_t rowBytes) const { if (0 == fHeight) { return 0; |