Index: Source/platform/graphics/gpu/DrawingBuffer.cpp |
diff --git a/Source/platform/graphics/gpu/DrawingBuffer.cpp b/Source/platform/graphics/gpu/DrawingBuffer.cpp |
index 0b562d02983a9fb5b4fa990ff06209708a000e75..aa528a3b761c82c8ed8dd9b4e8eaa86145009398 100644 |
--- a/Source/platform/graphics/gpu/DrawingBuffer.cpp |
+++ b/Source/platform/graphics/gpu/DrawingBuffer.cpp |
@@ -54,9 +54,6 @@ |
const float s_resourceAdjustedRatio = 0.5; |
-// Drawing buffers with more pixels than this will be explicitly checked for out of memory errors upon creation |
-const int s_largeBufferSize = 4096 * 4096; |
- |
DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, drawingBufferCounter, ("DrawingBuffer")); |
class ScopedTextureUnit0BindingRestorer { |
@@ -79,57 +76,6 @@ |
GLenum m_oldActiveTextureUnit; |
Platform3DObject m_oldTextureUnitZeroId; |
}; |
- |
-class ScopedConditionalErrorCache { |
-public: |
- ScopedConditionalErrorCache(WebGraphicsContext3D* context, bool active) |
- : m_context(context) |
- , m_active(active) |
- { |
- if (m_active) { |
- GLenum error = m_context->getError(); |
- int i = 0; |
- for (; i < 100 && error != GL_NO_ERROR; ++i) { |
- m_cachedErrors.append(error); |
- error = m_context->getError(); |
- } |
- ASSERT(i < 100); |
- } |
- } |
- |
- ~ScopedConditionalErrorCache() |
- { |
- while (m_cachedErrors.size()) { |
- m_context->synthesizeGLError(m_cachedErrors.first()); |
- m_cachedErrors.remove(0); |
- } |
- } |
- |
- bool consumeErrorIf(GLenum error) |
- { |
- if (m_active) { |
- GLenum nextError = m_context->getError(); |
- if (error == GL_NO_ERROR) |
- return false; |
- |
- if (nextError == error) |
- return true; |
- |
- m_cachedErrors.append(nextError); |
- } |
- return false; |
- } |
- |
-private: |
- WebGraphicsContext3D* m_context; |
- bool m_active; |
- Vector<GLenum> m_cachedErrors; |
-}; |
- |
-bool isLargeBuffer(const IntSize& size) |
-{ |
- return s_largeBufferSize <= size.width() * size.height(); |
-} |
} // namespace |
@@ -674,8 +620,7 @@ |
m_context->bindTexture(GL_TEXTURE_2D, m_colorBuffer.textureId); |
- if (!allocateTextureMemory(&m_colorBuffer, size)) |
- return false; |
+ allocateTextureMemory(&m_colorBuffer, size); |
if (m_multisampleMode == ImplicitResolve) |
m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount); |
@@ -684,10 +629,8 @@ |
m_context->bindTexture(GL_TEXTURE_2D, 0); |
- if (m_multisampleMode != ExplicitResolve) { |
- if (!resizeDepthStencil(size)) |
- return false; |
- } |
+ if (m_multisampleMode != ExplicitResolve) |
+ resizeDepthStencil(size); |
if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
return false; |
@@ -697,19 +640,16 @@ |
bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size) |
{ |
if (m_multisampleMode == ExplicitResolve) { |
- ScopedConditionalErrorCache errorCache(m_context.get(), isLargeBuffer(size)); |
- |
m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); |
m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, m_internalRenderbufferFormat, size.width(), size.height()); |
- if (errorCache.consumeErrorIf(GL_OUT_OF_MEMORY)) |
+ if (m_context->getError() == GL_OUT_OF_MEMORY) |
return false; |
m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer); |
- if (!resizeDepthStencil(size)) |
- return false; |
+ resizeDepthStencil(size); |
if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
return false; |
} |
@@ -717,12 +657,10 @@ |
return true; |
} |
-bool DrawingBuffer::resizeDepthStencil(const IntSize& size) |
+void DrawingBuffer::resizeDepthStencil(const IntSize& size) |
{ |
if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) |
- return true; |
- |
- ScopedConditionalErrorCache errorCache(m_context.get(), isLargeBuffer(size)); |
+ return; |
if (m_packedDepthStencilExtensionSupported) { |
if (!m_depthStencilBuffer) |
@@ -763,11 +701,6 @@ |
} |
} |
m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); |
- |
- if (errorCache.consumeErrorIf(GL_OUT_OF_MEMORY)) |
- return false; |
- |
- return true; |
} |
@@ -1030,30 +963,19 @@ |
m_context->texImage2D(target, level, internalformat, width, height, border, format, type, 0); |
} |
-bool DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size) |
-{ |
- ScopedConditionalErrorCache errorCache(m_context.get(), isLargeBuffer(size)); |
- |
+void DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size) |
+{ |
if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) { |
deleteChromiumImageForTexture(info); |
info->imageId = m_context->createGpuMemoryBufferImageCHROMIUM(size.width(), size.height(), GL_RGBA, GC3D_SCANOUT_CHROMIUM); |
- |
- if (errorCache.consumeErrorIf(GL_OUT_OF_MEMORY)) |
- return false; |
- |
if (info->imageId) { |
m_context->bindTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
- return true; |
+ return; |
} |
} |
texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, size.width(), size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE); |
- |
- if (errorCache.consumeErrorIf(GL_OUT_OF_MEMORY)) |
- return false; |
- |
- return true; |
} |
void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |