| 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/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 } | 432 } |
| 433 | 433 |
| 434 if (have_context) { | 434 if (have_context) { |
| 435 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); | 435 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); |
| 436 } | 436 } |
| 437 | 437 |
| 438 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); | 438 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 TextureBase::TextureBase(GLuint service_id) | 441 TextureBase::TextureBase(GLuint service_id) |
| 442 : service_id_(service_id), mailbox_manager_(nullptr) {} | 442 : service_id_(service_id), target_(GL_NONE), mailbox_manager_(nullptr) {} |
| 443 | 443 |
| 444 TextureBase::~TextureBase() { | 444 TextureBase::~TextureBase() { |
| 445 DCHECK_EQ(nullptr, mailbox_manager_); | 445 DCHECK_EQ(nullptr, mailbox_manager_); |
| 446 } | 446 } |
| 447 | 447 |
| 448 void TextureBase::SetTarget(GLenum target) { |
| 449 DCHECK_EQ(0u, target_); // you can only set this once. |
| 450 target_ = target; |
| 451 } |
| 452 |
| 448 void TextureBase::DeleteFromMailboxManager() { | 453 void TextureBase::DeleteFromMailboxManager() { |
| 449 if (mailbox_manager_) { | 454 if (mailbox_manager_) { |
| 450 mailbox_manager_->TextureDeleted(this); | 455 mailbox_manager_->TextureDeleted(this); |
| 451 mailbox_manager_ = nullptr; | 456 mailbox_manager_ = nullptr; |
| 452 } | 457 } |
| 453 } | 458 } |
| 454 | 459 |
| 455 void TextureBase::SetMailboxManager(MailboxManager* mailbox_manager) { | 460 void TextureBase::SetMailboxManager(MailboxManager* mailbox_manager) { |
| 456 DCHECK(!mailbox_manager_ || mailbox_manager_ == mailbox_manager); | 461 DCHECK(!mailbox_manager_ || mailbox_manager_ == mailbox_manager); |
| 457 mailbox_manager_ = mailbox_manager; | 462 mailbox_manager_ = mailbox_manager; |
| 458 } | 463 } |
| 459 | 464 |
| 460 TexturePassthrough::TexturePassthrough(GLuint service_id) | 465 TexturePassthrough::TexturePassthrough(GLuint service_id, GLenum target) |
| 461 : TextureBase(service_id), have_context_(true) {} | 466 : TextureBase(service_id), have_context_(true) { |
| 467 TextureBase::SetTarget(target); |
| 468 } |
| 462 | 469 |
| 463 TexturePassthrough::~TexturePassthrough() { | 470 TexturePassthrough::~TexturePassthrough() { |
| 464 DeleteFromMailboxManager(); | 471 DeleteFromMailboxManager(); |
| 465 if (have_context_) { | 472 if (have_context_) { |
| 466 glDeleteTextures(1, &service_id_); | 473 glDeleteTextures(1, &service_id_); |
| 467 } | 474 } |
| 468 } | 475 } |
| 469 | 476 |
| 470 void TexturePassthrough::MarkContextLost() { | 477 void TexturePassthrough::MarkContextLost() { |
| 471 have_context_ = false; | 478 have_context_ = false; |
| 472 } | 479 } |
| 473 | 480 |
| 474 Texture::Texture(GLuint service_id) | 481 Texture::Texture(GLuint service_id) |
| 475 : TextureBase(service_id), | 482 : TextureBase(service_id), |
| 476 memory_tracking_ref_(NULL), | 483 memory_tracking_ref_(NULL), |
| 477 owned_service_id_(service_id), | 484 owned_service_id_(service_id), |
| 478 cleared_(true), | 485 cleared_(true), |
| 479 num_uncleared_mips_(0), | 486 num_uncleared_mips_(0), |
| 480 num_npot_faces_(0), | 487 num_npot_faces_(0), |
| 481 target_(0), | |
| 482 usage_(GL_NONE), | 488 usage_(GL_NONE), |
| 483 base_level_(0), | 489 base_level_(0), |
| 484 max_level_(1000), | 490 max_level_(1000), |
| 485 swizzle_r_(GL_RED), | 491 swizzle_r_(GL_RED), |
| 486 swizzle_g_(GL_GREEN), | 492 swizzle_g_(GL_GREEN), |
| 487 swizzle_b_(GL_BLUE), | 493 swizzle_b_(GL_BLUE), |
| 488 swizzle_a_(GL_ALPHA), | 494 swizzle_a_(GL_ALPHA), |
| 489 max_level_set_(-1), | 495 max_level_set_(-1), |
| 490 texture_complete_(false), | 496 texture_complete_(false), |
| 491 texture_mips_dirty_(false), | 497 texture_mips_dirty_(false), |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 height = std::max(1, height >> 1); | 745 height = std::max(1, height >> 1); |
| 740 depth = target == GL_TEXTURE_2D_ARRAY ? depth : std::max(1, depth >> 1); | 746 depth = target == GL_TEXTURE_2D_ARRAY ? depth : std::max(1, depth >> 1); |
| 741 SetLevelInfo(target, level, level0_info.internal_format, | 747 SetLevelInfo(target, level, level0_info.internal_format, |
| 742 width, height, depth, level0_info.border, level0_info.format, | 748 width, height, depth, level0_info.border, level0_info.format, |
| 743 level0_info.type, gfx::Rect(width, height)); | 749 level0_info.type, gfx::Rect(width, height)); |
| 744 } | 750 } |
| 745 } | 751 } |
| 746 } | 752 } |
| 747 | 753 |
| 748 void Texture::SetTarget(GLenum target, GLint max_levels) { | 754 void Texture::SetTarget(GLenum target, GLint max_levels) { |
| 749 DCHECK_EQ(0u, target_); // you can only set this once. | 755 TextureBase::SetTarget(target); |
| 750 target_ = target; | |
| 751 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; | 756 size_t num_faces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; |
| 752 face_infos_.resize(num_faces); | 757 face_infos_.resize(num_faces); |
| 753 for (size_t ii = 0; ii < num_faces; ++ii) { | 758 for (size_t ii = 0; ii < num_faces; ++ii) { |
| 754 face_infos_[ii].level_infos.resize(max_levels); | 759 face_infos_[ii].level_infos.resize(max_levels); |
| 755 } | 760 } |
| 756 | 761 |
| 757 if (target == GL_TEXTURE_EXTERNAL_OES || target == GL_TEXTURE_RECTANGLE_ARB) { | 762 if (target == GL_TEXTURE_EXTERNAL_OES || target == GL_TEXTURE_RECTANGLE_ARB) { |
| 758 sampler_state_.min_filter = GL_LINEAR; | 763 sampler_state_.min_filter = GL_LINEAR; |
| 759 sampler_state_.wrap_s = sampler_state_.wrap_t = GL_CLAMP_TO_EDGE; | 764 sampler_state_.wrap_s = sampler_state_.wrap_t = GL_CLAMP_TO_EDGE; |
| 760 } | 765 } |
| (...skipping 2885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3646 uint32_t TextureManager::GetServiceIdGeneration() const { | 3651 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3647 return current_service_id_generation_; | 3652 return current_service_id_generation_; |
| 3648 } | 3653 } |
| 3649 | 3654 |
| 3650 void TextureManager::IncrementServiceIdGeneration() { | 3655 void TextureManager::IncrementServiceIdGeneration() { |
| 3651 current_service_id_generation_++; | 3656 current_service_id_generation_++; |
| 3652 } | 3657 } |
| 3653 | 3658 |
| 3654 } // namespace gles2 | 3659 } // namespace gles2 |
| 3655 } // namespace gpu | 3660 } // namespace gpu |
| OLD | NEW |