Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 source += "#extension GL_NV_EGL_stream_consumer_external : enable\n"; | 359 source += "#extension GL_NV_EGL_stream_consumer_external : enable\n"; |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 } else { | 362 } else { |
| 363 source += "#version 150\n"; | 363 source += "#version 150\n"; |
| 364 } | 364 } |
| 365 | 365 |
| 366 // Preamble for texture precision. | 366 // Preamble for texture precision. |
| 367 source += kShaderPrecisionPreamble; | 367 source += kShaderPrecisionPreamble; |
| 368 | 368 |
| 369 if (gpu::gles2::GLES2Util::IsSignedIntegerFormat(dest_format)) { | 369 // According to the spec, |dest_format| can be unsigend interger format, float |
| 370 source += "#define TextureType ivec4\n"; | 370 // format or unsigned normalized fixed-point format. |source_format| can only |
| 371 source += "#define ZERO 0\n"; | 371 // be unsigned normalized fixed-point format. |
| 372 source += "#define MAX_COLOR 255\n"; | 372 if (gpu::gles2::GLES2Util::IsUnsignedIntegerFormat(dest_format)) { |
| 373 if (gpu::gles2::GLES2Util::IsSignedIntegerFormat(source_format)) | |
| 374 source += "#define InnerScaleValue 1\n"; | |
| 375 else if (gpu::gles2::GLES2Util::IsUnsignedIntegerFormat(source_format)) | |
| 376 source += "#define InnerScaleValue 1u\n"; | |
| 377 else | |
| 378 source += "#define InnerScaleValue 255.0\n"; | |
| 379 source += "#define OuterScaleValue 1\n"; | |
| 380 } else if (gpu::gles2::GLES2Util::IsUnsignedIntegerFormat(dest_format)) { | |
| 381 source += "#define TextureType uvec4\n"; | 373 source += "#define TextureType uvec4\n"; |
| 382 source += "#define ZERO 0u\n"; | 374 source += "#define ZERO 0u\n"; |
| 383 source += "#define MAX_COLOR 255u\n"; | 375 source += "#define MAX_COLOR 255u\n"; |
| 384 if (gpu::gles2::GLES2Util::IsSignedIntegerFormat(source_format)) | 376 source += "#define InnerScaleValue 255.0\n"; |
| 385 source += "#define InnerScaleValue 1\n"; | |
| 386 else if (gpu::gles2::GLES2Util::IsUnsignedIntegerFormat(source_format)) | |
| 387 source += "#define InnerScaleValue 1u\n"; | |
| 388 else | |
| 389 source += "#define InnerScaleValue 255.0\n"; | |
| 390 source += "#define OuterScaleValue 1u\n"; | 377 source += "#define OuterScaleValue 1u\n"; |
| 391 } else { | 378 } else { |
|
Zhenyao Mo
2017/05/12 18:00:44
Can we add a DCHECK here to make sure we only get
jiajia.qin
2017/05/15 01:42:11
Done. I use DCHECK(!gpu::gles2::GLES2Util::IsInteg
| |
| 392 source += "#define TextureType vec4\n"; | 379 source += "#define TextureType vec4\n"; |
| 393 source += "#define ZERO 0.0\n"; | 380 source += "#define ZERO 0.0\n"; |
| 394 source += "#define MAX_COLOR 1.0\n"; | 381 source += "#define MAX_COLOR 1.0\n"; |
| 395 if (gpu::gles2::GLES2Util::IsSignedIntegerFormat(source_format)) { | 382 source += "#define InnerScaleValue 1.0\n"; |
| 396 source += "#define InnerScaleValue 1\n"; | 383 source += "#define OuterScaleValue 1.0\n"; |
| 397 source += "#define OuterScaleValue (1.0 / 255.0)\n"; | |
| 398 } else if (gpu::gles2::GLES2Util::IsUnsignedIntegerFormat(source_format)) { | |
| 399 source += "#define InnerScaleValue 1u\n"; | |
| 400 source += "#define OuterScaleValue (1.0 / 255.0)\n"; | |
| 401 } else { | |
| 402 source += "#define InnerScaleValue 1.0\n"; | |
| 403 source += "#define OuterScaleValue 1.0\n"; | |
| 404 } | |
| 405 } | 384 } |
| 406 if (gl_version_info.is_es2 || gl_version_info.IsLowerThanGL(3, 2) || | 385 if (gl_version_info.is_es2 || gl_version_info.IsLowerThanGL(3, 2) || |
| 407 target == GL_TEXTURE_EXTERNAL_OES) { | 386 target == GL_TEXTURE_EXTERNAL_OES) { |
| 408 switch (target) { | 387 switch (target) { |
| 409 case GL_TEXTURE_2D: | 388 case GL_TEXTURE_2D: |
| 410 case GL_TEXTURE_EXTERNAL_OES: | 389 case GL_TEXTURE_EXTERNAL_OES: |
| 411 source += "#define TextureLookup texture2D\n"; | 390 source += "#define TextureLookup texture2D\n"; |
| 412 break; | 391 break; |
| 413 default: | 392 default: |
| 414 NOTREACHED(); | 393 NOTREACHED(); |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1348 decoder->RestoreTextureUnitBindings(0); | 1327 decoder->RestoreTextureUnitBindings(0); |
| 1349 decoder->RestoreActiveTexture(); | 1328 decoder->RestoreActiveTexture(); |
| 1350 decoder->RestoreProgramBindings(); | 1329 decoder->RestoreProgramBindings(); |
| 1351 decoder->RestoreBufferBindings(); | 1330 decoder->RestoreBufferBindings(); |
| 1352 decoder->RestoreFramebufferBindings(); | 1331 decoder->RestoreFramebufferBindings(); |
| 1353 decoder->RestoreGlobalState(); | 1332 decoder->RestoreGlobalState(); |
| 1354 } | 1333 } |
| 1355 | 1334 |
| 1356 } // namespace gles2 | 1335 } // namespace gles2 |
| 1357 } // namespace gpu | 1336 } // namespace gpu |
| OLD | NEW |