Changeset 84259 in webkit


Ignore:
Timestamp:
Apr 19, 2011 9:52:34 AM (13 years ago)
Author:
senorblanco@chromium.org
Message:

2011-04-19 Stephen White <senorblanco@chromium.org>

Reviewed by Eric Seidel.

Pull framebuffer clearing out into its own function.
https://bugs.webkit.org/show_bug.cgi?id=58897

Covered by fast/canvas and canvas/philip tests.

  • platform/graphics/gpu/DrawingBuffer.cpp: (WebCore::DrawingBuffer::clearFramebuffer): (WebCore::DrawingBuffer::reset):
  • platform/graphics/gpu/DrawingBuffer.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84257 r84259  
     12011-04-19  Stephen White  <senorblanco@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Pull framebuffer clearing out into its own function.
     6        https://bugs.webkit.org/show_bug.cgi?id=58897
     7
     8        Covered by fast/canvas and canvas/philip tests.
     9
     10        * platform/graphics/gpu/DrawingBuffer.cpp:
     11        (WebCore::DrawingBuffer::clearFramebuffer):
     12        (WebCore::DrawingBuffer::reset):
     13        * platform/graphics/gpu/DrawingBuffer.h:
     14
    1152011-04-19 Brian Salomon <bsalomon@google.com>
    216
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp

    r84163 r84259  
    145145}
    146146
    147 bool DrawingBuffer::reset(const IntSize& newSize)
    148 {
    149     if (!m_context)
    150         return false;
    151 
    152     m_context->makeContextCurrent();
    153 
    154     int maxTextureSize = 0;
    155     m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
    156     if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) {
    157       clear();
    158       return false;
    159     }
    160 
     147void DrawingBuffer::clearFramebuffer()
     148{
     149    m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo);
    161150    const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes();
    162 
    163     if (newSize != m_size) {
    164         m_size = newSize;
    165 
    166         unsigned long internalColorFormat, colorFormat, internalRenderbufferFormat;
    167         if (attributes.alpha) {
    168             internalColorFormat = GraphicsContext3D::RGBA;
    169             colorFormat = GraphicsContext3D::RGBA;
    170             internalRenderbufferFormat = Extensions3D::RGBA8_OES;
    171         } else {
    172             internalColorFormat = GraphicsContext3D::RGB;
    173             colorFormat = GraphicsContext3D::RGB;
    174             internalRenderbufferFormat = Extensions3D::RGB8_OES;
    175         }
    176 
    177 
    178         // resize multisample FBO
    179         if (multisample()) {
    180             int maxSampleCount = 0;
    181            
    182             m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCount);
    183             int sampleCount = std::min(8, maxSampleCount);
    184 
    185             m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
    186 
    187             m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
    188             m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height());
    189             m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
    190             resizeDepthStencil(sampleCount);
    191             if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
    192                 // Cleanup
    193                 clear();
    194                 return false;
    195             }
    196         }
    197 
    198         // resize regular FBO
    199         m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
    200 
    201         m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
    202        
    203         m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE);
    204 
    205         m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
    206         m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
    207 
    208         if (!multisample())
    209             resizeDepthStencil(0);
    210         if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
    211             // Cleanup
    212             clear();
    213             return false;
    214         }
    215     }
    216 
    217     m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo);
    218 
    219     // Initialize renderbuffers (depth/stencil).
    220151    float clearDepth = 0;
    221152    int clearStencil = 0;
     
    259190    else
    260191        m_context->disable(GraphicsContext3D::SCISSOR_TEST);
     192}
     193
     194bool DrawingBuffer::reset(const IntSize& newSize)
     195{
     196    if (!m_context)
     197        return false;
     198
     199    m_context->makeContextCurrent();
     200
     201    int maxTextureSize = 0;
     202    m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
     203    if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) {
     204      clear();
     205      return false;
     206    }
     207
     208    const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes();
     209
     210    if (newSize != m_size) {
     211        m_size = newSize;
     212
     213        unsigned long internalColorFormat, colorFormat, internalRenderbufferFormat;
     214        if (attributes.alpha) {
     215            internalColorFormat = GraphicsContext3D::RGBA;
     216            colorFormat = GraphicsContext3D::RGBA;
     217            internalRenderbufferFormat = Extensions3D::RGBA8_OES;
     218        } else {
     219            internalColorFormat = GraphicsContext3D::RGB;
     220            colorFormat = GraphicsContext3D::RGB;
     221            internalRenderbufferFormat = Extensions3D::RGB8_OES;
     222        }
     223
     224
     225        // resize multisample FBO
     226        if (multisample()) {
     227            int maxSampleCount = 0;
     228           
     229            m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCount);
     230            int sampleCount = std::min(8, maxSampleCount);
     231
     232            m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
     233
     234            m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
     235            m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height());
     236            m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
     237            resizeDepthStencil(sampleCount);
     238            if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
     239                // Cleanup
     240                clear();
     241                return false;
     242            }
     243        }
     244
     245        // resize regular FBO
     246        m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     247
     248        m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
     249       
     250        m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE);
     251
     252        m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
     253        m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
     254
     255        if (!multisample())
     256            resizeDepthStencil(0);
     257        if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
     258            // Cleanup
     259            clear();
     260            return false;
     261        }
     262    }
     263
     264    clearFramebuffer();
    261265
    262266    didReset();
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h

    r83733 r84259  
    6161   
    6262    ~DrawingBuffer();
     63
     64    void clearFramebuffer();
    6365
    6466    // Returns true if the buffer was successfully resized.
Note: See TracChangeset for help on using the changeset viewer.