| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 texture_target_, query_type_)); | 420 texture_target_, query_type_)); |
| 421 } | 421 } |
| 422 | 422 |
| 423 if (use_zero_copy_) { | 423 if (use_zero_copy_) { |
| 424 // Zero-copy means using the contents texture directly. | 424 // Zero-copy means using the contents texture directly. |
| 425 Texture* texture = contents_texture_.get(); | 425 Texture* texture = contents_texture_.get(); |
| 426 | 426 |
| 427 // This binds the latest contents of this buffer to |texture|. | 427 // This binds the latest contents of this buffer to |texture|. |
| 428 gpu::SyncToken sync_token = texture->BindTexImage(); | 428 gpu::SyncToken sync_token = texture->BindTexImage(); |
| 429 | 429 |
| 430 *texture_mailbox = cc::TextureMailbox( | 430 *texture_mailbox = |
| 431 texture->mailbox(), sync_token, texture_target_, | 431 cc::TextureMailbox(texture->mailbox(), sync_token, texture_target_, |
| 432 gpu_memory_buffer_->GetSize(), gpu_memory_buffer_->GetId(), | 432 gpu_memory_buffer_->GetSize(), is_overlay_candidate_, |
| 433 is_overlay_candidate_, secure_output_only); | 433 secure_output_only); |
| 434 // The contents texture will be released when no longer used by the | 434 // The contents texture will be released when no longer used by the |
| 435 // compositor. | 435 // compositor. |
| 436 return cc::SingleReleaseCallback::Create( | 436 return cc::SingleReleaseCallback::Create( |
| 437 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), | 437 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), |
| 438 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 438 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
| 439 base::Passed(&contents_texture_)))); | 439 base::Passed(&contents_texture_)))); |
| 440 } | 440 } |
| 441 | 441 |
| 442 // Create a mailbox texture that we copy the buffer contents to. | 442 // Create a mailbox texture that we copy the buffer contents to. |
| 443 if (!texture_) | 443 if (!texture_) |
| 444 texture_ = base::WrapUnique(new Texture(context_provider.get())); | 444 texture_ = base::WrapUnique(new Texture(context_provider.get())); |
| 445 | 445 |
| 446 // Copy the contents of |contents_texture| to |texture| and produce a | 446 // Copy the contents of |contents_texture| to |texture| and produce a |
| 447 // texture mailbox from the result in |texture|. | 447 // texture mailbox from the result in |texture|. |
| 448 Texture* contents_texture = contents_texture_.get(); | 448 Texture* contents_texture = contents_texture_.get(); |
| 449 Texture* texture = texture_.get(); | 449 Texture* texture = texture_.get(); |
| 450 | 450 |
| 451 // The contents texture will be released when copy has completed. | 451 // The contents texture will be released when copy has completed. |
| 452 gpu::SyncToken sync_token = contents_texture->CopyTexImage( | 452 gpu::SyncToken sync_token = contents_texture->CopyTexImage( |
| 453 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 453 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
| 454 base::Passed(&contents_texture_))); | 454 base::Passed(&contents_texture_))); |
| 455 *texture_mailbox = cc::TextureMailbox( | 455 *texture_mailbox = |
| 456 texture->mailbox(), sync_token, GL_TEXTURE_2D, | 456 cc::TextureMailbox(texture->mailbox(), sync_token, GL_TEXTURE_2D, |
| 457 gpu_memory_buffer_->GetSize(), gfx::GpuMemoryBufferId(), | 457 gpu_memory_buffer_->GetSize(), |
| 458 false /* is_overlay_candidate */, secure_output_only); | 458 false /* is_overlay_candidate */, secure_output_only); |
| 459 // The mailbox texture will be released when no longer used by the | 459 // The mailbox texture will be released when no longer used by the |
| 460 // compositor. | 460 // compositor. |
| 461 return cc::SingleReleaseCallback::Create( | 461 return cc::SingleReleaseCallback::Create( |
| 462 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), | 462 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), |
| 463 base::Bind(&Buffer::ReleaseTexture, AsWeakPtr(), | 463 base::Bind(&Buffer::ReleaseTexture, AsWeakPtr(), |
| 464 base::Passed(&texture_)))); | 464 base::Passed(&texture_)))); |
| 465 } | 465 } |
| 466 | 466 |
| 467 gfx::Size Buffer::GetSize() const { | 467 gfx::Size Buffer::GetSize() const { |
| 468 return gpu_memory_buffer_->GetSize(); | 468 return gpu_memory_buffer_->GetSize(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 497 } | 497 } |
| 498 | 498 |
| 499 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { | 499 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { |
| 500 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); | 500 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); |
| 501 | 501 |
| 502 contents_texture_ = std::move(texture); | 502 contents_texture_ = std::move(texture); |
| 503 Release(); | 503 Release(); |
| 504 } | 504 } |
| 505 | 505 |
| 506 } // namespace exo | 506 } // namespace exo |
| OLD | NEW |