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/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 image_buffer_(image_buffer.get() | 367 image_buffer_(image_buffer.get() |
368 ? image_buffer | 368 ? image_buffer |
369 : NativeImageBuffer::Create(texture->service_id())), | 369 : NativeImageBuffer::Create(texture->service_id())), |
370 min_filter_(texture->min_filter()), | 370 min_filter_(texture->min_filter()), |
371 mag_filter_(texture->mag_filter()), | 371 mag_filter_(texture->mag_filter()), |
372 wrap_s_(texture->wrap_s()), | 372 wrap_s_(texture->wrap_s()), |
373 wrap_t_(texture->wrap_t()), | 373 wrap_t_(texture->wrap_t()), |
374 usage_(texture->usage()), | 374 usage_(texture->usage()), |
375 immutable_(texture->IsImmutable()) { | 375 immutable_(texture->IsImmutable()) { |
376 // TODO | 376 // TODO |
377 DCHECK(!texture->level_infos_.empty()); | 377 DCHECK(!texture->face_infos_.empty()); |
378 DCHECK(!texture->level_infos_[0].empty()); | 378 DCHECK(!texture->face_infos_[0].level_infos.empty()); |
379 DCHECK(!texture->NeedsMips()); | 379 DCHECK(!texture->NeedsMips()); |
380 DCHECK(texture->level_infos_[0][0].width); | 380 DCHECK(texture->face_infos_[0].level_infos[0].width); |
381 DCHECK(texture->level_infos_[0][0].height); | 381 DCHECK(texture->face_infos_[0].level_infos[0].height); |
382 | 382 |
| 383 const Texture::FaceInfo& first_face = texture->face_infos_[0]; |
383 scoped_refptr<gfx::GLImage> gl_image( | 384 scoped_refptr<gfx::GLImage> gl_image( |
384 new GLImageSync(image_buffer_, | 385 new GLImageSync(image_buffer_, |
385 gfx::Size(texture->level_infos_[0][0].width, | 386 gfx::Size(first_face.level_infos[0].width, |
386 texture->level_infos_[0][0].height))); | 387 first_face.level_infos[0].height))); |
387 texture->SetLevelImage(NULL, target, 0, gl_image.get()); | 388 texture->SetLevelImage(NULL, target, 0, gl_image.get()); |
388 | 389 |
389 // TODO: all levels | 390 // TODO: all levels |
390 level_infos_.clear(); | 391 level_infos_.clear(); |
391 const Texture::LevelInfo& level = texture->level_infos_[0][0]; | 392 const Texture::LevelInfo& level = first_face.level_infos[0]; |
392 LevelInfo info(level.target, | 393 LevelInfo info(level.target, |
393 level.internal_format, | 394 level.internal_format, |
394 level.width, | 395 level.width, |
395 level.height, | 396 level.height, |
396 level.depth, | 397 level.depth, |
397 level.border, | 398 level.border, |
398 level.format, | 399 level.format, |
399 level.type, | 400 level.type, |
400 level.cleared); | 401 level.cleared); |
401 std::vector<LevelInfo> infos; | 402 std::vector<LevelInfo> infos; |
(...skipping 26 matching lines...) Expand all Loading... |
428 if (image_buffer_.get()) | 429 if (image_buffer_.get()) |
429 image_buffer_->BindToTexture(target_); | 430 image_buffer_->BindToTexture(target_); |
430 // We have to make sure the changes are visible to other clients in this share | 431 // We have to make sure the changes are visible to other clients in this share |
431 // group. As far as the clients are concerned, the mailbox semantics only | 432 // group. As far as the clients are concerned, the mailbox semantics only |
432 // demand a single flush from the client after changes are first made, | 433 // demand a single flush from the client after changes are first made, |
433 // and it is not visible to them when another share group boundary is crossed. | 434 // and it is not visible to them when another share group boundary is crossed. |
434 // We could probably track this and be a bit smarter about when to flush | 435 // We could probably track this and be a bit smarter about when to flush |
435 // though. | 436 // though. |
436 glFlush(); | 437 glFlush(); |
437 | 438 |
438 texture->level_infos_.resize(1); | 439 texture->face_infos_.resize(1); |
439 for (size_t i = 0; i < level_infos_.size(); i++) { | 440 for (size_t i = 0; i < level_infos_.size(); i++) { |
440 const LevelInfo& base_info = level_infos_[i][0]; | 441 const LevelInfo& base_info = level_infos_[i][0]; |
441 const size_t levels_needed = TextureManager::ComputeMipMapCount( | 442 const size_t levels_needed = TextureManager::ComputeMipMapCount( |
442 base_info.target, base_info.width, base_info.height, base_info.depth); | 443 base_info.target, base_info.width, base_info.height, base_info.depth); |
443 DCHECK(level_infos_.size() <= levels_needed); | 444 DCHECK(level_infos_.size() <= levels_needed); |
444 texture->level_infos_[0].resize(levels_needed); | 445 texture->face_infos_[0].level_infos.resize(levels_needed); |
445 for (size_t n = 0; n < level_infos_.size(); n++) { | 446 for (size_t n = 0; n < level_infos_.size(); n++) { |
446 const LevelInfo& info = level_infos_[i][n]; | 447 const LevelInfo& info = level_infos_[i][n]; |
447 texture->SetLevelInfo(NULL, | 448 texture->SetLevelInfo(NULL, |
448 info.target, | 449 info.target, |
449 i, | 450 i, |
450 info.internal_format, | 451 info.internal_format, |
451 info.width, | 452 info.width, |
452 info.height, | 453 info.height, |
453 info.depth, | 454 info.depth, |
454 info.border, | 455 info.border, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 488 |
488 // All structural changes should have orphaned the texture. | 489 // All structural changes should have orphaned the texture. |
489 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0)) | 490 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0)) |
490 return false; | 491 return false; |
491 | 492 |
492 return true; | 493 return true; |
493 } | 494 } |
494 | 495 |
495 } // namespace gles2 | 496 } // namespace gles2 |
496 } // namespace gpu | 497 } // namespace gpu |
OLD | NEW |