Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| index 48142e6e57f8d5edfd193110a96c226fb54895eb..656505d2a8f0875bbd4ead81031a46cf3eaca742 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
| @@ -407,7 +407,10 @@ class BackRenderbuffer { |
| void Create(); |
| // Set the initial size and format of a render buffer or resize it. |
| - bool AllocateStorage(const gfx::Size& size, GLenum format, GLsizei samples); |
| + bool AllocateStorage(GLES2DecoderImpl* decoder, |
|
piman
2013/11/15 16:58:50
nit: kloveless@ tried to decouple these from the d
no sievers
2013/11/15 19:41:48
Done.
|
| + const gfx::Size& size, |
| + GLenum format, |
| + GLsizei samples); |
| // Destroy the render buffer. This must be explicitly called before destroying |
| // this object. |
| @@ -627,7 +630,22 @@ class GLES2DecoderImpl : public GLES2Decoder, |
| virtual void OnTextureRefDetachedFromFramebuffer( |
| TextureRef* texture) OVERRIDE; |
| - static bool IsAngle(); |
| + // Helpers to facilitate calling into compatible extensions. |
| + void RenderbufferStorageMultisampleHelper(GLenum target, |
| + GLsizei samples, |
| + GLenum internal_format, |
| + GLsizei width, |
| + GLsizei height); |
| + void BlitFramebufferHelper(GLint srcX0, |
| + GLint srcY0, |
| + GLint srcX1, |
| + GLint srcY1, |
| + GLint dstX0, |
| + GLint dstY0, |
| + GLint dstX1, |
| + GLint dstY1, |
| + GLbitfield mask, |
| + GLenum filter); |
| private: |
| friend class ScopedFrameBufferBinder; |
| @@ -1804,13 +1822,16 @@ ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( |
| const int width = decoder_->offscreen_size_.width(); |
| const int height = decoder_->offscreen_size_.height(); |
| glDisable(GL_SCISSOR_TEST); |
| - if (GLES2DecoderImpl::IsAngle()) { |
| - glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height, |
| - GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| - } else { |
| - glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, |
| - GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| - } |
| + decoder->BlitFramebufferHelper(0, |
| + 0, |
| + width, |
| + height, |
| + 0, |
| + 0, |
| + width, |
| + height, |
| + GL_COLOR_BUFFER_BIT, |
| + GL_NEAREST); |
| glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
| } |
| @@ -1962,7 +1983,9 @@ void BackRenderbuffer::Create() { |
| glGenRenderbuffersEXT(1, &id_); |
| } |
| -bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format, |
| +bool BackRenderbuffer::AllocateStorage(GLES2DecoderImpl* decoder, |
| + const gfx::Size& size, |
| + GLenum format, |
| GLsizei samples) { |
| ScopedGLErrorSuppressor suppressor( |
| "BackRenderbuffer::AllocateStorage", state_->GetErrorState()); |
| @@ -1984,19 +2007,8 @@ bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format, |
| size.width(), |
| size.height()); |
| } else { |
| - if (GLES2DecoderImpl::IsAngle()) { |
| - glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, |
| - samples, |
| - format, |
| - size.width(), |
| - size.height()); |
| - } else { |
| - glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, |
| - samples, |
| - format, |
| - size.width(), |
| - size.height()); |
| - } |
| + decoder->RenderbufferStorageMultisampleHelper( |
| + GL_RENDERBUFFER, samples, format, size.width(), size.height()); |
| } |
| bool success = glGetError() == GL_NO_ERROR; |
| if (success) { |
| @@ -2094,14 +2106,6 @@ GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
| return new GLES2DecoderImpl(group); |
| } |
| -bool GLES2DecoderImpl::IsAngle() { |
| -#if defined(OS_WIN) |
| - return gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; |
| -#else |
| - return false; |
| -#endif |
| -} |
| - |
| GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
| : GLES2Decoder(), |
| group_(group), |
| @@ -2303,7 +2307,7 @@ bool GLES2DecoderImpl::Initialize( |
| // ANGLE only supports packed depth/stencil formats, so use it if it is |
| // available. |
| const bool depth24_stencil8_supported = |
| - context_->HasExtension("GL_OES_packed_depth_stencil"); |
| + feature_info_->feature_flags().packed_depth24_stencil8; |
| VLOG(1) << "GL_OES_packed_depth_stencil " |
| << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
| if ((attrib_parser.depth_size_ > 0 || attrib_parser.stencil_size_ > 0) && |
| @@ -2326,7 +2330,7 @@ bool GLES2DecoderImpl::Initialize( |
| // it's available, as some desktop GL drivers don't support any non-packed |
| // formats for depth attachments. |
| const bool depth24_stencil8_supported = |
| - context_->HasExtension("GL_EXT_packed_depth_stencil"); |
| + feature_info_->feature_flags().packed_depth24_stencil8; |
| VLOG(1) << "GL_EXT_packed_depth_stencil " |
| << (depth24_stencil8_supported ? "" : "not ") << "supported."; |
| @@ -3321,7 +3325,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { |
| DCHECK(offscreen_target_color_format_); |
| if (IsOffscreenBufferMultisampled()) { |
| if (!offscreen_target_color_render_buffer_->AllocateStorage( |
| - offscreen_size_, offscreen_target_color_format_, |
| + this, offscreen_size_, offscreen_target_color_format_, |
| offscreen_target_samples_)) { |
| LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
| << "to allocate storage for offscreen target color buffer."; |
| @@ -3337,7 +3341,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { |
| } |
| if (offscreen_target_depth_format_ && |
| !offscreen_target_depth_render_buffer_->AllocateStorage( |
| - offscreen_size_, offscreen_target_depth_format_, |
| + this, offscreen_size_, offscreen_target_depth_format_, |
| offscreen_target_samples_)) { |
| LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
| << "to allocate storage for offscreen target depth buffer."; |
| @@ -3345,7 +3349,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { |
| } |
| if (offscreen_target_stencil_format_ && |
| !offscreen_target_stencil_render_buffer_->AllocateStorage( |
| - offscreen_size_, offscreen_target_stencil_format_, |
| + this, offscreen_size_, offscreen_target_stencil_format_, |
| offscreen_target_samples_)) { |
| LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
| << "to allocate storage for offscreen target stencil buffer."; |
| @@ -4997,14 +5001,53 @@ void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM( |
| } |
| glDisable(GL_SCISSOR_TEST); |
| - if (IsAngle()) { |
| + BlitFramebufferHelper( |
| + srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| + EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); |
| +} |
| + |
| +void GLES2DecoderImpl::RenderbufferStorageMultisampleHelper( |
| + GLenum target, |
| + GLsizei samples, |
| + GLenum internal_format, |
| + GLsizei width, |
| + GLsizei height) { |
| + // TODO(sievers): This could be resolved at the GL binding level, but the |
| + // binding process is currently a bit too 'brute force'. |
| + if (feature_info_->feature_flags().is_angle) { |
| + glRenderbufferStorageMultisampleANGLE( |
| + target, samples, internal_format, width, height); |
| + } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) { |
| + glRenderbufferStorageMultisample( |
| + target, samples, internal_format, width, height); |
| + } else { |
| + glRenderbufferStorageMultisampleEXT( |
| + target, samples, internal_format, width, height); |
| + } |
| +} |
| + |
| +void GLES2DecoderImpl::BlitFramebufferHelper(GLint srcX0, |
| + GLint srcY0, |
| + GLint srcX1, |
| + GLint srcY1, |
| + GLint dstX0, |
| + GLint dstY0, |
| + GLint dstX1, |
| + GLint dstY1, |
| + GLbitfield mask, |
| + GLenum filter) { |
| + // TODO(sievers): This could be resolved at the GL binding level, but the |
| + // binding process is currently a bit too 'brute force'. |
| + if (feature_info_->feature_flags().is_angle) { |
| glBlitFramebufferANGLE( |
| srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| + } else if (feature_info_->feature_flags().use_core_framebuffer_multisample) { |
| + glBlitFramebuffer( |
| + srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| } else { |
| glBlitFramebufferEXT( |
| srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| } |
| - EnableDisable(GL_SCISSOR_TEST, state_.enable_flags.scissor_test); |
| } |
| bool GLES2DecoderImpl::ValidateRenderbufferStorageMultisample( |
| @@ -5074,13 +5117,8 @@ void GLES2DecoderImpl::DoRenderbufferStorageMultisampleCHROMIUM( |
| internalformat); |
| LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER( |
| "glRenderbufferStorageMultisampleCHROMIUM"); |
| - if (IsAngle()) { |
| - glRenderbufferStorageMultisampleANGLE( |
| - target, samples, impl_format, width, height); |
| - } else { |
| - glRenderbufferStorageMultisampleEXT( |
| - target, samples, impl_format, width, height); |
| - } |
| + RenderbufferStorageMultisampleHelper( |
| + target, samples, impl_format, width, height); |
| GLenum error = |
| LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM"); |
| if (error == GL_NO_ERROR) { |
| @@ -5220,7 +5258,8 @@ bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity( |
| glBindFramebufferEXT(GL_READ_FRAMEBUFFER, validation_fbo_multisample_); |
| glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, validation_fbo_); |
| - glBlitFramebufferEXT(0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| + BlitFramebufferHelper( |
| + 0, 0, 1, 1, 0, 0, 1, 1, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| // Read a pixel from the buffer. |
| glBindFramebufferEXT(GL_FRAMEBUFFER, validation_fbo_); |
| @@ -8851,7 +8890,7 @@ void GLES2DecoderImpl::DoSwapBuffers() { |
| // Ensure the side effects of the copy are visible to the parent |
| // context. There is no need to do this for ANGLE because it uses a |
| // single D3D device for all contexts. |
| - if (!IsAngle()) |
| + if (!feature_info_->feature_flags().is_angle) |
| glFlush(); |
| } |
| } else { |