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