Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1199)

Unified Diff: components/exo/buffer.cc

Issue 2404513002: exo: Implement zcr_linux_explicit_synchronization_v1
Patch Set: rebase, address review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/exo/buffer.cc
diff --git a/components/exo/buffer.cc b/components/exo/buffer.cc
index 0c771df3d66a9af9af0a44c9fa7e7f412b238e52..3e2486a5ff90628eed325a41315e51e5987dbcab 100644
--- a/components/exo/buffer.cc
+++ b/components/exo/buffer.cc
@@ -28,6 +28,7 @@
#include "gpu/command_buffer/client/gles2_interface.h"
#include "ui/aura/env.h"
#include "ui/compositor/compositor.h"
+#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace exo {
@@ -118,7 +119,7 @@ class Buffer::Texture : public ui::ContextFactoryObserver {
// Binds the contents referenced by |image_id_| to the texture returned by
// mailbox(). Returns a sync token that can be used when accessing texture
// from a different context.
- gpu::SyncToken BindTexImage();
+ gpu::SyncToken BindTexImage(gfx::GpuFence* acquire_fence);
reveman 2016/10/12 19:20:19 nit: sometimes "acquire_fence" name is used and so
// Releases the contents referenced by |image_id_| after |sync_token| has
// passed and runs |callback| when completed.
@@ -129,7 +130,8 @@ class Buffer::Texture : public ui::ContextFactoryObserver {
// Copy the contents of texture to |destination| and runs |callback| when
// completed. Returns a sync token that can be used when accessing texture
// from a different context.
- gpu::SyncToken CopyTexImage(Texture* destination,
+ gpu::SyncToken CopyTexImage(gfx::GpuFence* acquire_fence,
+ Texture* destination,
const base::Closure& callback);
// Returns the mailbox for this texture.
@@ -150,6 +152,7 @@ class Buffer::Texture : public ui::ContextFactoryObserver {
unsigned image_id_ = 0;
unsigned query_id_ = 0;
unsigned texture_id_ = 0;
+ unsigned fence_id_ = 0;
gpu::Mailbox mailbox_;
base::Closure release_callback_;
base::TimeTicks wait_for_release_time_;
@@ -231,14 +234,18 @@ void Buffer::Texture::Release(const base::Closure& callback,
callback.Run();
}
-gpu::SyncToken Buffer::Texture::BindTexImage() {
+gpu::SyncToken Buffer::Texture::BindTexImage(gfx::GpuFence* acquire_fence) {
gpu::SyncToken sync_token;
if (context_provider_) {
gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL();
gles2->ActiveTexture(GL_TEXTURE0);
gles2->BindTexture(texture_target_, texture_id_);
DCHECK_NE(image_id_, 0u);
- gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, 0);
+ if (acquire_fence) {
+ fence_id_ = gles2->CreateFenceCHROMIUM(acquire_fence->AsClientFence());
+ DCHECK_NE(fence_id_, 0u);
+ }
+ gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, fence_id_);
// Generate a crypto-secure random mailbox name if not already done.
if (mailbox_.IsZero())
CreateGLTextureMailbox(gles2, texture_id_, texture_target_, &mailbox_);
@@ -264,6 +271,8 @@ void Buffer::Texture::ReleaseTexImage(const base::Closure& callback,
DCHECK_NE(query_id_, 0u);
gles2->BeginQueryEXT(query_type_, query_id_);
gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_);
+ if (fence_id_ != 0u)
reveman 2016/10/12 19:20:19 nit: "if (fence_id_)" is preferred in chromium cod
+ gles2->DestroyFenceCHROMIUM(fence_id_);
gles2->EndQueryEXT(query_type_);
// Run callback when query result is available and ReleaseTexImage has been
// handled if sync token has data and buffer has been used. If buffer was
@@ -276,7 +285,8 @@ void Buffer::Texture::ReleaseTexImage(const base::Closure& callback,
callback.Run();
}
-gpu::SyncToken Buffer::Texture::CopyTexImage(Texture* destination,
+gpu::SyncToken Buffer::Texture::CopyTexImage(gfx::GpuFence* acquire_fence,
+ Texture* destination,
const base::Closure& callback) {
gpu::SyncToken sync_token;
if (context_provider_) {
@@ -284,13 +294,19 @@ gpu::SyncToken Buffer::Texture::CopyTexImage(Texture* destination,
gles2->ActiveTexture(GL_TEXTURE0);
gles2->BindTexture(texture_target_, texture_id_);
DCHECK_NE(image_id_, 0u);
- gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, 0);
+ if (acquire_fence) {
+ fence_id_ = gles2->CreateFenceCHROMIUM(acquire_fence->AsClientFence());
+ DCHECK_NE(fence_id_, 0u);
+ }
+ gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, fence_id_);
gles2->CopyTextureCHROMIUM(texture_id_, destination->texture_id_,
internalformat_, GL_UNSIGNED_BYTE, false, false,
false);
DCHECK_NE(query_id_, 0u);
gles2->BeginQueryEXT(query_type_, query_id_);
gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_);
+ if (fence_id_ != 0u)
reveman 2016/10/12 19:20:18 nit: "if (fence_id_)" is preferred in chromium cod
+ gles2->DestroyFenceCHROMIUM(fence_id_);
reveman 2016/10/12 19:20:19 nit: set fence_id_ to 0 here so it's easier to tel
gles2->EndQueryEXT(query_type_);
// Run callback when query result is available and ReleaseTexImage has been
// handled.
@@ -400,6 +416,7 @@ Buffer::~Buffer() {}
std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
cc::TextureMailbox* texture_mailbox,
+ gfx::GpuFence* acquire_fence,
reveman 2016/10/12 19:20:19 nit: s/acquire_fence/fence/ to be consistent with
bool secure_output_only,
bool client_usage) {
DCHECK(attach_count_);
@@ -450,7 +467,7 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
Texture* texture = contents_texture_.get();
// This binds the latest contents of this buffer to |texture|.
- gpu::SyncToken sync_token = texture->BindTexImage();
+ gpu::SyncToken sync_token = texture->BindTexImage(std::move(acquire_fence));
*texture_mailbox =
cc::TextureMailbox(texture->mailbox(), sync_token, texture_target_,
@@ -476,7 +493,7 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
Texture* texture = texture_.get();
// The contents texture will be released when copy has completed.
- gpu::SyncToken sync_token = contents_texture->CopyTexImage(
+ gpu::SyncToken sync_token = contents_texture->CopyTexImage(std::move(acquire_fence),
texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(),
base::Passed(&contents_texture_)));
*texture_mailbox =
« no previous file with comments | « components/exo/buffer.h ('k') | components/exo/display.h » ('j') | components/exo/display.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698