| 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_copy_texture_chromium.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "gpu/command_buffer/service/gl_utils.h" | 10 #include "gpu/command_buffer/service/gl_utils.h" |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 GLsizei height, | 360 GLsizei height, |
| 361 bool flip_y, | 361 bool flip_y, |
| 362 bool premultiply_alpha, | 362 bool premultiply_alpha, |
| 363 bool unpremultiply_alpha) { | 363 bool unpremultiply_alpha) { |
| 364 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; | 364 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
| 365 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's | 365 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's |
| 366 // format does not contain a superset of the components required by the base | 366 // format does not contain a superset of the components required by the base |
| 367 // format of internalformat. | 367 // format of internalformat. |
| 368 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml | 368 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml |
| 369 bool source_format_contain_superset_of_dest_format = | 369 bool source_format_contain_superset_of_dest_format = |
| 370 source_internal_format == dest_internal_format || | 370 (source_internal_format == dest_internal_format && |
| 371 source_internal_format != GL_BGRA_EXT) || |
| 371 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); | 372 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); |
| 372 // Note: GL_TEXTURE_RECTANGLE_ARB is only available if supported on FBOs. | 373 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, |
| 373 bool valid_source_target = source_target == GL_TEXTURE_2D || | 374 // so restrict this to GL_TEXTURE_2D. |
| 374 source_target == GL_TEXTURE_RECTANGLE_ARB; | 375 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && |
| 375 if (valid_source_target && !flip_y && !premultiply_alpha_change && | |
| 376 source_format_contain_superset_of_dest_format) { | 376 source_format_contain_superset_of_dest_format) { |
| 377 DoCopyTexImage2D(decoder, | 377 DoCopyTexImage2D(decoder, |
| 378 source_target, | 378 source_target, |
| 379 source_id, | 379 source_id, |
| 380 dest_id, | 380 dest_id, |
| 381 dest_internal_format, | 381 dest_internal_format, |
| 382 width, | 382 width, |
| 383 height, | 383 height, |
| 384 framebuffer_); | 384 framebuffer_); |
| 385 return; | 385 return; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 410 GLsizei source_height, | 410 GLsizei source_height, |
| 411 bool flip_y, | 411 bool flip_y, |
| 412 bool premultiply_alpha, | 412 bool premultiply_alpha, |
| 413 bool unpremultiply_alpha) { | 413 bool unpremultiply_alpha) { |
| 414 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; | 414 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; |
| 415 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's | 415 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's |
| 416 // format does not contain a superset of the components required by the base | 416 // format does not contain a superset of the components required by the base |
| 417 // format of internalformat. | 417 // format of internalformat. |
| 418 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml | 418 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml |
| 419 bool source_format_contain_superset_of_dest_format = | 419 bool source_format_contain_superset_of_dest_format = |
| 420 source_internal_format == dest_internal_format || | 420 (source_internal_format == dest_internal_format && |
| 421 source_internal_format != GL_BGRA_EXT) || |
| 421 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); | 422 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); |
| 422 // Note: GL_TEXTURE_RECTANGLE_ARB is only available if supported on FBOs. | 423 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, |
| 423 bool valid_source_target = source_target == GL_TEXTURE_2D || | 424 // so restrict this to GL_TEXTURE_2D. |
| 424 source_target == GL_TEXTURE_RECTANGLE_ARB; | 425 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && |
| 425 if (valid_source_target && !flip_y && !premultiply_alpha_change && | |
| 426 source_format_contain_superset_of_dest_format) { | 426 source_format_contain_superset_of_dest_format) { |
| 427 DoCopyTexSubImage2D(decoder, source_target, source_id, dest_id, xoffset, | 427 DoCopyTexSubImage2D(decoder, source_target, source_id, dest_id, xoffset, |
| 428 yoffset, x, y, width, height, framebuffer_); | 428 yoffset, x, y, width, height, framebuffer_); |
| 429 return; | 429 return; |
| 430 } | 430 } |
| 431 | 431 |
| 432 DoCopyTextureInternal(decoder, source_target, source_id, dest_id, xoffset - x, | 432 DoCopyTextureInternal(decoder, source_target, source_id, dest_id, xoffset - x, |
| 433 yoffset - y, dest_width, dest_height, source_width, | 433 yoffset - y, dest_width, dest_height, source_width, |
| 434 source_height, flip_y, premultiply_alpha, | 434 source_height, flip_y, premultiply_alpha, |
| 435 unpremultiply_alpha, kIdentityMatrix, xoffset, yoffset, | 435 unpremultiply_alpha, kIdentityMatrix, xoffset, yoffset, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 decoder->RestoreTextureState(dest_id); | 586 decoder->RestoreTextureState(dest_id); |
| 587 decoder->RestoreTextureUnitBindings(0); | 587 decoder->RestoreTextureUnitBindings(0); |
| 588 decoder->RestoreActiveTexture(); | 588 decoder->RestoreActiveTexture(); |
| 589 decoder->RestoreProgramBindings(); | 589 decoder->RestoreProgramBindings(); |
| 590 decoder->RestoreBufferBindings(); | 590 decoder->RestoreBufferBindings(); |
| 591 decoder->RestoreFramebufferBindings(); | 591 decoder->RestoreFramebufferBindings(); |
| 592 decoder->RestoreGlobalState(); | 592 decoder->RestoreGlobalState(); |
| 593 } | 593 } |
| 594 | 594 |
| 595 } // namespace gpu | 595 } // namespace gpu |
| OLD | NEW |