Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: src/core/SkImageInfo.cpp

Issue 870023002: Don't use SK_ASSERT in header. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move function to cpp Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/core/SkImageInfo.h ('K') | « include/core/SkImageInfo.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageInfo.cpp
diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp
index 146a3aeed8b0a4a1b04af80f43cb0742e39069db..2bd90d105ed40b7aafc7d219989bd3b0c1cd090b 100644
--- a/src/core/SkImageInfo.cpp
+++ b/src/core/SkImageInfo.cpp
@@ -9,6 +9,23 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
+int SkColorTypeBytesPerPixel(SkColorType ct) {
+ static const uint8_t gSize[] = {
+ 0, // Unknown
+ 1, // Alpha_8
+ 2, // RGB_565
+ 2, // ARGB_4444
+ 4, // RGBA_8888
+ 4, // BGRA_8888
+ 1, // kIndex_8
+ };
+ SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gSize) == (size_t)(kLastEnum_SkColorType + 1),
+ size_mismatch_with_SkColorType_enum);
+
+ SkASSERT((size_t)ct < SK_ARRAY_COUNT(gSize));
+ return gSize[ct];
+}
+
static bool profile_type_is_valid(SkColorProfileType profileType) {
return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType);
}
@@ -21,6 +38,10 @@ static bool color_type_is_valid(SkColorType colorType) {
return (colorType >= 0) && (colorType <= kLastEnum_SkColorType);
}
+int SkImageInfo::bytesPerPixel() const {
+ return SkColorTypeBytesPerPixel(fColorType);
+}
+
void SkImageInfo::unflatten(SkReadBuffer& buffer) {
fWidth = buffer.read32();
fHeight = buffer.read32();
« include/core/SkImageInfo.h ('K') | « include/core/SkImageInfo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698