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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 query_type_(query_type), | 362 query_type_(query_type), |
363 use_zero_copy_(use_zero_copy), | 363 use_zero_copy_(use_zero_copy), |
364 is_overlay_candidate_(is_overlay_candidate), | 364 is_overlay_candidate_(is_overlay_candidate), |
365 use_count_(0) {} | 365 use_count_(0) {} |
366 | 366 |
367 Buffer::~Buffer() {} | 367 Buffer::~Buffer() {} |
368 | 368 |
369 std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox( | 369 std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox( |
370 cc::TextureMailbox* texture_mailbox, | 370 cc::TextureMailbox* texture_mailbox, |
371 bool secure_output_only, | 371 bool secure_output_only, |
372 bool lost_context) { | 372 bool non_client_usage) { |
373 DLOG_IF(WARNING, use_count_) | 373 // Non-client usage can only be allowed when the client is no allowed to |
Daniele Castagna
2016/06/06 02:47:53
no allow? no longer allowed? not allowed?
reveman
2016/06/06 03:17:36
not allowed, fixed.
| |
374 // use the buffer. If the buffer has been released to the client then it | |
375 // can no longer be used as the client might be writing to it. | |
376 if (non_client_usage && !use_count_) | |
377 return nullptr; | |
378 | |
379 DLOG_IF(WARNING, use_count_ && !non_client_usage) | |
Daniele Castagna
2016/06/06 02:47:53
I'd avoid the double negation of !non if possible.
reveman
2016/06/06 03:17:36
done
| |
374 << "Producing a texture mailbox for a buffer that has not been released"; | 380 << "Producing a texture mailbox for a buffer that has not been released"; |
375 | 381 |
376 // Some clients think that they can reuse a buffer before it's released by | 382 // Some clients think that they can reuse a buffer before it's released by |
377 // performing a fast blit into the buffer. This behavior is bad as it prevents | 383 // performing a fast blit into the buffer. This behavior is bad as it prevents |
378 // the client from knowing when the buffer is actually released (e.g. the | 384 // the client from knowing when the buffer is actually released (e.g. the |
379 // release notification for the previous use of buffer can arrive after the | 385 // release notification for the previous use of buffer can arrive after the |
380 // buffer has been reused). We stop running the release callback when this | 386 // buffer has been reused). We stop running the release callback when this |
381 // type of behavior is detected as having the buffer always be busy will | 387 // type of behavior is detected as having the buffer always be busy will |
382 // result in fewer drawing artifacts. | 388 // result in fewer drawing artifacts. |
383 if (use_count_ && !lost_context) | 389 if (use_count_ && !non_client_usage) |
384 release_callback_.Reset(); | 390 release_callback_.Reset(); |
385 | 391 |
386 // Increment the use count for this buffer. | 392 // Increment the use count for this buffer. |
387 ++use_count_; | 393 ++use_count_; |
388 | 394 |
389 // If textures are lost, destroy them to ensure that we create new ones below. | 395 // If textures are lost, destroy them to ensure that we create new ones below. |
390 if (contents_texture_ && contents_texture_->IsLost()) | 396 if (contents_texture_ && contents_texture_->IsLost()) |
391 contents_texture_.reset(); | 397 contents_texture_.reset(); |
392 if (texture_ && texture_->IsLost()) | 398 if (texture_ && texture_->IsLost()) |
393 texture_.reset(); | 399 texture_.reset(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 } | 495 } |
490 | 496 |
491 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { | 497 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { |
492 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); | 498 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); |
493 | 499 |
494 contents_texture_ = std::move(texture); | 500 contents_texture_ = std::move(texture); |
495 Release(); | 501 Release(); |
496 } | 502 } |
497 | 503 |
498 } // namespace exo | 504 } // namespace exo |
OLD | NEW |