Move SkPackBits to src/effects.
authorbungeman <bungeman@google.com>
Tue, 23 Feb 2016 20:55:20 +0000 (12:55 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 23 Feb 2016 20:55:20 +0000 (12:55 -0800)
Prior to this change SkPackBits.h was in include/core and SkPackBits.cpp
in src/core. However, SkPackBits appears to have been written
specifically as an implementation detail of the SkTableColorFilter
effect. This change moves SkPackBits out of core and into effects, which
is the only current user.

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

gyp/core.gypi
gyp/effects.gypi
src/effects/SkPackBits.cpp [moved from src/core/SkPackBits.cpp with 93% similarity]
src/effects/SkPackBits.h [moved from include/core/SkPackBits.h with 96% similarity]

index 63c9444..71a9d6f 100644 (file)
         '<(skia_src_path)/core/SkOpts.cpp',
         '<(skia_src_path)/core/SkOpts.h',
         '<(skia_src_path)/core/SkOrderedReadBuffer.h',
-        '<(skia_src_path)/core/SkPackBits.cpp',
         '<(skia_src_path)/core/SkPaint.cpp',
         '<(skia_src_path)/core/SkPaintDefaults.h',
         '<(skia_src_path)/core/SkPaintPriv.cpp',
         '<(skia_include_path)/core/SkMetaData.h',
         '<(skia_include_path)/core/SkMultiPictureDraw.h',
         '<(skia_include_path)/core/SkOSFile.h',
-        '<(skia_include_path)/core/SkPackBits.h',
         '<(skia_include_path)/core/SkPaint.h',
         '<(skia_include_path)/core/SkPath.h',
         '<(skia_include_path)/core/SkPathEffect.h',
index 347d140..d319fcb 100644 (file)
@@ -53,6 +53,8 @@
     '<(skia_src_path)/effects/SkMergeImageFilter.cpp',
     '<(skia_src_path)/effects/SkMorphologyImageFilter.cpp',
     '<(skia_src_path)/effects/SkOffsetImageFilter.cpp',
+    '<(skia_src_path)/effects/SkPackBits.cpp',
+    '<(skia_src_path)/effects/SkPackBits.h',
     '<(skia_src_path)/effects/SkPaintFlagsDrawFilter.cpp',
     '<(skia_src_path)/effects/SkPaintImageFilter.cpp',
     '<(skia_src_path)/effects/SkPerlinNoiseShader.cpp',
similarity index 93%
rename from src/core/SkPackBits.cpp
rename to src/effects/SkPackBits.cpp
index a3424e2..286d9d1 100644 (file)
@@ -6,14 +6,14 @@
  */
 #include "SkPackBits.h"
 
-size_t SkPackBits::ComputeMaxSize8(int count) {
+size_t SkPackBits::ComputeMaxSize8(size_t srcSize) {
     // worst case is the number of 8bit values + 1 byte per (up to) 128 entries.
-    return ((count + 127) >> 7) + count;
+    return ((srcSize + 127) >> 7) + srcSize;
 }
 
 static uint8_t* flush_same8(uint8_t dst[], uint8_t value, size_t count) {
     while (count > 0) {
-        int n = count > 128 ? 128 : count;
+        size_t n = count > 128 ? 128 : count;
         *dst++ = (uint8_t)(n - 1);
         *dst++ = (uint8_t)value;
         count -= n;
@@ -24,7 +24,7 @@ static uint8_t* flush_same8(uint8_t dst[], uint8_t value, size_t count) {
 static uint8_t* flush_diff8(uint8_t* SK_RESTRICT dst,
                             const uint8_t* SK_RESTRICT src, size_t count) {
     while (count > 0) {
-        int n = count > 128 ? 128 : count;
+        size_t n = count > 128 ? 128 : count;
         *dst++ = (uint8_t)(n + 127);
         memcpy(dst, src, n);
         src += n;
@@ -78,8 +78,6 @@ size_t SkPackBits::Pack8(const uint8_t* SK_RESTRICT src, size_t srcSize,
     return dst - origDst;
 }
 
-#include "SkUtils.h"
-
 int SkPackBits::Unpack8(const uint8_t* SK_RESTRICT src, size_t srcSize,
                         uint8_t* SK_RESTRICT dst, size_t dstSize) {
     uint8_t* const origDst = dst;
similarity index 96%
rename from include/core/SkPackBits.h
rename to src/effects/SkPackBits.h
index 1e32ee0..f6430fa 100644 (file)
@@ -17,7 +17,7 @@ public:
     /** Given the number of 8bit values that will be passed to Pack8,
         returns the worst-case size needed for the dst[] buffer.
     */
-    static size_t ComputeMaxSize8(int count);
+    static size_t ComputeMaxSize8(size_t srcSize);
 
     /** Write the src array into a packed format. The packing process may end
         up writing more bytes than it read, so dst[] must be large enough.