| 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 14337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14348 if (requires_luma_blit && | 14348 if (requires_luma_blit && |
| 14349 !InitializeCopyTexImageBlitter(func_name)) { | 14349 !InitializeCopyTexImageBlitter(func_name)) { |
| 14350 return; | 14350 return; |
| 14351 } | 14351 } |
| 14352 | 14352 |
| 14353 // Clip to size to source dimensions | 14353 // Clip to size to source dimensions |
| 14354 gfx::Rect src(x, y, width, height); | 14354 gfx::Rect src(x, y, width, height); |
| 14355 const gfx::Rect dst(0, 0, size.width(), size.height()); | 14355 const gfx::Rect dst(0, 0, size.width(), size.height()); |
| 14356 src.Intersect(dst); | 14356 src.Intersect(dst); |
| 14357 | 14357 |
| 14358 GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( |
| 14359 feature_info_.get(), internal_format); |
| 14360 if (workarounds().force_int_or_srgb_cube_texture_complete && |
| 14361 texture->target() == GL_TEXTURE_CUBE_MAP && |
| 14362 (GLES2Util::IsIntegerFormat(final_internal_format) || |
| 14363 GLES2Util::GetColorEncodingFromInternalFormat(final_internal_format) == |
| 14364 GL_SRGB)) { |
| 14365 TextureManager::DoTexImageArguments args = { |
| 14366 target, |
| 14367 level, |
| 14368 final_internal_format, |
| 14369 width, |
| 14370 height, |
| 14371 1, |
| 14372 border, |
| 14373 format, |
| 14374 type, |
| 14375 nullptr, |
| 14376 pixels_size, |
| 14377 0, |
| 14378 TextureManager::DoTexImageArguments::kTexImage2D}; |
| 14379 texture_manager()->WorkaroundCopyTexImageCubeMap( |
| 14380 &texture_state_, &state_, &framebuffer_state_, texture_ref, func_name, |
| 14381 args); |
| 14382 } |
| 14383 |
| 14358 if (src.x() != x || src.y() != y || | 14384 if (src.x() != x || src.y() != y || |
| 14359 src.width() != width || src.height() != height) { | 14385 src.width() != width || src.height() != height) { |
| 14360 { | 14386 { |
| 14361 // Add extra scope to destroy zero and the object it owns right | 14387 // Add extra scope to destroy zero and the object it owns right |
| 14362 // after its usage. | 14388 // after its usage. |
| 14363 // some part was clipped so clear the rect. | 14389 // some part was clipped so clear the rect. |
| 14364 | 14390 |
| 14365 std::unique_ptr<char[]> zero(new char[pixels_size]); | 14391 std::unique_ptr<char[]> zero(new char[pixels_size]); |
| 14366 memset(zero.get(), 0, pixels_size); | 14392 memset(zero.get(), 0, pixels_size); |
| 14367 glTexImage2D(target, level, TextureManager::AdjustTexInternalFormat( | 14393 glTexImage2D(target, level, final_internal_format, width, height, border, |
| 14368 feature_info_.get(), internal_format), | 14394 format, type, zero.get()); |
| 14369 width, height, border, format, type, zero.get()); | |
| 14370 } | 14395 } |
| 14371 | 14396 |
| 14372 if (!src.IsEmpty()) { | 14397 if (!src.IsEmpty()) { |
| 14373 GLint destX = src.x() - x; | 14398 GLint destX = src.x() - x; |
| 14374 GLint destY = src.y() - y; | 14399 GLint destY = src.y() - y; |
| 14375 if (requires_luma_blit) { | 14400 if (requires_luma_blit) { |
| 14376 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( | 14401 copy_tex_image_blit_->DoCopyTexSubImageToLUMACompatibilityTexture( |
| 14377 this, texture->service_id(), texture->target(), target, format, | 14402 this, texture->service_id(), texture->target(), target, format, |
| 14378 type, level, destX, destY, 0, | 14403 type, level, destX, destY, 0, |
| 14379 src.x(), src.y(), src.width(), src.height(), | 14404 src.x(), src.y(), src.width(), src.height(), |
| 14380 GetBoundReadFramebufferServiceId(), | 14405 GetBoundReadFramebufferServiceId(), |
| 14381 GetBoundReadFramebufferInternalFormat()); | 14406 GetBoundReadFramebufferInternalFormat()); |
| 14382 } else { | 14407 } else { |
| 14383 glCopyTexSubImage2D(target, level, destX, destY, | 14408 glCopyTexSubImage2D(target, level, destX, destY, |
| 14384 src.x(), src.y(), src.width(), src.height()); | 14409 src.x(), src.y(), src.width(), src.height()); |
| 14385 } | 14410 } |
| 14386 } | 14411 } |
| 14387 } else { | 14412 } else { |
| 14388 GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( | |
| 14389 feature_info_.get(), internal_format); | |
| 14390 if (workarounds().init_two_cube_map_levels_before_copyteximage && | 14413 if (workarounds().init_two_cube_map_levels_before_copyteximage && |
| 14391 texture->target() == GL_TEXTURE_CUBE_MAP && | 14414 texture->target() == GL_TEXTURE_CUBE_MAP && |
| 14392 target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { | 14415 target != GL_TEXTURE_CUBE_MAP_POSITIVE_X) { |
| 14393 for (int i = 0; i < 2; ++i) { | 14416 for (int i = 0; i < 2; ++i) { |
| 14394 TextureManager::DoTexImageArguments args = { | 14417 TextureManager::DoTexImageArguments args = { |
| 14395 target, i, final_internal_format, width, height, 1, border, | 14418 target, i, final_internal_format, width, height, 1, border, |
| 14396 format, type, nullptr, pixels_size, 0, | 14419 format, type, nullptr, pixels_size, 0, |
| 14397 TextureManager::DoTexImageArguments::kTexImage2D }; | 14420 TextureManager::DoTexImageArguments::kTexImage2D }; |
| 14398 texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, | 14421 texture_manager()->WorkaroundCopyTexImageCubeMap(&texture_state_, |
| 14399 &state_, &framebuffer_state_, texture_ref, func_name, args); | 14422 &state_, &framebuffer_state_, texture_ref, func_name, args); |
| (...skipping 5177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19577 } | 19600 } |
| 19578 | 19601 |
| 19579 // Include the auto-generated part of this file. We split this because it means | 19602 // Include the auto-generated part of this file. We split this because it means |
| 19580 // we can easily edit the non-auto generated parts right here in this file | 19603 // we can easily edit the non-auto generated parts right here in this file |
| 19581 // instead of having to edit some template or the code generator. | 19604 // instead of having to edit some template or the code generator. |
| 19582 #include "base/macros.h" | 19605 #include "base/macros.h" |
| 19583 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19606 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19584 | 19607 |
| 19585 } // namespace gles2 | 19608 } // namespace gles2 |
| 19586 } // namespace gpu | 19609 } // namespace gpu |
| OLD | NEW |