| 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 | 11 |
| 11 #include <algorithm> | 12 #include <algorithm> |
| 12 | 13 |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" |
| 14 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 15 #include "base/trace_event/trace_event_argument.h" | 17 #include "base/trace_event/trace_event_argument.h" |
| 16 #include "cc/output/context_provider.h" | 18 #include "cc/output/context_provider.h" |
| 17 #include "cc/resources/single_release_callback.h" | 19 #include "cc/resources/single_release_callback.h" |
| 18 #include "cc/resources/texture_mailbox.h" | 20 #include "cc/resources/texture_mailbox.h" |
| 19 #include "gpu/command_buffer/client/gles2_interface.h" | 21 #include "gpu/command_buffer/client/gles2_interface.h" |
| 20 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 21 #include "ui/compositor/compositor.h" | 23 #include "ui/compositor/compositor.h" |
| 22 #include "ui/gfx/gpu_memory_buffer.h" | 24 #include "ui/gfx/gpu_memory_buffer.h" |
| 23 | 25 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 126 } |
| 125 | 127 |
| 126 gpu::SyncToken Buffer::Texture::BindTexImage() { | 128 gpu::SyncToken Buffer::Texture::BindTexImage() { |
| 127 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 129 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 128 gles2->ActiveTexture(GL_TEXTURE0); | 130 gles2->ActiveTexture(GL_TEXTURE0); |
| 129 gles2->BindTexture(texture_target_, texture_id_); | 131 gles2->BindTexture(texture_target_, texture_id_); |
| 130 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_); | 132 gles2->BindTexImage2DCHROMIUM(texture_target_, image_id_); |
| 131 // Create and return a sync token that can be used to ensure that the | 133 // Create and return a sync token that can be used to ensure that the |
| 132 // BindTexImage2DCHROMIUM call is processed before issuing any commands | 134 // BindTexImage2DCHROMIUM call is processed before issuing any commands |
| 133 // that will read from the texture on a different context. | 135 // that will read from the texture on a different context. |
| 134 uint64 fence_sync = gles2->InsertFenceSyncCHROMIUM(); | 136 uint64_t fence_sync = gles2->InsertFenceSyncCHROMIUM(); |
| 135 gles2->OrderingBarrierCHROMIUM(); | 137 gles2->OrderingBarrierCHROMIUM(); |
| 136 gpu::SyncToken sync_token; | 138 gpu::SyncToken sync_token; |
| 137 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 139 gles2->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 138 return sync_token; | 140 return sync_token; |
| 139 } | 141 } |
| 140 | 142 |
| 141 void Buffer::Texture::ReleaseTexImage(const gpu::SyncToken& sync_token) { | 143 void Buffer::Texture::ReleaseTexImage(const gpu::SyncToken& sync_token) { |
| 142 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); | 144 gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL(); |
| 143 if (sync_token.HasData()) | 145 if (sync_token.HasData()) |
| 144 gles2->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); | 146 gles2->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return; | 250 return; |
| 249 | 251 |
| 250 // Allow buffer to reused texture if it's not lost. | 252 // Allow buffer to reused texture if it's not lost. |
| 251 if (!is_lost) | 253 if (!is_lost) |
| 252 buffer->last_texture_ = texture.Pass(); | 254 buffer->last_texture_ = texture.Pass(); |
| 253 | 255 |
| 254 buffer->Release(); | 256 buffer->Release(); |
| 255 } | 257 } |
| 256 | 258 |
| 257 } // namespace exo | 259 } // namespace exo |
| OLD | NEW |