OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/buffer.h" | 5 #include "components/exo/buffer.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 contents_texture_ = base::MakeUnique<Texture>( | 457 contents_texture_ = base::MakeUnique<Texture>( |
458 context_factory, context_provider.get(), gpu_memory_buffer_.get(), | 458 context_factory, context_provider.get(), gpu_memory_buffer_.get(), |
459 texture_target_, query_type_); | 459 texture_target_, query_type_); |
460 } | 460 } |
461 | 461 |
462 if (use_zero_copy_) { | 462 if (use_zero_copy_) { |
463 // Zero-copy means using the contents texture directly. | 463 // Zero-copy means using the contents texture directly. |
464 Texture* texture = contents_texture_.get(); | 464 Texture* texture = contents_texture_.get(); |
465 | 465 |
466 // This binds the latest contents of this buffer to |texture|. | 466 // This binds the latest contents of this buffer to |texture|. |
467 resource->mailbox_holder = gpu::MailboxHolder( | 467 gpu::SyncToken sync_token = texture->BindTexImage(); |
468 texture->mailbox(), texture->BindTexImage(), texture_target_); | |
469 | 468 |
469 resource->mailbox_holder = | |
470 gpu::MailboxHolder(texture->mailbox(), sync_token, texture_target_); | |
470 resource->is_overlay_candidate = is_overlay_candidate_; | 471 resource->is_overlay_candidate = is_overlay_candidate_; |
471 | 472 |
472 // The contents texture will be released when no longer used by the | 473 // The contents texture will be released when no longer used by the |
473 // compositor. | 474 // compositor. |
474 compositor_frame_sink_holder_->SetResourceReleaseCallback( | 475 compositor_frame_sink_holder_->SetResourceReleaseCallback( |
475 resource_id, | 476 resource_id, |
476 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), | 477 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), |
477 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 478 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
478 base::Passed(&contents_texture_)))); | 479 base::Passed(&contents_texture_)))); |
479 return true; | 480 return true; |
480 } | 481 } |
481 | 482 |
482 // Create a mailbox texture that we copy the buffer contents to. | 483 // Create a mailbox texture that we copy the buffer contents to. |
483 if (!texture_) { | 484 if (!texture_) { |
484 texture_ = | 485 texture_ = |
485 base::MakeUnique<Texture>(context_factory, context_provider.get()); | 486 base::MakeUnique<Texture>(context_factory, context_provider.get()); |
486 } | 487 } |
487 | 488 |
488 // Copy the contents of |contents_texture| to |texture| and produce a | 489 // Copy the contents of |contents_texture| to |texture| and produce a |
489 // texture mailbox from the result in |texture|. | 490 // texture mailbox from the result in |texture|. |
490 Texture* contents_texture = contents_texture_.get(); | 491 Texture* contents_texture = contents_texture_.get(); |
491 Texture* texture = texture_.get(); | 492 Texture* texture = texture_.get(); |
492 | 493 |
493 // The contents texture will be released when copy has completed. | 494 // The contents texture will be released when copy has completed. |
494 resource->mailbox_holder = gpu::MailboxHolder( | 495 resource->mailbox_holder = gpu::MailboxHolder( |
495 texture->mailbox(), | 496 texture->mailbox(), |
496 contents_texture->CopyTexImage( | 497 contents_texture->CopyTexImage( |
Alex Z.
2017/01/11 14:54:49
Another sync token is created here.
Does the text
reveman
2017/01/11 18:06:53
The mailbox for |texture| has already been created
| |
497 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 498 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
498 base::Passed(&contents_texture_))), | 499 base::Passed(&contents_texture_))), |
499 GL_TEXTURE_2D); | 500 GL_TEXTURE_2D); |
500 resource->is_overlay_candidate = false; | 501 resource->is_overlay_candidate = false; |
501 | 502 |
502 // The mailbox texture will be released when no longer used by the | 503 // The mailbox texture will be released when no longer used by the |
503 // compositor. | 504 // compositor. |
504 compositor_frame_sink_holder_->SetResourceReleaseCallback( | 505 compositor_frame_sink_holder_->SetResourceReleaseCallback( |
505 resource_id, | 506 resource_id, |
506 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), | 507 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 texture_ = std::move(texture); | 561 texture_ = std::move(texture); |
561 } | 562 } |
562 | 563 |
563 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { | 564 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { |
564 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); | 565 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); |
565 contents_texture_ = std::move(texture); | 566 contents_texture_ = std::move(texture); |
566 Release(); | 567 Release(); |
567 } | 568 } |
568 | 569 |
569 } // namespace exo | 570 } // namespace exo |
OLD | NEW |