| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_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 23 matching lines...) Expand all Loading... |
| 34 #include "gpu/command_buffer/service/buffer_manager.h" | 34 #include "gpu/command_buffer/service/buffer_manager.h" |
| 35 #include "gpu/command_buffer/service/context_group.h" | 35 #include "gpu/command_buffer/service/context_group.h" |
| 36 #include "gpu/command_buffer/service/context_state.h" | 36 #include "gpu/command_buffer/service/context_state.h" |
| 37 #include "gpu/command_buffer/service/error_state.h" | 37 #include "gpu/command_buffer/service/error_state.h" |
| 38 #include "gpu/command_buffer/service/feature_info.h" | 38 #include "gpu/command_buffer/service/feature_info.h" |
| 39 #include "gpu/command_buffer/service/framebuffer_manager.h" | 39 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 40 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 40 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
| 41 #include "gpu/command_buffer/service/gl_utils.h" | 41 #include "gpu/command_buffer/service/gl_utils.h" |
| 42 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" | 42 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" |
| 43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 44 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" |
| 44 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" | 45 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" |
| 45 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 46 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 46 #include "gpu/command_buffer/service/gpu_preferences.h" | 47 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 47 #include "gpu/command_buffer/service/gpu_state_tracer.h" | 48 #include "gpu/command_buffer/service/gpu_state_tracer.h" |
| 48 #include "gpu/command_buffer/service/gpu_tracer.h" | 49 #include "gpu/command_buffer/service/gpu_tracer.h" |
| 49 #include "gpu/command_buffer/service/image_manager.h" | 50 #include "gpu/command_buffer/service/image_manager.h" |
| 50 #include "gpu/command_buffer/service/logger.h" | 51 #include "gpu/command_buffer/service/logger.h" |
| 51 #include "gpu/command_buffer/service/mailbox_manager.h" | 52 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 52 #include "gpu/command_buffer/service/memory_tracking.h" | 53 #include "gpu/command_buffer/service/memory_tracking.h" |
| 53 #include "gpu/command_buffer/service/path_manager.h" | 54 #include "gpu/command_buffer/service/path_manager.h" |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 GLuint* source_texture_service_id, | 1982 GLuint* source_texture_service_id, |
| 1982 GLenum* source_texture_target); | 1983 GLenum* source_texture_target); |
| 1983 | 1984 |
| 1984 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment | 1985 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment |
| 1985 // is an IOSurface-backed texture causes corruption of future glReadPixels() | 1986 // is an IOSurface-backed texture causes corruption of future glReadPixels() |
| 1986 // calls, even those on different OpenGL contexts. It is believed that this | 1987 // calls, even those on different OpenGL contexts. It is believed that this |
| 1987 // is the root cause of top crasher | 1988 // is the root cause of top crasher |
| 1988 // http://crbug.com/99393. <rdar://problem/10949687> | 1989 // http://crbug.com/99393. <rdar://problem/10949687> |
| 1989 bool NeedsIOSurfaceReadbackWorkaround(); | 1990 bool NeedsIOSurfaceReadbackWorkaround(); |
| 1990 | 1991 |
| 1992 bool InitializeCopyTexImageBlitter(const char* function_name); |
| 1991 bool InitializeCopyTextureCHROMIUM(const char* function_name); | 1993 bool InitializeCopyTextureCHROMIUM(const char* function_name); |
| 1992 // Generate a member function prototype for each command in an automated and | 1994 // Generate a member function prototype for each command in an automated and |
| 1993 // typesafe way. | 1995 // typesafe way. |
| 1994 #define GLES2_CMD_OP(name) \ | 1996 #define GLES2_CMD_OP(name) \ |
| 1995 Error Handle##name(uint32_t immediate_data_size, const void* data); | 1997 Error Handle##name(uint32_t immediate_data_size, const void* data); |
| 1996 | 1998 |
| 1997 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1999 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
| 1998 | 2000 |
| 1999 #undef GLES2_CMD_OP | 2001 #undef GLES2_CMD_OP |
| 2000 | 2002 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2166 bool lose_context_when_out_of_memory_; | 2168 bool lose_context_when_out_of_memory_; |
| 2167 | 2169 |
| 2168 // Log extra info. | 2170 // Log extra info. |
| 2169 bool service_logging_; | 2171 bool service_logging_; |
| 2170 | 2172 |
| 2171 #if defined(OS_MACOSX) | 2173 #if defined(OS_MACOSX) |
| 2172 typedef std::map<GLuint, IOSurfaceRef> TextureToIOSurfaceMap; | 2174 typedef std::map<GLuint, IOSurfaceRef> TextureToIOSurfaceMap; |
| 2173 TextureToIOSurfaceMap texture_to_io_surface_map_; | 2175 TextureToIOSurfaceMap texture_to_io_surface_map_; |
| 2174 #endif | 2176 #endif |
| 2175 | 2177 |
| 2178 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; |
| 2176 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | 2179 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
| 2177 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; | 2180 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; |
| 2178 | 2181 |
| 2179 // Cached values of the currently assigned viewport dimensions. | 2182 // Cached values of the currently assigned viewport dimensions. |
| 2180 GLsizei viewport_max_width_; | 2183 GLsizei viewport_max_width_; |
| 2181 GLsizei viewport_max_height_; | 2184 GLsizei viewport_max_height_; |
| 2182 | 2185 |
| 2183 // Command buffer stats. | 2186 // Command buffer stats. |
| 2184 base::TimeDelta total_processing_commands_time_; | 2187 base::TimeDelta total_processing_commands_time_; |
| 2185 | 2188 |
| (...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4230 | 4233 |
| 4231 if (offscreen_saved_color_texture_info_.get()) { | 4234 if (offscreen_saved_color_texture_info_.get()) { |
| 4232 DCHECK(offscreen_saved_color_texture_); | 4235 DCHECK(offscreen_saved_color_texture_); |
| 4233 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), | 4236 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), |
| 4234 offscreen_saved_color_texture_->id()); | 4237 offscreen_saved_color_texture_->id()); |
| 4235 offscreen_saved_color_texture_->Invalidate(); | 4238 offscreen_saved_color_texture_->Invalidate(); |
| 4236 offscreen_saved_color_texture_info_ = NULL; | 4239 offscreen_saved_color_texture_info_ = NULL; |
| 4237 } | 4240 } |
| 4238 ReleaseAllBackTextures(); | 4241 ReleaseAllBackTextures(); |
| 4239 if (have_context) { | 4242 if (have_context) { |
| 4243 if (copy_tex_image_blit_.get()) { |
| 4244 copy_tex_image_blit_->Destroy(); |
| 4245 copy_tex_image_blit_.reset(); |
| 4246 } |
| 4247 |
| 4240 if (copy_texture_CHROMIUM_.get()) { | 4248 if (copy_texture_CHROMIUM_.get()) { |
| 4241 copy_texture_CHROMIUM_->Destroy(); | 4249 copy_texture_CHROMIUM_->Destroy(); |
| 4242 copy_texture_CHROMIUM_.reset(); | 4250 copy_texture_CHROMIUM_.reset(); |
| 4243 } | 4251 } |
| 4244 | 4252 |
| 4245 clear_framebuffer_blit_.reset(); | 4253 clear_framebuffer_blit_.reset(); |
| 4246 | 4254 |
| 4247 if (state_.current_program.get()) { | 4255 if (state_.current_program.get()) { |
| 4248 program_manager()->UnuseProgram(shader_manager(), | 4256 program_manager()->UnuseProgram(shader_manager(), |
| 4249 state_.current_program.get()); | 4257 state_.current_program.get()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4301 offscreen_resolved_color_texture_->Invalidate(); | 4309 offscreen_resolved_color_texture_->Invalidate(); |
| 4302 } | 4310 } |
| 4303 | 4311 |
| 4304 // Current program must be cleared after calling ProgramManager::UnuseProgram. | 4312 // Current program must be cleared after calling ProgramManager::UnuseProgram. |
| 4305 // Otherwise, we can leak objects. http://crbug.com/258772. | 4313 // Otherwise, we can leak objects. http://crbug.com/258772. |
| 4306 // state_.current_program must be reset before group_ is reset because | 4314 // state_.current_program must be reset before group_ is reset because |
| 4307 // the later deletes the ProgramManager object that referred by | 4315 // the later deletes the ProgramManager object that referred by |
| 4308 // state_.current_program object. | 4316 // state_.current_program object. |
| 4309 state_.current_program = NULL; | 4317 state_.current_program = NULL; |
| 4310 | 4318 |
| 4319 copy_tex_image_blit_.reset(); |
| 4311 copy_texture_CHROMIUM_.reset(); | 4320 copy_texture_CHROMIUM_.reset(); |
| 4312 clear_framebuffer_blit_.reset(); | 4321 clear_framebuffer_blit_.reset(); |
| 4313 | 4322 |
| 4314 if (query_manager_.get()) { | 4323 if (query_manager_.get()) { |
| 4315 query_manager_->Destroy(have_context); | 4324 query_manager_->Destroy(have_context); |
| 4316 query_manager_.reset(); | 4325 query_manager_.reset(); |
| 4317 } | 4326 } |
| 4318 | 4327 |
| 4319 if (vertex_array_manager_ .get()) { | 4328 if (vertex_array_manager_ .get()) { |
| 4320 vertex_array_manager_->Destroy(have_context); | 4329 vertex_array_manager_->Destroy(have_context); |
| (...skipping 7903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12224 } | 12233 } |
| 12225 | 12234 |
| 12226 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); | 12235 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTexImage2D"); |
| 12227 ScopedResolvedFrameBufferBinder binder(this, false, true); | 12236 ScopedResolvedFrameBufferBinder binder(this, false, true); |
| 12228 gfx::Size size = GetBoundReadFrameBufferSize(); | 12237 gfx::Size size = GetBoundReadFrameBufferSize(); |
| 12229 | 12238 |
| 12230 if (texture->IsAttachedToFramebuffer()) { | 12239 if (texture->IsAttachedToFramebuffer()) { |
| 12231 framebuffer_state_.clear_state_dirty = true; | 12240 framebuffer_state_.clear_state_dirty = true; |
| 12232 } | 12241 } |
| 12233 | 12242 |
| 12243 bool requires_luma_blit = |
| 12244 CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), |
| 12245 format); |
| 12246 if (requires_luma_blit && |
| 12247 !InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { |
| 12248 return; |
| 12249 } |
| 12250 |
| 12234 // Clip to size to source dimensions | 12251 // Clip to size to source dimensions |
| 12235 GLint copyX = 0; | 12252 GLint copyX = 0; |
| 12236 GLint copyY = 0; | 12253 GLint copyY = 0; |
| 12237 GLint copyWidth = 0; | 12254 GLint copyWidth = 0; |
| 12238 GLint copyHeight = 0; | 12255 GLint copyHeight = 0; |
| 12239 Clip(x, width, size.width(), ©X, ©Width); | 12256 Clip(x, width, size.width(), ©X, ©Width); |
| 12240 Clip(y, height, size.height(), ©Y, ©Height); | 12257 Clip(y, height, size.height(), ©Y, ©Height); |
| 12241 | 12258 |
| 12242 if (copyX != x || | 12259 if (copyX != x || |
| 12243 copyY != y || | 12260 copyY != y || |
| 12244 copyWidth != width || | 12261 copyWidth != width || |
| 12245 copyHeight != height) { | 12262 copyHeight != height) { |
| 12246 // some part was clipped so clear the rect. | 12263 // some part was clipped so clear the rect. |
| 12247 std::unique_ptr<char[]> zero(new char[pixels_size]); | 12264 std::unique_ptr<char[]> zero(new char[pixels_size]); |
| 12248 memset(zero.get(), 0, pixels_size); | 12265 memset(zero.get(), 0, pixels_size); |
| 12249 glTexImage2D(target, level, | 12266 glTexImage2D(target, level, TextureManager::AdjustTexInternalFormat( |
| 12250 texture_manager()->AdjustTexInternalFormat(internal_format), | 12267 feature_info_.get(), internal_format), |
| 12251 width, height, border, format, type, zero.get()); | 12268 width, height, border, format, type, zero.get()); |
| 12252 if (copyHeight > 0 && copyWidth > 0) { | 12269 if (copyHeight > 0 && copyWidth > 0) { |
| 12253 GLint dx = copyX - x; | 12270 GLint dx = copyX - x; |
| 12254 GLint dy = copyY - y; | 12271 GLint dy = copyY - y; |
| 12255 GLint destX = dx; | 12272 GLint destX = dx; |
| 12256 GLint destY = dy; | 12273 GLint destY = dy; |
| 12257 glCopyTexSubImage2D(target, level, | 12274 if (requires_luma_blit) { |
| 12258 destX, destY, copyX, copyY, | 12275 copy_tex_image_blit_->DoCopyTexSubImage2DToLUMAComatabilityTexture( |
| 12259 copyWidth, copyHeight); | 12276 this, texture->service_id(), texture->target(), target, format, |
| 12277 type, level, destX, destY, copyX, copyY, copyWidth, copyHeight, |
| 12278 framebuffer_state_.bound_read_framebuffer->service_id(), |
| 12279 framebuffer_state_.bound_read_framebuffer |
| 12280 ->GetReadBufferInternalFormat()); |
| 12281 } else { |
| 12282 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, |
| 12283 copyWidth, copyHeight); |
| 12284 } |
| 12260 } | 12285 } |
| 12261 } else { | 12286 } else { |
| 12262 GLenum final_internal_format = | 12287 GLenum final_internal_format = TextureManager::AdjustTexInternalFormat( |
| 12263 texture_manager()->AdjustTexInternalFormat(internal_format); | 12288 feature_info_.get(), internal_format); |
| 12264 | 12289 |
| 12265 // The service id and target of the texture attached to READ_FRAMEBUFFER. | 12290 // The service id and target of the texture attached to READ_FRAMEBUFFER. |
| 12266 GLuint source_texture_service_id = 0; | 12291 GLuint source_texture_service_id = 0; |
| 12267 GLenum source_texture_target = 0; | 12292 GLenum source_texture_target = 0; |
| 12268 bool use_workaround = NeedsCopyTextureImageWorkaround( | 12293 bool use_workaround = NeedsCopyTextureImageWorkaround( |
| 12269 final_internal_format, channels_exist, &source_texture_service_id, | 12294 final_internal_format, channels_exist, &source_texture_service_id, |
| 12270 &source_texture_target); | 12295 &source_texture_target); |
| 12271 if (use_workaround) { | 12296 if (use_workaround) { |
| 12297 DCHECK(!requires_luma_blit); |
| 12272 GLenum dest_texture_target = target; | 12298 GLenum dest_texture_target = target; |
| 12273 GLenum framebuffer_target = features().chromium_framebuffer_multisample | 12299 GLenum framebuffer_target = features().chromium_framebuffer_multisample |
| 12274 ? GL_READ_FRAMEBUFFER_EXT | 12300 ? GL_READ_FRAMEBUFFER_EXT |
| 12275 : GL_FRAMEBUFFER; | 12301 : GL_FRAMEBUFFER; |
| 12276 | 12302 |
| 12277 GLenum temp_internal_format = 0; | 12303 GLenum temp_internal_format = 0; |
| 12278 if (channels_exist == GLES2Util::kRGBA) { | 12304 if (channels_exist == GLES2Util::kRGBA) { |
| 12279 temp_internal_format = GL_RGBA; | 12305 temp_internal_format = GL_RGBA; |
| 12280 } else if (channels_exist == GLES2Util::kRGB) { | 12306 } else if (channels_exist == GLES2Util::kRGB) { |
| 12281 temp_internal_format = GL_RGB; | 12307 temp_internal_format = GL_RGB; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 12302 glCopyTexImage2D(dest_texture_target, level, final_internal_format, 0, 0, | 12328 glCopyTexImage2D(dest_texture_target, level, final_internal_format, 0, 0, |
| 12303 copyWidth, copyHeight, 0); | 12329 copyWidth, copyHeight, 0); |
| 12304 | 12330 |
| 12305 // Rebind source texture. | 12331 // Rebind source texture. |
| 12306 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, | 12332 glFramebufferTexture2DEXT(framebuffer_target, GL_COLOR_ATTACHMENT0, |
| 12307 source_texture_target, | 12333 source_texture_target, |
| 12308 source_texture_service_id, 0); | 12334 source_texture_service_id, 0); |
| 12309 | 12335 |
| 12310 glDeleteTextures(1, &temp_texture); | 12336 glDeleteTextures(1, &temp_texture); |
| 12311 } else { | 12337 } else { |
| 12312 glCopyTexImage2D(target, level, final_internal_format, copyX, copyY, | 12338 if (requires_luma_blit) { |
| 12313 copyWidth, copyHeight, border); | 12339 copy_tex_image_blit_->DoCopyTexImage2DToLUMAComatabilityTexture( |
| 12340 this, texture->service_id(), texture->target(), target, format, |
| 12341 type, level, internal_format, copyX, copyY, copyWidth, copyHeight, |
| 12342 framebuffer_state_.bound_read_framebuffer->service_id(), |
| 12343 framebuffer_state_.bound_read_framebuffer |
| 12344 ->GetReadBufferInternalFormat()); |
| 12345 } else { |
| 12346 glCopyTexImage2D(target, level, final_internal_format, copyX, copyY, |
| 12347 copyWidth, copyHeight, border); |
| 12348 } |
| 12314 } | 12349 } |
| 12315 } | 12350 } |
| 12316 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D"); | 12351 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTexImage2D"); |
| 12317 if (error == GL_NO_ERROR) { | 12352 if (error == GL_NO_ERROR) { |
| 12318 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, | 12353 texture_manager()->SetLevelInfo(texture_ref, target, level, internal_format, |
| 12319 width, height, 1, border, format, | 12354 width, height, 1, border, format, |
| 12320 type, gfx::Rect(width, height)); | 12355 type, gfx::Rect(width, height)); |
| 12321 texture->ApplyFormatWorkarounds(feature_info_.get()); | 12356 texture->ApplyFormatWorkarounds(feature_info_.get()); |
| 12322 } | 12357 } |
| 12323 | 12358 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12422 "dimensions too big"); | 12457 "dimensions too big"); |
| 12423 return; | 12458 return; |
| 12424 } | 12459 } |
| 12425 } | 12460 } |
| 12426 } else { | 12461 } else { |
| 12427 // Write all pixels in below. | 12462 // Write all pixels in below. |
| 12428 texture_manager()->SetLevelCleared(texture_ref, target, level, true); | 12463 texture_manager()->SetLevelCleared(texture_ref, target, level, true); |
| 12429 } | 12464 } |
| 12430 | 12465 |
| 12431 if (copyHeight > 0 && copyWidth > 0) { | 12466 if (copyHeight > 0 && copyWidth > 0) { |
| 12432 glCopyTexSubImage2D(target, level, | 12467 if (CopyTexImageResourceManager::CopyTexImageRequiresBlit( |
| 12433 destX, destY, copyX, copyY, | 12468 feature_info_.get(), format)) { |
| 12434 copyWidth, copyHeight); | 12469 if (!InitializeCopyTexImageBlitter("glCopyTexSubImage2D")) { |
| 12470 return; |
| 12471 } |
| 12472 copy_tex_image_blit_->DoCopyTexSubImage2DToLUMAComatabilityTexture( |
| 12473 this, texture->service_id(), texture->target(), target, format, type, |
| 12474 level, xoffset, yoffset, x, y, width, height, |
| 12475 framebuffer_state_.bound_read_framebuffer->service_id(), |
| 12476 framebuffer_state_.bound_read_framebuffer |
| 12477 ->GetReadBufferInternalFormat()); |
| 12478 } else { |
| 12479 glCopyTexSubImage2D(target, level, destX, destY, copyX, copyY, copyWidth, |
| 12480 copyHeight); |
| 12481 } |
| 12435 } | 12482 } |
| 12436 | 12483 |
| 12437 // This may be a slow command. Exit command processing to allow for | 12484 // This may be a slow command. Exit command processing to allow for |
| 12438 // context preemption and GPU watchdog checks. | 12485 // context preemption and GPU watchdog checks. |
| 12439 ExitCommandProcessingEarly(); | 12486 ExitCommandProcessingEarly(); |
| 12440 } | 12487 } |
| 12441 | 12488 |
| 12442 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, | 12489 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, |
| 12443 const void* cmd_data) { | 12490 const void* cmd_data) { |
| 12444 const gles2::cmds::TexSubImage2D& c = | 12491 const gles2::cmds::TexSubImage2D& c = |
| (...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14370 } | 14417 } |
| 14371 | 14418 |
| 14372 // Resize the destination texture to the dimensions of the source texture. | 14419 // Resize the destination texture to the dimensions of the source texture. |
| 14373 if (!dest_level_defined || dest_width != source_width || | 14420 if (!dest_level_defined || dest_width != source_width || |
| 14374 dest_height != source_height || | 14421 dest_height != source_height || |
| 14375 dest_internal_format != internal_format || | 14422 dest_internal_format != internal_format || |
| 14376 dest_type_previous != dest_type) { | 14423 dest_type_previous != dest_type) { |
| 14377 // Ensure that the glTexImage2D succeeds. | 14424 // Ensure that the glTexImage2D succeeds. |
| 14378 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); | 14425 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
| 14379 glBindTexture(dest_target, dest_texture->service_id()); | 14426 glBindTexture(dest_target, dest_texture->service_id()); |
| 14380 glTexImage2D(dest_target, 0, | 14427 glTexImage2D( |
| 14381 texture_manager()->AdjustTexInternalFormat(internal_format), | 14428 dest_target, 0, TextureManager::AdjustTexInternalFormat( |
| 14382 source_width, source_height, 0, | 14429 feature_info_.get(), internal_format), |
| 14383 texture_manager()->AdjustTexFormat(internal_format), dest_type, | 14430 source_width, source_height, 0, |
| 14384 NULL); | 14431 TextureManager::AdjustTexFormat(feature_info_.get(), internal_format), |
| 14432 dest_type, NULL); |
| 14385 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); | 14433 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
| 14386 if (error != GL_NO_ERROR) { | 14434 if (error != GL_NO_ERROR) { |
| 14387 RestoreCurrentTextureBindings(&state_, dest_target); | 14435 RestoreCurrentTextureBindings(&state_, dest_target); |
| 14388 return; | 14436 return; |
| 14389 } | 14437 } |
| 14390 | 14438 |
| 14391 texture_manager()->SetLevelInfo( | 14439 texture_manager()->SetLevelInfo( |
| 14392 dest_texture_ref, dest_target, 0, internal_format, source_width, | 14440 dest_texture_ref, dest_target, 0, internal_format, source_width, |
| 14393 source_height, 1, 0, internal_format, dest_type, | 14441 source_height, 1, 0, internal_format, dest_type, |
| 14394 gfx::Rect(source_width, source_height)); | 14442 gfx::Rect(source_width, source_height)); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14615 } | 14663 } |
| 14616 } | 14664 } |
| 14617 copy_texture_CHROMIUM_->DoCopySubTexture( | 14665 copy_texture_CHROMIUM_->DoCopySubTexture( |
| 14618 this, source_target, source_texture->service_id(), source_internal_format, | 14666 this, source_target, source_texture->service_id(), source_internal_format, |
| 14619 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, | 14667 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, |
| 14620 yoffset, x, y, width, height, dest_width, dest_height, source_width, | 14668 yoffset, x, y, width, height, dest_width, dest_height, source_width, |
| 14621 source_height, unpack_flip_y == GL_TRUE, | 14669 source_height, unpack_flip_y == GL_TRUE, |
| 14622 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); | 14670 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); |
| 14623 } | 14671 } |
| 14624 | 14672 |
| 14673 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( |
| 14674 const char* function_name) { |
| 14675 if (!copy_tex_image_blit_.get()) { |
| 14676 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); |
| 14677 copy_tex_image_blit_.reset( |
| 14678 new CopyTexImageResourceManager(feature_info_.get())); |
| 14679 copy_tex_image_blit_->Initialize(this); |
| 14680 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) |
| 14681 return false; |
| 14682 } |
| 14683 return true; |
| 14684 } |
| 14685 |
| 14625 bool GLES2DecoderImpl::InitializeCopyTextureCHROMIUM( | 14686 bool GLES2DecoderImpl::InitializeCopyTextureCHROMIUM( |
| 14626 const char* function_name) { | 14687 const char* function_name) { |
| 14627 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is | 14688 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is |
| 14628 // needed because it takes 10s of milliseconds to initialize. | 14689 // needed because it takes 10s of milliseconds to initialize. |
| 14629 if (!copy_texture_CHROMIUM_.get()) { | 14690 if (!copy_texture_CHROMIUM_.get()) { |
| 14630 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); | 14691 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); |
| 14631 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); | 14692 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); |
| 14632 copy_texture_CHROMIUM_->Initialize(this, features()); | 14693 copy_texture_CHROMIUM_->Initialize(this, features()); |
| 14633 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) | 14694 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) |
| 14634 return false; | 14695 return false; |
| (...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16825 } | 16886 } |
| 16826 | 16887 |
| 16827 // Include the auto-generated part of this file. We split this because it means | 16888 // Include the auto-generated part of this file. We split this because it means |
| 16828 // we can easily edit the non-auto generated parts right here in this file | 16889 // we can easily edit the non-auto generated parts right here in this file |
| 16829 // instead of having to edit some template or the code generator. | 16890 // instead of having to edit some template or the code generator. |
| 16830 #include "base/macros.h" | 16891 #include "base/macros.h" |
| 16831 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16892 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 16832 | 16893 |
| 16833 } // namespace gles2 | 16894 } // namespace gles2 |
| 16834 } // namespace gpu | 16895 } // namespace gpu |
| OLD | NEW |