Closed Bug 186103 Opened 22 years ago Closed 22 years ago

Transparent PNG background image is much darker than usual in today's build

Categories

(Core :: Layout: Images, Video, and HTML Frames, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: pascalc, Assigned: paper)

References

()

Details

Attachments

(3 files, 8 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20021218
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20021218

build 2002218008 WinXP
on the page http://pascal.chevrel.free.fr the PNG image used as a background for
the menu links ( http://pascal.chevrel.free.fr/images/transNB2.png ) is
displayed much darker than it should. You can compare its color with how NS7.01
or Phoenix 0.5 render it.

I think that this is a very recent regression


Reproducible: Always

Steps to Reproduce:
1. go to the page
2. look at the background color
3. compare it with another Mozilla build

Actual Results:  
color is incorrect
Yes, we re-enabled GDI alpablending yesterday.  I'll dig up a PNG that goes from
0 to 100% opacity (I saw it somewhere) and compare the RGBs in Mozilla to a
paint program.. but they should be the same now
I know the cause of this one, and it's due to nsImageWin::DrawTile not handling
optimized 8 bit alpha images correctly.

Taking, but I may not have a fix ready until next year (gone for xmas)
Assignee: jdunn → paper
Attached patch Fix (diff -uw) (obsolete) — Splinter Review
Attached patch Fix (diff -u) (obsolete) — Splinter Review
IMO, the -uw patch is much easier to read (review).

I added 8 bit alpha support to the ProgressiveDoubleBlit() function, and cleaned
up the function.

- ProgressiveDoubleBlit now checks for the 16M DDB limit that Win 95/98/ME has.
  The function used to always create a new DDB at the size of the whole area to
be tiled.  If > 16M and Win98/95/ME, it now makes a smaller DDB (as close to 16M
as possible using multiples of the imagesize) and draws it multiple times.

- Added spaces after commas, split lines > 80 cols, etc.

- Rewrote BuildTile so it doesn't call itself.  (it uses while loops now)  Moved
it next to ProgressiveDoubleBlit so it's easier to find when debugging.


This patch also has the side effect of increasing PNG tiling performance by 20%
- 40% on WinME, Win2K, WinXP, and maybe even WinNT. :)
In addition to the things mentioned in #mozilla, could you change BuildTile()
description comment and the comments inside the while loops? The rest looks ok
to me, assuming gAlphaBlend() does its job.
Attached patch Fix -uw (obsolete) — Splinter Review
Changes discussed on IRC:

- Comment before the call to ProgressiveDoubleBlit (in DrawTile) was confusing.


- "offDCBytesPerPix = ::GetDeviceCaps(theHDC, BITSPIXEL)" is just wrong

- theHDC in the above line should really be offDC (not that it matters, since
offDC is a copy of theHDC, but logically it looks better)


I've also changed the BuildTile comments
Attachment #110539 - Attachment is obsolete: true
Attached patch Fix -u (obsolete) — Splinter Review
Attachment #110540 - Attachment is obsolete: true
Attachment #110690 - Flags: review?(ere)
Comment on attachment 110690 [details] [diff] [review]
Fix -u

Two nits: Please update or remove the @update comment of BuildTile(). One thing
I missed before is that parameter TheHDC is aTheHDC in the comment. I know you
didn't do it, but consider changing the parameter name to be consistent with
the others. 

Otherwise it looks good to me. With the changes mentioned above, r=ere@atp.fi.
Attachment #110690 - Flags: review?(ere) → review+
Attached patch Fix -uw (obsolete) — Splinter Review
- removed @update comments
- change TheHDC to aTheHDC in BuildTile

Also, some unrequested changes:
- BuildTile declaration in .h said "HDC SrcDestDC" instead of "HDC aTheHDC"
- "PRBool result" was no longer being used in DrawTile. Removed.
Attachment #110689 - Attachment is obsolete: true
Attached patch Fix -u (obsolete) — Splinter Review
Attachment #110690 - Attachment is obsolete: true
Attachment #110726 - Flags: review?(ere)
Comment on attachment 110726 [details] [diff] [review]
Fix -u

One more nit now that you fixed the header too :) There's a comment about
@param aDS, which doesn't exist. I'd move the documentation comments from .cpp
to .h altogether. 
Anyway, with the comment fixed in .h, r=ere@atp.fi.
Attachment #110726 - Flags: review?(ere) → review+
Attached patch Fix -uw (obsolete) — Splinter Review
Attachment #110725 - Attachment is obsolete: true
Attached patch Fix -u (obsolete) — Splinter Review
Attachment #110726 - Attachment is obsolete: true
Comment on attachment 111114 [details] [diff] [review]
Fix -u

Updated to work in non 32 bit color displays.

The only changes from the last patch is changing:
// Create a bitmap of 1 plane, 32 bit color depth
tileBits = ::CreateBitmap(offDCWidth, offDCHeight, 1, 32, NULL);

to:
    // Can't use ::CreateBitmap, since the resulting HBITMAP will only be able
    // to be selected into a compatible HDC (ie. User is @ 24 bit, you can't
    // select the 32 HBITMAP into the HDC.)
    ALPHA32BITMAPINFO bmi(offDCWidth, offDCHeight);
    tileBits = ::CreateDIBSection(theHDC, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS,
				  NULL, NULL, 0);


Hopefully the comment should be self explanatory
Attachment #111114 - Flags: superreview?(tor)
Attachment #111114 - Flags: review?(ere)
Comment on attachment 111114 [details] [diff] [review]
Fix -u

Good catch. r=ere@atp.fi
Attachment #111114 - Flags: review?(ere) → review+
Keywords: mozilla1.3
Comment on attachment 111114 [details] [diff] [review]
Fix -u

sr=tor
Attachment #111114 - Flags: superreview?(tor) → superreview+
Checked-in. Thanks ere, tor.
Hello, thanks for the patch !

As a side effect, there is a *huge* performance boost (IMO, much more than the
20% to 40% indicated in comment #5) when scrolling pages with transparent PNG
images used as tiled backgrounds for elements. I had abandonned the use of png
backgrounds on my sites because scrolling was almost impossible with them. I
think that if it is safe, this patch should be checked into the 1.0.x branch so
as to allow the next Netscape version to benefit from this.

With an Athlon1700XP/WinXP/256MB ram, mouse scrolling the page uses about 40 to
60 % CPU while phoenix0.5 and NS7.01 which do not benefit from this patch have
choppy scrolling and above 90% CPU use.

test page : http://pascal.chevrel.free.fr/faqmoz2.html
Glad to hear of the speed improvement, Pascal. :)
The speed improvement is totally dependant upon the video card, so everyone will
probably have different results.

Bug 187822 should also provide more speed improvements.  Using
http://mozilla.animecity.nu/IMGTest/TileTest01.html  (PNG Tiles mode), I get the
following

20030115    : 13951ms
20030116    : 10575ms -> 1.319 or ~32% speed increase
w/Bug 187822:  8012ms -> another 1.3198 or 32% speed increase from 20030116, or
                         a total of 74% speed increase from 20030116

Anyway, resolving this bug to fixed :)
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
that should read "a total of 74% speed increase from 20030115"
As you can clearly see in this screenshot, there are problems with the fix for
this bug. There are other problems too (some transparent png's are not rendered
it seems).
Attached patch Regression FixSplinter Review
Normally, I'd suggest filing a new bug on this, but since I have a fix, we'll
let it slide this time.

r/srs: Patch fixes problem by not drawing beyond the area intended.
This regression can be tested by going to http://www.texturizer.net/phoenix/
and swishing a small window over top of the "English Dutch" table row until it
doesn't look right.  Windows Only.
Attachment #111113 - Attachment is obsolete: true
Attachment #111114 - Attachment is obsolete: true
Comment on attachment 111856 [details] [diff] [review]
Regression Fix

sr=tor
Attachment #111856 - Flags: superreview+
Comment on attachment 111856 [details] [diff] [review]
Regression Fix

r=ere@atp.fi
Attachment #111856 - Flags: review+
regression fix checked-in.
Moving a window over the area and out now works, however rollovers and moving
the mozilla window off screen still seem to have problems, as shown in the
testcase.

Using build 17th Jan 17:34 (2003011713)
2003011713 is actually the 1:00pm build.  I can't reproduce this.. try the
20030118xx build.
yes, it works fine on the latest, thanks.
Product: Core → Core Graveyard
Product: Core Graveyard → Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: