| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 callback.Run(); | 231 callback.Run(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 gpu::SyncToken Buffer::Texture::BindTexImage() { | 234 gpu::SyncToken Buffer::Texture::BindTexImage() { |
| 235 gpu::SyncToken sync_token; | 235 gpu::SyncToken sync_token; |
| 236 if (context_provider_) { | 236 if (context_provider_) { |
| 237 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 237 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 238 gles2->ActiveTexture(GL_TEXTURE0); | 238 gles2->ActiveTexture(GL_TEXTURE0); |
| 239 gles2->BindTexture(texture_target_, texture_id_); | 239 gles2->BindTexture(texture_target_, texture_id_); |
| 240 DCHECK_NE(image_id_, 0u); | 240 DCHECK_NE(image_id_, 0u); |
| 241 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_); | 241 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, 0); |
| 242 // Generate a crypto-secure random mailbox name if not already done. | 242 // Generate a crypto-secure random mailbox name if not already done. |
| 243 if (mailbox_.IsZero()) | 243 if (mailbox_.IsZero()) |
| 244 CreateGLTextureMailbox(gles2, texture_id_, texture_target_, &mailbox_); | 244 CreateGLTextureMailbox(gles2, texture_id_, texture_target_, &mailbox_); |
| 245 // Create and return a sync token that can be used to ensure that the | 245 // Create and return a sync token that can be used to ensure that the |
| 246 // BindTexImage2DCHROMIUM call is processed before issuing any commands | 246 // BindTexImage2DCHROMIUM call is processed before issuing any commands |
| 247 // that will read from the texture on a different context. | 247 // that will read from the texture on a different context. |
| 248 uint64_t fence_sync = gles2->InsertFenceSyncCHROMIUM(); | 248 uint64_t fence_sync = gles2->InsertFenceSyncCHROMIUM(); |
| 249 gles2->OrderingBarrierCHROMIUM(); | 249 gles2->OrderingBarrierCHROMIUM(); |
| 250 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 250 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 251 } | 251 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 gpu::SyncToken Buffer::Texture::CopyTexImage(Texture* destination, | 279 gpu::SyncToken Buffer::Texture::CopyTexImage(Texture* destination, |
| 280 const base::Closure& callback) { | 280 const base::Closure& callback) { |
| 281 gpu::SyncToken sync_token; | 281 gpu::SyncToken sync_token; |
| 282 if (context_provider_) { | 282 if (context_provider_) { |
| 283 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 283 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 284 gles2->ActiveTexture(GL_TEXTURE0); | 284 gles2->ActiveTexture(GL_TEXTURE0); |
| 285 gles2->BindTexture(texture_target_, texture_id_); | 285 gles2->BindTexture(texture_target_, texture_id_); |
| 286 DCHECK_NE(image_id_, 0u); | 286 DCHECK_NE(image_id_, 0u); |
| 287 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_); | 287 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_, 0); |
| 288 gles2->CopyTextureCHROMIUM(texture_id_, destination->texture_id_, | 288 gles2->CopyTextureCHROMIUM(texture_id_, destination->texture_id_, |
| 289 internalformat_, GL_UNSIGNED_BYTE, false, false, | 289 internalformat_, GL_UNSIGNED_BYTE, false, false, |
| 290 false); | 290 false); |
| 291 DCHECK_NE(query_id_, 0u); | 291 DCHECK_NE(query_id_, 0u); |
| 292 gles2->BeginQueryEXT(query_type_, query_id_); | 292 gles2->BeginQueryEXT(query_type_, query_id_); |
| 293 gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_); | 293 gles2->ReleaseTexImage2DCHROMIUM(texture_target_, image_id_); |
| 294 gles2->EndQueryEXT(query_type_); | 294 gles2->EndQueryEXT(query_type_); |
| 295 // Run callback when query result is available and ReleaseTexImage has been | 295 // Run callback when query result is available and ReleaseTexImage has been |
| 296 // handled. | 296 // handled. |
| 297 ReleaseWhenQueryResultIsAvailable(callback); | 297 ReleaseWhenQueryResultIsAvailable(callback); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 541 } |
| 542 | 542 |
| 543 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { | 543 void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) { |
| 544 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); | 544 TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture"); |
| 545 | 545 |
| 546 contents_texture_ = std::move(texture); | 546 contents_texture_ = std::move(texture); |
| 547 Release(); | 547 Release(); |
| 548 } | 548 } |
| 549 | 549 |
| 550 } // namespace exo | 550 } // namespace exo |
| OLD | NEW |