Commit Graph

407 Commits

Author SHA1 Message Date
Timothy Nikkel
fa7da9c935 Bug 1242093 - Fix assertion in Downscaler::ClearRow. r=njn
The starting column can be the last column, and we handle that correctly.

Also split function into ClearRow and ClearRestOfRow.
2016-02-16 08:04:57 +01:00
Timothy Nikkel
d4c4df334e Bug 1240629. Don't buffer image file data that we are never going to look at in the gap between the header and the pixel data for BMP files. r=njn
The length of the gap is computed from the BMP file header, so in a malformed BMP we could needlessly make our input file buffer huge for no reason.
2016-02-12 16:58:34 -06:00
Aidin Gharibnavaz
686438c658 Bug 1164581 - Adding an overload for NS_ProxyRelease that accepts already_AddRefed, and removing all the others. r=bobbyholley 2016-02-10 08:23:00 +01:00
Nicholas Nethercote
8c0fc6309a Bug 1238558 (part 1) - Add Decoder::BeforeFinishInternal(). r=tnikkel.
--HG--
extra : rebase_source : 613a2ce0931b8b6c67d93e4d55e965193bbb55d0
2016-01-27 16:15:06 -08:00
Carsten "Tomcat" Book
5b358688b7 Backed out changeset c18e29c1b369 (bug 1164581) for cpp unit tests test failures
--HG--
extra : rebase_source : fb6fd434c8e3f4b5fa53ea645a54c07cab207894
2016-02-08 11:17:38 +01:00
Aidin Gharibnavaz
69cf7e035f Bug 1164581 - Adding an overload for NS_ProxyRelease that accepts already_AddRefed, and removing all the others. r=bobbyholley
--HG--
extra : rebase_source : 3c6bba6613a14e48239d302bdd0f7fe2e322265d
2016-02-07 10:56:00 +01:00
Birunthan Mohanathas
d7371d07d0 Bug 1235261 - Part 1: Rename nsAutoTArray to AutoTArray. r=froydnj 2016-02-02 17:36:30 +02:00
Phil Ringnalda
d381b4bca6 Back out 7 changesets (bug 1235261) for cpptest failures in TestTArray
CLOSED TREE

Backed out changeset d66c3f19a210 (bug 1235261)
Backed out changeset 467d945426bb (bug 1235261)
Backed out changeset 32b61df13142 (bug 1235261)
Backed out changeset c50bb8ed4196 (bug 1235261)
Backed out changeset 0ff0fa6fe81f (bug 1235261)
Backed out changeset df70e89669da (bug 1235261)
Backed out changeset 064969357fc9 (bug 1235261)
2016-01-31 10:10:57 -08:00
Birunthan Mohanathas
373593275e Bug 1235261 - Part 1: Rename nsAutoTArray to AutoTArray. r=froydnj 2016-01-31 17:12:12 +02:00
Chris Peterson
c5cfbed605 Bug 1235297 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in image/decoders/. r=tn
image/FrameAnimator.cpp:442:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
image/FrameAnimator.cpp:576:7: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

image/decoders/nsGIFDecoder2.cpp:1110:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels

image/decoders/nsJPEGDecoder.cpp:418:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:444:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:465:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:537:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels

--HG--
extra : rebase_source : ec1da93105ef06d156d9d60ae8950d04f3197e38
2015-12-24 23:50:32 -07:00
Edwin Flores
4623e471a3 Bug 1207958 - Fix heuristic for choosing which ICO sub-image to render - r=tn 2016-01-20 11:00:12 +00:00
Nicholas Nethercote
f28cd689c3 Bug 1238551 (part 1) - Reject BITMAPV3INFOHEADER BMP images. r=tn.
This is an obscure BMP variant that's not worth supporting.

--HG--
extra : rebase_source : d4f8180a3e7700490daf4d07685a853c4f122c23
2016-01-17 21:12:17 -08:00
Nicholas Nethercote
02921e7c85 Bug 1237171 - Improve a case where ICO and BMP files disagree on an image size. r=tn.
--HG--
extra : rebase_source : 80701833249881c3022309f6237a3084b61b1881
2016-01-07 16:18:22 -08:00
Edwin Flores
cde8e15ecd Bug 1235605 - Use CheckedInt in Deinterlacer and make its buffer allocation fallible. r=tn 2015-12-30 17:03:24 -05:00
Edwin Flores
3c1a9580ee Bug 1229825 - Make GIF deinterlacer respect the frame rect bounds. r=tn 2015-12-29 18:19:27 -05:00
Christoph Kerschbaumer
413a60a063 Bug 1225641 - Change default security flags within NetUtil.newChannel (r=sicking) 2015-11-17 17:35:30 -08:00
Edwin Flores
ce990e88c7 Bug 1223465 - Clamp GIF frame rects to their screen rects - r=seth 2015-11-25 13:50:13 +00:00
Nicholas Nethercote
eeb418d47f Bug 1220021 (part 1) - Don't treat 0RGB ICO files as transparent. r=seth.
This approach is much the same as the one we had before bug 1062066 caused the
regression.
2015-11-23 15:32:39 -08:00
Nicholas Nethercote
2c9bfa2dec Bug 1223319 (part 1) - Remove unused function nsICODecoder::CalcAlphaRowSize(). r=seth. 2015-11-16 17:54:11 -08:00
Glenn Randers-Pehrson
fde5c53117 Bug 75077 - Interpolate interlaced PNG images instead of libpng blocky display. r=seth 2015-11-14 11:33:00 +01:00
sajitk
32ccc4c2b0 Bug 1219474 - Replace PRLogModuleInfo w/ LazyLogModule in the 'image/' directory. r=seth
--HG--
extra : rebase_source : 1ce8c7a9d4ff2610506584e9f58ab9d9a6e92e06
2015-11-16 18:21:00 +01:00
Nicholas Nethercote
ce10603db1 Bug 1210291 - Streamline StreamingLexer's handling of terminal states. r=seth.
This patch introduces TerminalState and changes LexerTransition::mNextState to
be a Variant<State, TerminalState>. This means that SUCCESS and FAILURE no
longer need to be part of State.

Some things to note:

- This simplifies the handling of Lex()'s return value, which is nice.

- The patch splits Terminate() into TerminateSuccess() and TerminateFailure().

- |const State& aNextState| wouldn't work for the first arg to
  LexerTransition's ctor due to errors in Variant construction that I didn't
  understand. I had to change it to |State aNextState|.

--HG--
extra : rebase_source : f405a67fdf0f1bb712409eafecb21ac9b59d6db0
2015-10-28 01:30:20 -07:00
Nicholas Nethercote
8b78d5e498 Bug 1217465 - Fill in missing pixels caused by truncated BMP files. r=seth.
This fixes failures for
image/test/reftest/bmp/bmpsuite/b/{badrle.bmp,shortfile.bmp} with the Skia
back-end.

--HG--
extra : rebase_source : 6c5b967cebf43cf5d49d0e532619bdd1c8ccc69e
2015-11-15 20:31:07 -08:00
Nathan Froyd
77af195199 Bug 1219405 - use LazyLogModule for PNG decoder logging; r=seth
This change eliminates some TSan warnings and also eliminates some
boilerplate.
2015-10-28 16:08:06 -04:00
Nicholas Nethercote
2a85ac5257 Bug 1215361 (part 3) - Deconvolute nsICODecoder's handling of endianness. r=seth.
nsICODecoder's reading and writing of little-endian values can be simplified
greatly.

Also, ReadBPP() was highly dodgy: BMP's bpp field is 16-bit
but ReadBPP() read it as if it's 32-bit. I think this currently works because
the bpp field is followed by the 32-bit compression field which is usually 0
for BMPs within ICOs!

--HG--
extra : rebase_source : 5fd43dedc036dca5bc2ff79b029855dc76d62515
2015-10-15 17:54:41 -07:00
Nicholas Nethercote
ad948a5a38 Bug 1215361 (part 2) - Streamline nsBMPDecoder's getters. r=seth.
- GetBitsPerPixel() and GetWidth() are no longer used.

- GetHeight() is now only used within nsBMPDecoder and can be renamed and
  inlined into the header.

- GetImageData() can be inlined into the header.

--HG--
extra : rebase_source : f902f7ce6513e54eaa7fe6210b4ff3ff6865c4bf
2015-10-15 17:38:32 -07:00
Nicholas Nethercote
5203886b92 Bug 1215361 (part 1) - Don't set mBPP twice in nsICODecoder.cpp. r=seth.
Seth's "XXX" comment is correct.

--HG--
extra : rebase_source : 0a3c20d7c8a67e8eb0ec21cdd197a901a463c707
2015-10-15 17:35:21 -07:00
Nicholas Nethercote
65c73a3e0e Bug 1215334 (part 2) - Avoid creating a fake header for BMP files in ICO files. r=seth.
This requires delaying the creation of the BMP decoder used by the ICO decoder.

--HG--
extra : rebase_source : 629a2ac387a9c8ee1a520c70733adb10cc156aa8
2015-10-15 15:43:31 -07:00
Nicholas Nethercote
a685206641 Bug 1215334 (part 1) - Avoid creating a fake header for BMP files in ICO files. r=seth.
The FileHeader and V5InfoHeader structs are shared by the BMP decoder and
encoder. But most of the fields within those structs are actually unused by the
decoder. It makes things clearer if we create a decoder-only struct that
contains the used fields, and then make FileHeader and V5InfoHeader only used
by the encoder. This patch does that.

This patch also renames BMPFileHeaders.h as BMPHeaders.h, which is now a better
name for it.

--HG--
rename : image/BMPFileHeaders.h => image/BMPHeaders.h
extra : rebase_source : 2227679b8aef25e48d3e8e7d38a3ba79a57c40d3
2015-10-15 15:43:25 -07:00
Nathan Froyd
e73e798e13 Bug 1218823 - use UniquePtr<> in preference to delete[] in image/; r=seth 2015-10-27 10:47:51 -04:00
Nicholas Nethercote
c5432f6a1e Bug 1214072 (part 2) - Implement transparency properly for BMP images. r=seth.
Currently we don't implement transparency at all in BMP images except for an
odd-duck case of BMPs within ICOs.

This patch does the following.

- It implements transparency properly for 16bpp and 32bpp images via bitfield
  masking. (For 32bpp images this also requires handling colors via bitfield
  masking.) The patch maintains the existing BMP-within-ICO transparency
  handling.

- It also reworks BitFields::Value::Set().

  * It now works correctly if the run of 1s goes all the way to bit 31 (the
    old code didn't set mBitWidth).

  * If the mask is 0, will give an mRightShift of 0 (old code gave 32, and
    right-shifting by 32 is dodgy).

  * It's now easier to read.

- It renames transparent.bmp as transparent-if-within-ico.bmp. Ironically
  enough this file currently uses BITFIELDS compression and is WinBMPv5 format,
  which means it contains well-specified alpha data. In order to use it to test
  the hacky BMP-within-ICO transparency scheme the patch changes it to be
  WinBMPv3 format with RGB compression (i.e. no compression). I left the
  now-excess bytes (including the bitfields) in the info header in place
  because that's allowed -- thanks to the start of the pixel data being
  specified by the |dataoffset| field -- they'll just be ignored.

- It tweaks the naming of the relevant gtests and some of their finer details
  to work with the new way of doing things.

This fixes all four remaining failures in bmpsuite.

--HG--
rename : image/test/gtest/transparent.bmp => image/test/gtest/transparent-if-within-ico.bmp
extra : rebase_source : 2f4838d04bbae4fac00cc69e8d75469105a5de3b
2015-10-13 21:20:10 -07:00
Nicholas Nethercote
6acba8cc1c Bug 1214072 (part 1) - Read BMP bitfields during metadata decoding. r=seth.
Currently we don't read BMP bitfields during metadata decoding. But we'll need
to in order implement alpha, because we need to know during metadata decoding
if alpha is used.

This patch moves code around to achieve this (and adds the required
mMayHaveTransparency field). The change has no noticeable effect for now.

--HG--
extra : rebase_source : 32106149bf064f0e44ec9dcf8f013612dceacbb7
2015-10-13 20:01:24 -07:00
Nathan Froyd
ed0f5e4822 Bug 1215763 - part 1 - remove unnecessary nsAutoPtr.h includes; r=seth
These turned up when grepping around for nsAutoPtr; it seemed easier to
remove them as a first step.
2015-10-17 06:52:21 -04:00
Nathan Froyd
d1d54b4b48 Bug 1215156 - move SetPixel* functions into nsBMPDecoder.cpp; r=seth
These functions are only used in nsBMPDecoder.cpp; we don't need them
anywhere else.  The only other place they might get used would be the
BMP encoder, but the encoder appears to have its own routines for
setting pixel data, which don't overlap very well with the decoder's.
2015-10-15 19:58:52 -04:00
Seth Fowler
6a4428a1e6 Bug 1213744 (Part 2) - Clamp the GIF frame rect to the visible rect for DDD and don't decode outside it. r=tn 2015-10-25 13:14:14 -07:00
Seth Fowler
02cb32707b Backed out changeset 154fa450fb1f (bug 1214055) because it wasn't ready to land. 2015-10-22 23:34:04 -07:00
Seth Fowler
a00ad7cec8 Bug 1214055 - Treat PNGs as transparent during the metadata decode. r=tn 2015-10-22 23:29:38 -07:00
Nathan Froyd
01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Nicholas Nethercote
bc8cdf084b Bug 1213613 (part 3) - Fix color-scaling of 16bpp BMP images. r=seth.
This patch implements proper color-scaling, instead of bit-shifting, and uses
it for 16bpp images.

It also cleans up the code relating to color masking in the process, by making
BitFields a proper class and introducing the Value class within it.

This fixes sub-optimal handling of four images in bmpsuite.
2015-10-13 20:01:02 -07:00
Nicholas Nethercote
74961773ab Bug 1213613 (part 2) - Move some BMP-related structs. r=seth.
This patch moves them into less exposed places. It also moves the RLE_*
constants into the RLE enum, and renames ColorTable and its fields.
2015-10-13 16:43:18 -07:00
Nicholas Nethercote
a96e894e1a Bug 1213613 (part 1) - Formatting cleanups for nsBMPEncoder.h. r=seth.
Two-space indents is the Gecko standard, and it's what nsBMPDecoder.cpp uses.
This patch changes nsBMPEncoder.h to use two-space indents as well. This will
help avoid possible mis-indentation if code is moved from the .h to the .cpp or
vice versa (as subsequent patches in this bug will do).

Also, it changes some of the // comments on public methods to doxygen-style ///
comments.
2015-10-13 16:08:06 -07:00
Nicholas Nethercote
5ca8040708 Bug 1204394 (part 1) - Using StreamingLexer in the BMP decoder. r=seth.
This patch is a major overhaul of nsBMPDecoder.

The patch improves the code in the following ways.

- It converts nsBMPDecoder to use StreamingLexer, which makes it much easier to
  read.

- It adds a detailed comment about the BMP format at the top of
  nsBMPDecoder.cpp.

- It fixes lots of inconsistent indenting.

- It moves |bihsize| from |mBFH| to |mBIH| to match the file format and common
  sense. The avoids the need for the confusing LENGTH/INTERNAL_LENGTH
  distinction.

- It renames most of the types in BMPFileHeader.h, so they have better names,
  in StudlyCaps form, and within the new |bmp| namespace.

- It removes the BMP_HEADER_LENGTH struct and inlines its values directly into
  the two places they were used.

- It removes the MOZ_LOG logging done on some of the failure cases. (Most
  failure cases lacked logging so why bother with some?)

- It removes over 200 lines of code, despite the addition of the big format
  comment.

The patch changes the way BMPs are decoded as follows.

- It adds stricter testing of the InfoHeader length, rejecting files with bad
  values.

- It moves all header sanity checking that can lead to file rejection into the
  metadata decode phase. (Previously, bpp/compression consistency checking did
  not occur during a metadata decode.)

- It removes BMPINFOHEADER::ALPHABITFIELDS, which was (a) a weird WinCE-only
  thing, and (b) we didn't actually allow it, and (c) we used the value 4
  instead of 6(!).

- It rejects the previously-accepted compression==RLE4 && bpp=1 combination
  because it doesn't make sense.

- It removes a fudge in RLE absolute mode handling that permitted one pixel too
  many in a row but only if the row's width was odd(!)

- It now rejects a file with a negative gap between the color table and the
  pixel data.

The patch leaves the following problems unaddressed.

- If bpp==32 we totally ignore compression==BITFIELDS and treat it like
  compression=RGB.

- Transparency as specified in WinBMPv{4,5} isn't handled at all.

These will be fixed in follow-ups.

All these changes affect (for the better) the results of the following tests
that will be added in part 2:

- g/pal8v4.bmp
- g/pal8v5.bmp
- q/pal8os2sp.bmp
- q/pal8os2v2.bmp
- q/pal8os2v2-16.bmp
- b/badheadersize.bmp
- b/badpalettesize.bmp
- b/badrle.bmp

--HG--
extra : rebase_source : 8ddc2f5fccce6998348097ff9f0a1072d273cdf4
2015-10-08 22:47:56 -07:00
Nicholas Nethercote
b7e5ba36b2 Bug 1204393 (part 1) - Use StreamingLexer in the ICON decoder. r=seth.
* * *
Bug 1204393 (part 1b) - Address review comments.

--HG--
extra : rebase_source : 0015ca99e20ccd6f4d5becab38fece63cb02332b
2015-10-05 14:29:01 -07:00
Steve Singer
9156f29954 Bug 1208935 - Move Deinterlacer to a standalone file. r=seth
--HG--
extra : rebase_source : 0c5a189769dd741953cab667127ffdef39a60aa7
2015-09-28 20:40:00 +02:00
Seth Fowler
ae6de3f01a Bug 1207378 (Part 2) - Use Downscaler to remove first-frame padding when downscaling GIFs. r=tn 2015-09-26 01:36:23 -07:00
Seth Fowler
ba99adc235 Bug 1207378 (Part 1) - Add support for a frame rect to Downscaler. r=tn 2015-09-26 01:36:19 -07:00
Chris Peterson
71920a9550 Bug 1207030 - Enable -Wshadow flag in more directories that have no -Wshadow warnings. r=glandium 2015-09-22 21:39:03 -07:00
Seth Fowler
7a466fae73 Bug 1206836 - When downscaling ICOs, downscale the AND mask as well. r=tn a=KWierso 2015-09-21 19:52:31 -07:00
Seth Fowler
c1229ef66c Bug 1146663 (Part 5) - Require that all image decoders support downscale-during-decode. r=tn 2015-09-19 16:21:08 -07:00
Seth Fowler
93cbaca5e0 Bug 1201796 (Part 4) - Add downscale-during-decode support for the ICO decoder. r=tn 2015-09-19 13:34:14 -07:00