Chromium Code Reviews| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 default_textures_[ii] = NULL; | 346 default_textures_[ii] = NULL; |
| 347 } | 347 } |
| 348 | 348 |
| 349 if (have_context) { | 349 if (have_context) { |
| 350 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); | 350 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); |
| 351 } | 351 } |
| 352 | 352 |
| 353 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); | 353 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); |
| 354 } | 354 } |
| 355 | 355 |
| 356 TextureBase::TextureBase(GLuint service_id) | |
| 357 : service_id_(service_id), mailbox_manager_(nullptr) {} | |
| 358 | |
| 359 TextureBase::~TextureBase() { | |
| 360 DCHECK_EQ(nullptr, mailbox_manager_); | |
|
piman
2016/09/07 17:38:31
nit: use chromium style for indents and {} below (
Geoff Lang
2016/09/07 18:14:49
Done.
| |
| 361 } | |
| 362 | |
| 363 void TextureBase::DeleteFromMailboxManager() | |
| 364 { | |
| 365 if (mailbox_manager_) { | |
| 366 mailbox_manager_->TextureDeleted(this); | |
| 367 mailbox_manager_ = nullptr; | |
| 368 } | |
| 369 } | |
| 370 | |
| 371 void TextureBase::SetMailboxManager(MailboxManager* mailbox_manager) { | |
| 372 DCHECK(!mailbox_manager_ || mailbox_manager_ == mailbox_manager); | |
| 373 mailbox_manager_ = mailbox_manager; | |
| 374 } | |
| 375 | |
| 376 Texture* TextureBase::AsTexture() { | |
| 377 return nullptr; | |
| 378 } | |
| 379 | |
| 356 Texture::Texture(GLuint service_id) | 380 Texture::Texture(GLuint service_id) |
| 357 : mailbox_manager_(NULL), | 381 : TextureBase(service_id), |
| 358 memory_tracking_ref_(NULL), | 382 memory_tracking_ref_(NULL), |
| 359 service_id_(service_id), | |
| 360 owned_service_id_(service_id), | 383 owned_service_id_(service_id), |
| 361 cleared_(true), | 384 cleared_(true), |
| 362 num_uncleared_mips_(0), | 385 num_uncleared_mips_(0), |
| 363 num_npot_faces_(0), | 386 num_npot_faces_(0), |
| 364 target_(0), | 387 target_(0), |
| 365 usage_(GL_NONE), | 388 usage_(GL_NONE), |
| 366 base_level_(0), | 389 base_level_(0), |
| 367 max_level_(1000), | 390 max_level_(1000), |
| 368 swizzle_r_(GL_RED), | 391 swizzle_r_(GL_RED), |
| 369 swizzle_g_(GL_GREEN), | 392 swizzle_g_(GL_GREEN), |
| 370 swizzle_b_(GL_BLUE), | 393 swizzle_b_(GL_BLUE), |
| 371 swizzle_a_(GL_ALPHA), | 394 swizzle_a_(GL_ALPHA), |
| 372 max_level_set_(-1), | 395 max_level_set_(-1), |
| 373 texture_complete_(false), | 396 texture_complete_(false), |
| 374 texture_mips_dirty_(false), | 397 texture_mips_dirty_(false), |
| 375 cube_complete_(false), | 398 cube_complete_(false), |
| 376 npot_(false), | 399 npot_(false), |
| 377 has_been_bound_(false), | 400 has_been_bound_(false), |
| 378 framebuffer_attachment_count_(0), | 401 framebuffer_attachment_count_(0), |
| 379 immutable_(false), | 402 immutable_(false), |
| 380 has_images_(false), | 403 has_images_(false), |
| 381 estimated_size_(0), | 404 estimated_size_(0), |
| 382 can_render_condition_(CAN_RENDER_ALWAYS), | 405 can_render_condition_(CAN_RENDER_ALWAYS), |
| 383 texture_max_anisotropy_initialized_(false), | 406 texture_max_anisotropy_initialized_(false), |
| 384 compatibility_swizzle_(nullptr), | 407 compatibility_swizzle_(nullptr), |
| 385 emulating_rgb_(false) {} | 408 emulating_rgb_(false) {} |
| 386 | 409 |
| 387 Texture::~Texture() { | 410 Texture::~Texture() { |
| 388 if (mailbox_manager_) | 411 DeleteFromMailboxManager(); |
| 389 mailbox_manager_->TextureDeleted(this); | 412 } |
| 413 | |
| 414 Texture* Texture::AsTexture() { | |
| 415 return this; | |
| 390 } | 416 } |
| 391 | 417 |
| 392 void Texture::AddTextureRef(TextureRef* ref) { | 418 void Texture::AddTextureRef(TextureRef* ref) { |
| 393 DCHECK(refs_.find(ref) == refs_.end()); | 419 DCHECK(refs_.find(ref) == refs_.end()); |
| 394 refs_.insert(ref); | 420 refs_.insert(ref); |
| 395 if (!memory_tracking_ref_) { | 421 if (!memory_tracking_ref_) { |
| 396 memory_tracking_ref_ = ref; | 422 memory_tracking_ref_ = ref; |
| 397 GetMemTracker()->TrackMemAlloc(estimated_size()); | 423 GetMemTracker()->TrackMemAlloc(estimated_size()); |
| 398 } | 424 } |
| 399 } | 425 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 CanRender(feature_info), | 620 CanRender(feature_info), |
| 595 CanRenderTo(feature_info, level), | 621 CanRenderTo(feature_info, level), |
| 596 npot_, | 622 npot_, |
| 597 emulating_rgb_); | 623 emulating_rgb_); |
| 598 | 624 |
| 599 signature->append(TextureTag, sizeof(TextureTag)); | 625 signature->append(TextureTag, sizeof(TextureTag)); |
| 600 signature->append(reinterpret_cast<const char*>(&signature_data), | 626 signature->append(reinterpret_cast<const char*>(&signature_data), |
| 601 sizeof(signature_data)); | 627 sizeof(signature_data)); |
| 602 } | 628 } |
| 603 | 629 |
| 604 void Texture::SetMailboxManager(MailboxManager* mailbox_manager) { | |
| 605 DCHECK(!mailbox_manager_ || mailbox_manager_ == mailbox_manager); | |
| 606 mailbox_manager_ = mailbox_manager; | |
| 607 } | |
| 608 | |
| 609 void Texture::MarkMipmapsGenerated() { | 630 void Texture::MarkMipmapsGenerated() { |
| 610 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { | 631 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
| 611 const Texture::FaceInfo& face_info = face_infos_[ii]; | 632 const Texture::FaceInfo& face_info = face_infos_[ii]; |
| 612 const Texture::LevelInfo& level0_info = face_info.level_infos[base_level_]; | 633 const Texture::LevelInfo& level0_info = face_info.level_infos[base_level_]; |
| 613 GLsizei width = level0_info.width; | 634 GLsizei width = level0_info.width; |
| 614 GLsizei height = level0_info.height; | 635 GLsizei height = level0_info.height; |
| 615 GLsizei depth = level0_info.depth; | 636 GLsizei depth = level0_info.depth; |
| 616 GLenum target = target_ == GL_TEXTURE_CUBE_MAP ? | 637 GLenum target = target_ == GL_TEXTURE_CUBE_MAP ? |
| 617 GLES2Util::IndexToGLFaceTarget(ii) : target_; | 638 GLES2Util::IndexToGLFaceTarget(ii) : target_; |
| 618 | 639 |
| (...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3383 uint32_t TextureManager::GetServiceIdGeneration() const { | 3404 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3384 return current_service_id_generation_; | 3405 return current_service_id_generation_; |
| 3385 } | 3406 } |
| 3386 | 3407 |
| 3387 void TextureManager::IncrementServiceIdGeneration() { | 3408 void TextureManager::IncrementServiceIdGeneration() { |
| 3388 current_service_id_generation_++; | 3409 current_service_id_generation_++; |
| 3389 } | 3410 } |
| 3390 | 3411 |
| 3391 } // namespace gles2 | 3412 } // namespace gles2 |
| 3392 } // namespace gpu | 3413 } // namespace gpu |
| OLD | NEW |