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

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

Issue 1149233005: Re-land: gpu: Add GL_TEXTURE_RECTANGLE_ARB support to CopyTexSubImage2D optimization of CopyTexture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: v2 Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/gl_utils.h" 11 #include "gpu/command_buffer/service/gl_utils.h"
11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
12 13
13 #define SHADER(src) \ 14 #define SHADER(src) \
14 "#ifdef GL_ES\n" \ 15 "#ifdef GL_ES\n" \
15 "precision mediump float;\n" \ 16 "precision mediump float;\n" \
16 "#define TexCoordPrecision mediump\n" \ 17 "#define TexCoordPrecision mediump\n" \
17 "#else\n" \ 18 "#else\n" \
18 "#define TexCoordPrecision\n" \ 19 "#define TexCoordPrecision\n" \
19 "#endif\n" #src 20 "#endif\n" #src
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 GLuint source_id, 356 GLuint source_id,
356 GLenum source_internal_format, 357 GLenum source_internal_format,
357 GLuint dest_id, 358 GLuint dest_id,
358 GLenum dest_internal_format, 359 GLenum dest_internal_format,
359 GLsizei width, 360 GLsizei width,
360 GLsizei height, 361 GLsizei height,
361 bool flip_y, 362 bool flip_y,
362 bool premultiply_alpha, 363 bool premultiply_alpha,
363 bool unpremultiply_alpha) { 364 bool unpremultiply_alpha) {
364 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; 365 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
366 uint32_t source_channels = gles2::GLES2Util::GetChannelsForFormat(
367 source_internal_format);
368 uint32_t dest_channels = gles2::GLES2Util::GetChannelsForFormat(
369 dest_internal_format);
365 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's 370 // 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 371 // format does not contain a superset of the components required by the base
367 // format of internalformat. 372 // format of internalformat.
368 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml 373 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
369 bool source_format_contain_superset_of_dest_format = 374 bool source_format_contain_superset_of_dest_format =
370 (source_internal_format == dest_internal_format && 375 (source_channels & dest_channels) == dest_channels;
371 source_internal_format != GL_BGRA_EXT) || 376 // Note: GL_TEXTURE_RECTANGLE_ARB is only available if supported on FBOs.
372 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); 377 bool valid_source_target = source_target == GL_TEXTURE_2D ||
373 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, 378 source_target == GL_TEXTURE_RECTANGLE_ARB;
374 // so restrict this to GL_TEXTURE_2D. 379 bool valid_dest_internal_format = dest_internal_format == GL_ALPHA ||
375 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && 380 dest_internal_format == GL_RGB ||
376 source_format_contain_superset_of_dest_format) { 381 dest_internal_format == GL_RGBA;
382 if (valid_source_target && !flip_y && !premultiply_alpha_change &&
383 source_format_contain_superset_of_dest_format &&
384 valid_dest_internal_format) {
377 DoCopyTexImage2D(decoder, 385 DoCopyTexImage2D(decoder,
378 source_target, 386 source_target,
379 source_id, 387 source_id,
380 dest_id, 388 dest_id,
381 dest_internal_format, 389 dest_internal_format,
382 width, 390 width,
383 height, 391 height,
384 framebuffer_); 392 framebuffer_);
385 return; 393 return;
386 } 394 }
(...skipping 18 matching lines...) Expand all
405 GLsizei width, 413 GLsizei width,
406 GLsizei height, 414 GLsizei height,
407 GLsizei dest_width, 415 GLsizei dest_width,
408 GLsizei dest_height, 416 GLsizei dest_height,
409 GLsizei source_width, 417 GLsizei source_width,
410 GLsizei source_height, 418 GLsizei source_height,
411 bool flip_y, 419 bool flip_y,
412 bool premultiply_alpha, 420 bool premultiply_alpha,
413 bool unpremultiply_alpha) { 421 bool unpremultiply_alpha) {
414 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha; 422 bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
423 uint32_t source_channels = gles2::GLES2Util::GetChannelsForFormat(
424 source_internal_format);
425 uint32_t dest_channels = gles2::GLES2Util::GetChannelsForFormat(
426 dest_internal_format);
415 // GL_INVALID_OPERATION is generated if the currently bound framebuffer's 427 // 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 428 // format does not contain a superset of the components required by the base
417 // format of internalformat. 429 // format of internalformat.
418 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml 430 // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
419 bool source_format_contain_superset_of_dest_format = 431 bool source_format_contain_superset_of_dest_format =
420 (source_internal_format == dest_internal_format && 432 (source_channels & dest_channels) == dest_channels;
421 source_internal_format != GL_BGRA_EXT) || 433 // Note: GL_TEXTURE_RECTANGLE_ARB is only available if supported on FBOs.
422 (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB); 434 bool valid_source_target = source_target == GL_TEXTURE_2D ||
423 // GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2, 435 source_target == GL_TEXTURE_RECTANGLE_ARB;
424 // so restrict this to GL_TEXTURE_2D. 436 bool valid_dest_internal_format = dest_internal_format == GL_ALPHA ||
425 if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change && 437 dest_internal_format == GL_RGB ||
426 source_format_contain_superset_of_dest_format) { 438 dest_internal_format == GL_RGBA;
439 if (valid_source_target && !flip_y && !premultiply_alpha_change &&
440 source_format_contain_superset_of_dest_format &&
441 valid_dest_internal_format) {
427 DoCopyTexSubImage2D(decoder, source_target, source_id, dest_id, xoffset, 442 DoCopyTexSubImage2D(decoder, source_target, source_id, dest_id, xoffset,
428 yoffset, x, y, width, height, framebuffer_); 443 yoffset, x, y, width, height, framebuffer_);
429 return; 444 return;
430 } 445 }
431 446
432 DoCopyTextureInternal(decoder, source_target, source_id, dest_id, xoffset, 447 DoCopyTextureInternal(decoder, source_target, source_id, dest_id, xoffset,
433 yoffset, x, y, width, height, dest_width, dest_height, 448 yoffset, x, y, width, height, dest_width, dest_height,
434 source_width, source_height, flip_y, premultiply_alpha, 449 source_width, source_height, flip_y, premultiply_alpha,
435 unpremultiply_alpha, kIdentityMatrix); 450 unpremultiply_alpha, kIdentityMatrix);
436 } 451 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 decoder->RestoreTextureState(dest_id); 607 decoder->RestoreTextureState(dest_id);
593 decoder->RestoreTextureUnitBindings(0); 608 decoder->RestoreTextureUnitBindings(0);
594 decoder->RestoreActiveTexture(); 609 decoder->RestoreActiveTexture();
595 decoder->RestoreProgramBindings(); 610 decoder->RestoreProgramBindings();
596 decoder->RestoreBufferBindings(); 611 decoder->RestoreBufferBindings();
597 decoder->RestoreFramebufferBindings(); 612 decoder->RestoreFramebufferBindings();
598 decoder->RestoreGlobalState(); 613 decoder->RestoreGlobalState();
599 } 614 }
600 615
601 } // namespace gpu 616 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698