OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::AutoLock lock(namespace_->lock); | 114 base::AutoLock lock(namespace_->lock); |
115 return namespace_->next_texture_id++; | 115 return namespace_->next_texture_id++; |
116 } | 116 } |
117 | 117 |
118 void RetireTextureId(GLuint) override {} | 118 void RetireTextureId(GLuint) override {} |
119 | 119 |
120 GLuint64 insertFenceSync() override { return next_fence_sync_++; } | 120 GLuint64 insertFenceSync() override { return next_fence_sync_++; } |
121 | 121 |
122 void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override { | 122 void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override { |
123 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, | 123 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, |
124 0x123, fence_sync); | 124 gpu::CommandBufferId::FromUnsafeValue(0x123), |
| 125 fence_sync); |
125 sync_token_data.SetVerifyFlush(); | 126 sync_token_data.SetVerifyFlush(); |
126 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); | 127 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); |
127 } | 128 } |
128 | 129 |
129 GLuint64 GetNextFenceSync() const { return next_fence_sync_; } | 130 GLuint64 GetNextFenceSync() const { return next_fence_sync_; } |
130 | 131 |
131 GLuint64 next_fence_sync_ = 1; | 132 GLuint64 next_fence_sync_ = 1; |
132 }; | 133 }; |
133 | 134 |
134 // Shared data between multiple ResourceProviderContext. This contains mailbox | 135 // Shared data between multiple ResourceProviderContext. This contains mailbox |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 ContextSharedData* shared_data) { | 193 ContextSharedData* shared_data) { |
193 return make_scoped_ptr(new ResourceProviderContext(shared_data)); | 194 return make_scoped_ptr(new ResourceProviderContext(shared_data)); |
194 } | 195 } |
195 | 196 |
196 GLuint64 insertFenceSync() override { | 197 GLuint64 insertFenceSync() override { |
197 return shared_data_->InsertFenceSync(); | 198 return shared_data_->InsertFenceSync(); |
198 } | 199 } |
199 | 200 |
200 void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override { | 201 void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token) override { |
201 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, | 202 gpu::SyncToken sync_token_data(gpu::CommandBufferNamespace::GPU_IO, 0, |
202 0x123, fence_sync); | 203 gpu::CommandBufferId::FromUnsafeValue(0x123), |
| 204 fence_sync); |
203 sync_token_data.SetVerifyFlush(); | 205 sync_token_data.SetVerifyFlush(); |
204 // Commit the produceTextureCHROMIUM calls at this point, so that | 206 // Commit the produceTextureCHROMIUM calls at this point, so that |
205 // they're associated with the sync point. | 207 // they're associated with the sync point. |
206 for (const scoped_ptr<PendingProduceTexture>& pending_texture : | 208 for (const scoped_ptr<PendingProduceTexture>& pending_texture : |
207 pending_produce_textures_) { | 209 pending_produce_textures_) { |
208 shared_data_->ProduceTexture(pending_texture->mailbox, sync_token_data, | 210 shared_data_->ProduceTexture(pending_texture->mailbox, sync_token_data, |
209 pending_texture->texture); | 211 pending_texture->texture); |
210 } | 212 } |
211 pending_produce_textures_.clear(); | 213 pending_produce_textures_.clear(); |
212 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); | 214 memcpy(sync_token, &sync_token_data, sizeof(sync_token_data)); |
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 scoped_ptr<OutputSurface> output_surface( | 2830 scoped_ptr<OutputSurface> output_surface( |
2829 FakeOutputSurface::Create3d(std::move(context_owned))); | 2831 FakeOutputSurface::Create3d(std::move(context_owned))); |
2830 CHECK(output_surface->BindToClient(&output_surface_client)); | 2832 CHECK(output_surface->BindToClient(&output_surface_client)); |
2831 | 2833 |
2832 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2834 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2833 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, | 2835 output_surface.get(), shared_bitmap_manager, gpu_memory_buffer_manager, |
2834 main_thread_task_runner, 0, 1, use_gpu_memory_buffer_resources_, | 2836 main_thread_task_runner, 0, 1, use_gpu_memory_buffer_resources_, |
2835 use_image_texture_targets_)); | 2837 use_image_texture_targets_)); |
2836 | 2838 |
2837 unsigned texture_id = 1; | 2839 unsigned texture_id = 1; |
2838 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0x12, | 2840 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 2841 gpu::CommandBufferId::FromUnsafeValue(0x12), |
2839 0x34); | 2842 0x34); |
2840 unsigned target = GL_TEXTURE_2D; | 2843 unsigned target = GL_TEXTURE_2D; |
2841 const GLuint64 current_fence_sync = context->GetNextFenceSync(); | 2844 const GLuint64 current_fence_sync = context->GetNextFenceSync(); |
2842 | 2845 |
2843 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2846 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2844 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); | 2847 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
2845 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2848 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2846 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 2849 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
2847 | 2850 |
2848 gpu::Mailbox gpu_mailbox; | 2851 gpu::Mailbox gpu_mailbox; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2971 FakeOutputSurfaceClient output_surface_client; | 2974 FakeOutputSurfaceClient output_surface_client; |
2972 scoped_ptr<OutputSurface> output_surface( | 2975 scoped_ptr<OutputSurface> output_surface( |
2973 FakeOutputSurface::Create3d(std::move(context_owned))); | 2976 FakeOutputSurface::Create3d(std::move(context_owned))); |
2974 CHECK(output_surface->BindToClient(&output_surface_client)); | 2977 CHECK(output_surface->BindToClient(&output_surface_client)); |
2975 | 2978 |
2976 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 2979 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
2977 output_surface.get(), shared_bitmap_manager_.get(), | 2980 output_surface.get(), shared_bitmap_manager_.get(), |
2978 gpu_memory_buffer_manager_.get(), NULL, 0, 1, | 2981 gpu_memory_buffer_manager_.get(), NULL, 0, 1, |
2979 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); | 2982 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); |
2980 | 2983 |
2981 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0x12, 0x34); | 2984 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 2985 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); |
2982 const GLuint64 current_fence_sync = context->GetNextFenceSync(); | 2986 const GLuint64 current_fence_sync = context->GetNextFenceSync(); |
2983 unsigned target = GL_TEXTURE_EXTERNAL_OES; | 2987 unsigned target = GL_TEXTURE_EXTERNAL_OES; |
2984 | 2988 |
2985 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 2989 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
2986 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); | 2990 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
2987 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 2991 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
2988 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 2992 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
2989 | 2993 |
2990 gpu::Mailbox gpu_mailbox; | 2994 gpu::Mailbox gpu_mailbox; |
2991 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 2995 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3040 FakeOutputSurfaceClient output_surface_client; | 3044 FakeOutputSurfaceClient output_surface_client; |
3041 scoped_ptr<OutputSurface> output_surface( | 3045 scoped_ptr<OutputSurface> output_surface( |
3042 FakeOutputSurface::Create3d(std::move(context_owned))); | 3046 FakeOutputSurface::Create3d(std::move(context_owned))); |
3043 CHECK(output_surface->BindToClient(&output_surface_client)); | 3047 CHECK(output_surface->BindToClient(&output_surface_client)); |
3044 | 3048 |
3045 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 3049 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
3046 output_surface.get(), shared_bitmap_manager_.get(), | 3050 output_surface.get(), shared_bitmap_manager_.get(), |
3047 gpu_memory_buffer_manager_.get(), NULL, 0, 1, | 3051 gpu_memory_buffer_manager_.get(), NULL, 0, 1, |
3048 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); | 3052 use_gpu_memory_buffer_resources_, use_image_texture_targets_)); |
3049 | 3053 |
3050 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0x12, 0x34); | 3054 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 3055 gpu::CommandBufferId::FromUnsafeValue(0x12), 0x34); |
3051 const GLuint64 current_fence_sync = context->GetNextFenceSync(); | 3056 const GLuint64 current_fence_sync = context->GetNextFenceSync(); |
3052 unsigned target = GL_TEXTURE_2D; | 3057 unsigned target = GL_TEXTURE_2D; |
3053 | 3058 |
3054 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); | 3059 EXPECT_CALL(*context, bindTexture(_, _)).Times(0); |
3055 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); | 3060 EXPECT_CALL(*context, waitSyncToken(_)).Times(0); |
3056 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); | 3061 EXPECT_CALL(*context, produceTextureDirectCHROMIUM(_, _, _)).Times(0); |
3057 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); | 3062 EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_, _)).Times(0); |
3058 | 3063 |
3059 gpu::Mailbox gpu_mailbox; | 3064 gpu::Mailbox gpu_mailbox; |
3060 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); | 3065 memcpy(gpu_mailbox.name, "Hello world", strlen("Hello world") + 1); |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3612 EXPECT_TRUE(resource_provider_->CanLockForWrite(id)); | 3617 EXPECT_TRUE(resource_provider_->CanLockForWrite(id)); |
3613 EXPECT_FALSE(resource_provider_->InUseByConsumer(id)); | 3618 EXPECT_FALSE(resource_provider_->InUseByConsumer(id)); |
3614 gpu_memory_buffer_manager_->SetGpuMemoryBufferIsInUseByMacOSWindowServer( | 3619 gpu_memory_buffer_manager_->SetGpuMemoryBufferIsInUseByMacOSWindowServer( |
3615 gpu_memory_buffer, true); | 3620 gpu_memory_buffer, true); |
3616 EXPECT_FALSE(resource_provider_->CanLockForWrite(id)); | 3621 EXPECT_FALSE(resource_provider_->CanLockForWrite(id)); |
3617 EXPECT_TRUE(resource_provider_->InUseByConsumer(id)); | 3622 EXPECT_TRUE(resource_provider_->InUseByConsumer(id)); |
3618 } | 3623 } |
3619 | 3624 |
3620 } // namespace | 3625 } // namespace |
3621 } // namespace cc | 3626 } // namespace cc |
OLD | NEW |