Closed Bug 207146 Opened 21 years ago Closed 10 years ago

Use GDI+ on Win32 to speed up -moz-opacity

Categories

(Core Graveyard :: GFX: Win32, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: kmcclusk, Unassigned)

Details

(Keywords: perf)

Attachments

(8 files, 2 obsolete files)

 
This patch optionally implements -moz-opacity using GDI+ for images. (Which is
the hard part :) ). 

It needs additional work to support opacity on other elements.	This shouldn't
be too difficult since GDI+ supports alpha when defining colors used for
brushes.
Comment on attachment 124221 [details] [diff] [review]
patch which uses GDI+ to render -moz-opacity for images 

sorry!, Wrong patch!
Attachment #124221 - Attachment is obsolete: true
Attached file gif with mask - speed test (obsolete) —
Attached file speed test 2 - jpeg
Attachment #124223 - Attachment is obsolete: true
speed test 1 - (pgn with alpha) + global opacity 
------------------------------------------------
original                 10264 (ms)
using AlphaBlend          4767 (ms)
using GDI+                2764 (ms)   3.7X faster


speed test 2 - jpeg + global opacity
------------------------------------
original                 8752 (ms)
using AlphaBlend         5148 (ms)
Using GDI+               3475 (ms)   2.5X faster


speed test 3 - (gif)
--------------------
(I don't have recent numbers for this, but should be faster as well)

speed test 4 -(pgn with alpha) *without* global opacity
--------------------------------------------------------
original               18757 (ms)
AlphaBlend              4456 (ms)
using GDI+              3195 (ms)    5.8X faster


summary: The patch which I attached can use use either the AlphaBlend call or 
GDI+ for alpha compositing of images. When using GDI+ it gives approx
2.5X - 5.8X speed improvement over the original.  Using Alpha blend gives a nice
speed improvement but there isn't an easy way to implement the full moz-opacity
for elements besides images. Using GDI+ on the otherhand will make it easy to
implement -moz-opacity on other elemnts since GDI+ supports alpha when defining
colors for brushes.

There are two aspects of the patch which speeds up -moz-opacity for images. 

(1) Using GDI+ bitmaps to perform alpha compositing instead of using the
existing cross platform global -moz-opacity implementation in the viewmanager.
(Note: There seems to be significant memory overhead when using GDI+. (5-6Mb
overhead just for initializing GDI+)

(2) Creating the backbuffer as a DIB instead of DDB.  This speeds up rendering
of  png's regardless of whether GDI+ is used. (Note: This will increase memory
footprint since the DIB can not be kept in video card memory and it is cached to
avoid the overhead of re-creating the DIB on each NS_PAINT)

Is this going to affect the SVG branch, which has a generic system in place to
do opacity, and already uses GDI+ to do opacity on SVG elements?
Kevin, I don't think this approach is compatible with the group opacity model.
the other issue is that doing this ( SVG branch has the same issue) requires we
distribute a copy of the MS gdiplus.dll with mozilla , since it only comes with
WinXp by default
Kevin, we should talk about this, both about why you want to do this (what
exactly is the workload you're trying to optimize for here) and where is the
right place to do it.

The approach you're trying will work when the view with -moz-opacity consists of
exactly one image and no other visible stuff (no borders or backgrounds etc) but
it won't give the right results (as per CSS) in other cases.
I wanted to apply patch into local build, but i was unable to. nsImageWin.cpp is
completly different in patch and in cvs. Kevin, could You make a patch for
recent trunk?
roc: The issue I was looking at was the slow resize performance of images in
mail and composer when the image is made large.

I see your point, the group opacity is incorrect with my approach since it will
be compositing each element as it is drawn, rather than compositing the elements
as a group.

Priority: -- → P2
Target Milestone: --- → Future
Assignee: kmcclusk → win32
Component: GFX → GFX: Win32
Priority: P2 → --
Target Milestone: Future → ---
If GDI+ had been used before Microsoft patched the JPEG problem with it, would
Mozilla have been susceptible to this exploit? If so, I would be wary of adding
GDI+ to Mozilla, despite the performance gain. If not, go GDI+!
No, the exploit only affected JPEG decoding, which would not be used here.
And even if it did, we're already linked to millions of lines of Microsoft code 
in Windows builds, purely by virtue of using the Win32 API. If you are worried 
about holes in Microsoft code affecting Mozilla, don't use a Microsoft OS.
Attached file speed test 3 - gif
Obsoletes 124228 (incorrect mime-type and marked as patch when it is a
testcase), but of course I don't have appropriate permissions to do so :)
Product: Core → Core Graveyard
This bug has been buried in the graveyard and has not been updated in over 5 years. It is probably safe to assume that it will never be fixed, so resolving as WONTFIX.

[Mass-change filter: graveyard-wontfix-2014-09-24]
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: