| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 texture_mips_dirty_(false), | 369 texture_mips_dirty_(false), |
| 370 cube_complete_(false), | 370 cube_complete_(false), |
| 371 npot_(false), | 371 npot_(false), |
| 372 has_been_bound_(false), | 372 has_been_bound_(false), |
| 373 framebuffer_attachment_count_(0), | 373 framebuffer_attachment_count_(0), |
| 374 immutable_(false), | 374 immutable_(false), |
| 375 has_images_(false), | 375 has_images_(false), |
| 376 estimated_size_(0), | 376 estimated_size_(0), |
| 377 can_render_condition_(CAN_RENDER_ALWAYS), | 377 can_render_condition_(CAN_RENDER_ALWAYS), |
| 378 texture_max_anisotropy_initialized_(false), | 378 texture_max_anisotropy_initialized_(false), |
| 379 compatibility_swizzle_(nullptr) {} | 379 compatibility_swizzle_(nullptr), |
| 380 emulating_rgb_(false) {} |
| 380 | 381 |
| 381 Texture::~Texture() { | 382 Texture::~Texture() { |
| 382 if (mailbox_manager_) | 383 if (mailbox_manager_) |
| 383 mailbox_manager_->TextureDeleted(this); | 384 mailbox_manager_->TextureDeleted(this); |
| 384 } | 385 } |
| 385 | 386 |
| 386 void Texture::AddTextureRef(TextureRef* ref) { | 387 void Texture::AddTextureRef(TextureRef* ref) { |
| 387 DCHECK(refs_.find(ref) == refs_.end()); | 388 DCHECK(refs_.find(ref) == refs_.end()); |
| 388 refs_.insert(ref); | 389 refs_.insert(ref); |
| 389 if (!memory_tracking_ref_) { | 390 if (!memory_tracking_ref_) { |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 } | 860 } |
| 860 | 861 |
| 861 if (has_images_ == has_images) | 862 if (has_images_ == has_images) |
| 862 return; | 863 return; |
| 863 has_images_ = has_images; | 864 has_images_ = has_images; |
| 864 int delta = has_images ? +1 : -1; | 865 int delta = has_images ? +1 : -1; |
| 865 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) | 866 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) |
| 866 (*it)->manager()->UpdateNumImages(delta); | 867 (*it)->manager()->UpdateNumImages(delta); |
| 867 } | 868 } |
| 868 | 869 |
| 870 void Texture::UpdateEmulatingRGB() { |
| 871 for (const FaceInfo& face_info : face_infos_) { |
| 872 for (const LevelInfo& level_info : face_info.level_infos) { |
| 873 if (level_info.image && level_info.image->EmulatingRGB()) |
| 874 emulating_rgb_ = true; |
| 875 return; |
| 876 } |
| 877 } |
| 878 emulating_rgb_ = false; |
| 879 } |
| 880 |
| 881 |
| 869 void Texture::IncAllFramebufferStateChangeCount() { | 882 void Texture::IncAllFramebufferStateChangeCount() { |
| 870 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) | 883 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) |
| 871 (*it)->manager()->IncFramebufferStateChangeCount(); | 884 (*it)->manager()->IncFramebufferStateChangeCount(); |
| 872 } | 885 } |
| 873 | 886 |
| 874 void Texture::UpdateBaseLevel(GLint base_level) { | 887 void Texture::UpdateBaseLevel(GLint base_level) { |
| 875 if (base_level_ == base_level) | 888 if (base_level_ == base_level) |
| 876 return; | 889 return; |
| 877 base_level_ = base_level; | 890 base_level_ = base_level; |
| 878 | 891 |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 Texture::LevelInfo& info = | 1451 Texture::LevelInfo& info = |
| 1439 face_infos_[face_index].level_infos[level]; | 1452 face_infos_[face_index].level_infos[level]; |
| 1440 DCHECK_EQ(info.target, target); | 1453 DCHECK_EQ(info.target, target); |
| 1441 DCHECK_EQ(info.level, level); | 1454 DCHECK_EQ(info.level, level); |
| 1442 info.image = image; | 1455 info.image = image; |
| 1443 info.stream_texture_image = stream_texture_image; | 1456 info.stream_texture_image = stream_texture_image; |
| 1444 info.image_state = state; | 1457 info.image_state = state; |
| 1445 | 1458 |
| 1446 UpdateCanRenderCondition(); | 1459 UpdateCanRenderCondition(); |
| 1447 UpdateHasImages(); | 1460 UpdateHasImages(); |
| 1461 UpdateEmulatingRGB(); |
| 1448 } | 1462 } |
| 1449 | 1463 |
| 1450 void Texture::SetLevelImage(GLenum target, | 1464 void Texture::SetLevelImage(GLenum target, |
| 1451 GLint level, | 1465 GLint level, |
| 1452 gl::GLImage* image, | 1466 gl::GLImage* image, |
| 1453 ImageState state) { | 1467 ImageState state) { |
| 1454 SetLevelImageInternal(target, level, image, nullptr, state); | 1468 SetLevelImageInternal(target, level, image, nullptr, state); |
| 1455 } | 1469 } |
| 1456 | 1470 |
| 1457 void Texture::SetLevelStreamTextureImage(GLenum target, | 1471 void Texture::SetLevelStreamTextureImage(GLenum target, |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 | 1628 |
| 1615 void Texture::ApplyFormatWorkarounds(FeatureInfo* feature_info) { | 1629 void Texture::ApplyFormatWorkarounds(FeatureInfo* feature_info) { |
| 1616 if (feature_info->gl_version_info().is_desktop_core_profile) { | 1630 if (feature_info->gl_version_info().is_desktop_core_profile) { |
| 1617 if (static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) | 1631 if (static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) |
| 1618 return; | 1632 return; |
| 1619 const Texture::LevelInfo& info = face_infos_[0].level_infos[base_level_]; | 1633 const Texture::LevelInfo& info = face_infos_[0].level_infos[base_level_]; |
| 1620 SetCompatibilitySwizzle(GetCompatibilitySwizzle(info.format)); | 1634 SetCompatibilitySwizzle(GetCompatibilitySwizzle(info.format)); |
| 1621 } | 1635 } |
| 1622 } | 1636 } |
| 1623 | 1637 |
| 1638 bool Texture::EmulatingRGB() { |
| 1639 return emulating_rgb_; |
| 1640 } |
| 1641 |
| 1624 TextureRef::TextureRef(TextureManager* manager, | 1642 TextureRef::TextureRef(TextureManager* manager, |
| 1625 GLuint client_id, | 1643 GLuint client_id, |
| 1626 Texture* texture) | 1644 Texture* texture) |
| 1627 : manager_(manager), | 1645 : manager_(manager), |
| 1628 texture_(texture), | 1646 texture_(texture), |
| 1629 client_id_(client_id), | 1647 client_id_(client_id), |
| 1630 num_observers_(0) { | 1648 num_observers_(0) { |
| 1631 DCHECK(manager_); | 1649 DCHECK(manager_); |
| 1632 DCHECK(texture_); | 1650 DCHECK(texture_); |
| 1633 texture_->AddTextureRef(this); | 1651 texture_->AddTextureRef(this); |
| (...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3134 uint32_t TextureManager::GetServiceIdGeneration() const { | 3152 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3135 return current_service_id_generation_; | 3153 return current_service_id_generation_; |
| 3136 } | 3154 } |
| 3137 | 3155 |
| 3138 void TextureManager::IncrementServiceIdGeneration() { | 3156 void TextureManager::IncrementServiceIdGeneration() { |
| 3139 current_service_id_generation_++; | 3157 current_service_id_generation_++; |
| 3140 } | 3158 } |
| 3141 | 3159 |
| 3142 } // namespace gles2 | 3160 } // namespace gles2 |
| 3143 } // namespace gpu | 3161 } // namespace gpu |
| OLD | NEW |