Commit Graph

384 Commits

Author SHA1 Message Date
Nathan Froyd
2a4a7f9cfe 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
55a0f62a5c 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!
2015-10-15 17:54:41 -07:00
Nicholas Nethercote
62b24e3b47 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.
2015-10-15 17:38:32 -07:00
Nicholas Nethercote
a30977afce Bug 1215361 (part 1) - Don't set mBPP twice in nsICODecoder.cpp. r=seth.
Seth's "XXX" comment is correct.
2015-10-15 17:35:21 -07:00
Nicholas Nethercote
197ed85202 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.
2015-10-15 15:43:31 -07:00
Nicholas Nethercote
2ea46d1849 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.
2015-10-15 15:43:25 -07:00
Nathan Froyd
889f2d5617 Bug 1218823 - use UniquePtr<> in preference to delete[] in image/; r=seth 2015-10-27 10:47:51 -04:00
Nicholas Nethercote
36df074e3e 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.
2015-10-13 21:20:10 -07:00
Nicholas Nethercote
ee9946f2bf 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.
2015-10-13 20:01:24 -07:00
Nathan Froyd
05430e2a2c 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
da8613e168 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
46fcf1376d 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
2f629074a5 Backed out changeset 154fa450fb1f (bug 1214055) because it wasn't ready to land. 2015-10-22 23:34:04 -07:00
Seth Fowler
4c1a030475 Bug 1214055 - Treat PNGs as transparent during the metadata decode. r=tn 2015-10-22 23:29:38 -07:00
Nathan Froyd
9c5965b035 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
2015-10-18 01:24:48 -04:00
Nicholas Nethercote
dec8c586b6 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
789dd0c48a 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
e839a533dd 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
01292964d7 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
2015-10-08 22:47:56 -07:00
Nicholas Nethercote
1a5f7cebe4 Bug 1204393 (part 1) - Use StreamingLexer in the ICON decoder. r=seth.
* * *
Bug 1204393 (part 1b) - Address review comments.
2015-10-05 14:29:01 -07:00
Steve Singer
0d65510876 Bug 1208935 - Move Deinterlacer to a standalone file. r=seth 2015-09-28 20:40:00 +02:00
Seth Fowler
e050c6dd57 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
3ec12300d0 Bug 1207378 (Part 1) - Add support for a frame rect to Downscaler. r=tn 2015-09-26 01:36:19 -07:00
Chris Peterson
b06d7f99a7 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
5f0c22c9c2 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
4c4c3a0ac0 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
a4a4772943 Bug 1201796 (Part 4) - Add downscale-during-decode support for the ICO decoder. r=tn 2015-09-19 13:34:14 -07:00
Seth Fowler
d7b7923baf Bug 1201796 (Part 1) - Treat ICOs with wrong widths and heights as corrupt. r=tn 2015-09-19 13:34:06 -07:00
Seth Fowler
1b38998856 Bug 1196066 (Part 3) - Rewrite nsICODecoder to use StreamingLexer. r=tn 2015-09-18 23:12:30 -07:00
Wes Kocher
9effa8d37d Backed out 8 changesets (bug 1201796, bug 1196066) for mulet gij(28) failures CLOSED TREE
Backed out changeset 159d5d2946d3 (bug 1201796)
Backed out changeset 958988218976 (bug 1201796)
Backed out changeset 494e7553d641 (bug 1201796)
Backed out changeset d58149411b7d (bug 1201796)
Backed out changeset 35bd769b49f8 (bug 1196066)
Backed out changeset e4f3d4279b4c (bug 1196066)
Backed out changeset ca467297fa07 (bug 1196066)
Backed out changeset b4851ce6637d (bug 1196066)
2015-09-18 13:01:25 -07:00
Seth Fowler
02713137f0 Bug 1201796 (Part 4) - Add downscale-during-decode support for the ICO decoder. r=tn 2015-09-18 10:54:40 -07:00
Seth Fowler
eef74d1ce4 Bug 1201796 (Part 1) - Treat ICOs with wrong widths and heights as corrupt. r=tn 2015-09-18 10:54:32 -07:00
Seth Fowler
01ad0622b3 Bug 1196066 (Part 3) - Rewrite nsICODecoder to use StreamingLexer. r=tn 2015-09-18 10:54:27 -07:00
Seth Fowler
23ffb90430 Bug 1194058 (Part 2) - Add downscale-during-decode support for the GIF decoder. r=tn 2015-09-17 15:03:34 -07:00
Seth Fowler
918fa8dbc9 Bug 1201763 - Add downscale-during-decode support for the ICON decoder. r=tn 2015-09-08 22:07:18 -07:00
Seth Fowler
5fcd0b5711 Bug 1062066 (Part 4) - Add downscale-during-decode support for the BMP decoder. r=tn 2015-09-08 22:07:12 -07:00
Seth Fowler
237b91e17d Bug 1062066 (Part 3) - Only mark BMP surfaces as transparent if they actually have alpha data. r=tn 2015-09-08 22:07:09 -07:00
Seth Fowler
c1711c7ad2 Bug 1060609 (Part 2) - Add downscale-during-decode support for the PNG decoder. r=tn,f=glennrp 2015-09-01 14:13:17 -07:00
Nicholas Nethercote
10d95cca57 Bug 1198334 (part 1) - Replace the opt-in FAIL_ON_WARNINGS with the opt-out ALLOW_COMPILER_WARNINGS. r=glandium.
The patch removes 455 occurrences of FAIL_ON_WARNINGS from moz.build files, and
adds 78 instances of ALLOW_COMPILER_WARNINGS. About half of those 78 are in
code we control and which should be removable with a little effort.
2015-08-27 20:44:53 -07:00
Gijs Kruitbosch
b413f1babe Bug 1173214, r=seth,bz 2015-08-26 10:24:04 +01:00
Seth Fowler
e93b360d02 Bug 1194900 - Stop deciding when to send invalidations in nsPNGDecoder and let Decoder handle it. r=tn 2015-08-24 19:49:36 -07:00
Glenn Randers-Pehrson
3ac19bf6eb Bug 1187569 - PNGs getting stuck in a pixelated state. r=seth 2015-08-20 14:17:10 -07:00
Michael Layzell
9ff696fed2 Bug 1195415 - Add asciiHostPort field to nsIURI, and use it in the implementation of nsPrincipal::GetOriginForURI, r=bholley 2015-08-18 14:52:24 -04:00
Seth Fowler
0119f3f595 Bug 1185800 - Add DecoderFlags and SurfaceFlags enum classes and use them instead of imgIContainer flags in all decoder-related code. r=tn 2015-08-14 17:56:44 -07:00
Seth Fowler
028f2c1726 Bug 1194059 (Part 2) - Always detect IS_ANIMATED during the metadata decode. r=tn 2015-08-14 00:37:13 -07:00
Christoph Kerschbaumer
18543664bb Bug 1193924 - Add assertion to AsyncOpen to make sure asyncOpen2() was called first when securityflags in loadInfo are set (r=sicking) 2015-08-12 21:36:33 -07:00
Ryan VanderMeulen
7bacf85e8a Backed out changeset f99b27e40987 (bug 1193924) for B2G emulator bustage.
CLOSED TREE
2015-08-13 12:45:05 -04:00
Christoph Kerschbaumer
1da578e09c Bug 1193924 - Add assertion to AsyncOpen to make sure asyncOpen2() was called first when securityflags in loadInfo are set (r=sicking) 2015-08-12 21:36:33 -07:00
Seth Fowler
c46c7a44cb Bug 1191114 (Part 1) - Always detect HAS_TRANSPARENCY during the metadata decode. r=tn 2015-08-12 10:41:02 -07:00
Seth Fowler
8fd303760d Bug 1191090 - Use the normal PNG decoder for PNG metadata decodes. r=tn 2015-08-10 15:34:27 -07:00