Closed Bug 1210514 Opened 9 years ago Closed 9 years ago

Fix color inversion when BasicCompositor is used on gonk

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: sotaro, Assigned: sotaro)

References

Details

Attachments

(1 file, 1 obsolete file)

When BasicCompositor is enabled on gonk, display shows color inverted rendering.
Blocks: 1206583
Assignee: nobody → sotaro.ikeda.g
(In reply to Sotaro Ikeda [:sotaro PTO 5/Oct - 14/Oct] from comment #0)
> When BasicCompositor is enabled on gonk, display shows color inverted
> rendering.

See Bug 1206583 Comment 15.
The problem happens by the following.
 - gecko renders content by BGR color.
 - DrawTargetCairo supports only BGR color.
   When RGB is requested, BGR render target is allocated.
   And even if we could allocate BGR render target, performance might not be good without GPU.
On gonk, hwc could expose RB swap capability. Flame-kk's hwc says that hwc supports RB swap, but it seems not work for DisplaySurface's RBSwap. I tried it, but it did not work.
Depends on: 1210189
Confirmed on master flame-KK with the following preference.
  - layers.acceleration.disabled -> true
  - gfx.canvas.azure.accelerated -> false
  - layers.gralloc.disable       -> true
Attachment #8668667 - Flags: review?(nical.bugzilla)
hwc seems not support rbswap of DisplaySurface's layer even when hwc suports rbswap. It seems that DisplaySurface's layer is always set as last hwc layer of hwc layers. From it, the layer seems to be automatically handled as HWC_FRAMEBUFFER_TARGET. It seems to affect to it.
(In reply to Sotaro Ikeda [:sotaro PTO 5/Oct - 14/Oct] from comment #5)
> hwc seems not support rbswap of DisplaySurface's layer even when hwc suports
> rbswap. It seems that DisplaySurface's layer is always set as last hwc layer
> of hwc layers. From it, the layer seems to be automatically handled as
> HWC_FRAMEBUFFER_TARGET. It seems to affect to it.

normal hwc need one HWC_FRAMEBUFFER_TARGET for composition.
Looks like with your path we perform the manual rb swap on the framebuffer after each composition. Wouldn't it be much cheaper to do it on layers after they are painted so that we don't have to do a lot of processing during scrolling?
nical: can you explain more about it? I do not know well to moz 2d api. DrawTargetCairo seems to support only BGR.
Flags: needinfo?(nical.bugzilla)
(In reply to Sotaro Ikeda [:sotaro PTO 5/Oct - 14/Oct] from comment #8)
> nical: can you explain more about it? I do not know well to moz 2d api.
> DrawTargetCairo seems to support only BGR.

Seems to support B8G8R8A8 and B8G8R8X8. But not support R8G8B8A8.
Comment on attachment 8668667 [details] [diff] [review]
patch - Convert BGR to RGB in nsWindow::EndRemoteDrawing()

Review of attachment 8668667 [details] [diff] [review]:
-----------------------------------------------------------------

R+ since this is a temporary solution. Please add big red-flags comments and performance warnings that this has very slow code paths that should not be used in production.
Attachment #8668667 - Flags: review?(nical.bugzilla) → review+
(In reply to Sotaro Ikeda [:sotaro PTO 5/Oct - 14/Oct intermittent during PTO] from comment #9)
> (In reply to Sotaro Ikeda [:sotaro PTO 5/Oct - 14/Oct] from comment #8)
> > nical: can you explain more about it? I do not know well to moz 2d api.
> > DrawTargetCairo seems to support only BGR.
> 
> Seems to support B8G8R8A8 and B8G8R8X8. But not support R8G8B8A8.

This is a problem if we do things that are not plain composite operations, but if all we do is blit semi-transparent pixels, we are better off rb-swapping content that we receive and composite it (even if means an extra copy and lying to moz2d about the format), as long as the alpha channel is in the same place. This way we only do extra work when things are painted rather than every time we present.
Better even, rb-swap on the content side after painting, to avoid the extra copy on the compositor side.

I know what I am suggesting can look worryingly hacky, but rb-swapping the entire screen every time we present is far too expensive to do on the cpu, especially on a platform that is supposedly very cheap because we don't have a gpu to do the composition.
Flags: needinfo?(nical.bugzilla)
Apply the comment.
Attachment #8668667 - Attachment is obsolete: true
Attachment #8674088 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/2aebb47a694b
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: