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

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

Issue 1551143002: Remove the "target" argument from CopyTextureChromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated revision history. Created 4 years, 11 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 <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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 const void * data); 934 const void * data);
935 935
936 // Wrapper for TexImageIOSurface2DCHROMIUM. 936 // Wrapper for TexImageIOSurface2DCHROMIUM.
937 void DoTexImageIOSurface2DCHROMIUM( 937 void DoTexImageIOSurface2DCHROMIUM(
938 GLenum target, 938 GLenum target,
939 GLsizei width, 939 GLsizei width,
940 GLsizei height, 940 GLsizei height,
941 GLuint io_surface_id, 941 GLuint io_surface_id,
942 GLuint plane); 942 GLuint plane);
943 943
944 void DoCopyTextureCHROMIUM(GLenum target, 944 void DoCopyTextureCHROMIUM(GLuint source_id,
945 GLuint source_id,
946 GLuint dest_id, 945 GLuint dest_id,
947 GLenum internal_format, 946 GLenum internal_format,
948 GLenum dest_type, 947 GLenum dest_type,
949 GLboolean unpack_flip_y, 948 GLboolean unpack_flip_y,
950 GLboolean unpack_premultiply_alpha, 949 GLboolean unpack_premultiply_alpha,
951 GLboolean unpack_unmultiply_alpha); 950 GLboolean unpack_unmultiply_alpha);
952 951
953 void DoCopySubTextureCHROMIUM(GLenum target, 952 void DoCopySubTextureCHROMIUM(GLuint source_id,
954 GLuint source_id,
955 GLuint dest_id, 953 GLuint dest_id,
956 GLint xoffset, 954 GLint xoffset,
957 GLint yoffset, 955 GLint yoffset,
958 GLint x, 956 GLint x,
959 GLint y, 957 GLint y,
960 GLsizei width, 958 GLsizei width,
961 GLsizei height, 959 GLsizei height,
962 GLboolean unpack_flip_y, 960 GLboolean unpack_flip_y,
963 GLboolean unpack_premultiply_alpha, 961 GLboolean unpack_premultiply_alpha,
964 GLboolean unpack_unmultiply_alpha); 962 GLboolean unpack_unmultiply_alpha);
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 GLsizei width, GLsizei height, GLsizei depth, GLenum format); 1803 GLsizei width, GLsizei height, GLsizei depth, GLenum format);
1806 bool ValidateCompressedTexFuncData( 1804 bool ValidateCompressedTexFuncData(
1807 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, 1805 const char* function_name, GLsizei width, GLsizei height, GLsizei depth,
1808 GLenum format, GLsizei size); 1806 GLenum format, GLsizei size);
1809 bool ValidateCompressedTexSubDimensions( 1807 bool ValidateCompressedTexSubDimensions(
1810 const char* function_name, 1808 const char* function_name,
1811 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, 1809 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
1812 GLsizei width, GLsizei height, GLsizei depth, GLenum format, 1810 GLsizei width, GLsizei height, GLsizei depth, GLenum format,
1813 Texture* texture); 1811 Texture* texture);
1814 bool ValidateCopyTextureCHROMIUM(const char* function_name, 1812 bool ValidateCopyTextureCHROMIUM(const char* function_name,
1815 GLenum target,
1816 TextureRef* source_texture_ref, 1813 TextureRef* source_texture_ref,
1817 TextureRef* dest_texture_ref, 1814 TextureRef* dest_texture_ref,
1818 GLenum dest_internal_format); 1815 GLenum dest_internal_format);
1819 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, 1816 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
1820 GLenum target, 1817 GLenum target,
1821 TextureRef* source_texture_ref, 1818 TextureRef* source_texture_ref,
1822 TextureRef* dest_texture_ref); 1819 TextureRef* dest_texture_ref);
1823 1820
1824 void RenderWarning(const char* filename, int line, const std::string& msg); 1821 void RenderWarning(const char* filename, int line, const std::string& msg);
1825 void PerformanceWarning( 1822 void PerformanceWarning(
(...skipping 11236 matching lines...) Expand 10 before | Expand all | Expand 10 after
13062 GL_UNSIGNED_INT_8_8_8_8_REV, gfx::Rect(width, height)); 13059 GL_UNSIGNED_INT_8_8_8_8_REV, gfx::Rect(width, height));
13063 13060
13064 #else 13061 #else
13065 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 13062 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
13066 "glTexImageIOSurface2DCHROMIUM", "not supported."); 13063 "glTexImageIOSurface2DCHROMIUM", "not supported.");
13067 #endif 13064 #endif
13068 } 13065 }
13069 13066
13070 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM( 13067 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
13071 const char* function_name, 13068 const char* function_name,
13072 GLenum target,
13073 TextureRef* source_texture_ref, 13069 TextureRef* source_texture_ref,
13074 TextureRef* dest_texture_ref, 13070 TextureRef* dest_texture_ref,
13075 GLenum dest_internal_format) { 13071 GLenum dest_internal_format) {
13076 if (!source_texture_ref || !dest_texture_ref) { 13072 if (!source_texture_ref || !dest_texture_ref) {
13077 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); 13073 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
13078 return false; 13074 return false;
13079 } 13075 }
13080 13076
13081 if (GL_TEXTURE_2D != target) {
13082 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
13083 "invalid texture target");
13084 return false;
13085 }
13086
13087 Texture* source_texture = source_texture_ref->texture(); 13077 Texture* source_texture = source_texture_ref->texture();
13088 Texture* dest_texture = dest_texture_ref->texture(); 13078 Texture* dest_texture = dest_texture_ref->texture();
13089 if (source_texture == dest_texture) { 13079 if (source_texture == dest_texture) {
13090 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 13080 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
13091 "source and destination textures are the same"); 13081 "source and destination textures are the same");
13092 return false; 13082 return false;
13093 } 13083 }
13094 13084
13095 if (dest_texture->target() != GL_TEXTURE_2D || 13085 if (dest_texture->target() != GL_TEXTURE_2D ||
13096 (source_texture->target() != GL_TEXTURE_2D && 13086 (source_texture->target() != GL_TEXTURE_2D &&
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
13175 if (!valid_format) { 13165 if (!valid_format) {
13176 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 13166 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
13177 "invalid internal format"); 13167 "invalid internal format");
13178 return false; 13168 return false;
13179 } 13169 }
13180 13170
13181 return true; 13171 return true;
13182 } 13172 }
13183 13173
13184 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 13174 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
13185 GLenum target,
13186 GLuint source_id, 13175 GLuint source_id,
13187 GLuint dest_id, 13176 GLuint dest_id,
13188 GLenum internal_format, 13177 GLenum internal_format,
13189 GLenum dest_type, 13178 GLenum dest_type,
13190 GLboolean unpack_flip_y, 13179 GLboolean unpack_flip_y,
13191 GLboolean unpack_premultiply_alpha, 13180 GLboolean unpack_premultiply_alpha,
13192 GLboolean unpack_unmultiply_alpha) { 13181 GLboolean unpack_unmultiply_alpha) {
13193 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 13182 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
13194 13183
13195 TextureRef* source_texture_ref = GetTexture(source_id); 13184 TextureRef* source_texture_ref = GetTexture(source_id);
13196 TextureRef* dest_texture_ref = GetTexture(dest_id); 13185 TextureRef* dest_texture_ref = GetTexture(dest_id);
13197 13186
13198 if (!source_texture_ref || !dest_texture_ref) { 13187 if (!source_texture_ref || !dest_texture_ref) {
13199 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13188 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13200 "unknown texture ids"); 13189 "unknown texture ids");
13201 return; 13190 return;
13202 } 13191 }
13203 13192
13204 Texture* source_texture = source_texture_ref->texture(); 13193 Texture* source_texture = source_texture_ref->texture();
13205 Texture* dest_texture = dest_texture_ref->texture(); 13194 Texture* dest_texture = dest_texture_ref->texture();
13195 GLenum source_target = source_texture->target();
13196 GLenum dest_target = dest_texture->target();
piman 2016/01/05 00:21:09 These can be 0 if this is used before the texture
erikchen 2016/01/05 00:34:15 This is checked by ValidateCopyTextureChromium().
13206 int source_width = 0; 13197 int source_width = 0;
13207 int source_height = 0; 13198 int source_height = 0;
13208 gl::GLImage* image = 13199 gl::GLImage* image =
13209 source_texture->GetLevelImage(source_texture->target(), 0); 13200 source_texture->GetLevelImage(source_target, 0);
13210 if (image) { 13201 if (image) {
13211 gfx::Size size = image->GetSize(); 13202 gfx::Size size = image->GetSize();
13212 source_width = size.width(); 13203 source_width = size.width();
13213 source_height = size.height(); 13204 source_height = size.height();
13214 if (source_width <= 0 || source_height <= 0) { 13205 if (source_width <= 0 || source_height <= 0) {
13215 LOCAL_SET_GL_ERROR( 13206 LOCAL_SET_GL_ERROR(
13216 GL_INVALID_VALUE, 13207 GL_INVALID_VALUE,
13217 "glCopyTextureChromium", "invalid image size"); 13208 "glCopyTextureChromium", "invalid image size");
13218 return; 13209 return;
13219 } 13210 }
13220 } else { 13211 } else {
13221 if (!source_texture->GetLevelSize(source_texture->target(), 0, 13212 if (!source_texture->GetLevelSize(source_target, 0,
13222 &source_width, &source_height, nullptr)) { 13213 &source_width, &source_height, nullptr)) {
13223 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, 13214 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
13224 "glCopyTextureChromium", 13215 "glCopyTextureChromium",
13225 "source texture has no level 0"); 13216 "source texture has no level 0");
13226 return; 13217 return;
13227 } 13218 }
13228 13219
13229 // Check that this type of texture is allowed. 13220 // Check that this type of texture is allowed.
13230 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, 13221 if (!texture_manager()->ValidForTarget(source_target, 0,
13231 source_width, source_height, 1)) { 13222 source_width, source_height, 1)) {
13232 LOCAL_SET_GL_ERROR( 13223 LOCAL_SET_GL_ERROR(
13233 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions"); 13224 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions");
13234 return; 13225 return;
13235 } 13226 }
13236 } 13227 }
13237 13228
13238 GLenum source_type = 0; 13229 GLenum source_type = 0;
13239 GLenum source_internal_format = 0; 13230 GLenum source_internal_format = 0;
13240 source_texture->GetLevelType( 13231 source_texture->GetLevelType(source_target, 0, &source_type,
13241 source_texture->target(), 0, &source_type, &source_internal_format); 13232 &source_internal_format);
13242 13233
13243 if (dest_texture->IsImmutable()) { 13234 if (dest_texture->IsImmutable()) {
13244 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM", 13235 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM",
13245 "texture is immutable"); 13236 "texture is immutable");
13246 return; 13237 return;
13247 } 13238 }
13248 13239
13249 if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", target, 13240 if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", source_texture_ref,
13250 source_texture_ref, dest_texture_ref, 13241 dest_texture_ref, internal_format)) {
13251 internal_format)) {
13252 return; 13242 return;
13253 } 13243 }
13254 13244
13255 // Clear the source texture if necessary. 13245 // Clear the source texture if necessary.
13256 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 13246 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
13257 source_texture->target(), 0)) { 13247 source_target, 0)) {
13258 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", 13248 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM",
13259 "dimensions too big"); 13249 "dimensions too big");
13260 return; 13250 return;
13261 } 13251 }
13262 13252
13263 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 13253 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
13264 // needed because it takes 10s of milliseconds to initialize. 13254 // needed because it takes 10s of milliseconds to initialize.
13265 if (!copy_texture_CHROMIUM_.get()) { 13255 if (!copy_texture_CHROMIUM_.get()) {
13266 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 13256 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
13267 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 13257 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
13268 copy_texture_CHROMIUM_->Initialize(this); 13258 copy_texture_CHROMIUM_->Initialize(this);
13269 RestoreCurrentFramebufferBindings(); 13259 RestoreCurrentFramebufferBindings();
13270 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 13260 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
13271 return; 13261 return;
13272 } 13262 }
13273 13263
13274 GLenum dest_type_previous = dest_type; 13264 GLenum dest_type_previous = dest_type;
13275 GLenum dest_internal_format = internal_format; 13265 GLenum dest_internal_format = internal_format;
13276 int dest_width = 0; 13266 int dest_width = 0;
13277 int dest_height = 0; 13267 int dest_height = 0;
13278 bool dest_level_defined = dest_texture->GetLevelSize( 13268 bool dest_level_defined = dest_texture->GetLevelSize(
13279 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); 13269 dest_target, 0, &dest_width, &dest_height, nullptr);
13280 13270
13281 if (dest_level_defined) { 13271 if (dest_level_defined) {
13282 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous, 13272 dest_texture->GetLevelType(dest_target, 0, &dest_type_previous,
13283 &dest_internal_format); 13273 &dest_internal_format);
13284 } 13274 }
13285 13275
13286 // Resize the destination texture to the dimensions of the source texture. 13276 // Resize the destination texture to the dimensions of the source texture.
13287 if (!dest_level_defined || dest_width != source_width || 13277 if (!dest_level_defined || dest_width != source_width ||
13288 dest_height != source_height || 13278 dest_height != source_height ||
13289 dest_internal_format != internal_format || 13279 dest_internal_format != internal_format ||
13290 dest_type_previous != dest_type) { 13280 dest_type_previous != dest_type) {
13291 // Ensure that the glTexImage2D succeeds. 13281 // Ensure that the glTexImage2D succeeds.
13292 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 13282 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
13293 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 13283 glBindTexture(dest_target, dest_texture->service_id());
13294 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height, 13284 glTexImage2D(dest_target, 0, internal_format, source_width, source_height,
13295 0, internal_format, dest_type, NULL); 13285 0, internal_format, dest_type, NULL);
13296 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); 13286 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM");
13297 if (error != GL_NO_ERROR) { 13287 if (error != GL_NO_ERROR) {
13298 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); 13288 RestoreCurrentTextureBindings(&state_, dest_target);
13299 return; 13289 return;
13300 } 13290 }
13301 13291
13302 texture_manager()->SetLevelInfo( 13292 texture_manager()->SetLevelInfo(
13303 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, 13293 dest_texture_ref, dest_target, 0, internal_format, source_width,
13304 source_height, 1, 0, internal_format, dest_type, 13294 source_height, 1, 0, internal_format, dest_type,
13305 gfx::Rect(source_width, source_height)); 13295 gfx::Rect(source_width, source_height));
13306 } else { 13296 } else {
13307 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, 13297 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0,
13308 true); 13298 true);
13309 } 13299 }
13310 13300
13311 // Try using GLImage::CopyTexImage when possible. 13301 // Try using GLImage::CopyTexImage when possible.
13312 bool unpack_premultiply_alpha_change = 13302 bool unpack_premultiply_alpha_change =
13313 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 13303 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
13314 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 13304 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
13315 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 13305 glBindTexture(dest_target, dest_texture->service_id());
13316 if (image->CopyTexImage(GL_TEXTURE_2D)) 13306 if (image->CopyTexImage(dest_target))
13317 return; 13307 return;
13318 } 13308 }
13319 13309
13320 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); 13310 DoCopyTexImageIfNeeded(source_texture, source_target);
13321 13311
13322 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13312 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
13323 // before presenting. 13313 // before presenting.
13324 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 13314 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
13325 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 13315 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13326 // instead of using kIdentityMatrix crbug.com/226218. 13316 // instead of using kIdentityMatrix crbug.com/226218.
13327 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 13317 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13328 this, source_texture->target(), source_texture->service_id(), 13318 this, source_target, source_texture->service_id(),
13329 dest_texture->service_id(), source_width, source_height, 13319 dest_texture->service_id(), source_width, source_height,
13330 unpack_flip_y == GL_TRUE, 13320 unpack_flip_y == GL_TRUE,
13331 unpack_premultiply_alpha == GL_TRUE, 13321 unpack_premultiply_alpha == GL_TRUE,
13332 unpack_unmultiply_alpha == GL_TRUE, 13322 unpack_unmultiply_alpha == GL_TRUE,
13333 kIdentityMatrix); 13323 kIdentityMatrix);
13334 } else { 13324 } else {
13335 copy_texture_CHROMIUM_->DoCopyTexture( 13325 copy_texture_CHROMIUM_->DoCopyTexture(
13336 this, source_texture->target(), source_texture->service_id(), 13326 this, source_target, source_texture->service_id(),
13337 source_internal_format, dest_texture->service_id(), internal_format, 13327 source_internal_format, dest_texture->service_id(), internal_format,
13338 source_width, source_height, 13328 source_width, source_height,
13339 unpack_flip_y == GL_TRUE, 13329 unpack_flip_y == GL_TRUE,
13340 unpack_premultiply_alpha == GL_TRUE, 13330 unpack_premultiply_alpha == GL_TRUE,
13341 unpack_unmultiply_alpha == GL_TRUE); 13331 unpack_unmultiply_alpha == GL_TRUE);
13342 } 13332 }
13343 } 13333 }
13344 13334
13345 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 13335 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
13346 GLenum target,
13347 GLuint source_id, 13336 GLuint source_id,
13348 GLuint dest_id, 13337 GLuint dest_id,
13349 GLint xoffset, 13338 GLint xoffset,
13350 GLint yoffset, 13339 GLint yoffset,
13351 GLint x, 13340 GLint x,
13352 GLint y, 13341 GLint y,
13353 GLsizei width, 13342 GLsizei width,
13354 GLsizei height, 13343 GLsizei height,
13355 GLboolean unpack_flip_y, 13344 GLboolean unpack_flip_y,
13356 GLboolean unpack_premultiply_alpha, 13345 GLboolean unpack_premultiply_alpha,
13357 GLboolean unpack_unmultiply_alpha) { 13346 GLboolean unpack_unmultiply_alpha) {
13358 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); 13347 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM");
13359 13348
13360 TextureRef* source_texture_ref = GetTexture(source_id); 13349 TextureRef* source_texture_ref = GetTexture(source_id);
13361 TextureRef* dest_texture_ref = GetTexture(dest_id); 13350 TextureRef* dest_texture_ref = GetTexture(dest_id);
13362 13351
13363 if (!source_texture_ref || !dest_texture_ref) { 13352 if (!source_texture_ref || !dest_texture_ref) {
13364 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13353 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13365 "unknown texture ids"); 13354 "unknown texture ids");
13366 return; 13355 return;
13367 } 13356 }
13368 13357
13369 Texture* source_texture = source_texture_ref->texture(); 13358 Texture* source_texture = source_texture_ref->texture();
13370 Texture* dest_texture = dest_texture_ref->texture(); 13359 Texture* dest_texture = dest_texture_ref->texture();
13360 GLenum source_target = source_texture->target();
13361 GLenum dest_target = dest_texture->target();
piman 2016/01/05 00:21:10 Ditto.
erikchen 2016/01/05 00:34:15 Done.
13371 int source_width = 0; 13362 int source_width = 0;
13372 int source_height = 0; 13363 int source_height = 0;
13373 gl::GLImage* image = 13364 gl::GLImage* image =
13374 source_texture->GetLevelImage(source_texture->target(), 0); 13365 source_texture->GetLevelImage(source_target, 0);
13375 if (image) { 13366 if (image) {
13376 gfx::Size size = image->GetSize(); 13367 gfx::Size size = image->GetSize();
13377 source_width = size.width(); 13368 source_width = size.width();
13378 source_height = size.height(); 13369 source_height = size.height();
13379 if (source_width <= 0 || source_height <= 0) { 13370 if (source_width <= 0 || source_height <= 0) {
13380 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13371 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13381 "invalid image size"); 13372 "invalid image size");
13382 return; 13373 return;
13383 } 13374 }
13384 } else { 13375 } else {
13385 if (!source_texture->GetLevelSize(source_texture->target(), 0, 13376 if (!source_texture->GetLevelSize(source_target, 0,
13386 &source_width, &source_height, nullptr)) { 13377 &source_width, &source_height, nullptr)) {
13387 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13378 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13388 "source texture has no level 0"); 13379 "source texture has no level 0");
13389 return; 13380 return;
13390 } 13381 }
13391 13382
13392 // Check that this type of texture is allowed. 13383 // Check that this type of texture is allowed.
13393 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, 13384 if (!texture_manager()->ValidForTarget(source_target, 0,
13394 source_width, source_height, 1)) { 13385 source_width, source_height, 1)) {
13395 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13386 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13396 "source texture bad dimensions"); 13387 "source texture bad dimensions");
13397 return; 13388 return;
13398 } 13389 }
13399 } 13390 }
13400 13391
13401 GLenum source_type = 0; 13392 GLenum source_type = 0;
13402 GLenum source_internal_format = 0; 13393 GLenum source_internal_format = 0;
13403 source_texture->GetLevelType(source_texture->target(), 0, &source_type, 13394 source_texture->GetLevelType(source_target, 0, &source_type,
13404 &source_internal_format); 13395 &source_internal_format);
13405 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, 13396 if (!source_texture->ValidForTexture(source_target, 0, x, y, 0,
13406 width, height, 1)) { 13397 width, height, 1)) {
13407 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13398 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13408 "source texture bad dimensions."); 13399 "source texture bad dimensions.");
13409 return; 13400 return;
13410 } 13401 }
13411 13402
13412 GLenum dest_type = 0; 13403 GLenum dest_type = 0;
13413 GLenum dest_internal_format = 0; 13404 GLenum dest_internal_format = 0;
13414 bool dest_level_defined = dest_texture->GetLevelType( 13405 bool dest_level_defined = dest_texture->GetLevelType(
13415 dest_texture->target(), 0, &dest_type, &dest_internal_format); 13406 dest_target, 0, &dest_type, &dest_internal_format);
13416 if (!dest_level_defined) { 13407 if (!dest_level_defined) {
13417 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", 13408 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM",
13418 "destination texture is not defined"); 13409 "destination texture is not defined");
13419 return; 13410 return;
13420 } 13411 }
13421 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, 13412 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset,
13422 yoffset, 0, width, height, 1)) { 13413 yoffset, 0, width, height, 1)) {
13423 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13414 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13424 "destination texture bad dimensions."); 13415 "destination texture bad dimensions.");
13425 return; 13416 return;
13426 } 13417 }
13427 13418
13428 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, 13419 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM",
13429 source_texture_ref, dest_texture_ref, 13420 source_texture_ref, dest_texture_ref,
13430 dest_internal_format)) { 13421 dest_internal_format)) {
13431 return; 13422 return;
13432 } 13423 }
13433 13424
13434 // Clear the source texture if necessary. 13425 // Clear the source texture if necessary.
13435 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 13426 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
13436 source_texture->target(), 0)) { 13427 source_target, 0)) {
13437 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", 13428 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
13438 "source texture dimensions too big"); 13429 "source texture dimensions too big");
13439 return; 13430 return;
13440 } 13431 }
13441 13432
13442 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 13433 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
13443 // needed because it takes 10s of milliseconds to initialize. 13434 // needed because it takes 10s of milliseconds to initialize.
13444 if (!copy_texture_CHROMIUM_.get()) { 13435 if (!copy_texture_CHROMIUM_.get()) {
13445 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM"); 13436 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM");
13446 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 13437 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
13447 copy_texture_CHROMIUM_->Initialize(this); 13438 copy_texture_CHROMIUM_->Initialize(this);
13448 RestoreCurrentFramebufferBindings(); 13439 RestoreCurrentFramebufferBindings();
13449 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) 13440 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR)
13450 return; 13441 return;
13451 } 13442 }
13452 13443
13453 int dest_width = 0; 13444 int dest_width = 0;
13454 int dest_height = 0; 13445 int dest_height = 0;
13455 bool ok = dest_texture->GetLevelSize( 13446 bool ok = dest_texture->GetLevelSize(
13456 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); 13447 dest_target, 0, &dest_width, &dest_height, nullptr);
13457 DCHECK(ok); 13448 DCHECK(ok);
13458 if (xoffset != 0 || yoffset != 0 || width != dest_width || 13449 if (xoffset != 0 || yoffset != 0 || width != dest_width ||
13459 height != dest_height) { 13450 height != dest_height) {
13460 gfx::Rect cleared_rect; 13451 gfx::Rect cleared_rect;
13461 if (TextureManager::CombineAdjacentRects( 13452 if (TextureManager::CombineAdjacentRects(
13462 dest_texture->GetLevelClearedRect(target, 0), 13453 dest_texture->GetLevelClearedRect(dest_target, 0),
13463 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) { 13454 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) {
13464 DCHECK_GE(cleared_rect.size().GetArea(), 13455 DCHECK_GE(
13465 dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); 13456 cleared_rect.size().GetArea(),
13466 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, 13457 dest_texture->GetLevelClearedRect(dest_target, 0).size().GetArea());
13458 texture_manager()->SetLevelClearedRect(dest_texture_ref, dest_target, 0,
13467 cleared_rect); 13459 cleared_rect);
13468 } else { 13460 } else {
13469 // Otherwise clear part of texture level that is not already cleared. 13461 // Otherwise clear part of texture level that is not already cleared.
13470 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, 13462 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref,
13471 0)) { 13463 dest_target, 0)) {
13472 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", 13464 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
13473 "destination texture dimensions too big"); 13465 "destination texture dimensions too big");
13474 return; 13466 return;
13475 } 13467 }
13476 } 13468 }
13477 } else { 13469 } else {
13478 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, 13470 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0,
13479 true); 13471 true);
13480 } 13472 }
13481 13473
13482 // Try using GLImage::CopyTexSubImage when possible. 13474 // Try using GLImage::CopyTexSubImage when possible.
13483 bool unpack_premultiply_alpha_change = 13475 bool unpack_premultiply_alpha_change =
13484 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 13476 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
13485 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 13477 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
13486 ScopedTextureBinder binder( 13478 ScopedTextureBinder binder(
13487 &state_, dest_texture->service_id(), GL_TEXTURE_2D); 13479 &state_, dest_texture->service_id(), dest_target);
13488 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), 13480 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset),
13489 gfx::Rect(x, y, width, height))) { 13481 gfx::Rect(x, y, width, height))) {
13490 return; 13482 return;
13491 } 13483 }
13492 } 13484 }
13493 13485
13494 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); 13486 DoCopyTexImageIfNeeded(source_texture, source_target);
13495 13487
13496 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 13488 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
13497 // crbug.com/226218. 13489 // crbug.com/226218.
13498 copy_texture_CHROMIUM_->DoCopySubTexture( 13490 copy_texture_CHROMIUM_->DoCopySubTexture(
13499 this, source_texture->target(), source_texture->service_id(), 13491 this, source_target, source_texture->service_id(),
13500 source_internal_format, dest_texture->service_id(), dest_internal_format, 13492 source_internal_format, dest_texture->service_id(), dest_internal_format,
13501 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 13493 xoffset, yoffset, x, y, width, height, dest_width, dest_height,
13502 source_width, source_height, 13494 source_width, source_height,
13503 unpack_flip_y == GL_TRUE, 13495 unpack_flip_y == GL_TRUE,
13504 unpack_premultiply_alpha == GL_TRUE, 13496 unpack_premultiply_alpha == GL_TRUE,
13505 unpack_unmultiply_alpha == GL_TRUE); 13497 unpack_unmultiply_alpha == GL_TRUE);
13506 } 13498 }
13507 13499
13508 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, 13500 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
13509 GLuint source_id, 13501 GLuint source_id,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
13560 source_texture->target(), 0, &source_type, &source_internal_format); 13552 source_texture->target(), 0, &source_type, &source_internal_format);
13561 13553
13562 if (dest_texture->IsImmutable()) { 13554 if (dest_texture->IsImmutable()) {
13563 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 13555 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
13564 "glCompressedCopyTextureCHROMIUM", 13556 "glCompressedCopyTextureCHROMIUM",
13565 "texture is immutable"); 13557 "texture is immutable");
13566 return; 13558 return;
13567 } 13559 }
13568 13560
13569 if (!ValidateCompressedCopyTextureCHROMIUM( 13561 if (!ValidateCompressedCopyTextureCHROMIUM(
13570 "glCompressedCopyTextureCHROMIUM", 13562 "glCompressedCopyTextureCHROMIUM", target,
13571 target,
13572 source_texture_ref, dest_texture_ref)) { 13563 source_texture_ref, dest_texture_ref)) {
13573 return; 13564 return;
13574 } 13565 }
13575 13566
13576 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 13567 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
13577 // needed because it takes 10s of milliseconds to initialize. 13568 // needed because it takes 10s of milliseconds to initialize.
13578 if (!copy_texture_CHROMIUM_.get()) { 13569 if (!copy_texture_CHROMIUM_.get()) {
13579 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 13570 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
13580 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 13571 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
13581 copy_texture_CHROMIUM_->Initialize(this); 13572 copy_texture_CHROMIUM_->Initialize(this);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
13757 } 13748 }
13758 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, 13749 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset,
13759 yoffset, 0, width, height, 1)) { 13750 yoffset, 0, width, height, 1)) {
13760 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", 13751 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
13761 "destination texture bad dimensions."); 13752 "destination texture bad dimensions.");
13762 return; 13753 return;
13763 } 13754 }
13764 13755
13765 if (!ValidateCompressedCopyTextureCHROMIUM( 13756 if (!ValidateCompressedCopyTextureCHROMIUM(
13766 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref, 13757 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref,
13767 dest_texture_ref)) { 13758 dest_texture_ref)) {
13768 return; 13759 return;
13769 } 13760 }
13770 13761
13771 if (!ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM", 13762 if (!ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM",
13772 source_texture->target(), 0, x, y, 0, 13763 source_texture->target(), 0, x, y, 0,
13773 width, height, 1, 13764 width, height, 1,
13774 source_internal_format, 13765 source_internal_format,
13775 source_texture) || 13766 source_texture) ||
13776 !ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM", 13767 !ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM",
13777 dest_texture->target(), 0, 13768 dest_texture->target(), 0,
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
15786 } 15777 }
15787 15778
15788 // Include the auto-generated part of this file. We split this because it means 15779 // Include the auto-generated part of this file. We split this because it means
15789 // we can easily edit the non-auto generated parts right here in this file 15780 // we can easily edit the non-auto generated parts right here in this file
15790 // instead of having to edit some template or the code generator. 15781 // instead of having to edit some template or the code generator.
15791 #include "base/macros.h" 15782 #include "base/macros.h"
15792 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15783 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15793 15784
15794 } // namespace gles2 15785 } // namespace gles2
15795 } // namespace gpu 15786 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_format_test_autogen.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698