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 <algorithm> | 7 #include <algorithm> |
| 8 #include <deque> |
8 #include <map> | 9 #include <map> |
9 #include <set> | 10 #include <set> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "cc/base/scoped_ptr_deque.h" | |
17 #include "cc/output/output_surface.h" | 17 #include "cc/output/output_surface.h" |
18 #include "cc/resources/returned_resource.h" | 18 #include "cc/resources/returned_resource.h" |
19 #include "cc/resources/shared_bitmap_manager.h" | 19 #include "cc/resources/shared_bitmap_manager.h" |
20 #include "cc/resources/single_release_callback.h" | 20 #include "cc/resources/single_release_callback.h" |
21 #include "cc/test/fake_output_surface.h" | 21 #include "cc/test/fake_output_surface.h" |
22 #include "cc/test/fake_output_surface_client.h" | 22 #include "cc/test/fake_output_surface_client.h" |
23 #include "cc/test/test_gpu_memory_buffer_manager.h" | 23 #include "cc/test/test_gpu_memory_buffer_manager.h" |
24 #include "cc/test/test_shared_bitmap_manager.h" | 24 #include "cc/test/test_shared_bitmap_manager.h" |
25 #include "cc/test/test_texture.h" | 25 #include "cc/test/test_texture.h" |
26 #include "cc/test/test_web_graphics_context_3d.h" | 26 #include "cc/test/test_web_graphics_context_3d.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 public: | 175 public: |
176 static scoped_ptr<ResourceProviderContext> Create( | 176 static scoped_ptr<ResourceProviderContext> Create( |
177 ContextSharedData* shared_data) { | 177 ContextSharedData* shared_data) { |
178 return make_scoped_ptr(new ResourceProviderContext(shared_data)); | 178 return make_scoped_ptr(new ResourceProviderContext(shared_data)); |
179 } | 179 } |
180 | 180 |
181 GLuint insertSyncPoint() override { | 181 GLuint insertSyncPoint() override { |
182 uint32 sync_point = shared_data_->InsertSyncPoint(); | 182 uint32 sync_point = shared_data_->InsertSyncPoint(); |
183 // Commit the produceTextureCHROMIUM calls at this point, so that | 183 // Commit the produceTextureCHROMIUM calls at this point, so that |
184 // they're associated with the sync point. | 184 // they're associated with the sync point. |
185 for (PendingProduceTextureList::iterator it = | 185 for (const scoped_ptr<PendingProduceTexture>& pending_texture : |
186 pending_produce_textures_.begin(); | 186 pending_produce_textures_) { |
187 it != pending_produce_textures_.end(); | 187 shared_data_->ProduceTexture(pending_texture->mailbox, |
188 ++it) { | 188 gpu::SyncToken(sync_point), |
189 shared_data_->ProduceTexture((*it)->mailbox, gpu::SyncToken(sync_point), | 189 pending_texture->texture); |
190 (*it)->texture); | |
191 } | 190 } |
192 pending_produce_textures_.clear(); | 191 pending_produce_textures_.clear(); |
193 return sync_point; | 192 return sync_point; |
194 } | 193 } |
195 | 194 |
196 void waitSyncToken(const GLbyte* sync_token) override { | 195 void waitSyncToken(const GLbyte* sync_token) override { |
197 gpu::SyncToken sync_token_data; | 196 gpu::SyncToken sync_token_data; |
198 if (sync_token) | 197 if (sync_token) |
199 memcpy(&sync_token_data, sync_token, sizeof(sync_token_data)); | 198 memcpy(&sync_token_data, sync_token, sizeof(sync_token_data)); |
200 | 199 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 memcpy(dest, src, in_pitch); | 349 memcpy(dest, src, in_pitch); |
351 dest += out_pitch; | 350 dest += out_pitch; |
352 src += in_pitch; | 351 src += in_pitch; |
353 } | 352 } |
354 } | 353 } |
355 | 354 |
356 struct PendingProduceTexture { | 355 struct PendingProduceTexture { |
357 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 356 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
358 scoped_refptr<TestTexture> texture; | 357 scoped_refptr<TestTexture> texture; |
359 }; | 358 }; |
360 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; | |
361 ContextSharedData* shared_data_; | 359 ContextSharedData* shared_data_; |
362 gpu::SyncToken last_waited_sync_token_; | 360 gpu::SyncToken last_waited_sync_token_; |
363 PendingProduceTextureList pending_produce_textures_; | 361 std::deque<scoped_ptr<PendingProduceTexture>> pending_produce_textures_; |
364 }; | 362 }; |
365 | 363 |
366 void GetResourcePixels(ResourceProvider* resource_provider, | 364 void GetResourcePixels(ResourceProvider* resource_provider, |
367 ResourceProviderContext* context, | 365 ResourceProviderContext* context, |
368 ResourceId id, | 366 ResourceId id, |
369 const gfx::Size& size, | 367 const gfx::Size& size, |
370 ResourceFormat format, | 368 ResourceFormat format, |
371 uint8_t* pixels) { | 369 uint8_t* pixels) { |
372 resource_provider->WaitSyncTokenIfNeeded(id); | 370 resource_provider->WaitSyncTokenIfNeeded(id); |
373 switch (resource_provider->default_resource_type()) { | 371 switch (resource_provider->default_resource_type()) { |
(...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3555 resource_provider->AllocateForTesting(id); | 3553 resource_provider->AllocateForTesting(id); |
3556 Mock::VerifyAndClearExpectations(context); | 3554 Mock::VerifyAndClearExpectations(context); |
3557 | 3555 |
3558 DCHECK_EQ(10u, context->PeekTextureId()); | 3556 DCHECK_EQ(10u, context->PeekTextureId()); |
3559 resource_provider->DeleteResource(id); | 3557 resource_provider->DeleteResource(id); |
3560 } | 3558 } |
3561 } | 3559 } |
3562 | 3560 |
3563 } // namespace | 3561 } // namespace |
3564 } // namespace cc | 3562 } // namespace cc |
OLD | NEW |