⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267711 in webkit


Ignore:
Timestamp:
Sep 28, 2020, 1:04:47 PM (6 years ago)
Author:
Fujii Hironori
Message:

[TextureMapper] Enable a depth buffer for preserve-3d
https://bugs.webkit.org/show_bug.cgi?id=90078

Reviewed by Don Olmstead.

Source/WebCore:

Test: transforms/3d/general/preserve-3d.html

  • platform/graphics/egl/GLContextEGL.cpp:

(WebCore::GLContextEGL::getEGLConfig):

  • platform/graphics/texmap/TextureMapper.h:

(WebCore::TextureMapper::beginPreserves3D): Added a new virtual method.
(WebCore::TextureMapper::endPreserves3D): Ditto.

  • platform/graphics/texmap/TextureMapperGL.cpp:

(WebCore::TextureMapperGL::beginPainting):
(WebCore::createProjectionMatrix): Swapped nearValue and farValue
so that the depth buffer works as expected.
(WebCore::TextureMapperGL::beginPreserves3D): Added.
(WebCore::TextureMapperGL::endPreserves3D): Ditto.

  • platform/graphics/texmap/TextureMapperGL.h:
  • platform/graphics/texmap/TextureMapperLayer.cpp:

(WebCore::TextureMapperLayer::paintSelfAndChildren): Call
beginPreserves3D() and endPreserves3D() if m_state.preserves3D.

LayoutTests:

  • transforms/3d/general/preserve-3d-expected.html: Added.
  • transforms/3d/general/preserve-3d.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r267703 r267711  
     12020-09-28  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [TextureMapper] Enable a depth buffer for preserve-3d
     4        https://bugs.webkit.org/show_bug.cgi?id=90078
     5
     6        Reviewed by Don Olmstead.
     7
     8        * transforms/3d/general/preserve-3d-expected.html: Added.
     9        * transforms/3d/general/preserve-3d.html: Added.
     10
    1112020-09-28  Zalan Bujtas  <zalan@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r267709 r267711  
     12020-09-28  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [TextureMapper] Enable a depth buffer for preserve-3d
     4        https://bugs.webkit.org/show_bug.cgi?id=90078
     5
     6        Reviewed by Don Olmstead.
     7
     8        Test: transforms/3d/general/preserve-3d.html
     9
     10        * platform/graphics/egl/GLContextEGL.cpp:
     11        (WebCore::GLContextEGL::getEGLConfig):
     12        * platform/graphics/texmap/TextureMapper.h:
     13        (WebCore::TextureMapper::beginPreserves3D): Added a new virtual method.
     14        (WebCore::TextureMapper::endPreserves3D): Ditto.
     15        * platform/graphics/texmap/TextureMapperGL.cpp:
     16        (WebCore::TextureMapperGL::beginPainting):
     17        (WebCore::createProjectionMatrix): Swapped nearValue and farValue
     18        so that the depth buffer works as expected.
     19        (WebCore::TextureMapperGL::beginPreserves3D): Added.
     20        (WebCore::TextureMapperGL::endPreserves3D): Ditto.
     21        * platform/graphics/texmap/TextureMapperGL.h:
     22        * platform/graphics/texmap/TextureMapperLayer.cpp:
     23        (WebCore::TextureMapperLayer::paintSelfAndChildren): Call
     24        beginPreserves3D() and endPreserves3D() if m_state.preserves3D.
     25
    1262020-09-28  Devin Rousso  <drousso@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp

    r265031 r267711  
    119119        EGL_STENCIL_SIZE, 8,
    120120        EGL_SURFACE_TYPE, EGL_NONE,
     121        EGL_DEPTH_SIZE, 8,
    121122        EGL_NONE
    122123    };
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h

    r241120 r267711  
    7979    virtual void endClip() = 0;
    8080    virtual IntRect clipBounds() = 0;
     81    virtual void beginPreserves3D() { };
     82    virtual void endPreserves3D() { };
    8183    virtual Ref<BitmapTexture> createTexture() = 0;
    8284    virtual Ref<BitmapTexture> createTexture(int internalFormat) = 0;
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

    r263941 r267711  
    202202    data().previousDepthState = glIsEnabled(GL_DEPTH_TEST);
    203203    glDisable(GL_DEPTH_TEST);
     204    glDepthFunc(GL_LEQUAL);
    204205    glEnable(GL_SCISSOR_TEST);
    205206    data().didModifyStencil = false;
    206     glDepthMask(0);
    207207    glGetIntegerv(GL_VIEWPORT, data().viewport);
    208208    glGetIntegerv(GL_SCISSOR_BOX, data().previousScissor);
     
    825825static inline TransformationMatrix createProjectionMatrix(const IntSize& size, bool mirrored)
    826826{
    827     const float nearValue = 9999999;
    828     const float farValue = -99999;
     827    const float nearValue = -99999;
     828    const float farValue = 9999999;
    829829
    830830    return TransformationMatrix(2.0 / float(size.width()), 0, 0, 0,
     
    950950}
    951951
     952void TextureMapperGL::beginPreserves3D()
     953{
     954    glEnable(GL_DEPTH_TEST);
     955    glClear(GL_DEPTH_BUFFER_BIT);
     956}
     957
     958void TextureMapperGL::endPreserves3D()
     959{
     960    glDisable(GL_DEPTH_TEST);
     961}
     962
    952963Ref<BitmapTexture> TextureMapperGL::createTexture(GLint internalFormat)
    953964{
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h

    r258197 r267711  
    8080    void endPainting() override;
    8181    void endClip() override;
     82    void beginPreserves3D() override;
     83    void endPreserves3D() override;
    8284    IntRect clipBounds() override;
    8385    IntSize maxTextureSize() const override { return IntSize(2000, 2000); }
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r264968 r267711  
    223223        return;
    224224
     225    if (m_state.preserves3D)
     226        options.textureMapper.beginPreserves3D();
     227
    225228    if (m_state.backdropLayer && !options.backdropLayer) {
    226229        TransformationMatrix clipTransform;
     
    235238    paintSelf(options);
    236239
    237     if (m_children.isEmpty())
    238         return;
     240    if (m_children.isEmpty()) {
     241        if (m_state.preserves3D)
     242            options.textureMapper.endPreserves3D();
     243        return;
     244    }
    239245
    240246    bool shouldClip = m_state.masksToBounds && !m_state.preserves3D;
     
    260266    if (shouldClip)
    261267        options.textureMapper.endClip();
     268    if (m_state.preserves3D)
     269        options.textureMapper.endPreserves3D();
    262270}
    263271
Note: See TracChangeset for help on using the changeset viewer.