| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 return cc::SingleReleaseCallback::Create( | 342 return cc::SingleReleaseCallback::Create( |
| 343 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), | 343 base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture), |
| 344 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 344 base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
| 345 base::Passed(&contents_texture_)))); | 345 base::Passed(&contents_texture_)))); |
| 346 } | 346 } |
| 347 | 347 |
| 348 // Create a mailbox texture that we copy the buffer contents to. | 348 // Create a mailbox texture that we copy the buffer contents to. |
| 349 if (!texture_) | 349 if (!texture_) |
| 350 texture_ = make_scoped_ptr(new Texture(context_provider.get())); | 350 texture_ = make_scoped_ptr(new Texture(context_provider.get())); |
| 351 | 351 |
| 352 // Copy the contents of |contents_texture| to |texture| and produce a |
| 353 // texture mailbox from the result in |texture|. |
| 354 Texture* contents_texture = contents_texture_.get(); |
| 352 Texture* texture = texture_.get(); | 355 Texture* texture = texture_.get(); |
| 353 | 356 |
| 354 // The contents texture will be released when copy has completed. | 357 // The contents texture will be released when copy has completed. |
| 355 gpu::SyncToken sync_token = contents_texture_->CopyTexImage( | 358 gpu::SyncToken sync_token = contents_texture->CopyTexImage( |
| 356 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), | 359 texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(), |
| 357 base::Passed(&contents_texture_))); | 360 base::Passed(&contents_texture_))); |
| 358 *texture_mailbox = cc::TextureMailbox( | 361 *texture_mailbox = cc::TextureMailbox( |
| 359 texture->mailbox(), sync_token, GL_TEXTURE_2D, | 362 texture->mailbox(), sync_token, GL_TEXTURE_2D, |
| 360 gpu_memory_buffer_->GetSize(), false /* is_overlay_candidate*/); | 363 gpu_memory_buffer_->GetSize(), false /* is_overlay_candidate*/); |
| 361 // The mailbox texture will be released when no longer used by the | 364 // The mailbox texture will be released when no longer used by the |
| 362 // compositor. | 365 // compositor. |
| 363 return cc::SingleReleaseCallback::Create( | 366 return cc::SingleReleaseCallback::Create( |
| 364 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), | 367 base::Bind(&Buffer::Texture::Release, base::Unretained(texture), |
| 365 base::Bind(&Buffer::ReleaseTexture, AsWeakPtr(), | 368 base::Bind(&Buffer::ReleaseTexture, AsWeakPtr(), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 402 } |
| 400 | 403 |
| 401 void Buffer::ReleaseContentsTexture(scoped_ptr<Texture> texture) { | 404 void Buffer::ReleaseContentsTexture(scoped_ptr<Texture> texture) { |
| 402 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); | 405 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); |
| 403 | 406 |
| 404 contents_texture_ = std::move(texture); | 407 contents_texture_ = std::move(texture); |
| 405 Release(); | 408 Release(); |
| 406 } | 409 } |
| 407 | 410 |
| 408 } // namespace exo | 411 } // namespace exo |
| OLD | NEW |