| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 texture_target_(texture_target), | 358 texture_target_(texture_target), |
| 359 query_type_(query_type), | 359 query_type_(query_type), |
| 360 use_zero_copy_(use_zero_copy), | 360 use_zero_copy_(use_zero_copy), |
| 361 is_overlay_candidate_(is_overlay_candidate), | 361 is_overlay_candidate_(is_overlay_candidate), |
| 362 use_count_(0) {} | 362 use_count_(0) {} |
| 363 | 363 |
| 364 Buffer::~Buffer() {} | 364 Buffer::~Buffer() {} |
| 365 | 365 |
| 366 scoped_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox( | 366 scoped_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox( |
| 367 cc::TextureMailbox* texture_mailbox, | 367 cc::TextureMailbox* texture_mailbox, |
| 368 bool secure_output_only, |
| 368 bool lost_context) { | 369 bool lost_context) { |
| 369 DLOG_IF(WARNING, use_count_) | 370 DLOG_IF(WARNING, use_count_) |
| 370 << "Producing a texture mailbox for a buffer that has not been released"; | 371 << "Producing a texture mailbox for a buffer that has not been released"; |
| 371 | 372 |
| 372 // Some clients think that they can reuse a buffer before it's released by | 373 // Some clients think that they can reuse a buffer before it's released by |
| 373 // performing a fast blit into the buffer. This behavior is bad as it prevents | 374 // performing a fast blit into the buffer. This behavior is bad as it prevents |
| 374 // the client from knowing when the buffer is actually released (e.g. the | 375 // the client from knowing when the buffer is actually released (e.g. the |
| 375 // release notification for the previous use of buffer can arrive after the | 376 // release notification for the previous use of buffer can arrive after the |
| 376 // buffer has been reused). We stop running the release callback when this | 377 // buffer has been reused). We stop running the release callback when this |
| 377 // type of behavior is detected as having the buffer always be busy will | 378 // type of behavior is detected as having the buffer always be busy will |
| (...skipping 23 matching lines...) Expand all Loading... |
| 401 | 402 |
| 402 // Create a new image texture for |gpu_memory_buffer_| with |texture_target_| | 403 // Create a new image texture for |gpu_memory_buffer_| with |texture_target_| |
| 403 // if one doesn't already exist. The contents of this buffer are copied to | 404 // if one doesn't already exist. The contents of this buffer are copied to |
| 404 // |texture| using a call to CopyTexImage. | 405 // |texture| using a call to CopyTexImage. |
| 405 if (!contents_texture_) { | 406 if (!contents_texture_) { |
| 406 contents_texture_ = make_scoped_ptr( | 407 contents_texture_ = make_scoped_ptr( |
| 407 new Texture(context_provider.get(), gpu_memory_buffer_.get(), | 408 new Texture(context_provider.get(), gpu_memory_buffer_.get(), |
| 408 texture_target_, query_type_)); | 409 texture_target_, query_type_)); |
| 409 } | 410 } |
| 410 | 411 |
| 411 // TODO(dcastagna): Set properly based on the flag on the imported buffer. | |
| 412 bool secure_output_only = false; | |
| 413 | |
| 414 if (use_zero_copy_) { | 412 if (use_zero_copy_) { |
| 415 // Zero-copy means using the contents texture directly. | 413 // Zero-copy means using the contents texture directly. |
| 416 Texture* texture = contents_texture_.get(); | 414 Texture* texture = contents_texture_.get(); |
| 417 | 415 |
| 418 // This binds the latest contents of this buffer to |texture|. | 416 // This binds the latest contents of this buffer to |texture|. |
| 419 gpu::SyncToken sync_token = texture->BindTexImage(); | 417 gpu::SyncToken sync_token = texture->BindTexImage(); |
| 420 | 418 |
| 421 *texture_mailbox = | 419 *texture_mailbox = |
| 422 cc::TextureMailbox(texture->mailbox(), sync_token, texture_target_, | 420 cc::TextureMailbox(texture->mailbox(), sync_token, texture_target_, |
| 423 gpu_memory_buffer_->GetSize(), is_overlay_candidate_, | 421 gpu_memory_buffer_->GetSize(), is_overlay_candidate_, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 486 } |
| 489 | 487 |
| 490 void Buffer::ReleaseContentsTexture(scoped_ptr<Texture> texture) { | 488 void Buffer::ReleaseContentsTexture(scoped_ptr<Texture> texture) { |
| 491 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); | 489 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); |
| 492 | 490 |
| 493 contents_texture_ = std::move(texture); | 491 contents_texture_ = std::move(texture); |
| 494 Release(); | 492 Release(); |
| 495 } | 493 } |
| 496 | 494 |
| 497 } // namespace exo | 495 } // namespace exo |
| OLD | NEW |