Changeset 92520 in webkit


Ignore:
Timestamp:
Aug 5, 2011 3:14:37 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Accelerated canvas breaks when moving canvases or resources between Pages
https://bugs.webkit.org/show_bug.cgi?id=65402

Patch by James Robinson <jamesr@chromium.org> on 2011-08-05
Reviewed by Stephen White.

Source/WebCore:

Use one shared GraphicsContext3D for the whole process instead of one per Page as canvases can move between
pages and directly draw into contexts in different pages. Also switches DrawingBufferChromium over to use a
directly shared the color attachment instead of copying it to a separate texture and removes the now-unnecessary
DrawingBuffer::didReset() call and WillPublishCallback mechanism.

  • page/Page.cpp:

(WebCore::Page::sharedGraphicsContext3D):

  • page/Page.h:
  • platform/graphics/chromium/Canvas2DLayerChromium.cpp:

(WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium):
(WebCore::Canvas2DLayerChromium::updateCompositorResources):
(WebCore::Canvas2DLayerChromium::textureId):
(WebCore::Canvas2DLayerChromium::setDrawingBuffer):

  • platform/graphics/chromium/CanvasLayerChromium.cpp:

(WebCore::CanvasLayerChromium::CanvasLayerChromium):

  • platform/graphics/chromium/CanvasLayerChromium.h:
  • platform/graphics/chromium/DrawingBufferChromium.cpp:

(WebCore::DrawingBuffer::DrawingBuffer):
(WebCore::DrawingBuffer::publishToPlatformLayer):

  • platform/graphics/chromium/Extensions3DChromium.h:
  • platform/graphics/chromium/WebGLLayerChromium.cpp:

(WebCore::WebGLLayerChromium::WebGLLayerChromium):

  • platform/graphics/chromium/WebGLLayerChromium.h:

Source/WebKit/chromium:

Remove plumbing for copyTextureToParentTexture extension, it's no longer used or needed.

  • public/WebGraphicsContext3D.h:
  • src/Extensions3DChromium.cpp:
  • src/GraphicsContext3DChromium.cpp:
  • src/GraphicsContext3DInternal.h:
Location:
trunk/Source
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92499 r92520  
     12011-08-05  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Accelerated canvas breaks when moving canvases or resources between Pages
     4        https://bugs.webkit.org/show_bug.cgi?id=65402
     5
     6        Reviewed by Stephen White.
     7
     8        Use one shared GraphicsContext3D for the whole process instead of one per Page as canvases can move between
     9        pages and directly draw into contexts in different pages.  Also switches DrawingBufferChromium over to use a
     10        directly shared the color attachment instead of copying it to a separate texture and removes the now-unnecessary
     11        DrawingBuffer::didReset() call and WillPublishCallback mechanism.
     12
     13        * page/Page.cpp:
     14        (WebCore::Page::sharedGraphicsContext3D):
     15        * page/Page.h:
     16        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
     17        (WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium):
     18        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
     19        (WebCore::Canvas2DLayerChromium::textureId):
     20        (WebCore::Canvas2DLayerChromium::setDrawingBuffer):
     21        * platform/graphics/chromium/CanvasLayerChromium.cpp:
     22        (WebCore::CanvasLayerChromium::CanvasLayerChromium):
     23        * platform/graphics/chromium/CanvasLayerChromium.h:
     24        * platform/graphics/chromium/DrawingBufferChromium.cpp:
     25        (WebCore::DrawingBuffer::DrawingBuffer):
     26        (WebCore::DrawingBuffer::publishToPlatformLayer):
     27        * platform/graphics/chromium/Extensions3DChromium.h:
     28        * platform/graphics/chromium/WebGLLayerChromium.cpp:
     29        (WebCore::WebGLLayerChromium::WebGLLayerChromium):
     30        * platform/graphics/chromium/WebGLLayerChromium.h:
     31
    1322011-08-05  Anders Carlsson  <andersca@apple.com>
    233
  • trunk/Source/WebCore/WebCore.gypi

    r92500 r92520  
    36513651            'platform/graphics/gpu/Shader.cpp',
    36523652            'platform/graphics/gpu/Shader.h',
     3653            'platform/graphics/gpu/SharedGraphicsContext3D.cpp',
     3654            'platform/graphics/gpu/SharedGraphicsContext3D.h',
    36533655            'platform/graphics/gpu/Texture.cpp',
    36543656            'platform/graphics/gpu/Texture.h',
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r91638 r92520  
    6767#include "DrawingBuffer.h"
    6868#include "FrameView.h"
     69#include "SharedGraphicsContext3D.h"
    6970#if USE(ACCELERATED_COMPOSITING)
    7071#include "RenderLayer.h"
     
    142143#if ENABLE(DASHBOARD_SUPPORT)
    143144    , m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode)
    144 #endif
    145 #if ENABLE(ACCELERATED_2D_CANVAS)
    146     , m_context3D(0)
    147145#endif
    148146{
     
    196194#if ENABLE(ACCELERATED_2D_CANVAS)
    197195    if (m_context3D)
    198         return m_context3D->paintsIntoCanvasBuffer();
     196        return m_context3D->context()->paintsIntoCanvasBuffer();
    199197#endif
    200198    return true;
     
    20512049    if (!m_context3D) {
    20522050        Page* page = canvas()->document()->page();
    2053         m_context3D = page->sharedGraphicsContext3D();
     2051        m_context3D = SharedGraphicsContext3D::create(page->chrome());
    20542052        if (!m_context3D) {
    20552053            clearAcceleration();
     
    20642062        }
    20652063    } else {
    2066         m_drawingBuffer = m_context3D->createDrawingBuffer(canvas()->size());
     2064        m_drawingBuffer = m_context3D->context()->createDrawingBuffer(canvas()->size());
    20672065        if (!m_drawingBuffer) {
    20682066            clearAcceleration();
     
    20712069    }
    20722070
    2073     ctx->setGraphicsContext3D(m_context3D.get(), m_drawingBuffer.get(), canvas()->size());
     2071    ctx->setGraphicsContext3D(m_context3D->context(), m_drawingBuffer.get(), canvas()->size());
    20742072}
    20752073#endif
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h

    r91599 r92520  
    3737#include <wtf/Vector.h>
    3838
    39 
    4039#if USE(ACCELERATED_COMPOSITING)
    4140#include "GraphicsLayer.h"
     
    5756#if ENABLE(ACCELERATED_2D_CANVAS)
    5857class DrawingBuffer;
    59 class GraphicsContext3D;
     58class SharedGraphicsContext3D;
    6059#endif
    6160
     
    309308#if ENABLE(ACCELERATED_2D_CANVAS)
    310309    RefPtr<DrawingBuffer> m_drawingBuffer;
    311     RefPtr<GraphicsContext3D> m_context3D;
     310    RefPtr<SharedGraphicsContext3D> m_context3D;
    312311#endif
    313312};
  • trunk/Source/WebCore/page/Page.cpp

    r92492 r92520  
    7575#include <wtf/text/StringHash.h>
    7676
    77 #if ENABLE(ACCELERATED_2D_CANVAS)
    78 #include "GraphicsContext3D.h"
    79 #endif
    80 
    8177#if ENABLE(DOM_STORAGE)
    8278#include "StorageArea.h"
     
    747743}
    748744
    749 GraphicsContext3D* Page::sharedGraphicsContext3D()
    750 {
    751 #if ENABLE(ACCELERATED_2D_CANVAS)
    752     if (!m_sharedGraphicsContext3D) {
    753         GraphicsContext3D::Attributes attr;
    754         attr.depth = false;
    755         attr.stencil = true;
    756         attr.antialias = false;
    757         attr.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts.
    758         m_sharedGraphicsContext3D = GraphicsContext3D::create(attr, chrome());
    759     }
    760     return m_sharedGraphicsContext3D.get();
    761 #else // !ENABLE(ACCELERATED_2D_CANVAS)
    762     return 0;
    763 #endif
    764 }
    765 
    766745#if ENABLE(DOM_STORAGE)
    767746StorageNamespace* Page::sessionStorage(bool optionalCreate)
  • trunk/Source/WebCore/page/Page.h

    r92492 r92520  
    8080    class ScrollableArea;
    8181    class Settings;
    82     class GraphicsContext3D;
    8382    class SpeechInput;
    8483    class SpeechInputClient;
     
    260259        static void visitedStateChanged(PageGroup*, LinkHash visitedHash);
    261260
    262         GraphicsContext3D* sharedGraphicsContext3D();
    263 
    264261#if ENABLE(DOM_STORAGE)
    265262        StorageNamespace* sessionStorage(bool optionalCreate = true);
     
    318315        OwnPtr<DragCaretController> m_dragCaretController;
    319316
    320 #if ENABLE(ACCELERATED_2D_CANVAS)
    321         RefPtr<GraphicsContext3D> m_sharedGraphicsContext3D;
    322 #endif
    323        
    324317#if ENABLE(DRAG_SUPPORT)
    325318        OwnPtr<DragController> m_dragController;
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp

    r91736 r92520  
    5555Canvas2DLayerChromium::~Canvas2DLayerChromium()
    5656{
    57     if (m_textureId)
    58         layerRendererContext()->deleteTexture(m_textureId);
    5957    if (m_drawingBuffer && layerRenderer())
    6058        layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D().get());
     
    7371    if (!m_contentsDirty || !drawsContent())
    7472        return;
    75     if (m_textureChanged) { // We have to generate a new backing texture.
    76         GraphicsContext3D* context = layerRendererContext();
    77         if (m_textureId)
    78             context->deleteTexture(m_textureId);
    79         m_textureId = context->createTexture();
    80         context->activeTexture(GraphicsContext3D::TEXTURE0);
    81         context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId);
    82         IntSize size = m_drawingBuffer->size();
    83         context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, size.width(), size.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE);
    84         // Set the min-mag filters to linear and wrap modes to GraphicsContext3D::CLAMP_TO_EDGE
    85         // to get around NPOT texture limitations of GLES.
    86         context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
    87         context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
    88         context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
    89         context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
    90         m_textureChanged = false;
    91         // The flush() here is required because we have to make sure that the texture created in this
    92         // context (the compositor context) is actually created by the service side before the child context
    93         // attempts to use it (in publishToPlatformLayer).
    94         context->flush();
    95     }
    9673    // Update the contents of the texture used by the compositor.
    9774    if (m_contentsDirty) {
     
    10178}
    10279
    103 void Canvas2DLayerChromium::setTextureChanged()
    104 {
    105     m_textureChanged = true;
    106 }
    107 
    10880unsigned Canvas2DLayerChromium::textureId() const
    10981{
    110     return m_textureId;
     82    return m_drawingBuffer ? m_drawingBuffer->platformColorBuffer() : 0;
    11183}
    11284
     
    11890
    11991        m_drawingBuffer = drawingBuffer;
    120         m_textureChanged = true;
    12192
    12293        if (drawingBuffer && layerRenderer())
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h

    r89635 r92520  
    5050
    5151    void setTextureChanged();
    52     unsigned textureId() const;
     52    virtual unsigned textureId() const;
    5353    void setDrawingBuffer(DrawingBuffer*);
    5454
  • trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp

    r92245 r92520  
    4343CanvasLayerChromium::CanvasLayerChromium(GraphicsLayerChromium* owner)
    4444    : LayerChromium(owner)
    45     , m_textureChanged(true)
    46     , m_textureId(0)
    4745    , m_hasAlpha(true)
    4846    , m_premultipliedAlpha(true)
     
    6462
    6563    CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer);
    66     canvasLayer->setTextureId(m_textureId);
     64    canvasLayer->setTextureId(textureId());
    6765    canvasLayer->setHasAlpha(m_hasAlpha);
    6866    canvasLayer->setPremultipliedAlpha(m_premultipliedAlpha);
  • trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h

    r86905 r92520  
    5151    explicit CanvasLayerChromium(GraphicsLayerChromium* owner);
    5252
     53    virtual unsigned textureId() const = 0;
    5354    virtual const char* layerTypeAsString() const { return "CanvasLayer"; }
    5455
    55     bool m_textureChanged;
    56     unsigned m_textureId;
    5756    bool m_hasAlpha;
    5857    bool m_premultipliedAlpha;
  • trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp

    r91736 r92520  
    3333#include "DrawingBuffer.h"
    3434
    35 #include "Extensions3DChromium.h"
    3635#include "GraphicsContext3D.h"
    37 
    3836#if USE(SKIA)
    3937#include "GrContext.h"
     
    6361}
    6462
    65 
    6663DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
    6764                             const IntSize& size,
     
    8380#endif
    8481{
    85     if (!m_context->getExtensions()->supports("GL_CHROMIUM_copy_texture_to_parent_texture")) {
    86         m_context.clear();
    87         return;
    88     }
    8982    m_fbo = context->createFramebuffer();
    9083    context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     
    116109        return;
    117110
    118     if (m_callback)
    119         m_callback->willPublish();
    120111    if (multisample())
    121112        commit();
    122     unsigned parentTexture = m_platformLayer->textureId();
    123     // We do the copy in the canvas' (child) context so that it executes in the correct order relative to
    124     // other commands in the child context. This ensures that the parent texture always contains a complete
    125     // frame and not some intermediate result.
    126113    m_context->makeContextCurrent();
    127114#if USE(SKIA)
     
    129116        m_grContext->flush(0);
    130117#endif
    131     static_cast<Extensions3DChromium*>(m_context->getExtensions())->copyTextureToParentTextureCHROMIUM(m_colorBuffer, parentTexture);
    132118    m_context->flush();
    133119}
    134120#endif
    135 
    136 void DrawingBuffer::didReset()
    137 {
    138 #if USE(ACCELERATED_COMPOSITING)
    139     if (m_platformLayer)
    140         m_platformLayer->setTextureChanged();
    141 #endif
    142 }
    143121
    144122#if USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h

    r91736 r92520  
    4141    //   GL_CHROMIUM_strict_attribs : indicating a GL error is generated for out-of-bounds buffer accesses.
    4242    //   GL_CHROMIUM_map_sub
    43     //   GL_CHROMIUM_copy_texture_to_parent_texture
    4443    //   GL_CHROMIUM_swapbuffers_complete_callback
    4544    //   GL_CHROMIUM_rate_limit_offscreen_context
     
    6968    void unmapTexSubImage2DCHROMIUM(const void*);
    7069
    71     // GL_CHROMIUM_copy_texture_to_parent_texture
    72     void copyTextureToParentTextureCHROMIUM(unsigned texture, unsigned parentTexture);
    73 
    7470    // GL_CHROMIUM_swapbuffers_complete_callback
    7571    class SwapBuffersCompleteCallbackCHROMIUM {
  • trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp

    r89635 r92520  
    5050    : CanvasLayerChromium(owner)
    5151    , m_context(0)
     52    , m_textureId(0)
     53    , m_textureChanged(true)
    5254    , m_contextSupportsRateLimitingExtension(false)
    5355    , m_rateLimitingTimer(this, &WebGLLayerChromium::rateLimitContext)
  • trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h

    r89635 r92520  
    6666    friend class WebGLLayerChromiumRateLimitTask;
    6767
     68    virtual unsigned textureId() const { return m_textureId; }
    6869    void rateLimitContext(Timer<WebGLLayerChromium>*);
    6970
     
    7273    // layer's context to 0.
    7374    GraphicsContext3D* m_context;
     75    unsigned m_textureId;
     76    bool m_textureChanged;
    7477    bool m_contextSupportsRateLimitingExtension;
    7578    Timer<WebGLLayerChromium> m_rateLimitingTimer;
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp

    r92430 r92520  
    287287    clearFramebuffer();
    288288
    289     didReset();
    290 
    291289    return true;
    292290}
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h

    r92430 r92520  
    9191#endif
    9292
    93 #if PLATFORM(CHROMIUM)
    94     class WillPublishCallback {
    95         WTF_MAKE_NONCOPYABLE(WillPublishCallback);
    96     public:
    97         WillPublishCallback() { }
    98         virtual ~WillPublishCallback() { }
    99        
    100         virtual void willPublish() = 0;
    101     };
    102 
    103     void setWillPublishCallback(PassOwnPtr<WillPublishCallback> callback) { m_callback = callback; }
    104 #endif
    105 
    10693#if USE(SKIA)
    10794    void setGrContext(GrContext* ctx);
     
    115102   
    116103    DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported);
    117 
    118     // Platform specific function called after reset() so each platform can do extra work if needed
    119     void didReset();
    120104
    121105    RefPtr<GraphicsContext3D> m_context;
     
    138122
    139123#if PLATFORM(CHROMIUM)
    140     OwnPtr<WillPublishCallback> m_callback;
    141124#if USE(ACCELERATED_COMPOSITING)
    142125    RefPtr<Canvas2DLayerChromium> m_platformLayer;
  • trunk/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm

    r85891 r92520  
    8585}
    8686
    87 void DrawingBuffer::didReset()
    88 {
    89 }
    90 
    9187PlatformLayer* DrawingBuffer::platformLayer()
    9288{
  • trunk/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp

    r85891 r92520  
    7272}
    7373
    74 void DrawingBuffer::didReset()
    75 {
    76 }
    77 
    7874#if USE(ACCELERATED_COMPOSITING)
    7975PlatformLayer* DrawingBuffer::platformLayer()
  • trunk/Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp

    r85891 r92520  
    7272}
    7373
    74 void DrawingBuffer::didReset()
    75 {
    76 }
    77 
    7874Platform3DObject DrawingBuffer::platformColorBuffer() const
    7975{
  • trunk/Source/WebKit/chromium/ChangeLog

    r92487 r92520  
     12011-08-05  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Accelerated canvas breaks when moving canvases or resources between Pages
     4        https://bugs.webkit.org/show_bug.cgi?id=65402
     5
     6        Reviewed by Stephen White.
     7
     8        Remove plumbing for copyTextureToParentTexture extension, it's no longer used or needed.
     9
     10        * public/WebGraphicsContext3D.h:
     11        * src/Extensions3DChromium.cpp:
     12        * src/GraphicsContext3DChromium.cpp:
     13        * src/GraphicsContext3DInternal.h:
     14
    1152011-08-05  Jochen Eisinger  <jochen@chromium.org>
    216
  • trunk/Source/WebKit/chromium/public/WebGraphicsContext3D.h

    r91736 r92520  
    168168    virtual void unmapTexSubImage2DCHROMIUM(const void*) = 0;
    169169
    170     // GL_CHROMIUM_copy_texture_to_parent_texture
    171     virtual void copyTextureToParentTextureCHROMIUM(WebGLId texture, WebGLId parentTexture) = 0;
    172 
    173170    // GL_CHROMIUM_request_extension
    174171    virtual WebString getRequestableExtensionsCHROMIUM() = 0;
  • trunk/Source/WebKit/chromium/src/Extensions3DChromium.cpp

    r91736 r92520  
    9898}
    9999
    100 void Extensions3DChromium::copyTextureToParentTextureCHROMIUM(unsigned texture, unsigned parentTexture)
    101 {
    102     m_internal->copyTextureToParentTextureCHROMIUM(texture, parentTexture);
    103 }
    104 
    105100Platform3DObject Extensions3DChromium::createVertexArrayOES()
    106101{
  • trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp

    r92145 r92520  
    833833DELEGATE_TO_IMPL_1(unmapTexSubImage2DCHROMIUM, const void*)
    834834
    835 void GraphicsContext3DInternal::copyTextureToParentTextureCHROMIUM(Platform3DObject texture, Platform3DObject parentTexture)
    836 {
    837     m_impl->setParentContext(m_webViewImpl->graphicsContext3D());
    838     m_impl->copyTextureToParentTextureCHROMIUM(texture, parentTexture);
    839 }
    840 
    841835DELEGATE_TO_IMPL_10(blitFramebufferCHROMIUM, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dbitfield, GC3Denum)
    842836DELEGATE_TO_IMPL_5(renderbufferStorageMultisampleCHROMIUM, GC3Denum, GC3Dsizei, GC3Denum, GC3Dsizei, GC3Dsizei)
  • trunk/Source/WebKit/chromium/src/GraphicsContext3DInternal.h

    r91736 r92520  
    273273    void unmapTexSubImage2DCHROMIUM(const void*);
    274274
    275     // GL_CHROMIUM_copy_texture_to_parent_texture
    276     bool supportsCopyTextureToParentTextureCHROMIUM();
    277     void copyTextureToParentTextureCHROMIUM(Platform3DObject texture, Platform3DObject parentTexture);
    278 
    279275    // GL_CHROMIUM_framebuffer_multisample
    280276    void blitFramebufferCHROMIUM(GC3Dint srcX0, GC3Dint srcY0, GC3Dint srcX1, GC3Dint srcY1, GC3Dint dstX0, GC3Dint dstY0, GC3Dint dstX1, GC3Dint dstY1, GC3Dbitfield mask, GC3Denum filter);
Note: See TracChangeset for help on using the changeset viewer.