Revert of move static arrays into impl, to avoid multiple copies (patchset #3 id...
authorreed <reed@google.com>
Sat, 16 Apr 2016 19:24:09 +0000 (12:24 -0700)
committerCommit bot <commit-bot@chromium.org>
Sat, 16 Apr 2016 19:24:09 +0000 (12:24 -0700)
Reason for revert:
FAILED: if [ ! -e lib/libgfx.so -o ! -e lib/libgfx.so.TOC ]; then /b/build/slave/linux_chromeos/build/src/build/goma/client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -Wl,-z,defs -pthread -Wl,-z,noexecstack -fPIC -fuse-ld=gold -B/b/build/slave/linux_chromeos/build/src/third_party/binutils/Linux_x64/Release/bin -Wl,--disable-new-dtags -m64 -Wl,--icf=all -o lib/libgfx.so -Wl,-soname=libgfx.so @lib/libgfx.so.rsp && { readelf -d lib/libgfx.so | grep SONAME ; nm -gD -f p lib/libgfx.so | cut -f1-2 -d' '; } > lib/libgfx.so.TOC; else /b/build/slave/linux_chromeos/build/src/build/goma/client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -Wl,-z,defs -pthread -Wl,-z,noexecstack -fPIC -fuse-ld=gold -B/b/build/slave/linux_chromeos/build/src/third_party/binutils/Linux_x64/Release/bin -Wl,--disable-new-dtags -m64 -Wl,--icf=all -o lib/libgfx.so -Wl,-soname=libgfx.so @lib/libgfx.so.rsp && { readelf -d lib/libgfx.so | grep SONAME ; nm -gD -f p lib/libgfx.so | cut -f1-2 -d' '; } > lib/libgfx.so.tmp && if ! cmp -s lib/libgfx.so.tmp lib/libgfx.so.TOC; then mv lib/libgfx.so.tmp lib/libgfx.so.TOC ; fi; fi
obj/ui/gfx/gfx.blit.o:../../ui/gfx/blit.cc:function SkColorTypeBytesPerPixel(SkColorType): error: undefined reference to 'gPrivate_SkColorTypeBytesPerPixel'
obj/ui/gfx/gfx.canvas.o:../../ui/gfx/canvas.cc:function SkColorTypeBytesPerPixel(SkColorType): error: undefined reference to 'gPrivate_SkColorTypeBytesPerPixel'
obj/ui/gfx/gfx.canvas_skia.o:../../ui/gfx/canvas_skia.cc:function SkColorTypeBytesPerPixel(SkColorType): error: undefined reference to 'gPrivate_SkColorTypeBytesPerPixel'
obj/ui/gfx/codec/gfx.jpeg_codec.o:../../ui/gfx/codec/jpeg_codec.cc:function SkColorTypeBytesPerPixel(SkColorType): error: undefined reference to 'gPrivate_SkColorTypeBytesPerPixel'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Original issue's description:
> move static arrays into impl, to avoid multiple copies
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1889793007
>
> Committed: https://skia.googlesource.com/skia/+/6d7cd1f421dbde43dd2db655ca477c05312ec5fd

TBR=fmalita@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=skia:

Review URL: https://codereview.chromium.org/1899563002

include/core/SkImageInfo.h
src/core/SkImageInfo.cpp

index 1cac7eb..4b308c0 100644 (file)
@@ -86,18 +86,42 @@ enum SkColorType {
 #endif
 };
 
-extern const uint8_t gPrivate_SkColorTypeBytesPerPixel[];
-
 static int SkColorTypeBytesPerPixel(SkColorType ct) {
-    SkASSERT((unsigned)ct <= (unsigned)kLastEnum_SkColorType);
-    return gPrivate_SkColorTypeBytesPerPixel[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
+        1,  // kGray_8
+        8,  // kRGBA_F16
+    };
+    static_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];
 }
 
-extern const uint8_t gPrivate_SkColorTypeShiftPerPixel[];
-
 static int SkColorTypeShiftPerPixel(SkColorType ct) {
-    SkASSERT((unsigned)ct <= (unsigned)kLastEnum_SkColorType);
-    return gPrivate_SkColorTypeShiftPerPixel[ct];
+    static const uint8_t gShift[] = {
+        0,  // Unknown
+        0,  // Alpha_8
+        1,  // RGB_565
+        1,  // ARGB_4444
+        2,  // RGBA_8888
+        2,  // BGRA_8888
+        0,  // kIndex_8
+        0,  // kGray_8
+        3,  // kRGBA_F16
+    };
+    static_assert(SK_ARRAY_COUNT(gShift) == (size_t)(kLastEnum_SkColorType + 1),
+                  "size_mismatch_with_SkColorType_enum");
+    
+    SkASSERT((size_t)ct < SK_ARRAY_COUNT(gShift));
+    return gShift[ct];
 }
 
 static inline size_t SkColorTypeMinRowBytes(SkColorType ct, int width) {
index 6b6fb17..16f0a01 100644 (file)
@@ -9,34 +9,6 @@
 #include "SkReadBuffer.h"
 #include "SkWriteBuffer.h"
 
-const uint8_t gPrivate_SkColorTypeBytesPerPixel[] = {
-    0,  // Unknown
-    1,  // Alpha_8
-    2,  // RGB_565
-    2,  // ARGB_4444
-    4,  // RGBA_8888
-    4,  // BGRA_8888
-    1,  // kIndex_8
-    1,  // kGray_8
-    8,  // kRGBA_F16
-};
-static_assert(SK_ARRAY_COUNT(gPrivate_SkColorTypeBytesPerPixel) == (size_t)(kLastEnum_SkColorType + 1),
-              "size_mismatch_with_SkColorType_enum");
-
-const uint8_t gPrivate_SkColorTypeShiftPerPixel[] = {
-    0,  // Unknown
-    0,  // Alpha_8
-    1,  // RGB_565
-    1,  // ARGB_4444
-    2,  // RGBA_8888
-    2,  // BGRA_8888
-    0,  // kIndex_8
-    0,  // kGray_8
-    3,  // kRGBA_F16
-};
-static_assert(SK_ARRAY_COUNT(gPrivate_SkColorTypeShiftPerPixel) == (size_t)(kLastEnum_SkColorType + 1),
-              "size_mismatch_with_SkColorType_enum");
-
 static bool profile_type_is_valid(SkColorProfileType profileType) {
     return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType);
 }