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

Unified Diff: components/exo/buffer.cc

Issue 2404513002: exo: Implement zcr_linux_explicit_synchronization_v1
Patch Set: 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..1dc71fe95769b696a45422392707101af4daa99b 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(std::unique_ptr<gfx::GpuFence> acquire_fence);
// 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(std::unique_ptr<gfx::GpuFence> acquire_fence,
+ Texture* destination,
const base::Closure& callback);
// Returns the mailbox for this texture.
@@ -231,14 +233,19 @@ void Buffer::Texture::Release(const base::Closure& callback,
callback.Run();
}
-gpu::SyncToken Buffer::Texture::BindTexImage() {
+gpu::SyncToken Buffer::Texture::BindTexImage(std::unique_ptr<gfx::GpuFence> acquire_fence) {
gpu::SyncToken sync_token;
if (context_provider_) {
+ GLuint fence_id = 0;
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 = glCreateFenceCHROMIUM(acquire_fence->AsClientFence());
reveman 2016/10/09 19:03:16 Please use gles2->CreateFenceCHROMIUM here and it
fooishbar 2016/10/12 15:41:55 Oops, yes. Where would we defer it though? I can h
+ 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_);
@@ -276,15 +283,21 @@ void Buffer::Texture::ReleaseTexImage(const base::Closure& callback,
callback.Run();
}
-gpu::SyncToken Buffer::Texture::CopyTexImage(Texture* destination,
+gpu::SyncToken Buffer::Texture::CopyTexImage(std::unique_ptr<gfx::GpuFence> acquire_fence,
+ Texture* destination,
const base::Closure& callback) {
gpu::SyncToken sync_token;
if (context_provider_) {
+ GLuint fence_id = 0;
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 = glCreateFenceCHROMIUM(acquire_fence->AsClientFence());
reveman 2016/10/09 19:03:16 ditto
+ 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);
@@ -400,6 +413,7 @@ Buffer::~Buffer() {}
std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
cc::TextureMailbox* texture_mailbox,
+ std::unique_ptr<gfx::GpuFence> acquire_fence,
bool secure_output_only,
bool client_usage) {
DCHECK(attach_count_);
@@ -450,7 +464,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 +490,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 =

Powered by Google App Engine
This is Rietveld 408576698