Skip to content

Transparent Off Screen rendering: Rendered incorrectly with black background before alpha-channel applied #584

Closed

Description

@magreenblatt

Original report by Anonymous.


Original issue 584 created by [email protected] on 2012-04-27T12:16:49.000Z:

What steps will reproduce the problem?

  1. set m_bTransparentPainting to true
  2. load up a html page with some transparent elements (preferably white)
  3. render offscreen output against a bright background (so it gets obvious)

or
use cefclient integrated Off-Screen Rendering test with attached sample HTML file

What is the expected output? What do you see instead?
the alpha channel is correct. however not the RGB colors will appear as if pre-rendered against a black background before actual alpha channel is applied.
so if you got a white transparent pixel with r255 g255 b255 a127 it outputs as r127 g127 b127 a127 in the buffer.
a white transparent box would appear greyish, instead of white

I have attached three files:
test.html - the file i have tested with in cefclient.exe from revision 533 and my actual project.
actualoutput.png - the test.html file loaded in the Off-Screen Rendering App Example of cefclient.exe resulting in a greyish appearance
comparison.png - the same as "actualoutput.png" but with a transparent white Box overlay made with a graphics program for comparison

What version of the product are you using? On what operating system?
I am currently using the Delphi Wrapper of chromiumembedded (http://code.google.com/p/delphichromiumembedded/) which currently uses the older CEF 1.963.439. However i made tests with the cefclient from the current revision 533.

Activity

  1. magreenblatt commented on May 18, 2012

    @magreenblatt
    CollaboratorAuthor

    Comment 1. originally posted by magreenblatt on 2012-05-18T22:22:42.000Z:

  2. magreenblatt commented on May 18, 2012

    @magreenblatt
    CollaboratorAuthor
    • set state to "open"
  3. magreenblatt commented on May 23, 2012

    @magreenblatt
    CollaboratorAuthor

    Comment 2. originally posted by magreenblatt on 2012-05-23T17:40:30.000Z:

    Revision 643 improves the cefclient transparency test by adding the ability to view individual pixel values.

  4. magreenblatt commented on May 24, 2012

    @magreenblatt
    CollaboratorAuthor

    Comment 3. originally posted by magreenblatt on 2012-05-24T18:16:31.000Z:

    Transparent painting in WebKit works as follows:

    1. GraphisContext::beginTransparencyLayer creates a new layer (bitmap) for the transparent region.

    2. Painting is done on the new layer using just RGB values.

    3. GraphicsContext::endTransparencyLayer is called to paint the new layer onto the underlying layer and apply the alpha component at the same time.

    The call stack for comment 3. is as follows:

    libcef.dll!S32A_Blend_BlitRow32_SSE2(unsigned int * dst, const unsigned int * src, int count, unsigned int alpha) Line 233 C++
    libcef.dll!Sprite_D32_S32::blitRect(int x, int y, int width, int height) Line 48 + 0x15 bytes C++
    libcef.dll!blitrect(SkBlitter * blitter, const SkIRect & r) Line 15 + 0x2e bytes C++
    libcef.dll!SkScan::FillIRect(const SkIRect & r, const SkRegion * clip, SkBlitter * blitter) Line 26 + 0xd bytes C++
    libcef.dll!SkScan::FillIRect(const SkIRect & r, const SkRasterClip & clip, SkBlitter * blitter) Line 77 + 0x16 bytes C++
    libcef.dll!SkDraw::drawSprite(const SkBitmap & bitmap, int x, int y, const SkPaint & origPaint) Line 1248 + 0x17 bytes C++
    libcef.dll!SkDevice::drawDevice(const SkDraw & draw, SkDevice * device, int x, int y, const SkPaint & paint) Line 357 C++
    libcef.dll!SkCanvas::drawDevice(SkDevice * device, int x, int y, const SkPaint * paint) Line 858 + 0x4e bytes C++
    libcef.dll!SkCanvas::internalRestore() Line 799 C++
    libcef.dll!SkCanvas::restore() Line 769 C++
    libcef.dll!WebCore::GraphicsContext::endPlatformTransparencyLayer() Line 290 + 0x21 bytes C++
    libcef.dll!WebCore::GraphicsContext::endTransparencyLayer() Line 346 C++

    So, in conclusion, the S32A_Blend_BlitRow32_SSE2 function intentionally applies alpha blending to all 4 components of the RGBA value.

  5. magreenblatt commented on May 24, 2012

    @magreenblatt
    CollaboratorAuthor

    Comment 4. originally posted by magreenblatt on 2012-05-24T18:44:19.000Z:

    For example, in S32A_Blend_BlitRow32_SSE2:

    alpha = 0xbf
    src_pixel = 0xffffffffffffffffffffffffffffffff (new/transparent layer)
    dst_pixel = 0000000000000000000000000000000000 (bb) (underlying layer)
    result = 0xbfbfbfbfbfbfbfbfbfbfbfbfbfbfbfbf

  6. magreenblatt commented on May 24, 2012

    @magreenblatt
    CollaboratorAuthor
  7. magreenblatt commented on May 24, 2012

    @magreenblatt
    CollaboratorAuthor
  8. magreenblatt commented on May 24, 2012

    @magreenblatt
    CollaboratorAuthor

    Original comment by Anonymous.


    Comment 7. originally posted by [email protected] on 2012-05-24T22:50:37.000Z:

    good you found a lead. i suspected that it is nothing that comes from cef itself. thanks for your dedication in this project :)

  9. magreenblatt commented on May 25, 2012

    @magreenblatt
    CollaboratorAuthor

    Original comment by Anonymous.


    Comment 8. originally posted by [email protected] on 2012-05-25T12:19:48.000Z:

    Skia writes premultpilied alpha. That's the only pixel format you're going to get out of Chromium.

  10. magreenblatt commented on May 25, 2012

    @magreenblatt
    CollaboratorAuthor

    Comment 9. originally posted by magreenblatt on 2012-05-25T14:24:00.000Z:

    Revision 648 updates the cefclient example to account for premultiplied alpha values.

  11. magreenblatt commented on May 25, 2012

    @magreenblatt
    CollaboratorAuthor
    • set state to "resolved"
  12. magreenblatt commented on May 25, 2012

    @magreenblatt
    CollaboratorAuthor

    Original comment by Anonymous.


    Comment 10. originally posted by [email protected] on 2012-05-25T14:25:58.000Z:

    Ahh, I was wondering if it was a question of blend functions. Nice clean fix.

  13. magreenblatt commented on May 25, 2012

    @magreenblatt
    CollaboratorAuthor

    Comment 11. originally posted by magreenblatt on 2012-05-25T14:35:49.000Z:

    The cefclient changes have been merged to all branches in revision 649.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions