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

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

Issue 374193002: gpu: Optimize and cleanup code used for CHROMIUM_copy_texture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix window's webgl conformance test Created 6 years, 4 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 10037 matching lines...) Expand 10 before | Expand all | Expand 10 after
10048 // needed because it takes 10s of milliseconds to initialize. 10048 // needed because it takes 10s of milliseconds to initialize.
10049 if (!copy_texture_CHROMIUM_.get()) { 10049 if (!copy_texture_CHROMIUM_.get()) {
10050 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 10050 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
10051 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 10051 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
10052 copy_texture_CHROMIUM_->Initialize(this); 10052 copy_texture_CHROMIUM_->Initialize(this);
10053 RestoreCurrentFramebufferBindings(); 10053 RestoreCurrentFramebufferBindings();
10054 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 10054 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
10055 return; 10055 return;
10056 } 10056 }
10057 10057
10058 GLenum source_type = 0;
10059 GLenum source_internal_format = 0;
10060 source_texture->GetLevelType(
10061 source_texture->target(), 0, &source_type, &source_internal_format);
10062
10058 GLenum dest_type_previous = dest_type; 10063 GLenum dest_type_previous = dest_type;
10059 GLenum dest_internal_format = internal_format; 10064 GLenum dest_internal_format = internal_format;
10060 bool dest_level_defined = dest_texture->GetLevelSize( 10065 bool dest_level_defined = dest_texture->GetLevelSize(
10061 GL_TEXTURE_2D, level, &dest_width, &dest_height); 10066 GL_TEXTURE_2D, level, &dest_width, &dest_height);
10062 10067
10063 if (dest_level_defined) { 10068 if (dest_level_defined) {
10064 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, 10069 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous,
10065 &dest_internal_format); 10070 &dest_internal_format);
10066 } 10071 }
10067 10072
10073 // The format should be GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, or
10074 // GL_LUMINANCE_ALPHA.
10075 bool valid_source_format = source_internal_format >= GL_ALPHA &&
10076 source_internal_format <= GL_LUMINANCE_ALPHA;
10077 bool valid_dest_format = dest_internal_format >= GL_ALPHA &&
10078 dest_internal_format <= GL_LUMINANCE_ALPHA;
10079 if (!valid_source_format || !valid_dest_format) {
10080 LOCAL_SET_GL_ERROR(
10081 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid internal format");
10082 return;
10083 }
10084
10068 // Resize the destination texture to the dimensions of the source texture. 10085 // Resize the destination texture to the dimensions of the source texture.
10069 if (!dest_level_defined || dest_width != source_width || 10086 if (!dest_level_defined || dest_width != source_width ||
10070 dest_height != source_height || 10087 dest_height != source_height ||
10071 dest_internal_format != internal_format || 10088 dest_internal_format != internal_format ||
10072 dest_type_previous != dest_type) { 10089 dest_type_previous != dest_type) {
10073 // Ensure that the glTexImage2D succeeds. 10090 // Ensure that the glTexImage2D succeeds.
10074 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 10091 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
10075 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 10092 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
10076 glTexImage2D( 10093 glTexImage2D(
10077 GL_TEXTURE_2D, level, internal_format, source_width, source_height, 10094 GL_TEXTURE_2D, level, internal_format, source_width, source_height,
(...skipping 20 matching lines...) Expand all
10098 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 10115 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
10099 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 10116 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
10100 // instead of using default matrix crbug.com/226218. 10117 // instead of using default matrix crbug.com/226218.
10101 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 10118 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
10102 0.0f, 1.0f, 0.0f, 0.0f, 10119 0.0f, 1.0f, 0.0f, 0.0f,
10103 0.0f, 0.0f, 1.0f, 0.0f, 10120 0.0f, 0.0f, 1.0f, 0.0f,
10104 0.0f, 0.0f, 0.0f, 1.0f}; 10121 0.0f, 0.0f, 0.0f, 1.0f};
10105 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 10122 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
10106 this, 10123 this,
10107 source_texture->target(), 10124 source_texture->target(),
10108 dest_texture->target(),
10109 source_texture->service_id(), 10125 source_texture->service_id(),
10110 dest_texture->service_id(), level, 10126 dest_texture->service_id(),
10111 source_width, source_height, 10127 level,
10128 source_width,
10129 source_height,
10112 unpack_flip_y_, 10130 unpack_flip_y_,
10113 unpack_premultiply_alpha_, 10131 unpack_premultiply_alpha_,
10114 unpack_unpremultiply_alpha_, 10132 unpack_unpremultiply_alpha_,
10115 default_matrix); 10133 default_matrix);
10116 } else { 10134 } else {
10117 copy_texture_CHROMIUM_->DoCopyTexture( 10135 copy_texture_CHROMIUM_->DoCopyTexture(this,
10118 this, 10136 source_texture->target(),
10119 source_texture->target(), 10137 source_texture->service_id(),
10120 dest_texture->target(), 10138 source_internal_format,
10121 source_texture->service_id(), 10139 dest_texture->service_id(),
10122 dest_texture->service_id(), level, 10140 level,
10123 source_width, source_height, 10141 internal_format,
10124 unpack_flip_y_, 10142 source_width,
10125 unpack_premultiply_alpha_, 10143 source_height,
10126 unpack_unpremultiply_alpha_); 10144 unpack_flip_y_,
10145 unpack_premultiply_alpha_,
10146 unpack_unpremultiply_alpha_);
10127 } 10147 }
10128 10148
10129 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 10149 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
10130 } 10150 }
10131 10151
10132 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 10152 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
10133 switch (internalformat) { 10153 switch (internalformat) {
10134 case GL_RGB565: 10154 case GL_RGB565:
10135 return GL_UNSIGNED_SHORT_5_6_5; 10155 return GL_UNSIGNED_SHORT_5_6_5;
10136 case GL_RGBA4: 10156 case GL_RGBA4:
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
10932 } 10952 }
10933 } 10953 }
10934 10954
10935 // Include the auto-generated part of this file. We split this because it means 10955 // Include the auto-generated part of this file. We split this because it means
10936 // we can easily edit the non-auto generated parts right here in this file 10956 // we can easily edit the non-auto generated parts right here in this file
10937 // instead of having to edit some template or the code generator. 10957 // instead of having to edit some template or the code generator.
10938 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10958 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10939 10959
10940 } // namespace gles2 10960 } // namespace gles2
10941 } // namespace gpu 10961 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698