Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1929203003: Revert of Fix ReadPixels from float fbo buffer in ES2/WebGL1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 bool SetCapabilityState(GLenum cap, bool enabled); 1276 bool SetCapabilityState(GLenum cap, bool enabled);
1277 1277
1278 // Infer color encoding from internalformat 1278 // Infer color encoding from internalformat
1279 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat); 1279 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat);
1280 1280
1281 // Check that the currently bound read framebuffer's color image 1281 // Check that the currently bound read framebuffer's color image
1282 // isn't the target texture of the glCopyTex{Sub}Image2D. 1282 // isn't the target texture of the glCopyTex{Sub}Image2D.
1283 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); 1283 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
1284 1284
1285 // Check if a framebuffer meets our requirements. 1285 // Check if a framebuffer meets our requirements.
1286 // Generates |gl_error| if the framebuffer is incomplete.
1287 bool CheckFramebufferValid( 1286 bool CheckFramebufferValid(
1288 Framebuffer* framebuffer, 1287 Framebuffer* framebuffer,
1289 GLenum target, 1288 GLenum target,
1290 bool clear_uncleared_images, 1289 bool clear_uncleared_images,
1291 GLenum gl_error,
1292 const char* func_name); 1290 const char* func_name);
1293 1291
1294 bool CheckBoundDrawFramebufferValid( 1292 bool CheckBoundDrawFramebufferValid(
1295 bool clear_uncleared_images, const char* func_name); 1293 bool clear_uncleared_images, const char* func_name);
1296 // Generates |gl_error| if the bound read fbo is incomplete. 1294 bool CheckBoundReadFramebufferValid(const char* func_name);
1297 bool CheckBoundReadFramebufferValid(const char* func_name, GLenum gl_error);
1298 1295
1299 // Checks if the current program exists and is valid. If not generates the 1296 // Checks if the current program exists and is valid. If not generates the
1300 // appropriate GL error. Returns true if the current program is in a usable 1297 // appropriate GL error. Returns true if the current program is in a usable
1301 // state. 1298 // state.
1302 bool CheckCurrentProgram(const char* function_name); 1299 bool CheckCurrentProgram(const char* function_name);
1303 1300
1304 // Checks if the current program exists and is valid and that location is not 1301 // Checks if the current program exists and is valid and that location is not
1305 // -1. If the current program is not valid generates the appropriate GL 1302 // -1. If the current program is not valid generates the appropriate GL
1306 // error. Returns true if the current program is in a usable state and 1303 // error. Returns true if the current program is in a usable state and
1307 // location is not -1. 1304 // location is not -1.
(...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 framebuffer_state_.bound_draw_framebuffer.get(), 3717 framebuffer_state_.bound_draw_framebuffer.get(),
3721 GetBackbufferServiceId()); 3718 GetBackbufferServiceId());
3722 } 3719 }
3723 OnFboChanged(); 3720 OnFboChanged();
3724 } 3721 }
3725 3722
3726 bool GLES2DecoderImpl::CheckFramebufferValid( 3723 bool GLES2DecoderImpl::CheckFramebufferValid(
3727 Framebuffer* framebuffer, 3724 Framebuffer* framebuffer,
3728 GLenum target, 3725 GLenum target,
3729 bool clear_uncleared_images, 3726 bool clear_uncleared_images,
3730 GLenum gl_error,
3731 const char* func_name) { 3727 const char* func_name) {
3732 if (!framebuffer) { 3728 if (!framebuffer) {
3733 if (surfaceless_) 3729 if (surfaceless_)
3734 return false; 3730 return false;
3735 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) { 3731 if (backbuffer_needs_clear_bits_ && clear_uncleared_images) {
3736 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f); 3732 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f);
3737 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 3733 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3738 glClearStencil(0); 3734 glClearStencil(0);
3739 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); 3735 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
3740 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); 3736 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask);
(...skipping 19 matching lines...) Expand all
3760 } 3756 }
3761 return true; 3757 return true;
3762 } 3758 }
3763 3759
3764 if (framebuffer_manager()->IsComplete(framebuffer)) { 3760 if (framebuffer_manager()->IsComplete(framebuffer)) {
3765 return true; 3761 return true;
3766 } 3762 }
3767 3763
3768 GLenum completeness = framebuffer->IsPossiblyComplete(feature_info_.get()); 3764 GLenum completeness = framebuffer->IsPossiblyComplete(feature_info_.get());
3769 if (completeness != GL_FRAMEBUFFER_COMPLETE) { 3765 if (completeness != GL_FRAMEBUFFER_COMPLETE) {
3770 LOCAL_SET_GL_ERROR(gl_error, func_name, "framebuffer incomplete"); 3766 LOCAL_SET_GL_ERROR(
3767 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete");
3771 return false; 3768 return false;
3772 } 3769 }
3773 3770
3774 // Are all the attachments cleared? 3771 // Are all the attachments cleared?
3775 if (clear_uncleared_images && 3772 if (clear_uncleared_images &&
3776 (renderbuffer_manager()->HaveUnclearedRenderbuffers() || 3773 (renderbuffer_manager()->HaveUnclearedRenderbuffers() ||
3777 texture_manager()->HaveUnclearedMips())) { 3774 texture_manager()->HaveUnclearedMips())) {
3778 if (!framebuffer->IsCleared()) { 3775 if (!framebuffer->IsCleared()) {
3779 // Can we clear them? 3776 // Can we clear them?
3780 if (framebuffer->GetStatus(texture_manager(), target) != 3777 if (framebuffer->GetStatus(texture_manager(), target) !=
3781 GL_FRAMEBUFFER_COMPLETE) { 3778 GL_FRAMEBUFFER_COMPLETE) {
3782 LOCAL_SET_GL_ERROR( 3779 LOCAL_SET_GL_ERROR(
3783 gl_error, func_name, "framebuffer incomplete (clear)"); 3780 GL_INVALID_FRAMEBUFFER_OPERATION, func_name,
3781 "framebuffer incomplete (clear)");
3784 return false; 3782 return false;
3785 } 3783 }
3786 ClearUnclearedAttachments(target, framebuffer); 3784 ClearUnclearedAttachments(target, framebuffer);
3787 } 3785 }
3788 } 3786 }
3789 3787
3790 if (!framebuffer_manager()->IsComplete(framebuffer)) { 3788 if (!framebuffer_manager()->IsComplete(framebuffer)) {
3791 if (framebuffer->GetStatus(texture_manager(), target) != 3789 if (framebuffer->GetStatus(texture_manager(), target) !=
3792 GL_FRAMEBUFFER_COMPLETE) { 3790 GL_FRAMEBUFFER_COMPLETE) {
3793 LOCAL_SET_GL_ERROR( 3791 LOCAL_SET_GL_ERROR(
3794 gl_error, func_name, "framebuffer incomplete (check)"); 3792 GL_INVALID_FRAMEBUFFER_OPERATION, func_name,
3793 "framebuffer incomplete (check)");
3795 return false; 3794 return false;
3796 } 3795 }
3797 framebuffer_manager()->MarkAsComplete(framebuffer); 3796 framebuffer_manager()->MarkAsComplete(framebuffer);
3798 } 3797 }
3799 return true; 3798 return true;
3800 } 3799 }
3801 3800
3802 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid( 3801 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(
3803 bool clear_uncleared_images, const char* func_name) { 3802 bool clear_uncleared_images, const char* func_name) {
3804 GLenum target = features().chromium_framebuffer_multisample ? 3803 GLenum target = features().chromium_framebuffer_multisample ?
3805 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; 3804 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
3806 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); 3805 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
3807 bool valid = CheckFramebufferValid( 3806 bool valid = CheckFramebufferValid(
3808 framebuffer, target, clear_uncleared_images, 3807 framebuffer, target, clear_uncleared_images, func_name);
3809 GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
3810 if (valid && !features().chromium_framebuffer_multisample) 3808 if (valid && !features().chromium_framebuffer_multisample)
3811 OnUseFramebuffer(); 3809 OnUseFramebuffer();
3812 return valid; 3810 return valid;
3813 } 3811 }
3814 3812
3815 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( 3813 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(const char* func_name) {
3816 const char* func_name, GLenum gl_error) {
3817 GLenum target = features().chromium_framebuffer_multisample ? 3814 GLenum target = features().chromium_framebuffer_multisample ?
3818 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; 3815 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
3819 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); 3816 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
3820 bool valid = CheckFramebufferValid( 3817 bool valid = CheckFramebufferValid(framebuffer, target, true, func_name);
3821 framebuffer, target, true, gl_error, func_name);
3822 return valid; 3818 return valid;
3823 } 3819 }
3824 3820
3825 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( 3821 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
3826 GLenum internalformat) { 3822 GLenum internalformat) {
3827 switch (internalformat) { 3823 switch (internalformat) {
3828 case GL_SRGB_EXT: 3824 case GL_SRGB_EXT:
3829 case GL_SRGB_ALPHA_EXT: 3825 case GL_SRGB_ALPHA_EXT:
3830 case GL_SRGB8: 3826 case GL_SRGB8:
3831 case GL_SRGB8_ALPHA8: 3827 case GL_SRGB8_ALPHA8:
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
5251 } 5247 }
5252 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); 5248 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap");
5253 if (error == GL_NO_ERROR) { 5249 if (error == GL_NO_ERROR) {
5254 texture_manager()->MarkMipmapsGenerated(texture_ref); 5250 texture_manager()->MarkMipmapsGenerated(texture_ref);
5255 } 5251 }
5256 } 5252 }
5257 5253
5258 bool GLES2DecoderImpl::GetHelper( 5254 bool GLES2DecoderImpl::GetHelper(
5259 GLenum pname, GLint* params, GLsizei* num_written) { 5255 GLenum pname, GLint* params, GLsizei* num_written) {
5260 DCHECK(num_written); 5256 DCHECK(num_written);
5261 switch (pname) { 5257 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
5262 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: 5258 switch (pname) {
5263 case GL_IMPLEMENTATION_COLOR_READ_TYPE: 5259 case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
5264 // They are not supported on Desktop GL until 4.1, but could be exposed 5260 *num_written = 1;
5265 // through GL_OES_read_format extension. However, a conflicting extension 5261 // Return the GL implementation's preferred format and (see below type)
5266 // GL_ARB_ES2_compatibility specifies an error case when requested on 5262 // if we have the GL extension that exposes this. This allows the GPU
5267 // integer/floating point buffers. 5263 // client to use the implementation's preferred format for glReadPixels
5268 // To simpify the handling, we just query and check for GL errors. If an 5264 // for optimisation.
5269 // GL error occur, we fall back to our internal implementation. 5265 //
5270 *num_written = 1; 5266 // A conflicting extension (GL_ARB_ES2_compatibility) specifies an error
5271 if (!CheckBoundReadFramebufferValid("glGetIntegerv", 5267 // case when requested on integer/floating point buffers but which is
5272 GL_INVALID_OPERATION)) { 5268 // acceptable on GLES2 and with the GL_OES_read_format extension.
5269 //
5270 // Therefore if an error occurs we swallow the error and use the
5271 // internal implementation.
5273 if (params) { 5272 if (params) {
5274 *params = 0; 5273 if (context_->HasExtension("GL_OES_read_format")) {
5274 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5275 GetErrorState());
5276 glGetIntegerv(pname, params);
5277 if (glGetError() == GL_NO_ERROR)
5278 return true;
5279 }
5280 *params = GLES2Util::GetGLReadPixelsImplementationFormat(
5281 GetBoundReadFrameBufferInternalFormat(),
5282 GetBoundReadFrameBufferTextureType(),
5283 feature_info_->feature_flags().ext_read_format_bgra);
5275 } 5284 }
5276 return true; 5285 return true;
5277 } 5286 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
5278 if (params) { 5287 *num_written = 1;
5279 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper", 5288 if (params) {
5280 GetErrorState()); 5289 if (context_->HasExtension("GL_OES_read_format")) {
5281 glGetIntegerv(pname, params); 5290 ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
5282 if (glGetError() != GL_NO_ERROR) { 5291 GetErrorState());
5283 if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) { 5292 glGetIntegerv(pname, params);
5284 *params = GLES2Util::GetGLReadPixelsImplementationFormat( 5293 if (glGetError() == GL_NO_ERROR)
5285 GetBoundReadFrameBufferInternalFormat(), 5294 return true;
5286 GetBoundReadFrameBufferTextureType(),
5287 feature_info_->feature_flags().ext_read_format_bgra);
5288 } else {
5289 *params = GLES2Util::GetGLReadPixelsImplementationType(
5290 GetBoundReadFrameBufferInternalFormat(),
5291 GetBoundReadFrameBufferTextureType());
5292 } 5295 }
5296 *params = GLES2Util::GetGLReadPixelsImplementationType(
5297 GetBoundReadFrameBufferInternalFormat(),
5298 GetBoundReadFrameBufferTextureType());
5293 } 5299 }
5294 if (*params == GL_HALF_FLOAT && 5300 return true;
5295 (feature_info_->context_type() == CONTEXT_TYPE_WEBGL1 ||
5296 feature_info_->context_type() == CONTEXT_TYPE_OPENGLES2)) {
5297 *params = GL_HALF_FLOAT_OES;
5298 }
5299 }
5300 return true;
5301 default:
5302 break;
5303 }
5304
5305 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
5306 switch (pname) {
5307 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 5301 case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
5308 *num_written = 1; 5302 *num_written = 1;
5309 if (params) { 5303 if (params) {
5310 *params = group_->max_fragment_uniform_vectors(); 5304 *params = group_->max_fragment_uniform_vectors();
5311 } 5305 }
5312 return true; 5306 return true;
5313 case GL_MAX_VARYING_VECTORS: 5307 case GL_MAX_VARYING_VECTORS:
5314 *num_written = 1; 5308 *num_written = 1;
5315 if (params) { 5309 if (params) {
5316 *params = group_->max_varying_vectors(); 5310 *params = group_->max_varying_vectors();
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
6672 } 6666 }
6673 } 6667 }
6674 6668
6675 void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM( 6669 void GLES2DecoderImpl::DoBlitFramebufferCHROMIUM(
6676 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 6670 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
6677 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 6671 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
6678 GLbitfield mask, GLenum filter) { 6672 GLbitfield mask, GLenum filter) {
6679 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws()); 6673 DCHECK(!ShouldDeferReads() && !ShouldDeferDraws());
6680 6674
6681 if (!CheckBoundDrawFramebufferValid(true, "glBlitFramebufferCHROMIUM") || 6675 if (!CheckBoundDrawFramebufferValid(true, "glBlitFramebufferCHROMIUM") ||
6682 !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM", 6676 !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM")) {
6683 GL_INVALID_FRAMEBUFFER_OPERATION)) {
6684 return; 6677 return;
6685 } 6678 }
6686 6679
6687 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 6680 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
6688 BlitFramebufferHelper( 6681 BlitFramebufferHelper(
6689 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 6682 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
6690 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, 6683 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
6691 state_.enable_flags.scissor_test); 6684 state_.enable_flags.scissor_test);
6692 } 6685 }
6693 6686
(...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after
9463 9456
9464 if (!validators_->read_pixel_format.IsValid(format)) { 9457 if (!validators_->read_pixel_format.IsValid(format)) {
9465 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format"); 9458 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", format, "format");
9466 return error::kNoError; 9459 return error::kNoError;
9467 } 9460 }
9468 if (!validators_->read_pixel_type.IsValid(type)) { 9461 if (!validators_->read_pixel_type.IsValid(type)) {
9469 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type"); 9462 LOCAL_SET_GL_ERROR_INVALID_ENUM("glReadPixels", type, "type");
9470 return error::kNoError; 9463 return error::kNoError;
9471 } 9464 }
9472 9465
9473 if (!CheckBoundReadFramebufferValid("glReadPixels", 9466 if (!CheckBoundReadFramebufferValid("glReadPixels")) {
9474 GL_INVALID_FRAMEBUFFER_OPERATION)) {
9475 return error::kNoError; 9467 return error::kNoError;
9476 } 9468 }
9477 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat(); 9469 GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat();
9478 if (src_internal_format == 0) { 9470 if (src_internal_format == 0) {
9479 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", 9471 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9480 "no valid color image"); 9472 "no valid color image");
9481 return error::kNoError; 9473 return error::kNoError;
9482 } 9474 }
9483 std::vector<GLenum> accepted_formats; 9475 std::vector<GLenum> accepted_formats;
9484 std::vector<GLenum> accepted_types; 9476 std::vector<GLenum> accepted_types;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
9518 break; 9510 break;
9519 default: 9511 default:
9520 accepted_formats.push_back(GL_RGBA); 9512 accepted_formats.push_back(GL_RGBA);
9521 { 9513 {
9522 GLenum src_type = GetBoundReadFrameBufferTextureType(); 9514 GLenum src_type = GetBoundReadFrameBufferTextureType();
9523 switch (src_type) { 9515 switch (src_type) {
9524 case GL_HALF_FLOAT: 9516 case GL_HALF_FLOAT:
9525 case GL_HALF_FLOAT_OES: 9517 case GL_HALF_FLOAT_OES:
9526 case GL_FLOAT: 9518 case GL_FLOAT:
9527 case GL_UNSIGNED_INT_10F_11F_11F_REV: 9519 case GL_UNSIGNED_INT_10F_11F_11F_REV:
9528 accepted_types.push_back(GL_FLOAT); 9520 if (!feature_info_->IsES3Enabled()) {
9521 accepted_types.push_back(GL_UNSIGNED_BYTE);
9522 } else {
9523 accepted_types.push_back(GL_FLOAT);
9524 }
9529 break; 9525 break;
9530 default: 9526 default:
9531 accepted_types.push_back(GL_UNSIGNED_BYTE); 9527 accepted_types.push_back(GL_UNSIGNED_BYTE);
9532 break; 9528 break;
9533 } 9529 }
9534 } 9530 }
9535 break; 9531 break;
9536 } 9532 }
9537 if (!feature_info_->IsWebGLContext()) { 9533 if (!feature_info_->IsWebGLContext()) {
9538 accepted_formats.push_back(GL_BGRA_EXT); 9534 accepted_formats.push_back(GL_BGRA_EXT);
(...skipping 17 matching lines...) Expand all
9556 if (format == static_cast<GLenum>(preferred_format) && 9552 if (format == static_cast<GLenum>(preferred_format) &&
9557 type == static_cast<GLenum>(preferred_type)) { 9553 type == static_cast<GLenum>(preferred_type)) {
9558 format_type_acceptable = true; 9554 format_type_acceptable = true;
9559 } 9555 }
9560 } 9556 }
9561 if (!format_type_acceptable) { 9557 if (!format_type_acceptable) {
9562 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels", 9558 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
9563 "format and type incompatible with the current read framebuffer"); 9559 "format and type incompatible with the current read framebuffer");
9564 return error::kNoError; 9560 return error::kNoError;
9565 } 9561 }
9566 if (type == GL_HALF_FLOAT_OES &&
9567 !(feature_info_->gl_version_info().is_es2)) {
9568 type = GL_HALF_FLOAT;
9569 }
9570 if (width == 0 || height == 0) { 9562 if (width == 0 || height == 0) {
9571 return error::kNoError; 9563 return error::kNoError;
9572 } 9564 }
9573 9565
9574 // Get the size of the current fbo or backbuffer. 9566 // Get the size of the current fbo or backbuffer.
9575 gfx::Size max_size = GetBoundReadFrameBufferSize(); 9567 gfx::Size max_size = GetBoundReadFrameBufferSize();
9576 9568
9577 int32_t max_x; 9569 int32_t max_x;
9578 int32_t max_y; 9570 int32_t max_y;
9579 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { 9571 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) {
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after
11680 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); 11672 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable");
11681 return; 11673 return;
11682 } 11674 }
11683 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 11675 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
11684 border != 0) { 11676 border != 0) {
11685 LOCAL_SET_GL_ERROR( 11677 LOCAL_SET_GL_ERROR(
11686 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); 11678 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range");
11687 return; 11679 return;
11688 } 11680 }
11689 11681
11690 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D", 11682 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) {
11691 GL_INVALID_FRAMEBUFFER_OPERATION)) {
11692 return; 11683 return;
11693 } 11684 }
11694 11685
11695 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 11686 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
11696 if (read_format == 0) { 11687 if (read_format == 0) {
11697 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", 11688 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D",
11698 "no valid color image"); 11689 "no valid color image");
11699 return; 11690 return;
11700 } 11691 }
11701 11692
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
11880 GLenum type = 0; 11871 GLenum type = 0;
11881 GLenum format = 0; 11872 GLenum format = 0;
11882 if (!texture->GetLevelType(target, level, &type, &format) || 11873 if (!texture->GetLevelType(target, level, &type, &format) ||
11883 !texture->ValidForTexture( 11874 !texture->ValidForTexture(
11884 target, level, xoffset, yoffset, 0, width, height, 1)) { 11875 target, level, xoffset, yoffset, 0, width, height, 1)) {
11885 LOCAL_SET_GL_ERROR( 11876 LOCAL_SET_GL_ERROR(
11886 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); 11877 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions.");
11887 return; 11878 return;
11888 } 11879 }
11889 11880
11890 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D", 11881 if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) {
11891 GL_INVALID_FRAMEBUFFER_OPERATION)) {
11892 return; 11882 return;
11893 } 11883 }
11894 11884
11895 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 11885 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
11896 if (read_format == 0) { 11886 if (read_format == 0) {
11897 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D", 11887 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTexImage2D",
11898 "no valid color image"); 11888 "no valid color image");
11899 return; 11889 return;
11900 } 11890 }
11901 // Check we have compatible formats. 11891 // Check we have compatible formats.
(...skipping 4495 matching lines...) Expand 10 before | Expand all | Expand 10 after
16397 } 16387 }
16398 16388
16399 // Include the auto-generated part of this file. We split this because it means 16389 // Include the auto-generated part of this file. We split this because it means
16400 // we can easily edit the non-auto generated parts right here in this file 16390 // we can easily edit the non-auto generated parts right here in this file
16401 // instead of having to edit some template or the code generator. 16391 // instead of having to edit some template or the code generator.
16402 #include "base/macros.h" 16392 #include "base/macros.h"
16403 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16393 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16404 16394
16405 } // namespace gles2 16395 } // namespace gles2
16406 } // namespace gpu 16396 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698