| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 304 } |
| 305 | 305 |
| 306 TextureDefinition::LevelInfo::LevelInfo() | 306 TextureDefinition::LevelInfo::LevelInfo() |
| 307 : target(0), | 307 : target(0), |
| 308 internal_format(0), | 308 internal_format(0), |
| 309 width(0), | 309 width(0), |
| 310 height(0), | 310 height(0), |
| 311 depth(0), | 311 depth(0), |
| 312 border(0), | 312 border(0), |
| 313 format(0), | 313 format(0), |
| 314 type(0), | 314 type(0) { |
| 315 cleared(false) { | |
| 316 } | 315 } |
| 317 | 316 |
| 318 TextureDefinition::LevelInfo::LevelInfo(GLenum target, | 317 TextureDefinition::LevelInfo::LevelInfo(GLenum target, |
| 319 GLenum internal_format, | 318 GLenum internal_format, |
| 320 GLsizei width, | 319 GLsizei width, |
| 321 GLsizei height, | 320 GLsizei height, |
| 322 GLsizei depth, | 321 GLsizei depth, |
| 323 GLint border, | 322 GLint border, |
| 324 GLenum format, | 323 GLenum format, |
| 325 GLenum type, | 324 GLenum type, |
| 326 bool cleared) | 325 const gfx::Rect& cleared_rect) |
| 327 : target(target), | 326 : target(target), |
| 328 internal_format(internal_format), | 327 internal_format(internal_format), |
| 329 width(width), | 328 width(width), |
| 330 height(height), | 329 height(height), |
| 331 depth(depth), | 330 depth(depth), |
| 332 border(border), | 331 border(border), |
| 333 format(format), | 332 format(format), |
| 334 type(type), | 333 type(type), |
| 335 cleared(cleared) {} | 334 cleared_rect(cleared_rect) { |
| 335 } |
| 336 | 336 |
| 337 TextureDefinition::LevelInfo::~LevelInfo() {} | 337 TextureDefinition::LevelInfo::~LevelInfo() {} |
| 338 | 338 |
| 339 TextureDefinition::TextureDefinition() | 339 TextureDefinition::TextureDefinition() |
| 340 : version_(0), | 340 : version_(0), |
| 341 target_(0), | 341 target_(0), |
| 342 min_filter_(0), | 342 min_filter_(0), |
| 343 mag_filter_(0), | 343 mag_filter_(0), |
| 344 wrap_s_(0), | 344 wrap_s_(0), |
| 345 wrap_t_(0), | 345 wrap_t_(0), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 372 scoped_refptr<gfx::GLImage> gl_image( | 372 scoped_refptr<gfx::GLImage> gl_image( |
| 373 new GLImageSync(image_buffer_, | 373 new GLImageSync(image_buffer_, |
| 374 gfx::Size(first_face.level_infos[0].width, | 374 gfx::Size(first_face.level_infos[0].width, |
| 375 first_face.level_infos[0].height))); | 375 first_face.level_infos[0].height))); |
| 376 texture->SetLevelImage(NULL, target_, 0, gl_image.get()); | 376 texture->SetLevelImage(NULL, target_, 0, gl_image.get()); |
| 377 } | 377 } |
| 378 | 378 |
| 379 const Texture::LevelInfo& level = first_face.level_infos[0]; | 379 const Texture::LevelInfo& level = first_face.level_infos[0]; |
| 380 level_info_ = LevelInfo(level.target, level.internal_format, level.width, | 380 level_info_ = LevelInfo(level.target, level.internal_format, level.width, |
| 381 level.height, level.depth, level.border, level.format, | 381 level.height, level.depth, level.border, level.format, |
| 382 level.type, level.cleared); | 382 level.type, level.cleared_rect); |
| 383 } | 383 } |
| 384 | 384 |
| 385 TextureDefinition::~TextureDefinition() { | 385 TextureDefinition::~TextureDefinition() { |
| 386 } | 386 } |
| 387 | 387 |
| 388 Texture* TextureDefinition::CreateTexture() const { | 388 Texture* TextureDefinition::CreateTexture() const { |
| 389 GLuint texture_id; | 389 GLuint texture_id; |
| 390 glGenTextures(1, &texture_id); | 390 glGenTextures(1, &texture_id); |
| 391 | 391 |
| 392 Texture* texture(new Texture(texture_id)); | 392 Texture* texture(new Texture(texture_id)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 | 416 |
| 417 if (defined_) { | 417 if (defined_) { |
| 418 texture->face_infos_.resize(1); | 418 texture->face_infos_.resize(1); |
| 419 texture->face_infos_[0].level_infos.resize(1); | 419 texture->face_infos_[0].level_infos.resize(1); |
| 420 texture->SetLevelInfo(NULL, level_info_.target, 0, | 420 texture->SetLevelInfo(NULL, level_info_.target, 0, |
| 421 level_info_.internal_format, level_info_.width, | 421 level_info_.internal_format, level_info_.width, |
| 422 level_info_.height, level_info_.depth, | 422 level_info_.height, level_info_.depth, |
| 423 level_info_.border, level_info_.format, | 423 level_info_.border, level_info_.format, |
| 424 level_info_.type, level_info_.cleared); | 424 level_info_.type, level_info_.cleared_rect); |
| 425 } | 425 } |
| 426 | 426 |
| 427 if (image_buffer_.get()) { | 427 if (image_buffer_.get()) { |
| 428 texture->SetLevelImage( | 428 texture->SetLevelImage( |
| 429 NULL, | 429 NULL, |
| 430 target_, | 430 target_, |
| 431 0, | 431 0, |
| 432 new GLImageSync( | 432 new GLImageSync( |
| 433 image_buffer_, | 433 image_buffer_, |
| 434 gfx::Size(level_info_.width, level_info_.height))); | 434 gfx::Size(level_info_.width, level_info_.height))); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 return false; | 482 return false; |
| 483 | 483 |
| 484 // All structural changes should have orphaned the texture. | 484 // All structural changes should have orphaned the texture. |
| 485 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0)) | 485 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0)) |
| 486 return false; | 486 return false; |
| 487 | 487 |
| 488 return true; | 488 return true; |
| 489 } | 489 } |
| 490 | 490 |
| 491 bool TextureDefinition::SafeToRenderFrom() const { | 491 bool TextureDefinition::SafeToRenderFrom() const { |
| 492 return level_info_.cleared; | 492 return level_info_.cleared_rect.Contains( |
| 493 gfx::Rect(level_info_.width, level_info_.height)); |
| 493 } | 494 } |
| 494 | 495 |
| 495 } // namespace gles2 | 496 } // namespace gles2 |
| 496 } // namespace gpu | 497 } // namespace gpu |
| OLD | NEW |