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

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: Fix compile error. 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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 const char* function_name, GLenum target, GLint level, 1802 const char* function_name, GLenum target, GLint level,
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 ValidateCopyTextureCHROMIUMTextures(const char* function_name,
1815 GLenum target, 1813 TextureRef* source_texture_ref,
1816 TextureRef* source_texture_ref, 1814 TextureRef* dest_texture_ref);
1817 TextureRef* dest_texture_ref, 1815 bool ValidateCopyTextureCHROMIUMInternalFormats(
1818 GLenum dest_internal_format); 1816 const char* function_name,
1817 TextureRef* source_texture_ref,
1818 GLenum dest_internal_format);
1819 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, 1819 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
1820 GLenum target, 1820 GLenum target,
1821 TextureRef* source_texture_ref, 1821 TextureRef* source_texture_ref,
1822 TextureRef* dest_texture_ref); 1822 TextureRef* dest_texture_ref);
1823 1823
1824 void RenderWarning(const char* filename, int line, const std::string& msg); 1824 void RenderWarning(const char* filename, int line, const std::string& msg);
1825 void PerformanceWarning( 1825 void PerformanceWarning(
1826 const char* filename, int line, const std::string& msg); 1826 const char* filename, int line, const std::string& msg);
1827 1827
1828 const FeatureInfo::FeatureFlags& features() const { 1828 const FeatureInfo::FeatureFlags& features() const {
(...skipping 11231 matching lines...) Expand 10 before | Expand all | Expand 10 after
13060 texture_manager()->SetLevelInfo( 13060 texture_manager()->SetLevelInfo(
13061 texture_ref, target, 0, GL_RGBA, width, height, 1, 0, GL_BGRA, 13061 texture_ref, target, 0, GL_RGBA, width, height, 1, 0, GL_BGRA,
13062 GL_UNSIGNED_INT_8_8_8_8_REV, gfx::Rect(width, height)); 13062 GL_UNSIGNED_INT_8_8_8_8_REV, gfx::Rect(width, height));
13063 13063
13064 #else 13064 #else
13065 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 13065 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
13066 "glTexImageIOSurface2DCHROMIUM", "not supported."); 13066 "glTexImageIOSurface2DCHROMIUM", "not supported.");
13067 #endif 13067 #endif
13068 } 13068 }
13069 13069
13070 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM( 13070 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMTextures(
13071 const char* function_name, 13071 const char* function_name,
13072 GLenum target,
13073 TextureRef* source_texture_ref, 13072 TextureRef* source_texture_ref,
13074 TextureRef* dest_texture_ref, 13073 TextureRef* dest_texture_ref) {
13075 GLenum dest_internal_format) {
13076 if (!source_texture_ref || !dest_texture_ref) { 13074 if (!source_texture_ref || !dest_texture_ref) {
13077 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); 13075 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
13078 return false; 13076 return false;
13079 } 13077 }
13080 13078
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(); 13079 Texture* source_texture = source_texture_ref->texture();
13088 Texture* dest_texture = dest_texture_ref->texture(); 13080 Texture* dest_texture = dest_texture_ref->texture();
13089 if (source_texture == dest_texture) { 13081 if (source_texture == dest_texture) {
13090 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 13082 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
13091 "source and destination textures are the same"); 13083 "source and destination textures are the same");
13092 return false; 13084 return false;
13093 } 13085 }
13094 13086
13095 if (dest_texture->target() != GL_TEXTURE_2D || 13087 if (dest_texture->target() != GL_TEXTURE_2D ||
13096 (source_texture->target() != GL_TEXTURE_2D && 13088 (source_texture->target() != GL_TEXTURE_2D &&
13097 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && 13089 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
13098 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { 13090 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
13099 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, 13091 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
13100 "invalid texture target binding"); 13092 "invalid texture target binding");
13101 return false; 13093 return false;
13102 } 13094 }
13095 return true;
13096 }
13103 13097
13098 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
13099 const char* function_name,
13100 TextureRef* source_texture_ref,
13101 GLenum dest_internal_format) {
13104 GLenum source_type = 0; 13102 GLenum source_type = 0;
13105 GLenum source_internal_format = 0; 13103 GLenum source_internal_format = 0;
13104 Texture* source_texture = source_texture_ref->texture();
13106 source_texture->GetLevelType(source_texture->target(), 0, &source_type, 13105 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
13107 &source_internal_format); 13106 &source_internal_format);
13108 13107
13109 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, 13108 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA,
13110 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not 13109 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not
13111 // renderable on some platforms. 13110 // renderable on some platforms.
13112 bool valid_dest_format = dest_internal_format == GL_RGB || 13111 bool valid_dest_format = dest_internal_format == GL_RGB ||
13113 dest_internal_format == GL_RGBA || 13112 dest_internal_format == GL_RGBA ||
13114 dest_internal_format == GL_BGRA_EXT; 13113 dest_internal_format == GL_BGRA_EXT;
13115 bool valid_source_format = 13114 bool valid_source_format =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
13175 if (!valid_format) { 13174 if (!valid_format) {
13176 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 13175 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
13177 "invalid internal format"); 13176 "invalid internal format");
13178 return false; 13177 return false;
13179 } 13178 }
13180 13179
13181 return true; 13180 return true;
13182 } 13181 }
13183 13182
13184 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 13183 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
13185 GLenum target,
13186 GLuint source_id, 13184 GLuint source_id,
13187 GLuint dest_id, 13185 GLuint dest_id,
13188 GLenum internal_format, 13186 GLenum internal_format,
13189 GLenum dest_type, 13187 GLenum dest_type,
13190 GLboolean unpack_flip_y, 13188 GLboolean unpack_flip_y,
13191 GLboolean unpack_premultiply_alpha, 13189 GLboolean unpack_premultiply_alpha,
13192 GLboolean unpack_unmultiply_alpha) { 13190 GLboolean unpack_unmultiply_alpha) {
13193 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 13191 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
13194 13192
13195 TextureRef* source_texture_ref = GetTexture(source_id); 13193 TextureRef* source_texture_ref = GetTexture(source_id);
13196 TextureRef* dest_texture_ref = GetTexture(dest_id); 13194 TextureRef* dest_texture_ref = GetTexture(dest_id);
13197 13195
13198 if (!source_texture_ref || !dest_texture_ref) { 13196 if (!ValidateCopyTextureCHROMIUMTextures(
13199 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13197 "glCopyTextureCHROMIUM", source_texture_ref, dest_texture_ref)) {
13200 "unknown texture ids"); 13198 return;
13199 }
13200
13201 if (!ValidateCopyTextureCHROMIUMInternalFormats(
13202 "glCopyTextureCHROMIUM", source_texture_ref, internal_format)) {
13201 return; 13203 return;
13202 } 13204 }
13203 13205
13204 Texture* source_texture = source_texture_ref->texture(); 13206 Texture* source_texture = source_texture_ref->texture();
13205 Texture* dest_texture = dest_texture_ref->texture(); 13207 Texture* dest_texture = dest_texture_ref->texture();
13208 GLenum source_target = source_texture->target();
13209 GLenum dest_target = dest_texture->target();
13206 int source_width = 0; 13210 int source_width = 0;
13207 int source_height = 0; 13211 int source_height = 0;
13208 gl::GLImage* image = 13212 gl::GLImage* image =
13209 source_texture->GetLevelImage(source_texture->target(), 0); 13213 source_texture->GetLevelImage(source_target, 0);
13210 if (image) { 13214 if (image) {
13211 gfx::Size size = image->GetSize(); 13215 gfx::Size size = image->GetSize();
13212 source_width = size.width(); 13216 source_width = size.width();
13213 source_height = size.height(); 13217 source_height = size.height();
13214 if (source_width <= 0 || source_height <= 0) { 13218 if (source_width <= 0 || source_height <= 0) {
13215 LOCAL_SET_GL_ERROR( 13219 LOCAL_SET_GL_ERROR(
13216 GL_INVALID_VALUE, 13220 GL_INVALID_VALUE,
13217 "glCopyTextureChromium", "invalid image size"); 13221 "glCopyTextureChromium", "invalid image size");
13218 return; 13222 return;
13219 } 13223 }
13220 } else { 13224 } else {
13221 if (!source_texture->GetLevelSize(source_texture->target(), 0, 13225 if (!source_texture->GetLevelSize(source_target, 0,
13222 &source_width, &source_height, nullptr)) { 13226 &source_width, &source_height, nullptr)) {
13223 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, 13227 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
13224 "glCopyTextureChromium", 13228 "glCopyTextureChromium",
13225 "source texture has no level 0"); 13229 "source texture has no level 0");
13226 return; 13230 return;
13227 } 13231 }
13228 13232
13229 // Check that this type of texture is allowed. 13233 // Check that this type of texture is allowed.
13230 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, 13234 if (!texture_manager()->ValidForTarget(source_target, 0,
13231 source_width, source_height, 1)) { 13235 source_width, source_height, 1)) {
13232 LOCAL_SET_GL_ERROR( 13236 LOCAL_SET_GL_ERROR(
13233 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions"); 13237 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions");
13234 return; 13238 return;
13235 } 13239 }
13236 } 13240 }
13237 13241
13238 GLenum source_type = 0; 13242 GLenum source_type = 0;
13239 GLenum source_internal_format = 0; 13243 GLenum source_internal_format = 0;
13240 source_texture->GetLevelType( 13244 source_texture->GetLevelType(source_target, 0, &source_type,
13241 source_texture->target(), 0, &source_type, &source_internal_format); 13245 &source_internal_format);
13242 13246
13243 if (dest_texture->IsImmutable()) { 13247 if (dest_texture->IsImmutable()) {
13244 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM", 13248 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM",
13245 "texture is immutable"); 13249 "texture is immutable");
13246 return; 13250 return;
13247 } 13251 }
13248 13252
13249 if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", target,
13250 source_texture_ref, dest_texture_ref,
13251 internal_format)) {
13252 return;
13253 }
13254
13255 // Clear the source texture if necessary. 13253 // Clear the source texture if necessary.
13256 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 13254 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
13257 source_texture->target(), 0)) { 13255 source_target, 0)) {
13258 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", 13256 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM",
13259 "dimensions too big"); 13257 "dimensions too big");
13260 return; 13258 return;
13261 } 13259 }
13262 13260
13263 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 13261 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
13264 // needed because it takes 10s of milliseconds to initialize. 13262 // needed because it takes 10s of milliseconds to initialize.
13265 if (!copy_texture_CHROMIUM_.get()) { 13263 if (!copy_texture_CHROMIUM_.get()) {
13266 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 13264 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
13267 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 13265 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
13268 copy_texture_CHROMIUM_->Initialize(this); 13266 copy_texture_CHROMIUM_->Initialize(this);
13269 RestoreCurrentFramebufferBindings(); 13267 RestoreCurrentFramebufferBindings();
13270 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 13268 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
13271 return; 13269 return;
13272 } 13270 }
13273 13271
13274 GLenum dest_type_previous = dest_type; 13272 GLenum dest_type_previous = dest_type;
13275 GLenum dest_internal_format = internal_format; 13273 GLenum dest_internal_format = internal_format;
13276 int dest_width = 0; 13274 int dest_width = 0;
13277 int dest_height = 0; 13275 int dest_height = 0;
13278 bool dest_level_defined = dest_texture->GetLevelSize( 13276 bool dest_level_defined = dest_texture->GetLevelSize(
13279 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); 13277 dest_target, 0, &dest_width, &dest_height, nullptr);
13280 13278
13281 if (dest_level_defined) { 13279 if (dest_level_defined) {
13282 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous, 13280 dest_texture->GetLevelType(dest_target, 0, &dest_type_previous,
13283 &dest_internal_format); 13281 &dest_internal_format);
13284 } 13282 }
13285 13283
13286 // Resize the destination texture to the dimensions of the source texture. 13284 // Resize the destination texture to the dimensions of the source texture.
13287 if (!dest_level_defined || dest_width != source_width || 13285 if (!dest_level_defined || dest_width != source_width ||
13288 dest_height != source_height || 13286 dest_height != source_height ||
13289 dest_internal_format != internal_format || 13287 dest_internal_format != internal_format ||
13290 dest_type_previous != dest_type) { 13288 dest_type_previous != dest_type) {
13291 // Ensure that the glTexImage2D succeeds. 13289 // Ensure that the glTexImage2D succeeds.
13292 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 13290 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
13293 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 13291 glBindTexture(dest_target, dest_texture->service_id());
13294 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height, 13292 glTexImage2D(dest_target, 0, internal_format, source_width, source_height,
13295 0, internal_format, dest_type, NULL); 13293 0, internal_format, dest_type, NULL);
13296 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); 13294 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM");
13297 if (error != GL_NO_ERROR) { 13295 if (error != GL_NO_ERROR) {
13298 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); 13296 RestoreCurrentTextureBindings(&state_, dest_target);
13299 return; 13297 return;
13300 } 13298 }
13301 13299
13302 texture_manager()->SetLevelInfo( 13300 texture_manager()->SetLevelInfo(
13303 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width, 13301 dest_texture_ref, dest_target, 0, internal_format, source_width,
13304 source_height, 1, 0, internal_format, dest_type, 13302 source_height, 1, 0, internal_format, dest_type,
13305 gfx::Rect(source_width, source_height)); 13303 gfx::Rect(source_width, source_height));
13306 } else { 13304 } else {
13307 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, 13305 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0,
13308 true); 13306 true);
13309 } 13307 }
13310 13308
13311 // Try using GLImage::CopyTexImage when possible. 13309 // Try using GLImage::CopyTexImage when possible.
13312 bool unpack_premultiply_alpha_change = 13310 bool unpack_premultiply_alpha_change =
13313 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 13311 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
13314 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 13312 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
13315 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 13313 glBindTexture(dest_target, dest_texture->service_id());
13316 if (image->CopyTexImage(GL_TEXTURE_2D)) 13314 if (image->CopyTexImage(dest_target))
13317 return; 13315 return;
13318 } 13316 }
13319 13317
13320 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); 13318 DoCopyTexImageIfNeeded(source_texture, source_target);
13321 13319
13322 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 13320 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
13323 // before presenting. 13321 // before presenting.
13324 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 13322 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
13325 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 13323 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
13326 // instead of using kIdentityMatrix crbug.com/226218. 13324 // instead of using kIdentityMatrix crbug.com/226218.
13327 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 13325 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
13328 this, source_texture->target(), source_texture->service_id(), 13326 this, source_target, source_texture->service_id(),
13329 dest_texture->service_id(), source_width, source_height, 13327 dest_texture->service_id(), source_width, source_height,
13330 unpack_flip_y == GL_TRUE, 13328 unpack_flip_y == GL_TRUE,
13331 unpack_premultiply_alpha == GL_TRUE, 13329 unpack_premultiply_alpha == GL_TRUE,
13332 unpack_unmultiply_alpha == GL_TRUE, 13330 unpack_unmultiply_alpha == GL_TRUE,
13333 kIdentityMatrix); 13331 kIdentityMatrix);
13334 } else { 13332 } else {
13335 copy_texture_CHROMIUM_->DoCopyTexture( 13333 copy_texture_CHROMIUM_->DoCopyTexture(
13336 this, source_texture->target(), source_texture->service_id(), 13334 this, source_target, source_texture->service_id(),
13337 source_internal_format, dest_texture->service_id(), internal_format, 13335 source_internal_format, dest_texture->service_id(), internal_format,
13338 source_width, source_height, 13336 source_width, source_height,
13339 unpack_flip_y == GL_TRUE, 13337 unpack_flip_y == GL_TRUE,
13340 unpack_premultiply_alpha == GL_TRUE, 13338 unpack_premultiply_alpha == GL_TRUE,
13341 unpack_unmultiply_alpha == GL_TRUE); 13339 unpack_unmultiply_alpha == GL_TRUE);
13342 } 13340 }
13343 } 13341 }
13344 13342
13345 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 13343 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
13346 GLenum target,
13347 GLuint source_id, 13344 GLuint source_id,
13348 GLuint dest_id, 13345 GLuint dest_id,
13349 GLint xoffset, 13346 GLint xoffset,
13350 GLint yoffset, 13347 GLint yoffset,
13351 GLint x, 13348 GLint x,
13352 GLint y, 13349 GLint y,
13353 GLsizei width, 13350 GLsizei width,
13354 GLsizei height, 13351 GLsizei height,
13355 GLboolean unpack_flip_y, 13352 GLboolean unpack_flip_y,
13356 GLboolean unpack_premultiply_alpha, 13353 GLboolean unpack_premultiply_alpha,
13357 GLboolean unpack_unmultiply_alpha) { 13354 GLboolean unpack_unmultiply_alpha) {
13358 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM"); 13355 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM");
13359 13356
13360 TextureRef* source_texture_ref = GetTexture(source_id); 13357 TextureRef* source_texture_ref = GetTexture(source_id);
13361 TextureRef* dest_texture_ref = GetTexture(dest_id); 13358 TextureRef* dest_texture_ref = GetTexture(dest_id);
13362 13359
13363 if (!source_texture_ref || !dest_texture_ref) { 13360 if (!ValidateCopyTextureCHROMIUMTextures(
13364 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13361 "glCopySubTextureCHROMIUM", source_texture_ref, dest_texture_ref)) {
13365 "unknown texture ids");
13366 return; 13362 return;
13367 } 13363 }
13368 13364
13369 Texture* source_texture = source_texture_ref->texture(); 13365 Texture* source_texture = source_texture_ref->texture();
13370 Texture* dest_texture = dest_texture_ref->texture(); 13366 Texture* dest_texture = dest_texture_ref->texture();
13367 GLenum source_target = source_texture->target();
13368 GLenum dest_target = dest_texture->target();
13371 int source_width = 0; 13369 int source_width = 0;
13372 int source_height = 0; 13370 int source_height = 0;
13373 gl::GLImage* image = 13371 gl::GLImage* image =
13374 source_texture->GetLevelImage(source_texture->target(), 0); 13372 source_texture->GetLevelImage(source_target, 0);
13375 if (image) { 13373 if (image) {
13376 gfx::Size size = image->GetSize(); 13374 gfx::Size size = image->GetSize();
13377 source_width = size.width(); 13375 source_width = size.width();
13378 source_height = size.height(); 13376 source_height = size.height();
13379 if (source_width <= 0 || source_height <= 0) { 13377 if (source_width <= 0 || source_height <= 0) {
13380 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13378 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13381 "invalid image size"); 13379 "invalid image size");
13382 return; 13380 return;
13383 } 13381 }
13384 } else { 13382 } else {
13385 if (!source_texture->GetLevelSize(source_texture->target(), 0, 13383 if (!source_texture->GetLevelSize(source_target, 0,
13386 &source_width, &source_height, nullptr)) { 13384 &source_width, &source_height, nullptr)) {
13387 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13385 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13388 "source texture has no level 0"); 13386 "source texture has no level 0");
13389 return; 13387 return;
13390 } 13388 }
13391 13389
13392 // Check that this type of texture is allowed. 13390 // Check that this type of texture is allowed.
13393 if (!texture_manager()->ValidForTarget(source_texture->target(), 0, 13391 if (!texture_manager()->ValidForTarget(source_target, 0,
13394 source_width, source_height, 1)) { 13392 source_width, source_height, 1)) {
13395 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13393 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13396 "source texture bad dimensions"); 13394 "source texture bad dimensions");
13397 return; 13395 return;
13398 } 13396 }
13399 } 13397 }
13400 13398
13401 GLenum source_type = 0; 13399 GLenum source_type = 0;
13402 GLenum source_internal_format = 0; 13400 GLenum source_internal_format = 0;
13403 source_texture->GetLevelType(source_texture->target(), 0, &source_type, 13401 source_texture->GetLevelType(source_target, 0, &source_type,
13404 &source_internal_format); 13402 &source_internal_format);
13405 if (!source_texture->ValidForTexture(source_texture->target(), 0, x, y, 0, 13403 if (!source_texture->ValidForTexture(source_target, 0, x, y, 0,
13406 width, height, 1)) { 13404 width, height, 1)) {
13407 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13405 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13408 "source texture bad dimensions."); 13406 "source texture bad dimensions.");
13409 return; 13407 return;
13410 } 13408 }
13411 13409
13412 GLenum dest_type = 0; 13410 GLenum dest_type = 0;
13413 GLenum dest_internal_format = 0; 13411 GLenum dest_internal_format = 0;
13414 bool dest_level_defined = dest_texture->GetLevelType( 13412 bool dest_level_defined = dest_texture->GetLevelType(
13415 dest_texture->target(), 0, &dest_type, &dest_internal_format); 13413 dest_target, 0, &dest_type, &dest_internal_format);
13416 if (!dest_level_defined) { 13414 if (!dest_level_defined) {
13417 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM", 13415 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM",
13418 "destination texture is not defined"); 13416 "destination texture is not defined");
13419 return; 13417 return;
13420 } 13418 }
13421 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, 13419 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset,
13422 yoffset, 0, width, height, 1)) { 13420 yoffset, 0, width, height, 1)) {
13423 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM", 13421 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
13424 "destination texture bad dimensions."); 13422 "destination texture bad dimensions.");
13425 return; 13423 return;
13426 } 13424 }
13427 13425
13428 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target, 13426 if (!ValidateCopyTextureCHROMIUMInternalFormats("glCopySubTextureCHROMIUM",
13429 source_texture_ref, dest_texture_ref, 13427 source_texture_ref,
13430 dest_internal_format)) { 13428 dest_internal_format)) {
13431 return; 13429 return;
13432 } 13430 }
13433 13431
13434 // Clear the source texture if necessary. 13432 // Clear the source texture if necessary.
13435 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 13433 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
13436 source_texture->target(), 0)) { 13434 source_target, 0)) {
13437 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", 13435 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
13438 "source texture dimensions too big"); 13436 "source texture dimensions too big");
13439 return; 13437 return;
13440 } 13438 }
13441 13439
13442 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 13440 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
13443 // needed because it takes 10s of milliseconds to initialize. 13441 // needed because it takes 10s of milliseconds to initialize.
13444 if (!copy_texture_CHROMIUM_.get()) { 13442 if (!copy_texture_CHROMIUM_.get()) {
13445 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM"); 13443 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM");
13446 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 13444 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
13447 copy_texture_CHROMIUM_->Initialize(this); 13445 copy_texture_CHROMIUM_->Initialize(this);
13448 RestoreCurrentFramebufferBindings(); 13446 RestoreCurrentFramebufferBindings();
13449 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR) 13447 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR)
13450 return; 13448 return;
13451 } 13449 }
13452 13450
13453 int dest_width = 0; 13451 int dest_width = 0;
13454 int dest_height = 0; 13452 int dest_height = 0;
13455 bool ok = dest_texture->GetLevelSize( 13453 bool ok = dest_texture->GetLevelSize(
13456 GL_TEXTURE_2D, 0, &dest_width, &dest_height, nullptr); 13454 dest_target, 0, &dest_width, &dest_height, nullptr);
13457 DCHECK(ok); 13455 DCHECK(ok);
13458 if (xoffset != 0 || yoffset != 0 || width != dest_width || 13456 if (xoffset != 0 || yoffset != 0 || width != dest_width ||
13459 height != dest_height) { 13457 height != dest_height) {
13460 gfx::Rect cleared_rect; 13458 gfx::Rect cleared_rect;
13461 if (TextureManager::CombineAdjacentRects( 13459 if (TextureManager::CombineAdjacentRects(
13462 dest_texture->GetLevelClearedRect(target, 0), 13460 dest_texture->GetLevelClearedRect(dest_target, 0),
13463 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) { 13461 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) {
13464 DCHECK_GE(cleared_rect.size().GetArea(), 13462 DCHECK_GE(
13465 dest_texture->GetLevelClearedRect(target, 0).size().GetArea()); 13463 cleared_rect.size().GetArea(),
13466 texture_manager()->SetLevelClearedRect(dest_texture_ref, target, 0, 13464 dest_texture->GetLevelClearedRect(dest_target, 0).size().GetArea());
13465 texture_manager()->SetLevelClearedRect(dest_texture_ref, dest_target, 0,
13467 cleared_rect); 13466 cleared_rect);
13468 } else { 13467 } else {
13469 // Otherwise clear part of texture level that is not already cleared. 13468 // Otherwise clear part of texture level that is not already cleared.
13470 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target, 13469 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref,
13471 0)) { 13470 dest_target, 0)) {
13472 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM", 13471 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
13473 "destination texture dimensions too big"); 13472 "destination texture dimensions too big");
13474 return; 13473 return;
13475 } 13474 }
13476 } 13475 }
13477 } else { 13476 } else {
13478 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0, 13477 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0,
13479 true); 13478 true);
13480 } 13479 }
13481 13480
13482 // Try using GLImage::CopyTexSubImage when possible. 13481 // Try using GLImage::CopyTexSubImage when possible.
13483 bool unpack_premultiply_alpha_change = 13482 bool unpack_premultiply_alpha_change =
13484 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 13483 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
13485 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 13484 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
13486 ScopedTextureBinder binder( 13485 ScopedTextureBinder binder(
13487 &state_, dest_texture->service_id(), GL_TEXTURE_2D); 13486 &state_, dest_texture->service_id(), dest_target);
13488 if (image->CopyTexSubImage(GL_TEXTURE_2D, gfx::Point(xoffset, yoffset), 13487 if (image->CopyTexSubImage(dest_target, gfx::Point(xoffset, yoffset),
13489 gfx::Rect(x, y, width, height))) { 13488 gfx::Rect(x, y, width, height))) {
13490 return; 13489 return;
13491 } 13490 }
13492 } 13491 }
13493 13492
13494 DoCopyTexImageIfNeeded(source_texture, source_texture->target()); 13493 DoCopyTexImageIfNeeded(source_texture, source_target);
13495 13494
13496 // TODO(hkuang): get the StreamTexture transform matrix in GPU process. 13495 // TODO(hkuang): get the StreamTexture transform matrix in GPU process.
13497 // crbug.com/226218. 13496 // crbug.com/226218.
13498 copy_texture_CHROMIUM_->DoCopySubTexture( 13497 copy_texture_CHROMIUM_->DoCopySubTexture(
13499 this, source_texture->target(), source_texture->service_id(), 13498 this, source_target, source_texture->service_id(),
13500 source_internal_format, dest_texture->service_id(), dest_internal_format, 13499 source_internal_format, dest_texture->service_id(), dest_internal_format,
13501 xoffset, yoffset, x, y, width, height, dest_width, dest_height, 13500 xoffset, yoffset, x, y, width, height, dest_width, dest_height,
13502 source_width, source_height, 13501 source_width, source_height,
13503 unpack_flip_y == GL_TRUE, 13502 unpack_flip_y == GL_TRUE,
13504 unpack_premultiply_alpha == GL_TRUE, 13503 unpack_premultiply_alpha == GL_TRUE,
13505 unpack_unmultiply_alpha == GL_TRUE); 13504 unpack_unmultiply_alpha == GL_TRUE);
13506 } 13505 }
13507 13506
13508 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target, 13507 void GLES2DecoderImpl::DoCompressedCopyTextureCHROMIUM(GLenum target,
13509 GLuint source_id, 13508 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); 13559 source_texture->target(), 0, &source_type, &source_internal_format);
13561 13560
13562 if (dest_texture->IsImmutable()) { 13561 if (dest_texture->IsImmutable()) {
13563 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 13562 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
13564 "glCompressedCopyTextureCHROMIUM", 13563 "glCompressedCopyTextureCHROMIUM",
13565 "texture is immutable"); 13564 "texture is immutable");
13566 return; 13565 return;
13567 } 13566 }
13568 13567
13569 if (!ValidateCompressedCopyTextureCHROMIUM( 13568 if (!ValidateCompressedCopyTextureCHROMIUM(
13570 "glCompressedCopyTextureCHROMIUM", 13569 "glCompressedCopyTextureCHROMIUM", target,
13571 target,
13572 source_texture_ref, dest_texture_ref)) { 13570 source_texture_ref, dest_texture_ref)) {
13573 return; 13571 return;
13574 } 13572 }
13575 13573
13576 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 13574 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
13577 // needed because it takes 10s of milliseconds to initialize. 13575 // needed because it takes 10s of milliseconds to initialize.
13578 if (!copy_texture_CHROMIUM_.get()) { 13576 if (!copy_texture_CHROMIUM_.get()) {
13579 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 13577 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
13580 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 13578 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
13581 copy_texture_CHROMIUM_->Initialize(this); 13579 copy_texture_CHROMIUM_->Initialize(this);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
13757 } 13755 }
13758 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset, 13756 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset,
13759 yoffset, 0, width, height, 1)) { 13757 yoffset, 0, width, height, 1)) {
13760 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM", 13758 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCompressedCopySubTextureCHROMIUM",
13761 "destination texture bad dimensions."); 13759 "destination texture bad dimensions.");
13762 return; 13760 return;
13763 } 13761 }
13764 13762
13765 if (!ValidateCompressedCopyTextureCHROMIUM( 13763 if (!ValidateCompressedCopyTextureCHROMIUM(
13766 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref, 13764 "glCompressedCopySubTextureCHROMIUM", target, source_texture_ref,
13767 dest_texture_ref)) { 13765 dest_texture_ref)) {
13768 return; 13766 return;
13769 } 13767 }
13770 13768
13771 if (!ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM", 13769 if (!ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM",
13772 source_texture->target(), 0, x, y, 0, 13770 source_texture->target(), 0, x, y, 0,
13773 width, height, 1, 13771 width, height, 1,
13774 source_internal_format, 13772 source_internal_format,
13775 source_texture) || 13773 source_texture) ||
13776 !ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM", 13774 !ValidateCompressedTexSubDimensions("glCompressedCopySubTextureCHROMIUM",
13777 dest_texture->target(), 0, 13775 dest_texture->target(), 0,
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
15786 } 15784 }
15787 15785
15788 // Include the auto-generated part of this file. We split this because it means 15786 // 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 15787 // 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. 15788 // instead of having to edit some template or the code generator.
15791 #include "base/macros.h" 15789 #include "base/macros.h"
15792 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15790 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15793 15791
15794 } // namespace gles2 15792 } // namespace gles2
15795 } // namespace gpu 15793 } // 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