Closed Bug 1087863 Opened 11 years ago Closed 9 years ago

Use clip rects to restrict area that blend modes apply to

Categories

(Firefox Graveyard :: Shumway, defect, P1)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: mbx, Unassigned)

References

Details

Attachments

(2 files)

Attached file copy.html
The destination-in blend mode is necessary to perform masking operations and is extremely slow in Canvas 2D. This is happening on both cg and skia. (It is a lot faster in skia if hardware acceleration is enabled.) In the attached test case, click "Blend Destination-In" and compare that with "Blend Normal". Chrome is about 20x faster than Firefox.
Looks like it's highly dependent on the size of the destination canvas: Canvas Size 272 4235.77 Op/s. 288 3964.51 Op/s. 304 3712.44 Op/s. 320 3499.25 Op/s. 336 3155.50 Op/s. 352 3060.90 Op/s. 368 2337.76 Op/s. 384 2616.64 Op/s. 400 2523.93 Op/s. 416 2343.32 Op/s. 432 2141.08 Op/s. 448 2070.86 Op/s. 464 1928.59 Op/s. 480 1826.05 Op/s. 496 1735.63 Op/s. // There's an interesting spike here. 512 787.29 Op/s. 528 775.89 Op/s. 544 794.76 Op/s. 560 708.13 Op/s. 576 714.09 Op/s. 592 637.03 Op/s. 608 613.41 Op/s. 624 568.76 Op/s. 640 466.16 Op/s. 656 526.14 Op/s. 672 520.99 Op/s. 688 485.88 Op/s. 704 480.86 Op/s. 720 440.36 Op/s. 736 434.81 Op/s. 752 391.43 Op/s. 768 379.30 Op/s. 784 366.19 Op/s. 800 343.73 Op/s. 816 338.45 Op/s. 832 331.79 Op/s. 848 311.56 Op/s. 864 309.31 Op/s. 880 298.01 Op/s. 896 286.89 Op/s. 912 273.57 Op/s. 944 251.94 Op/s. 960 245.26 Op/s. 976 207.67 Op/s. 992 232.02 Op/s. 1008 220.63 Op/s. 1024 216.49 Op/s. 1040 208.22 Op/s. 1056 204.39 Op/s. 1072 201.92 Op/s. 1088 198.23 Op/s. 1104 189.14 Op/s. One question is, what is it about destination-in that requires a read back?
Attached image blend-chart.png
Blend operations copying a 64x64 pixel rectangle to a destination canvas of varying size 256, 512, 1024 and 2048.
Operator destination-in affects all pixels in the target canvas, even if you only draw a small rect. If you want to contain the effects of drawImage to the rect that you're drawing, you need to set a clip first.
I see, that makes a lot of sense.
Priority: -- → P1
Blocks: shumway-m5
No longer blocks: shumway-m3
Component: Canvas: 2D → Shumway
Product: Core → Firefox
Summary: Destination-in blend mode is 80x slower than normal blend mode. → Use clip rects to restrict area that blend modes apply to
Product: Firefox → Firefox Graveyard
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: