aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2015-11-17 11:18:03 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-17 11:18:03 -0800
commit5af4e0bc8fd17944f3c0527462aeba367f6d590a (patch)
treeff0c7b83d85fc5480879732e8e7cee68757fc391 /dm
parentc08d53ee175e190254d8fd6659d9ad051ac0ba46 (diff)
Make SkAndroidCodec support gif
Involves a few bug fixes in SkCodec_libgif and a bit more complexity in SkSwizzler. BUG=skia:4405 Review URL: https://codereview.chromium.org/1445313002
Diffstat (limited to 'dm')
-rw-r--r--dm/DM.cpp9
-rw-r--r--dm/DMSrcSink.cpp76
-rw-r--r--dm/DMSrcSink.h1
3 files changed, 3 insertions, 83 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 0cbf9440db..8873dcabbe 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -230,9 +230,6 @@ static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp
case CodecSrc::kScanline_Mode:
folder.append("scanline");
break;
- case CodecSrc::kScanline_Subset_Mode:
- folder.append("scanline_subset");
- break;
case CodecSrc::kStripe_Mode:
folder.append("stripe");
break;
@@ -310,7 +307,7 @@ static void push_codec_srcs(Path path) {
const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f };
const CodecSrc::Mode nativeModes[] = { CodecSrc::kCodec_Mode, CodecSrc::kScanline_Mode,
- CodecSrc::kScanline_Subset_Mode, CodecSrc::kStripe_Mode, CodecSrc::kSubset_Mode };
+ CodecSrc::kStripe_Mode, CodecSrc::kSubset_Mode };
CodecSrc::DstColorType colorTypes[3];
uint32_t numColorTypes;
@@ -363,8 +360,8 @@ static void push_codec_srcs(Path path) {
// The following image types are only supported by BitmapFactory,
// so we only need to test full image decodes.
static const char* fullExts[] = {
- "wbmp", "bmp",
- "WBMP", "BMP",
+ "wbmp", "bmp", "gif",
+ "WBMP", "BMP", "GIF",
};
for (const char* ext : fullExts) {
if (path.endsWith(ext)) {
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 75f954f453..af62dafdd4 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -372,82 +372,6 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
canvas->drawBitmap(bitmap, 0, 0);
break;
}
- case kScanline_Subset_Mode: {
- //this mode decodes the image in divisor*divisor subsets, using a scanline decoder
- const int divisor = 2;
- const int w = decodeInfo.width();
- const int h = decodeInfo.height();
- if (divisor > w || divisor > h) {
- return Error::Nonfatal(SkStringPrintf("Cannot decode subset: divisor %d is too big"
- "for %s with dimensions (%d x %d)", divisor, fPath.c_str(), w, h));
- }
- const int subsetWidth = w/divisor;
- const int subsetHeight = h/divisor;
- // One of our subsets will be larger to contain any pixels that do not divide evenly.
- const int extraX = w % divisor;
- const int extraY = h % divisor;
- /*
- * if w or h are not evenly divided by divisor need to adjust width and height of end
- * subsets to cover entire image.
- * Add extraX and extraY to largestSubsetBm's width and height to adjust width
- * and height of end subsets.
- * subsetBm is extracted from largestSubsetBm.
- * subsetBm's size is determined based on the current subset and may be larger for end
- * subsets.
- */
- SkImageInfo largestSubsetDecodeInfo =
- decodeInfo.makeWH(subsetWidth + extraX, subsetHeight + extraY);
- SkBitmap largestSubsetBm;
- if (!largestSubsetBm.tryAllocPixels(largestSubsetDecodeInfo, nullptr,
- colorTable.get())) {
- return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str(),
- largestSubsetDecodeInfo.width(), largestSubsetDecodeInfo.height());
- }
- for (int col = 0; col < divisor; col++) {
- //currentSubsetWidth may be larger than subsetWidth for rightmost subsets
- const int currentSubsetWidth = (col + 1 == divisor) ?
- subsetWidth + extraX : subsetWidth;
- const int x = col * subsetWidth;
- for (int row = 0; row < divisor; row++) {
- //currentSubsetHeight may be larger than subsetHeight for bottom subsets
- const int currentSubsetHeight = (row + 1 == divisor) ?
- subsetHeight + extraY : subsetHeight;
- const int y = row * subsetHeight;
- //create scanline decoder for each subset
- SkCodec::Options options;
- SkIRect subset = SkIRect::MakeXYWH(x, 0, currentSubsetWidth, h);
- options.fSubset = &subset;
- // TODO (msarett): Support this mode for all scanline orderings.
- if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &options,
- colorPtr, colorCountPtr) ||
- SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
- if (x == 0 && y == 0) {
- //first try, image may not be compatible
- return Error::Nonfatal("Could not start top-down scanline decoder");
- } else {
- return "Error scanline decoder is nullptr";
- }
- }
- // Skip to the first line of subset. We ignore the result value here.
- // If the skip value fails, this will indicate an incomplete image.
- // This means that the call to getScanlines() will also fail, but it
- // will fill the buffer with a default value, so we can still draw the
- // image.
- codec->skipScanlines(y);
-
- //create and set size of subsetBm
- SkBitmap subsetBm;
- SkIRect bounds = SkIRect::MakeWH(currentSubsetWidth, currentSubsetHeight);
- SkAssertResult(largestSubsetBm.extractSubset(&subsetBm, bounds));
- SkAutoLockPixels autolock(subsetBm, true);
- codec->getScanlines(subsetBm.getAddr(0, 0), currentSubsetHeight,
- subsetBm.rowBytes());
- subsetBm.notifyPixelsChanged();
- canvas->drawBitmap(subsetBm, SkIntToScalar(x), SkIntToScalar(y));
- }
- }
- break;
- }
case kStripe_Mode: {
const int height = decodeInfo.height();
// This value is chosen arbitrarily. We exercise more cases by choosing a value that
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 6371a9046f..e155508ac2 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -106,7 +106,6 @@ public:
enum Mode {
kCodec_Mode,
kScanline_Mode,
- kScanline_Subset_Mode,
kStripe_Mode, // Tests the skipping of scanlines
kSubset_Mode, // For codecs that support subsets directly.
};