Changeset 84163 in webkit
- Timestamp:
- Apr 18, 2011 11:16:12 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84161 r84163 1 2011-04-15 Stephen White <senorblanco@chromium.org> 2 3 Reviewed by Kenneth Russell. 4 5 Speed up DrawingBuffer::reset(). 6 https://bugs.webkit.org/show_bug.cgi?id=58706 7 8 When DrawingBuffer::reset() is called, it should not reallocate 9 the FBOs if the size has not changed. It should just do a glClear(). 10 11 Covered by tests in fast/canvas and canvas/philip. 12 13 * platform/graphics/chromium/DrawingBufferChromium.cpp: 14 (WebCore::DrawingBuffer::DrawingBuffer): 15 Initialize the size to -1, -1, so the size change check will work on 16 first reset. 17 * platform/graphics/gpu/DrawingBuffer.cpp: 18 (WebCore::DrawingBuffer::reset): 19 If the size hasn't changed, don't resize the FBOs. Just clear the 20 relevant buffers. 21 1 22 2011-04-18 Pavel Feldman <pfeldman@google.com> 2 23 -
trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
r83733 r84163 77 77 bool packedDepthStencilExtensionSupported) 78 78 : m_context(context) 79 , m_size( size)79 , m_size(-1, -1) 80 80 , m_multisampleExtensionSupported(multisampleExtensionSupported) 81 81 , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported) -
trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
r83355 r84163 159 159 } 160 160 161 m_size = newSize;162 163 161 const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); 164 unsigned long internalColorFormat, colorFormat, internalRenderbufferFormat; 165 if (attributes.alpha) { 166 internalColorFormat = GraphicsContext3D::RGBA; 167 colorFormat = GraphicsContext3D::RGBA; 168 internalRenderbufferFormat = Extensions3D::RGBA8_OES; 169 } else { 170 internalColorFormat = GraphicsContext3D::RGB; 171 colorFormat = GraphicsContext3D::RGB; 172 internalRenderbufferFormat = Extensions3D::RGB8_OES; 173 } 174 175 176 // resize multisample FBO 177 if (multisample()) { 178 int maxSampleCount = 0; 179 180 m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCount); 181 int sampleCount = std::min(8, maxSampleCount); 182 183 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); 184 185 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); 186 m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height()); 187 m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); 188 resizeDepthStencil(sampleCount); 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); 189 210 if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { 190 211 // Cleanup … … 194 215 } 195 216 196 // resize regular FBO 197 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); 198 199 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer); 200 201 m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE); 202 203 m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0); 204 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); 205 206 if (!multisample()) 207 resizeDepthStencil(0); 208 if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { 209 // Cleanup 210 clear(); 211 return false; 212 } 213 214 if (multisample()) 215 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); 216 217 if (!m_context->getExtensions()->supports("GL_CHROMIUM_resource_safe")) { 218 // Initialize renderbuffers (depth/stencil). 219 float clearDepth = 0; 220 int clearStencil = 0; 221 unsigned char depthMask = true; 222 unsigned int stencilMask = 0xffffffff; 223 unsigned char isScissorEnabled = false; 224 unsigned long clearMask = 0; 225 if (attributes.depth) { 226 m_context->getFloatv(GraphicsContext3D::DEPTH_CLEAR_VALUE, &clearDepth); 227 m_context->clearDepth(1); 228 m_context->getBooleanv(GraphicsContext3D::DEPTH_WRITEMASK, &depthMask); 229 m_context->depthMask(true); 230 clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; 231 } 232 if (attributes.stencil) { 233 m_context->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &clearStencil); 234 m_context->clearStencil(0); 235 m_context->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<int*>(&stencilMask)); 236 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xffffffff); 237 clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; 238 } 239 if (clearMask) { 240 isScissorEnabled = m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST); 241 m_context->disable(GraphicsContext3D::SCISSOR_TEST); 242 243 m_context->clear(clearMask); 244 245 if (attributes.depth) { 246 m_context->clearDepth(clearDepth); 247 m_context->depthMask(depthMask); 248 } 249 if (attributes.stencil) { 250 m_context->clearStencil(clearStencil); 251 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, stencilMask); 252 } 253 if (isScissorEnabled) 254 m_context->enable(GraphicsContext3D::SCISSOR_TEST); 255 else 256 m_context->disable(GraphicsContext3D::SCISSOR_TEST); 257 } 258 } 259 260 m_context->flush(); 261 217 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); 218 219 // Initialize renderbuffers (depth/stencil). 220 float clearDepth = 0; 221 int clearStencil = 0; 222 unsigned char depthMask = true; 223 unsigned int stencilMask = 0xffffffff; 224 unsigned char isScissorEnabled = false; 225 unsigned long clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; 226 if (attributes.depth) { 227 m_context->getFloatv(GraphicsContext3D::DEPTH_CLEAR_VALUE, &clearDepth); 228 m_context->clearDepth(1); 229 m_context->getBooleanv(GraphicsContext3D::DEPTH_WRITEMASK, &depthMask); 230 m_context->depthMask(true); 231 clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; 232 } 233 if (attributes.stencil) { 234 m_context->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &clearStencil); 235 m_context->clearStencil(0); 236 m_context->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<int*>(&stencilMask)); 237 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xffffffff); 238 clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; 239 } 240 isScissorEnabled = m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST); 241 m_context->disable(GraphicsContext3D::SCISSOR_TEST); 242 243 float clearColor[4]; 244 m_context->getFloatv(GraphicsContext3D::COLOR_CLEAR_VALUE, clearColor); 245 m_context->clearColor(0, 0, 0, 0); 246 m_context->clear(clearMask); 247 m_context->clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); 248 249 if (attributes.depth) { 250 m_context->clearDepth(clearDepth); 251 m_context->depthMask(depthMask); 252 } 253 if (attributes.stencil) { 254 m_context->clearStencil(clearStencil); 255 m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, stencilMask); 256 } 257 if (isScissorEnabled) 258 m_context->enable(GraphicsContext3D::SCISSOR_TEST); 259 else 260 m_context->disable(GraphicsContext3D::SCISSOR_TEST); 261 262 262 didReset(); 263 263
Note: See TracChangeset
for help on using the changeset viewer.