| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/texture_definition.h" | 5 #include "gpu/command_buffer/service/texture_definition.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 if (image_buffer_.get()) { | 395 if (image_buffer_.get()) { |
| 396 texture->SetLevelImage( | 396 texture->SetLevelImage( |
| 397 target_, 0, | 397 target_, 0, |
| 398 new GLImageSync(image_buffer_, | 398 new GLImageSync(image_buffer_, |
| 399 gfx::Size(level_info_.width, level_info_.height)), | 399 gfx::Size(level_info_.width, level_info_.height)), |
| 400 Texture::BOUND); | 400 Texture::BOUND); |
| 401 } | 401 } |
| 402 | 402 |
| 403 texture->target_ = target_; | 403 texture->target_ = target_; |
| 404 texture->SetImmutable(immutable_); | 404 texture->SetImmutable(immutable_); |
| 405 texture->min_filter_ = min_filter_; | 405 texture->sampler_state_.min_filter = min_filter_; |
| 406 texture->mag_filter_ = mag_filter_; | 406 texture->sampler_state_.mag_filter = mag_filter_; |
| 407 texture->wrap_s_ = wrap_s_; | 407 texture->sampler_state_.wrap_s = wrap_s_; |
| 408 texture->wrap_t_ = wrap_t_; | 408 texture->sampler_state_.wrap_t = wrap_t_; |
| 409 texture->usage_ = usage_; | 409 texture->usage_ = usage_; |
| 410 } | 410 } |
| 411 | 411 |
| 412 void TextureDefinition::UpdateTexture(Texture* texture) const { | 412 void TextureDefinition::UpdateTexture(Texture* texture) const { |
| 413 GLuint old_service_id = 0u; | 413 GLuint old_service_id = 0u; |
| 414 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { | 414 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { |
| 415 GLuint service_id = 0u; | 415 GLuint service_id = 0u; |
| 416 glGenTextures(1, &service_id); | 416 glGenTextures(1, &service_id); |
| 417 old_service_id = texture->service_id(); | 417 old_service_id = texture->service_id(); |
| 418 texture->SetServiceId(service_id); | 418 texture->SetServiceId(service_id); |
| 419 | 419 |
| 420 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target_); | 420 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target_); |
| 421 GLint bound_id = 0; | 421 GLint bound_id = 0; |
| 422 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_id); | 422 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_id); |
| 423 if (bound_id == static_cast<GLint>(old_service_id)) { | 423 if (bound_id == static_cast<GLint>(old_service_id)) { |
| 424 glBindTexture(target_, service_id); | 424 glBindTexture(target_, service_id); |
| 425 } | 425 } |
| 426 texture->SetLevelImage(target_, 0, NULL, Texture::UNBOUND); | 426 texture->SetLevelImage(target_, 0, NULL, Texture::UNBOUND); |
| 427 } | 427 } |
| 428 | 428 |
| 429 UpdateTextureInternal(texture); | 429 UpdateTextureInternal(texture); |
| 430 | 430 |
| 431 if (old_service_id) { | 431 if (old_service_id) { |
| 432 glDeleteTextures(1, &old_service_id); | 432 glDeleteTextures(1, &old_service_id); |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 | 435 |
| 436 bool TextureDefinition::Matches(const Texture* texture) const { | 436 bool TextureDefinition::Matches(const Texture* texture) const { |
| 437 DCHECK(target_ == texture->target()); | 437 DCHECK(target_ == texture->target()); |
| 438 if (texture->min_filter_ != min_filter_ || | 438 if (texture->sampler_state_.min_filter != min_filter_ || |
| 439 texture->mag_filter_ != mag_filter_ || | 439 texture->sampler_state_.mag_filter != mag_filter_ || |
| 440 texture->wrap_s_ != wrap_s_ || | 440 texture->sampler_state_.wrap_s != wrap_s_ || |
| 441 texture->wrap_t_ != wrap_t_ || | 441 texture->sampler_state_.wrap_t != wrap_t_ || |
| 442 texture->SafeToRenderFrom() != SafeToRenderFrom()) { | 442 texture->SafeToRenderFrom() != SafeToRenderFrom()) { |
| 443 return false; | 443 return false; |
| 444 } | 444 } |
| 445 | 445 |
| 446 // Texture became defined. | 446 // Texture became defined. |
| 447 if (!image_buffer_.get() && texture->IsDefined()) | 447 if (!image_buffer_.get() && texture->IsDefined()) |
| 448 return false; | 448 return false; |
| 449 | 449 |
| 450 // All structural changes should have orphaned the texture. | 450 // All structural changes should have orphaned the texture. |
| 451 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0)) | 451 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0)) |
| 452 return false; | 452 return false; |
| 453 | 453 |
| 454 return true; | 454 return true; |
| 455 } | 455 } |
| 456 | 456 |
| 457 bool TextureDefinition::SafeToRenderFrom() const { | 457 bool TextureDefinition::SafeToRenderFrom() const { |
| 458 return level_info_.cleared_rect.Contains( | 458 return level_info_.cleared_rect.Contains( |
| 459 gfx::Rect(level_info_.width, level_info_.height)); | 459 gfx::Rect(level_info_.width, level_info_.height)); |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace gles2 | 462 } // namespace gles2 |
| 463 } // namespace gpu | 463 } // namespace gpu |
| OLD | NEW |