Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
| 23 #include "base/trace_event/trace_event_argument.h" | 23 #include "base/trace_event/trace_event_argument.h" |
| 24 #include "cc/output/context_provider.h" | 24 #include "cc/output/context_provider.h" |
| 25 #include "cc/resources/single_release_callback.h" | 25 #include "cc/resources/single_release_callback.h" |
| 26 #include "cc/resources/texture_mailbox.h" | 26 #include "cc/resources/texture_mailbox.h" |
| 27 #include "gpu/command_buffer/client/context_support.h" | 27 #include "gpu/command_buffer/client/context_support.h" |
| 28 #include "gpu/command_buffer/client/gles2_interface.h" | 28 #include "gpu/command_buffer/client/gles2_interface.h" |
| 29 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
| 30 #include "ui/compositor/compositor.h" | 30 #include "ui/compositor/compositor.h" |
| 31 #include "ui/gfx/gpu_fence.h" | |
| 31 #include "ui/gfx/gpu_memory_buffer.h" | 32 #include "ui/gfx/gpu_memory_buffer.h" |
| 32 | 33 |
| 33 namespace exo { | 34 namespace exo { |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 // The amount of time before we wait for release queries using | 37 // The amount of time before we wait for release queries using |
| 37 // GetQueryObjectuivEXT(GL_QUERY_RESULT_EXT). | 38 // GetQueryObjectuivEXT(GL_QUERY_RESULT_EXT). |
| 38 const int kWaitForReleaseDelayMs = 500; | 39 const int kWaitForReleaseDelayMs = 500; |
| 39 | 40 |
| 40 GLenum GLInternalFormat(gfx::BufferFormat format) { | 41 GLenum GLInternalFormat(gfx::BufferFormat format) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 112 |
| 112 // Allow texture to be reused after |sync_token| has passed and runs | 113 // Allow texture to be reused after |sync_token| has passed and runs |
| 113 // |callback|. | 114 // |callback|. |
| 114 void Release(const base::Closure& callback, | 115 void Release(const base::Closure& callback, |
| 115 const gpu::SyncToken& sync_token, | 116 const gpu::SyncToken& sync_token, |
| 116 bool is_lost); | 117 bool is_lost); |
| 117 | 118 |
| 118 // Binds the contents referenced by |image_id_| to the texture returned by | 119 // Binds the contents referenced by |image_id_| to the texture returned by |
| 119 // mailbox(). Returns a sync token that can be used when accessing texture | 120 // mailbox(). Returns a sync token that can be used when accessing texture |
| 120 // from a different context. | 121 // from a different context. |
| 121 gpu::SyncToken BindTexImage(); | 122 gpu::SyncToken BindTexImage(gfx::GpuFence* acquire_fence); |
|
reveman
2016/10/12 19:20:19
nit: sometimes "acquire_fence" name is used and so
| |
| 122 | 123 |
| 123 // Releases the contents referenced by |image_id_| after |sync_token| has | 124 // Releases the contents referenced by |image_id_| after |sync_token| has |
| 124 // passed and runs |callback| when completed. | 125 // passed and runs |callback| when completed. |
| 125 void ReleaseTexImage(const base::Closure& callback, | 126 void ReleaseTexImage(const base::Closure& callback, |
| 126 const gpu::SyncToken& sync_token, | 127 const gpu::SyncToken& sync_token, |
| 127 bool is_lost); | 128 bool is_lost); |
| 128 | 129 |
| 129 // Copy the contents of texture to |destination| and runs |callback| when | 130 // Copy the contents of texture to |destination| and runs |callback| when |
| 130 // completed. Returns a sync token that can be used when accessing texture | 131 // completed. Returns a sync token that can be used when accessing texture |
| 131 // from a different context. | 132 // from a different context. |
| 132 gpu::SyncToken CopyTexImage(Texture* destination, | 133 gpu::SyncToken CopyTexImage(gfx::GpuFence* acquire_fence, |
| 134 Texture* destination, | |
| 133 const base::Closure& callback); | 135 const base::Closure& callback); |
| 134 | 136 |
| 135 // Returns the mailbox for this texture. | 137 // Returns the mailbox for this texture. |
| 136 gpu::Mailbox mailbox() const { return mailbox_; } | 138 gpu::Mailbox mailbox() const { return mailbox_; } |
| 137 | 139 |
| 138 private: | 140 private: |
| 139 void DestroyResources(); | 141 void DestroyResources(); |
| 140 void ReleaseWhenQueryResultIsAvailable(const base::Closure& callback); | 142 void ReleaseWhenQueryResultIsAvailable(const base::Closure& callback); |
| 141 void Released(); | 143 void Released(); |
| 142 void ScheduleWaitForRelease(base::TimeDelta delay); | 144 void ScheduleWaitForRelease(base::TimeDelta delay); |
| 143 void WaitForRelease(); | 145 void WaitForRelease(); |
| 144 | 146 |
| 145 ui::ContextFactory* context_factory_; | 147 ui::ContextFactory* context_factory_; |
| 146 scoped_refptr<cc::ContextProvider> context_provider_; | 148 scoped_refptr<cc::ContextProvider> context_provider_; |
| 147 const unsigned texture_target_; | 149 const unsigned texture_target_; |
| 148 const unsigned query_type_; | 150 const unsigned query_type_; |
| 149 const GLenum internalformat_; | 151 const GLenum internalformat_; |
| 150 unsigned image_id_ = 0; | 152 unsigned image_id_ = 0; |
| 151 unsigned query_id_ = 0; | 153 unsigned query_id_ = 0; |
| 152 unsigned texture_id_ = 0; | 154 unsigned texture_id_ = 0; |
| 155 unsigned fence_id_ = 0; | |
| 153 gpu::Mailbox mailbox_; | 156 gpu::Mailbox mailbox_; |
| 154 base::Closure release_callback_; | 157 base::Closure release_callback_; |
| 155 base::TimeTicks wait_for_release_time_; | 158 base::TimeTicks wait_for_release_time_; |
| 156 bool wait_for_release_pending_ = false; | 159 bool wait_for_release_pending_ = false; |
| 157 base::WeakPtrFactory<Texture> weak_ptr_factory_; | 160 base::WeakPtrFactory<Texture> weak_ptr_factory_; |
| 158 | 161 |
| 159 DISALLOW_COPY_AND_ASSIGN(Texture); | 162 DISALLOW_COPY_AND_ASSIGN(Texture); |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 Buffer::Texture::Texture(ui::ContextFactory* context_factory, | 165 Buffer::Texture::Texture(ui::ContextFactory* context_factory, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 227 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 225 if (sync_token.HasData()) | 228 if (sync_token.HasData()) |
| 226 gles2->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); | 229 gles2->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); |
| 227 } | 230 } |
| 228 | 231 |
| 229 // Run callback as texture can be reused immediately after waiting for sync | 232 // Run callback as texture can be reused immediately after waiting for sync |
| 230 // token. | 233 // token. |
| 231 callback.Run(); | 234 callback.Run(); |
| 232 } | 235 } |
| 233 | 236 |
| 234 gpu::SyncToken Buffer::Texture::BindTexImage() { | 237 gpu::SyncToken Buffer::Texture::BindTexImage(gfx::GpuFence* acquire_fence) { |
| 235 gpu::SyncToken sync_token; | 238 gpu::SyncToken sync_token; |
| 236 if (context_provider_) { | 239 if (context_provider_) { |
| 237 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 240 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 238 gles2->ActiveTexture(GL_TEXTURE0); | 241 gles2->ActiveTexture(GL_TEXTURE0); |
| 239 gles2->BindTexture(texture_target_, texture_id_); | 242 gles2->BindTexture(texture_target_, texture_id_); |
| 240 DCHECK_NE(image_id_, 0u); | 243 DCHECK_NE(image_id_, 0u); |
| 241 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, 0); | 244 if (acquire_fence) { |
| 245 fence_id_ = gles2->CreateFenceCHROMIUM(acquire_fence->AsClientFence()); | |
| 246 DCHECK_NE(fence_id_, 0u); | |
| 247 } | |
| 248 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, fence_id_); | |
| 242 // Generate a crypto-secure random mailbox name if not already done. | 249 // Generate a crypto-secure random mailbox name if not already done. |
| 243 if (mailbox_.IsZero()) | 250 if (mailbox_.IsZero()) |
| 244 CreateGLTextureMailbox(gles2, texture_id_, texture_target_, &mailbox_); | 251 CreateGLTextureMailbox(gles2, texture_id_, texture_target_, &mailbox_); |
| 245 // Create and return a sync token that can be used to ensure that the | 252 // Create and return a sync token that can be used to ensure that the |
| 246 // BindTexImage2DCHROMIUM call is processed before issuing any commands | 253 // BindTexImage2DCHROMIUM call is processed before issuing any commands |
| 247 // that will read from the texture on a different context. | 254 // that will read from the texture on a different context. |
| 248 uint64_t fence_sync = gles2->InsertFenceSyncCHROMIUM(); | 255 uint64_t fence_sync = gles2->InsertFenceSyncCHROMIUM(); |
| 249 gles2->OrderingBarrierCHROMIUM(); | 256 gles2->OrderingBarrierCHROMIUM(); |
| 250 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 257 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 251 } | 258 } |
| 252 return sync_token; | 259 return sync_token; |
| 253 } | 260 } |
| 254 | 261 |
| 255 void Buffer::Texture::ReleaseTexImage(const base::Closure& callback, | 262 void Buffer::Texture::ReleaseTexImage(const base::Closure& callback, |
| 256 const gpu::SyncToken& sync_token, | 263 const gpu::SyncToken& sync_token, |
| 257 bool is_lost) { | 264 bool is_lost) { |
| 258 if (context_provider_) { | 265 if (context_provider_) { |
| 259 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 266 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 260 if (sync_token.HasData()) | 267 if (sync_token.HasData()) |
| 261 gles2->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); | 268 gles2->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); |
| 262 gles2->ActiveTexture(GL_TEXTURE0); | 269 gles2->ActiveTexture(GL_TEXTURE0); |
| 263 gles2->BindTexture(texture_target_, texture_id_); | 270 gles2->BindTexture(texture_target_, texture_id_); |
| 264 DCHECK_NE(query_id_, 0u); | 271 DCHECK_NE(query_id_, 0u); |
| 265 gles2->BeginQueryEXT(query_type_, query_id_); | 272 gles2->BeginQueryEXT(query_type_, query_id_); |
| 266 gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_); | 273 gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_); |
| 274 if (fence_id_ != 0u) | |
|
reveman
2016/10/12 19:20:19
nit: "if (fence_id_)" is preferred in chromium cod
| |
| 275 gles2->DestroyFenceCHROMIUM(fence_id_); | |
| 267 gles2->EndQueryEXT(query_type_); | 276 gles2->EndQueryEXT(query_type_); |
| 268 // Run callback when query result is available and ReleaseTexImage has been | 277 // Run callback when query result is available and ReleaseTexImage has been |
| 269 // handled if sync token has data and buffer has been used. If buffer was | 278 // handled if sync token has data and buffer has been used. If buffer was |
| 270 // never used then run the callback immediately. | 279 // never used then run the callback immediately. |
| 271 if (sync_token.HasData()) { | 280 if (sync_token.HasData()) { |
| 272 ReleaseWhenQueryResultIsAvailable(callback); | 281 ReleaseWhenQueryResultIsAvailable(callback); |
| 273 return; | 282 return; |
| 274 } | 283 } |
| 275 } | 284 } |
| 276 callback.Run(); | 285 callback.Run(); |
| 277 } | 286 } |
| 278 | 287 |
| 279 gpu::SyncToken Buffer::Texture::CopyTexImage(Texture* destination, | 288 gpu::SyncToken Buffer::Texture::CopyTexImage(gfx::GpuFence* acquire_fence, |
| 289 Texture* destination, | |
| 280 const base::Closure& callback) { | 290 const base::Closure& callback) { |
| 281 gpu::SyncToken sync_token; | 291 gpu::SyncToken sync_token; |
| 282 if (context_provider_) { | 292 if (context_provider_) { |
| 283 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 293 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 284 gles2->ActiveTexture(GL_TEXTURE0); | 294 gles2->ActiveTexture(GL_TEXTURE0); |
| 285 gles2->BindTexture(texture_target_, texture_id_); | 295 gles2->BindTexture(texture_target_, texture_id_); |
| 286 DCHECK_NE(image_id_, 0u); | 296 DCHECK_NE(image_id_, 0u); |
| 287 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, 0); | 297 if (acquire_fence) { |
| 298 fence_id_ = gles2->CreateFenceCHROMIUM(acquire_fence->AsClientFence()); | |
| 299 DCHECK_NE(fence_id_, 0u); | |
| 300 } | |
| 301 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, fence_id_); | |
| 288 gles2->CopyTextureCHROMIUM(texture_id_, destination->texture_id_, | 302 gles2->CopyTextureCHROMIUM(texture_id_, destination->texture_id_, |
| 289 internalformat_, GL_UNSIGNED_BYTE, false, false, | 303 internalformat_, GL_UNSIGNED_BYTE, false, false, |
| 290 false); | 304 false); |
| 291 DCHECK_NE(query_id_, 0u); | 305 DCHECK_NE(query_id_, 0u); |
| 292 gles2->BeginQueryEXT(query_type_, query_id_); | 306 gles2->BeginQueryEXT(query_type_, query_id_); |
| 293 gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_); | 307 gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_); |
| 308 if (fence_id_ != 0u) | |
|
reveman
2016/10/12 19:20:18
nit: "if (fence_id_)" is preferred in chromium cod
| |
| 309 gles2->DestroyFenceCHROMIUM(fence_id_); | |
|
reveman
2016/10/12 19:20:19
nit: set fence_id_ to 0 here so it's easier to tel
| |
| 294 gles2->EndQueryEXT(query_type_); | 310 gles2->EndQueryEXT(query_type_); |
| 295 // Run callback when query result is available and ReleaseTexImage has been | 311 // Run callback when query result is available and ReleaseTexImage has been |
| 296 // handled. | 312 // handled. |
| 297 ReleaseWhenQueryResultIsAvailable(callback); | 313 ReleaseWhenQueryResultIsAvailable(callback); |
| 298 // Create and return a sync token that can be used to ensure that the | 314 // Create and return a sync token that can be used to ensure that the |
| 299 // CopyTextureCHROMIUM call is processed before issuing any commands | 315 // CopyTextureCHROMIUM call is processed before issuing any commands |
| 300 // that will read from the target texture on a different context. | 316 // that will read from the target texture on a different context. |
| 301 uint64_t fence_sync = gles2->InsertFenceSyncCHROMIUM(); | 317 uint64_t fence_sync = gles2->InsertFenceSyncCHROMIUM(); |
| 302 gles2->OrderingBarrierCHROMIUM(); | 318 gles2->OrderingBarrierCHROMIUM(); |
| 303 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 319 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 304 } | 320 } |
| 305 return sync_token; | 321 return sync_token; |
| 306 } | 322 } |
| 307 | 323 |
| 308 void Buffer::Texture::DestroyResources() { | 324 void Buffer::Texture::DestroyResources() { |
|
reveman
2016/10/12 19:20:19
Can you add "if (fence_id_) gles2->DestroyFenceCHR
| |
| 309 if (context_provider_) { | 325 if (context_provider_) { |
| 310 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 326 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 311 gles2->DeleteTextures(1, &texture_id_); | 327 gles2->DeleteTextures(1, &texture_id_); |
| 312 if (query_id_) | 328 if (query_id_) |
| 313 gles2->DeleteQueriesEXT(1, &query_id_); | 329 gles2->DeleteQueriesEXT(1, &query_id_); |
| 314 if (image_id_) | 330 if (image_id_) |
| 315 gles2->DestroyImageCHROMIUM(image_id_); | 331 gles2->DestroyImageCHROMIUM(image_id_); |
| 316 } | 332 } |
| 317 } | 333 } |
| 318 | 334 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 : gpu_memory_buffer_(std::move(gpu_memory_buffer)), | 409 : gpu_memory_buffer_(std::move(gpu_memory_buffer)), |
| 394 texture_target_(texture_target), | 410 texture_target_(texture_target), |
| 395 query_type_(query_type), | 411 query_type_(query_type), |
| 396 use_zero_copy_(use_zero_copy), | 412 use_zero_copy_(use_zero_copy), |
| 397 is_overlay_candidate_(is_overlay_candidate) {} | 413 is_overlay_candidate_(is_overlay_candidate) {} |
| 398 | 414 |
| 399 Buffer::~Buffer() {} | 415 Buffer::~Buffer() {} |
| 400 | 416 |
| 401 std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox( | 417 std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox( |
| 402 cc::TextureMailbox* texture_mailbox, | 418 cc::TextureMailbox* texture_mailbox, |
| 419 gfx::GpuFence* acquire_fence, | |
|
reveman
2016/10/12 19:20:19
nit: s/acquire_fence/fence/ to be consistent with
| |
| 403 bool secure_output_only, | 420 bool secure_output_only, |
| 404 bool client_usage) { | 421 bool client_usage) { |
| 405 DCHECK(attach_count_); | 422 DCHECK(attach_count_); |
| 406 DLOG_IF(WARNING, use_count_ && client_usage) | 423 DLOG_IF(WARNING, use_count_ && client_usage) |
| 407 << "Producing a texture mailbox for a buffer that has not been released"; | 424 << "Producing a texture mailbox for a buffer that has not been released"; |
| 408 | 425 |
| 409 // Some clients think that they can reuse a buffer before it's released by | 426 // Some clients think that they can reuse a buffer before it's released by |
| 410 // performing a fast blit into the buffer. This behavior is bad as it prevents | 427 // performing a fast blit into the buffer. This behavior is bad as it prevents |
| 411 // the client from knowing when the buffer is actually released (e.g. the | 428 // the client from knowing when the buffer is actually released (e.g. the |
| 412 // release notification for the previous use of buffer can arrive after the | 429 // release notification for the previous use of buffer can arrive after the |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 443 contents_texture_ = base::MakeUnique<Texture>( | 460 contents_texture_ = base::MakeUnique<Texture>( |
| 444 context_factory, context_provider.get(), gpu_memory_buffer_.get(), | 461 context_factory, context_provider.get(), gpu_memory_buffer_.get(), |
| 445 texture_target_, query_type_); | 462 texture_target_, query_type_); |
| 446 } | 463 } |
| 447 | 464 |
| 448 if (use_zero_copy_) { | 465 if (use_zero_copy_) { |
| 449 // Zero-copy means using the contents texture directly. | 466 // Zero-copy means using the contents texture directly. |
| 450 Texture* texture = contents_texture_.get(); | 467 Texture* texture = contents_texture_.get(); |
| 451 | 468 |
| 452 // This binds the latest contents of this buffer to |texture|. | 469 // This binds the latest contents of this buffer to |texture|. |
| 453 gpu::SyncToken sync_token = texture->BindTexImage(); | 470 gpu::SyncToken sync_token = texture->BindTexImage(std::move(acquire_fence)); |
| 454 | 471 |
| 455 *texture_mailbox = | 472 *texture_mailbox = |
| 456 cc::TextureMailbox(texture->mailbox(), sync_token, texture_target_, | 473 cc::TextureMailbox(texture->mailbox(), sync_token, texture_target_, |
| 457 gpu_memory_buffer_->GetSize(), is_overlay_candidate_, | 474 gpu_memory_buffer_->GetSize(), is_overlay_candidate_, |
| 458 secure_output_only); | 475 secure_output_only); |
| 459 // The contents texture will be released when no longer used by the | 476 // The contents texture will be released when no longer used by the |
| 460 // compositor. | 477 // compositor. |
| 461 return cc::SingleReleaseCallback::Create( | 478 return cc::SingleReleaseCallback::Create( |
| 462 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), | 479 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), |
| 463 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 480 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
| 464 base::Passed(&contents_texture_)))); | 481 base::Passed(&contents_texture_)))); |
| 465 } | 482 } |
| 466 | 483 |
| 467 // Create a mailbox texture that we copy the buffer contents to. | 484 // Create a mailbox texture that we copy the buffer contents to. |
| 468 if (!texture_) { | 485 if (!texture_) { |
| 469 texture_ = | 486 texture_ = |
| 470 base::MakeUnique<Texture>(context_factory, context_provider.get()); | 487 base::MakeUnique<Texture>(context_factory, context_provider.get()); |
| 471 } | 488 } |
| 472 | 489 |
| 473 // Copy the contents of |contents_texture| to |texture| and produce a | 490 // Copy the contents of |contents_texture| to |texture| and produce a |
| 474 // texture mailbox from the result in |texture|. | 491 // texture mailbox from the result in |texture|. |
| 475 Texture* contents_texture = contents_texture_.get(); | 492 Texture* contents_texture = contents_texture_.get(); |
| 476 Texture* texture = texture_.get(); | 493 Texture* texture = texture_.get(); |
| 477 | 494 |
| 478 // The contents texture will be released when copy has completed. | 495 // The contents texture will be released when copy has completed. |
| 479 gpu::SyncToken sync_token = contents_texture->CopyTexImage( | 496 gpu::SyncToken sync_token = contents_texture->CopyTexImage(std::move(acquire_f ence), |
| 480 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 497 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
| 481 base::Passed(&contents_texture_))); | 498 base::Passed(&contents_texture_))); |
| 482 *texture_mailbox = | 499 *texture_mailbox = |
| 483 cc::TextureMailbox(texture->mailbox(), sync_token, GL_TEXTURE_2D, | 500 cc::TextureMailbox(texture->mailbox(), sync_token, GL_TEXTURE_2D, |
| 484 gpu_memory_buffer_->GetSize(), | 501 gpu_memory_buffer_->GetSize(), |
| 485 false /* is_overlay_candidate */, secure_output_only); | 502 false /* is_overlay_candidate */, secure_output_only); |
| 486 // The mailbox texture will be released when no longer used by the | 503 // The mailbox texture will be released when no longer used by the |
| 487 // compositor. | 504 // compositor. |
| 488 return cc::SingleReleaseCallback::Create( | 505 return cc::SingleReleaseCallback::Create( |
| 489 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), | 506 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 } | 558 } |
| 542 | 559 |
| 543 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { | 560 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { |
| 544 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); | 561 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); |
| 545 | 562 |
| 546 contents_texture_ = std::move(texture); | 563 contents_texture_ = std::move(texture); |
| 547 Release(); | 564 Release(); |
| 548 } | 565 } |
| 549 | 566 |
| 550 } // namespace exo | 567 } // namespace exo |
| OLD | NEW |