| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 bool SetCapabilityState(GLenum cap, bool enabled); | 1277 bool SetCapabilityState(GLenum cap, bool enabled); |
| 1278 | 1278 |
| 1279 // Infer color encoding from internalformat | 1279 // Infer color encoding from internalformat |
| 1280 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat); | 1280 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat); |
| 1281 | 1281 |
| 1282 // Check that the currently bound read framebuffer's color image | 1282 // Check that the currently bound read framebuffer's color image |
| 1283 // isn't the target texture of the glCopyTex{Sub}Image2D. | 1283 // isn't the target texture of the glCopyTex{Sub}Image2D. |
| 1284 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); | 1284 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); |
| 1285 | 1285 |
| 1286 // Check if a framebuffer meets our requirements. | 1286 // Check if a framebuffer meets our requirements. |
| 1287 // Generates |gl_error| if the framebuffer is incomplete. |
| 1287 bool CheckFramebufferValid( | 1288 bool CheckFramebufferValid( |
| 1288 Framebuffer* framebuffer, | 1289 Framebuffer* framebuffer, |
| 1289 GLenum target, | 1290 GLenum target, |
| 1290 bool clear_uncleared_images, | 1291 bool clear_uncleared_images, |
| 1292 GLenum gl_error, |
| 1291 const char* func_name); | 1293 const char* func_name); |
| 1292 | 1294 |
| 1293 bool CheckBoundDrawFramebufferValid( | 1295 bool CheckBoundDrawFramebufferValid( |
| 1294 bool clear_uncleared_images, const char* func_name); | 1296 bool clear_uncleared_images, const char* func_name); |
| 1295 bool CheckBoundReadFramebufferValid(const char* func_name); | 1297 // Generates |gl_error| if the bound read fbo is incomplete. |
| 1298 bool CheckBoundReadFramebufferValid(const char* func_name, GLenum gl_error); |
| 1296 | 1299 |
| 1297 // Checks if the current program exists and is valid. If not generates the | 1300 // Checks if the current program exists and is valid. If not generates the |
| 1298 // appropriate GL error. Returns true if the current program is in a usable | 1301 // appropriate GL error. Returns true if the current program is in a usable |
| 1299 // state. | 1302 // state. |
| 1300 bool CheckCurrentProgram(const char* function_name); | 1303 bool CheckCurrentProgram(const char* function_name); |
| 1301 | 1304 |
| 1302 // Checks if the current program exists and is valid and that location is not | 1305 // Checks if the current program exists and is valid and that location is not |
| 1303 // -1. If the current program is not valid generates the appropriate GL | 1306 // -1. If the current program is not valid generates the appropriate GL |
| 1304 // error. Returns true if the current program is in a usable state and | 1307 // error. Returns true if the current program is in a usable state and |
| 1305 // location is not -1. | 1308 // location is not -1. |
| (...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3746 framebuffer_state_.bound_draw_framebuffer.get(), | 3749 framebuffer_state_.bound_draw_framebuffer.get(), |
| 3747 GetBackbufferServiceId()); | 3750 GetBackbufferServiceId()); |
| 3748 } | 3751 } |
| 3749 OnFboChanged(); | 3752 OnFboChanged(); |
| 3750 } | 3753 } |
| 3751 | 3754 |
| 3752 bool GLES2DecoderImpl::CheckFramebufferValid( | 3755 bool GLES2DecoderImpl::CheckFramebufferValid( |
| 3753 Framebuffer* framebuffer, | 3756 Framebuffer* framebuffer, |
| 3754 GLenum target, | 3757 GLenum target, |
| 3755 bool clear_uncleared_images, | 3758 bool clear_uncleared_images, |
| 3759 GLenum gl_error, |
| 3756 const char* func_name) { | 3760 const char* func_name) { |
| 3757 if (!framebuffer) { | 3761 if (!framebuffer) { |
| 3758 if (surfaceless_) | 3762 if (surfaceless_) |
| 3759 return false; | 3763 return false; |
| 3760 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) { | 3764 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) { |
| 3761 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f); | 3765 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f); |
| 3762 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 3766 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 3763 glClearStencil(0); | 3767 glClearStencil(0); |
| 3764 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 3768 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
| 3765 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 3769 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3785 } | 3789 } |
| 3786 return true; | 3790 return true; |
| 3787 } | 3791 } |
| 3788 | 3792 |
| 3789 if (framebuffer_manager()->IsComplete(framebuffer)) { | 3793 if (framebuffer_manager()->IsComplete(framebuffer)) { |
| 3790 return true; | 3794 return true; |
| 3791 } | 3795 } |
| 3792 | 3796 |
| 3793 GLenum completeness = framebuffer->IsPossiblyComplete(feature_info_.get()); | 3797 GLenum completeness = framebuffer->IsPossiblyComplete(feature_info_.get()); |
| 3794 if (completeness != GL_FRAMEBUFFER_COMPLETE) { | 3798 if (completeness != GL_FRAMEBUFFER_COMPLETE) { |
| 3795 LOCAL_SET_GL_ERROR( | 3799 LOCAL_SET_GL_ERROR(gl_error, func_name, "framebuffer incomplete"); |
| 3796 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete"); | |
| 3797 return false; | 3800 return false; |
| 3798 } | 3801 } |
| 3799 | 3802 |
| 3800 // Are all the attachments cleared? | 3803 // Are all the attachments cleared? |
| 3801 if (clear_uncleared_images && | 3804 if (clear_uncleared_images && |
| 3802 (renderbuffer_manager()->HaveUnclearedRenderbuffers() || | 3805 (renderbuffer_manager()->HaveUnclearedRenderbuffers() || |
| 3803 texture_manager()->HaveUnclearedMips())) { | 3806 texture_manager()->HaveUnclearedMips())) { |
| 3804 if (!framebuffer->IsCleared()) { | 3807 if (!framebuffer->IsCleared()) { |
| 3805 // Can we clear them? | 3808 // Can we clear them? |
| 3806 if (framebuffer->GetStatus(texture_manager(), target) != | 3809 if (framebuffer->GetStatus(texture_manager(), target) != |
| 3807 GL_FRAMEBUFFER_COMPLETE) { | 3810 GL_FRAMEBUFFER_COMPLETE) { |
| 3808 LOCAL_SET_GL_ERROR( | 3811 LOCAL_SET_GL_ERROR( |
| 3809 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, | 3812 gl_error, func_name, "framebuffer incomplete (clear)"); |
| 3810 "framebuffer incomplete (clear)"); | |
| 3811 return false; | 3813 return false; |
| 3812 } | 3814 } |
| 3813 ClearUnclearedAttachments(target, framebuffer); | 3815 ClearUnclearedAttachments(target, framebuffer); |
| 3814 } | 3816 } |
| 3815 } | 3817 } |
| 3816 | 3818 |
| 3817 if (!framebuffer_manager()->IsComplete(framebuffer)) { | 3819 if (!framebuffer_manager()->IsComplete(framebuffer)) { |
| 3818 if (framebuffer->GetStatus(texture_manager(), target) != | 3820 if (framebuffer->GetStatus(texture_manager(), target) != |
| 3819 GL_FRAMEBUFFER_COMPLETE) { | 3821 GL_FRAMEBUFFER_COMPLETE) { |
| 3820 LOCAL_SET_GL_ERROR( | 3822 LOCAL_SET_GL_ERROR( |
| 3821 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, | 3823 gl_error, func_name, "framebuffer incomplete (check)"); |
| 3822 "framebuffer incomplete (check)"); | |
| 3823 return false; | 3824 return false; |
| 3824 } | 3825 } |
| 3825 framebuffer_manager()->MarkAsComplete(framebuffer); | 3826 framebuffer_manager()->MarkAsComplete(framebuffer); |
| 3826 } | 3827 } |
| 3827 return true; | 3828 return true; |
| 3828 } | 3829 } |
| 3829 | 3830 |
| 3830 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid( | 3831 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid( |
| 3831 bool clear_uncleared_images, const char* func_name) { | 3832 bool clear_uncleared_images, const char* func_name) { |
| 3832 GLenum target = features().chromium_framebuffer_multisample ? | 3833 GLenum target = features().chromium_framebuffer_multisample ? |
| 3833 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 3834 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 3834 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 3835 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 3835 bool valid = CheckFramebufferValid( | 3836 bool valid = CheckFramebufferValid( |
| 3836 framebuffer, target, clear_uncleared_images, func_name); | 3837 framebuffer, target, clear_uncleared_images, |
| 3838 GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
| 3837 if (valid && !features().chromium_framebuffer_multisample) | 3839 if (valid && !features().chromium_framebuffer_multisample) |
| 3838 OnUseFramebuffer(); | 3840 OnUseFramebuffer(); |
| 3839 return valid; | 3841 return valid; |
| 3840 } | 3842 } |
| 3841 | 3843 |
| 3842 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(const char* func_name) { | 3844 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( |
| 3845 const char* func_name, GLenum gl_error) { |
| 3843 GLenum target = features().chromium_framebuffer_multisample ? | 3846 GLenum target = features().chromium_framebuffer_multisample ? |
| 3844 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 3847 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 3845 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 3848 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 3846 bool valid = CheckFramebufferValid(framebuffer, target, true, func_name); | 3849 bool valid = CheckFramebufferValid( |
| 3850 framebuffer, target, true, gl_error, func_name); |
| 3847 return valid; | 3851 return valid; |
| 3848 } | 3852 } |
| 3849 | 3853 |
| 3850 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( | 3854 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( |
| 3851 GLenum internalformat) { | 3855 GLenum internalformat) { |
| 3852 switch (internalformat) { | 3856 switch (internalformat) { |
| 3853 case GL_SRGB_EXT: | 3857 case GL_SRGB_EXT: |
| 3854 case GL_SRGB_ALPHA_EXT: | 3858 case GL_SRGB_ALPHA_EXT: |
| 3855 case GL_SRGB8: | 3859 case GL_SRGB8: |
| 3856 case GL_SRGB8_ALPHA8: | 3860 case GL_SRGB8_ALPHA8: |
| (...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5362 } | 5366 } |
| 5363 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); | 5367 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); |
| 5364 if (error == GL_NO_ERROR) { | 5368 if (error == GL_NO_ERROR) { |
| 5365 texture_manager()->MarkMipmapsGenerated(texture_ref); | 5369 texture_manager()->MarkMipmapsGenerated(texture_ref); |
| 5366 } | 5370 } |
| 5367 } | 5371 } |
| 5368 | 5372 |
| 5369 bool GLES2DecoderImpl::GetHelper( | 5373 bool GLES2DecoderImpl::GetHelper( |
| 5370 GLenum pname, GLint* params, GLsizei* num_written) { | 5374 GLenum pname, GLint* params, GLsizei* num_written) { |
| 5371 DCHECK(num_written); | 5375 DCHECK(num_written); |
| 5376 switch (pname) { |
| 5377 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 5378 case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 5379 // They are not supported on Desktop GL until 4.1, but could be exposed |
| 5380 // through GL_OES_read_format extension. However, a conflicting extension |
| 5381 // GL_ARB_ES2_compatibility specifies an error case when requested on |
| 5382 // integer/floating point buffers. |
| 5383 // To simpify the handling, we just query and check for GL errors. If an |
| 5384 // GL error occur, we fall back to our internal implementation. |
| 5385 *num_written = 1; |
| 5386 if (!CheckBoundReadFramebufferValid("glGetIntegerv", |
| 5387 GL_INVALID_OPERATION)) { |
| 5388 if (params) { |
| 5389 *params = 0; |
| 5390 } |
| 5391 return true; |
| 5392 } |
| 5393 if (params) { |
| 5394 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", |
| 5395 GetErrorState()); |
| 5396 glGetIntegerv(pname, params); |
| 5397 if (glGetError() != GL_NO_ERROR) { |
| 5398 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { |
| 5399 *params = GLES2Util::GetGLReadPixelsImplementationFormat( |
| 5400 GetBoundReadFrameBufferInternalFormat(), |
| 5401 GetBoundReadFrameBufferTextureType(), |
| 5402 feature_info_->feature_flags().ext_read_format_bgra); |
| 5403 } else { |
| 5404 *params = GLES2Util::GetGLReadPixelsImplementationType( |
| 5405 GetBoundReadFrameBufferInternalFormat(), |
| 5406 GetBoundReadFrameBufferTextureType()); |
| 5407 } |
| 5408 } |
| 5409 if (*params == GL_HALF_FLOAT && |
| 5410 (feature_info_->context_type() == CONTEXT_TYPE_WEBGL1 || |
| 5411 feature_info_->context_type() == CONTEXT_TYPE_OPENGLES2)) { |
| 5412 *params = GL_HALF_FLOAT_OES; |
| 5413 } |
| 5414 } |
| 5415 return true; |
| 5416 default: |
| 5417 break; |
| 5418 } |
| 5419 |
| 5372 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 5420 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 5373 switch (pname) { | 5421 switch (pname) { |
| 5374 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: | |
| 5375 *num_written = 1; | |
| 5376 // Return the GL implementation's preferred format and (see below type) | |
| 5377 // if we have the GL extension that exposes this. This allows the GPU | |
| 5378 // client to use the implementation's preferred format for glReadPixels | |
| 5379 // for optimisation. | |
| 5380 // | |
| 5381 // A conflicting extension (GL_ARB_ES2_compatibility) specifies an error | |
| 5382 // case when requested on integer/floating point buffers but which is | |
| 5383 // acceptable on GLES2 and with the GL_OES_read_format extension. | |
| 5384 // | |
| 5385 // Therefore if an error occurs we swallow the error and use the | |
| 5386 // internal implementation. | |
| 5387 if (params) { | |
| 5388 if (context_->HasExtension("GL_OES_read_format")) { | |
| 5389 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", | |
| 5390 GetErrorState()); | |
| 5391 glGetIntegerv(pname, params); | |
| 5392 if (glGetError() == GL_NO_ERROR) | |
| 5393 return true; | |
| 5394 } | |
| 5395 *params = GLES2Util::GetGLReadPixelsImplementationFormat( | |
| 5396 GetBoundReadFrameBufferInternalFormat(), | |
| 5397 GetBoundReadFrameBufferTextureType(), | |
| 5398 feature_info_->feature_flags().ext_read_format_bgra); | |
| 5399 } | |
| 5400 return true; | |
| 5401 case GL_IMPLEMENTATION_COLOR_READ_TYPE: | |
| 5402 *num_written = 1; | |
| 5403 if (params) { | |
| 5404 if (context_->HasExtension("GL_OES_read_format")) { | |
| 5405 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", | |
| 5406 GetErrorState()); | |
| 5407 glGetIntegerv(pname, params); | |
| 5408 if (glGetError() == GL_NO_ERROR) | |
| 5409 return true; | |
| 5410 } | |
| 5411 *params = GLES2Util::GetGLReadPixelsImplementationType( | |
| 5412 GetBoundReadFrameBufferInternalFormat(), | |
| 5413 GetBoundReadFrameBufferTextureType()); | |
| 5414 } | |
| 5415 return true; | |
| 5416 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: | 5422 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 5417 *num_written = 1; | 5423 *num_written = 1; |
| 5418 if (params) { | 5424 if (params) { |
| 5419 *params = group_->max_fragment_uniform_vectors(); | 5425 *params = group_->max_fragment_uniform_vectors(); |
| 5420 } | 5426 } |
| 5421 return true; | 5427 return true; |
| 5422 case GL_MAX_VARYING_VECTORS: | 5428 case GL_MAX_VARYING_VECTORS: |
| 5423 *num_written = 1; | 5429 *num_written = 1; |
| 5424 if (params) { | 5430 if (params) { |
| 5425 *params = group_->max_varying_vectors(); | 5431 *params = group_->max_varying_vectors(); |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6781 } | 6787 } |
| 6782 } | 6788 } |
| 6783 | 6789 |
| 6784 void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM( | 6790 void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM( |
| 6785 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, | 6791 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 6786 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, | 6792 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 6787 GLbitfield mask, GLenum filter) { | 6793 GLbitfield mask, GLenum filter) { |
| 6788 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws()); | 6794 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws()); |
| 6789 | 6795 |
| 6790 if (!CheckBoundDrawFramebufferValid(true, "glBlitFramebufferCHROMIUM") || | 6796 if (!CheckBoundDrawFramebufferValid(true, "glBlitFramebufferCHROMIUM") || |
| 6791 !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM")) { | 6797 !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM", |
| 6798 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
| 6792 return; | 6799 return; |
| 6793 } | 6800 } |
| 6794 | 6801 |
| 6795 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 6802 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
| 6796 BlitFramebufferHelper( | 6803 BlitFramebufferHelper( |
| 6797 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 6804 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 6798 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 6805 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, |
| 6799 state_.enable_flags.scissor_test); | 6806 state_.enable_flags.scissor_test); |
| 6800 } | 6807 } |
| 6801 | 6808 |
| (...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9571 | 9578 |
| 9572 if (!validators_->read_pixel_format.IsValid(format)) { | 9579 if (!validators_->read_pixel_format.IsValid(format)) { |
| 9573 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format"); | 9580 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format"); |
| 9574 return error::kNoError; | 9581 return error::kNoError; |
| 9575 } | 9582 } |
| 9576 if (!validators_->read_pixel_type.IsValid(type)) { | 9583 if (!validators_->read_pixel_type.IsValid(type)) { |
| 9577 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); | 9584 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); |
| 9578 return error::kNoError; | 9585 return error::kNoError; |
| 9579 } | 9586 } |
| 9580 | 9587 |
| 9581 if (!CheckBoundReadFramebufferValid("glReadPixels")) { | 9588 if (!CheckBoundReadFramebufferValid("glReadPixels", |
| 9589 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
| 9582 return error::kNoError; | 9590 return error::kNoError; |
| 9583 } | 9591 } |
| 9584 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat(); | 9592 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat(); |
| 9585 if (src_internal_format == 0) { | 9593 if (src_internal_format == 0) { |
| 9586 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", | 9594 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", |
| 9587 "no valid color image"); | 9595 "no valid color image"); |
| 9588 return error::kNoError; | 9596 return error::kNoError; |
| 9589 } | 9597 } |
| 9590 std::vector<GLenum> accepted_formats; | 9598 std::vector<GLenum> accepted_formats; |
| 9591 std::vector<GLenum> accepted_types; | 9599 std::vector<GLenum> accepted_types; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9625 break; | 9633 break; |
| 9626 default: | 9634 default: |
| 9627 accepted_formats.push_back(GL_RGBA); | 9635 accepted_formats.push_back(GL_RGBA); |
| 9628 { | 9636 { |
| 9629 GLenum src_type = GetBoundReadFrameBufferTextureType(); | 9637 GLenum src_type = GetBoundReadFrameBufferTextureType(); |
| 9630 switch (src_type) { | 9638 switch (src_type) { |
| 9631 case GL_HALF_FLOAT: | 9639 case GL_HALF_FLOAT: |
| 9632 case GL_HALF_FLOAT_OES: | 9640 case GL_HALF_FLOAT_OES: |
| 9633 case GL_FLOAT: | 9641 case GL_FLOAT: |
| 9634 case GL_UNSIGNED_INT_10F_11F_11F_REV: | 9642 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
| 9635 if (!feature_info_->IsES3Enabled()) { | 9643 accepted_types.push_back(GL_FLOAT); |
| 9636 accepted_types.push_back(GL_UNSIGNED_BYTE); | |
| 9637 } else { | |
| 9638 accepted_types.push_back(GL_FLOAT); | |
| 9639 } | |
| 9640 break; | 9644 break; |
| 9641 default: | 9645 default: |
| 9642 accepted_types.push_back(GL_UNSIGNED_BYTE); | 9646 accepted_types.push_back(GL_UNSIGNED_BYTE); |
| 9643 break; | 9647 break; |
| 9644 } | 9648 } |
| 9645 } | 9649 } |
| 9646 break; | 9650 break; |
| 9647 } | 9651 } |
| 9648 if (!feature_info_->IsWebGLContext()) { | 9652 if (!feature_info_->IsWebGLContext()) { |
| 9649 accepted_formats.push_back(GL_BGRA_EXT); | 9653 accepted_formats.push_back(GL_BGRA_EXT); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9667 if (format == static_cast<GLenum>(preferred_format) && | 9671 if (format == static_cast<GLenum>(preferred_format) && |
| 9668 type == static_cast<GLenum>(preferred_type)) { | 9672 type == static_cast<GLenum>(preferred_type)) { |
| 9669 format_type_acceptable = true; | 9673 format_type_acceptable = true; |
| 9670 } | 9674 } |
| 9671 } | 9675 } |
| 9672 if (!format_type_acceptable) { | 9676 if (!format_type_acceptable) { |
| 9673 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", | 9677 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", |
| 9674 "format and type incompatible with the current read framebuffer"); | 9678 "format and type incompatible with the current read framebuffer"); |
| 9675 return error::kNoError; | 9679 return error::kNoError; |
| 9676 } | 9680 } |
| 9681 if (type == GL_HALF_FLOAT_OES && |
| 9682 !(feature_info_->gl_version_info().is_es2)) { |
| 9683 type = GL_HALF_FLOAT; |
| 9684 } |
| 9677 if (width == 0 || height == 0) { | 9685 if (width == 0 || height == 0) { |
| 9678 return error::kNoError; | 9686 return error::kNoError; |
| 9679 } | 9687 } |
| 9680 | 9688 |
| 9681 // Get the size of the current fbo or backbuffer. | 9689 // Get the size of the current fbo or backbuffer. |
| 9682 gfx::Size max_size = GetBoundReadFrameBufferSize(); | 9690 gfx::Size max_size = GetBoundReadFrameBufferSize(); |
| 9683 | 9691 |
| 9684 int32_t max_x; | 9692 int32_t max_x; |
| 9685 int32_t max_y; | 9693 int32_t max_y; |
| 9686 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { | 9694 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { |
| (...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11787 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); | 11795 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); |
| 11788 return; | 11796 return; |
| 11789 } | 11797 } |
| 11790 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || | 11798 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || |
| 11791 border != 0) { | 11799 border != 0) { |
| 11792 LOCAL_SET_GL_ERROR( | 11800 LOCAL_SET_GL_ERROR( |
| 11793 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); | 11801 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); |
| 11794 return; | 11802 return; |
| 11795 } | 11803 } |
| 11796 | 11804 |
| 11797 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) { | 11805 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D", |
| 11806 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
| 11798 return; | 11807 return; |
| 11799 } | 11808 } |
| 11800 | 11809 |
| 11801 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 11810 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
| 11802 if (read_format == 0) { | 11811 if (read_format == 0) { |
| 11803 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", | 11812 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", |
| 11804 "no valid color image"); | 11813 "no valid color image"); |
| 11805 return; | 11814 return; |
| 11806 } | 11815 } |
| 11807 | 11816 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11986 GLenum type = 0; | 11995 GLenum type = 0; |
| 11987 GLenum format = 0; | 11996 GLenum format = 0; |
| 11988 if (!texture->GetLevelType(target, level, &type, &format) || | 11997 if (!texture->GetLevelType(target, level, &type, &format) || |
| 11989 !texture->ValidForTexture( | 11998 !texture->ValidForTexture( |
| 11990 target, level, xoffset, yoffset, 0, width, height, 1)) { | 11999 target, level, xoffset, yoffset, 0, width, height, 1)) { |
| 11991 LOCAL_SET_GL_ERROR( | 12000 LOCAL_SET_GL_ERROR( |
| 11992 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); | 12001 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); |
| 11993 return; | 12002 return; |
| 11994 } | 12003 } |
| 11995 | 12004 |
| 11996 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) { | 12005 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D", |
| 12006 GL_INVALID_FRAMEBUFFER_OPERATION)) { |
| 11997 return; | 12007 return; |
| 11998 } | 12008 } |
| 11999 | 12009 |
| 12000 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 12010 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
| 12001 if (read_format == 0) { | 12011 if (read_format == 0) { |
| 12002 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", | 12012 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", |
| 12003 "no valid color image"); | 12013 "no valid color image"); |
| 12004 return; | 12014 return; |
| 12005 } | 12015 } |
| 12006 // Check we have compatible formats. | 12016 // Check we have compatible formats. |
| (...skipping 4477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16484 } | 16494 } |
| 16485 | 16495 |
| 16486 // Include the auto-generated part of this file. We split this because it means | 16496 // Include the auto-generated part of this file. We split this because it means |
| 16487 // we can easily edit the non-auto generated parts right here in this file | 16497 // we can easily edit the non-auto generated parts right here in this file |
| 16488 // instead of having to edit some template or the code generator. | 16498 // instead of having to edit some template or the code generator. |
| 16489 #include "base/macros.h" | 16499 #include "base/macros.h" |
| 16490 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16500 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 16491 | 16501 |
| 16492 } // namespace gles2 | 16502 } // namespace gles2 |
| 16493 } // namespace gpu | 16503 } // namespace gpu |
| OLD | NEW |