Changeset 211681 in webkit


Ignore:
Timestamp:
Feb 5, 2017 9:22:45 AM (7 years ago)
Author:
zandobersek@gmail.com
Message:

Move TextureMapper-specific logic out of GraphicsContext3DPrivate
https://bugs.webkit.org/show_bug.cgi?id=167096

Reviewed by Alex Christensen.

Move the TextureMapper-specific functionality in GraphicsContext3DPrivate into a
separate class. The new TextureMapperGC3DPlatformLayer class inherits from the
class that's aliased to the PlatformLayer type, like GraphicsContext3DPrivate did
before.

In GraphicsContext3D, the new m_texmapLayer member variable of the
std::unique_ptr<TextureMapperGC3DPlatformLayer> type is used for configurations
that enable TextureMapper, largely the same way the GraphicsContext3DPrivate
object was used before. The remaining code in GraphicsContext3DPrivate is left
unchanged to keep it working for other ports.

No new tests -- no change in behavior.

  • platform/TextureMapper.cmake:
  • platform/graphics/GraphicsContext3D.h:
  • platform/graphics/GraphicsContext3DPrivate.cpp:

(WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
(WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): Deleted.
(WebCore::GraphicsContext3DPrivate::proxy): Deleted.
(WebCore::GraphicsContext3DPrivate::swapBuffersIfNeeded): Deleted.
(WebCore::GraphicsContext3DPrivate::paintToTextureMapper): Deleted.

  • platform/graphics/GraphicsContext3DPrivate.h:
  • platform/graphics/cairo/GraphicsContext3DCairo.cpp:

(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::~GraphicsContext3D):
(WebCore::GraphicsContext3D::makeContextCurrent):
(WebCore::GraphicsContext3D::platformGraphicsContext3D):
(WebCore::GraphicsContext3D::platformLayer):

  • platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:

(WebCore::GraphicsContext3D::createForCurrentGLContext):

  • platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp.

(WebCore::TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer):
(WebCore::TextureMapperGC3DPlatformLayer::~TextureMapperGC3DPlatformLayer):
(WebCore::TextureMapperGC3DPlatformLayer::makeContextCurrent):
(WebCore::TextureMapperGC3DPlatformLayer::platformContext):
(WebCore::TextureMapperGC3DPlatformLayer::proxy):
(WebCore::TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded):
(WebCore::TextureMapperGC3DPlatformLayer::paintToTextureMapper):

  • platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h.

(WebCore::TextureMapperGC3DPlatformLayer::renderStyle):

Location:
trunk/Source/WebCore
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r211680 r211681  
     12017-02-05  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        Move TextureMapper-specific logic out of GraphicsContext3DPrivate
     4        https://bugs.webkit.org/show_bug.cgi?id=167096
     5
     6        Reviewed by Alex Christensen.
     7
     8        Move the TextureMapper-specific functionality in GraphicsContext3DPrivate into a
     9        separate class. The new TextureMapperGC3DPlatformLayer class inherits from the
     10        class that's aliased to the PlatformLayer type, like GraphicsContext3DPrivate did
     11        before.
     12
     13        In GraphicsContext3D, the new m_texmapLayer member variable of the
     14        std::unique_ptr<TextureMapperGC3DPlatformLayer> type is used for configurations
     15        that enable TextureMapper, largely the same way the GraphicsContext3DPrivate
     16        object was used before. The remaining code in GraphicsContext3DPrivate is left
     17        unchanged to keep it working for other ports.
     18
     19        No new tests -- no change in behavior.
     20
     21        * platform/TextureMapper.cmake:
     22        * platform/graphics/GraphicsContext3D.h:
     23        * platform/graphics/GraphicsContext3DPrivate.cpp:
     24        (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
     25        (WebCore::GraphicsContext3DPrivate::~GraphicsContext3DPrivate): Deleted.
     26        (WebCore::GraphicsContext3DPrivate::proxy): Deleted.
     27        (WebCore::GraphicsContext3DPrivate::swapBuffersIfNeeded): Deleted.
     28        (WebCore::GraphicsContext3DPrivate::paintToTextureMapper): Deleted.
     29        * platform/graphics/GraphicsContext3DPrivate.h:
     30        * platform/graphics/cairo/GraphicsContext3DCairo.cpp:
     31        (WebCore::GraphicsContext3D::GraphicsContext3D):
     32        (WebCore::GraphicsContext3D::~GraphicsContext3D):
     33        (WebCore::GraphicsContext3D::makeContextCurrent):
     34        (WebCore::GraphicsContext3D::platformGraphicsContext3D):
     35        (WebCore::GraphicsContext3D::platformLayer):
     36        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
     37        (WebCore::GraphicsContext3D::createForCurrentGLContext):
     38        * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp.
     39        (WebCore::TextureMapperGC3DPlatformLayer::TextureMapperGC3DPlatformLayer):
     40        (WebCore::TextureMapperGC3DPlatformLayer::~TextureMapperGC3DPlatformLayer):
     41        (WebCore::TextureMapperGC3DPlatformLayer::makeContextCurrent):
     42        (WebCore::TextureMapperGC3DPlatformLayer::platformContext):
     43        (WebCore::TextureMapperGC3DPlatformLayer::proxy):
     44        (WebCore::TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded):
     45        (WebCore::TextureMapperGC3DPlatformLayer::paintToTextureMapper):
     46        * platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h: Copied from Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h.
     47        (WebCore::TextureMapperGC3DPlatformLayer::renderStyle):
     48
    1492017-02-05  Zalan Bujtas  <zalan@apple.com>
    250
  • trunk/Source/WebCore/platform/TextureMapper.cmake

    r202675 r211681  
    1010    platform/graphics/texmap/TextureMapperBackingStore.cpp
    1111    platform/graphics/texmap/TextureMapperFPSCounter.cpp
     12    platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp
    1213    platform/graphics/texmap/TextureMapperLayer.cpp
    1314    platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r211244 r211681  
    101101#if USE(CAIRO)
    102102class PlatformContextCairo;
     103#endif
     104#if USE(TEXTURE_MAPPER)
     105class TextureMapperGC3DPlatformLayer;
    103106#endif
    104107
     
    14171420    ListHashSet<GC3Denum> m_syntheticErrors;
    14181421
     1422#if USE(TEXTURE_MAPPER) && !PLATFORM(EFL)
     1423    friend class TextureMapperGC3DPlatformLayer;
     1424    std::unique_ptr<TextureMapperGC3DPlatformLayer> m_texmapLayer;
     1425#else
    14191426    friend class GraphicsContext3DPrivate;
    14201427    std::unique_ptr<GraphicsContext3DPrivate> m_private;
     1428#endif
    14211429   
    14221430    WebGLRenderingContextBase* m_webglContext;
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp

    r210828 r211681  
    2626#include <wtf/StdLibExtras.h>
    2727
    28 #if USE(CAIRO)
    29 #include "PlatformContextCairo.h"
    30 #endif
    3128
    3229#if USE(OPENGL_ES_2)
     
    3734#endif
    3835
    39 #if USE(TEXTURE_MAPPER_GL)
    40 #include <texmap/TextureMapperGL.h>
    41 #endif
    42 
    43 #if USE(COORDINATED_GRAPHICS_THREADED)
    44 #include "TextureMapperPlatformLayerBuffer.h"
    45 #endif
    46 
    4736using namespace std;
    4837
    4938namespace WebCore {
    5039
    51 GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, GraphicsContext3D::RenderStyle renderStyle)
    52     : m_context(context)
    53     , m_renderStyle(renderStyle)
     40GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle renderStyle)
     41    : m_renderStyle(renderStyle)
    5442{
    5543    switch (renderStyle) {
     
    6351        break;
    6452    }
    65 
    66 #if USE(COORDINATED_GRAPHICS_THREADED)
    67     if (m_renderStyle == GraphicsContext3D::RenderOffscreen)
    68         m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy());
    69 #endif
    7053}
    7154
    72 GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
    73 {
    74 #if USE(TEXTURE_MAPPER) && !USE(COORDINATED_GRAPHICS_THREADED)
    75     if (client())
    76         client()->platformLayerWillBeDestroyed();
    77 #endif
    78 }
     55GraphicsContext3DPrivate::~GraphicsContext3DPrivate() = default;
    7956
    8057bool GraphicsContext3DPrivate::makeContextCurrent()
     
    8865}
    8966
    90 #if USE(COORDINATED_GRAPHICS_THREADED)
    91 RefPtr<TextureMapperPlatformLayerProxy> GraphicsContext3DPrivate::proxy() const
    92 {
    93     return m_platformLayerProxy.copyRef();
    94 }
    95 
    96 void GraphicsContext3DPrivate::swapBuffersIfNeeded()
    97 {
    98     ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
    99     if (m_context->layerComposited())
    100         return;
    101 
    102     m_context->prepareTexture();
    103     IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
    104     TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
    105 
    106     {
    107         LockHolder holder(m_platformLayerProxy->lock());
    108         m_platformLayerProxy->pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_context->m_compositorTexture, textureSize, flags));
    109     }
    110 
    111     m_context->markLayerComposited();
    112 }
    113 #elif USE(TEXTURE_MAPPER)
    114 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
    115 {
    116     if (!m_glContext)
    117         return;
    118 
    119     ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
    120 
    121     m_context->markLayerComposited();
    122 
    123 #if USE(TEXTURE_MAPPER_GL)
    124     if (m_context->m_attrs.antialias && m_context->m_state.boundFBO == m_context->m_multisampleFBO) {
    125         GLContext* previousActiveContext = GLContext::current();
    126         if (previousActiveContext != m_glContext.get())
    127             m_context->makeContextCurrent();
    128 
    129         m_context->resolveMultisamplingIfNecessary();
    130         ::glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO);
    131 
    132         if (previousActiveContext && previousActiveContext != m_glContext.get())
    133             previousActiveContext->makeContextCurrent();
    134     }
    135 
    136     TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(textureMapper);
    137     TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
    138     IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
    139     texmapGL.drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity);
    140 #endif // USE(TEXTURE_MAPPER_GL)
    141 }
    142 #endif // USE(TEXTURE_MAPPER)
    143 
    14467} // namespace WebCore
    14568
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h

    r202854 r211681  
    2525#include "PlatformLayer.h"
    2626
    27 #if USE(TEXTURE_MAPPER)
    28 #include "TextureMapperPlatformLayer.h"
    29 #include "TextureMapperPlatformLayerProxy.h"
    30 #endif
    31 
    3227namespace WebCore {
    3328
    3429class BitmapTextureGL;
    3530
    36 class GraphicsContext3DPrivate
    37 #if USE(TEXTURE_MAPPER)
    38     : public PlatformLayer
    39 #endif
    40 {
     31class GraphicsContext3DPrivate {
    4132public:
    4233    GraphicsContext3DPrivate(GraphicsContext3D*, GraphicsContext3D::RenderStyle);
     
    4738    GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
    4839
    49 #if USE(COORDINATED_GRAPHICS_THREADED)
    50     RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;
    51     void swapBuffersIfNeeded() override;
    52 #elif USE(TEXTURE_MAPPER)
    53     virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity);
    54 #endif
    55 
    5640private:
    57     GraphicsContext3D* m_context;
    5841    std::unique_ptr<GLContext> m_glContext;
    5942    GraphicsContext3D::RenderStyle m_renderStyle;
    60 
    61 #if USE(COORDINATED_GRAPHICS_THREADED)
    62     RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
    63     RefPtr<BitmapTextureGL> m_compositorTexture;
    64 #endif
    6543};
    6644
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp

    r210800 r211681  
    5555#endif
    5656
     57#if USE(TEXTURE_MAPPER)
     58#include "TextureMapperGC3DPlatformLayer.h"
     59#endif
     60
    5761namespace WebCore {
    5862
     
    9296    , m_multisampleDepthStencilBuffer(0)
    9397    , m_multisampleColorBuffer(0)
    94     , m_private(std::make_unique<GraphicsContext3DPrivate>(this, renderStyle))
    95 {
     98{
     99#if USE(TEXTURE_MAPPER)
     100    m_texmapLayer = std::make_unique<TextureMapperGC3DPlatformLayer>(*this, renderStyle);
     101#else
     102    m_private = std::make_unique<GraphicsContext3DPrivate>(this, renderStyle);
     103#endif
     104
    96105    makeContextCurrent();
    97106
     
    201210GraphicsContext3D::~GraphicsContext3D()
    202211{
     212#if USE(TEXTURE_MAPPER)
     213    if (m_texmapLayer->renderStyle() == RenderToCurrentGLContext)
     214        return;
     215#else
    203216    if (m_private->renderStyle() == RenderToCurrentGLContext)
    204217        return;
     218#endif
    205219
    206220    makeContextCurrent();
     
    339353bool GraphicsContext3D::makeContextCurrent()
    340354{
    341     if (!m_private)
    342         return false;
    343     return m_private->makeContextCurrent();
     355#if USE(TEXTURE_MAPPER)
     356    if (m_texmapLayer)
     357        return m_texmapLayer->makeContextCurrent();
     358#else
     359    if (m_private)
     360        return m_private->makeContextCurrent();
     361#endif
     362    return false;
    344363}
    345364
     
    350369PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
    351370{
     371#if USE(TEXTURE_MAPPER)
     372    return m_texmapLayer->platformContext();
     373#else
    352374    return m_private->platformContext();
     375#endif
    353376}
    354377
     
    369392PlatformLayer* GraphicsContext3D::platformLayer() const
    370393{
     394#if USE(TEXTURE_MAPPER)
     395    return m_texmapLayer.get();
     396#else
    371397    return m_private.get();
     398#endif
    372399}
    373400
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r210800 r211681  
    134134{
    135135    auto context = adoptRef(*new GraphicsContext3D({ }, 0, GraphicsContext3D::RenderToCurrentGLContext));
     136#if USE(TEXTURE_MAPPER) && !PLATFORM(EFL)
     137    if (!context->m_texmapLayer)
     138        return nullptr;
     139#else
    136140    if (!context->m_private)
    137141        return nullptr;
     142#endif
    138143    return WTFMove(context);
    139144}
Note: See TracChangeset for help on using the changeset viewer.