Chromium Code Reviews| 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 (auto it = pending_produce_textures_.begin(); |
|
danakj
2015/11/13 23:41:06
um, actually not sure why not use range-based for
vmpstr
2015/11/13 23:50:49
Yep, changed it to that. A lot of these changes we
| |
| 186 pending_produce_textures_.begin(); | 186 it != pending_produce_textures_.end(); ++it) { |
| 187 it != pending_produce_textures_.end(); | |
| 188 ++it) { | |
| 189 shared_data_->ProduceTexture((*it)->mailbox, gpu::SyncToken(sync_point), | 187 shared_data_->ProduceTexture((*it)->mailbox, gpu::SyncToken(sync_point), |
| 190 (*it)->texture); | 188 (*it)->texture); |
| 191 } | 189 } |
| 192 pending_produce_textures_.clear(); | 190 pending_produce_textures_.clear(); |
| 193 return sync_point; | 191 return sync_point; |
| 194 } | 192 } |
| 195 | 193 |
| 196 void waitSyncToken(const GLbyte* sync_token) override { | 194 void waitSyncToken(const GLbyte* sync_token) override { |
| 197 gpu::SyncToken sync_token_data; | 195 gpu::SyncToken sync_token_data; |
| 198 if (sync_token) | 196 if (sync_token) |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 memcpy(dest, src, in_pitch); | 348 memcpy(dest, src, in_pitch); |
| 351 dest += out_pitch; | 349 dest += out_pitch; |
| 352 src += in_pitch; | 350 src += in_pitch; |
| 353 } | 351 } |
| 354 } | 352 } |
| 355 | 353 |
| 356 struct PendingProduceTexture { | 354 struct PendingProduceTexture { |
| 357 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 355 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
| 358 scoped_refptr<TestTexture> texture; | 356 scoped_refptr<TestTexture> texture; |
| 359 }; | 357 }; |
| 360 typedef ScopedPtrDeque<PendingProduceTexture> PendingProduceTextureList; | |
| 361 ContextSharedData* shared_data_; | 358 ContextSharedData* shared_data_; |
| 362 gpu::SyncToken last_waited_sync_token_; | 359 gpu::SyncToken last_waited_sync_token_; |
| 363 PendingProduceTextureList pending_produce_textures_; | 360 std::deque<scoped_ptr<PendingProduceTexture>> pending_produce_textures_; |
| 364 }; | 361 }; |
| 365 | 362 |
| 366 void GetResourcePixels(ResourceProvider* resource_provider, | 363 void GetResourcePixels(ResourceProvider* resource_provider, |
| 367 ResourceProviderContext* context, | 364 ResourceProviderContext* context, |
| 368 ResourceId id, | 365 ResourceId id, |
| 369 const gfx::Size& size, | 366 const gfx::Size& size, |
| 370 ResourceFormat format, | 367 ResourceFormat format, |
| 371 uint8_t* pixels) { | 368 uint8_t* pixels) { |
| 372 resource_provider->WaitSyncTokenIfNeeded(id); | 369 resource_provider->WaitSyncTokenIfNeeded(id); |
| 373 switch (resource_provider->default_resource_type()) { | 370 switch (resource_provider->default_resource_type()) { |
| (...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3555 resource_provider->AllocateForTesting(id); | 3552 resource_provider->AllocateForTesting(id); |
| 3556 Mock::VerifyAndClearExpectations(context); | 3553 Mock::VerifyAndClearExpectations(context); |
| 3557 | 3554 |
| 3558 DCHECK_EQ(10u, context->PeekTextureId()); | 3555 DCHECK_EQ(10u, context->PeekTextureId()); |
| 3559 resource_provider->DeleteResource(id); | 3556 resource_provider->DeleteResource(id); |
| 3560 } | 3557 } |
| 3561 } | 3558 } |
| 3562 | 3559 |
| 3563 } // namespace | 3560 } // namespace |
| 3564 } // namespace cc | 3561 } // namespace cc |
| OLD | NEW |