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 <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
589 DCHECK(thread_checker_.CalledOnValidThread()); | 589 DCHECK(thread_checker_.CalledOnValidThread()); |
590 // Just store the information. Mailbox will be consumed in LockForRead(). | 590 // Just store the information. Mailbox will be consumed in LockForRead(). |
591 ResourceId id = next_id_++; | 591 ResourceId id = next_id_++; |
592 DCHECK(mailbox.IsValid()); | 592 DCHECK(mailbox.IsValid()); |
593 Resource& resource = resources_[id]; | 593 Resource& resource = resources_[id]; |
594 if (mailbox.IsTexture()) { | 594 if (mailbox.IsTexture()) { |
595 resource = Resource(0, | 595 resource = Resource(0, |
596 gfx::Size(), | 596 gfx::Size(), |
597 Resource::External, | 597 Resource::External, |
598 mailbox.target(), | 598 mailbox.target(), |
599 GL_LINEAR, | 599 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR, |
600 0, | 600 0, |
601 GL_CLAMP_TO_EDGE, | 601 GL_CLAMP_TO_EDGE, |
602 TextureHintImmutable, | 602 TextureHintDefault, |
piman
2014/10/28 05:09:50
Why change this?
jackhou1
2014/10/29 00:12:25
Done.
| |
603 RGBA_8888); | 603 RGBA_8888); |
604 } else { | 604 } else { |
605 DCHECK(mailbox.IsSharedMemory()); | 605 DCHECK(mailbox.IsSharedMemory()); |
606 base::SharedMemory* shared_memory = mailbox.shared_memory(); | 606 base::SharedMemory* shared_memory = mailbox.shared_memory(); |
607 DCHECK(shared_memory->memory()); | 607 DCHECK(shared_memory->memory()); |
608 uint8_t* pixels = reinterpret_cast<uint8_t*>(shared_memory->memory()); | 608 uint8_t* pixels = reinterpret_cast<uint8_t*>(shared_memory->memory()); |
609 DCHECK(pixels); | 609 DCHECK(pixels); |
610 scoped_ptr<SharedBitmap> shared_bitmap; | 610 scoped_ptr<SharedBitmap> shared_bitmap; |
611 if (shared_bitmap_manager_) { | 611 if (shared_bitmap_manager_) { |
612 shared_bitmap = | 612 shared_bitmap = |
613 shared_bitmap_manager_->GetBitmapForSharedMemory(shared_memory); | 613 shared_bitmap_manager_->GetBitmapForSharedMemory(shared_memory); |
614 } | 614 } |
615 resource = Resource(pixels, | 615 resource = Resource(pixels, |
616 shared_bitmap.release(), | 616 shared_bitmap.release(), |
617 mailbox.shared_memory_size(), | 617 mailbox.shared_memory_size(), |
618 Resource::External, | 618 Resource::External, |
619 GL_LINEAR, | 619 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR, |
620 GL_CLAMP_TO_EDGE); | 620 GL_CLAMP_TO_EDGE); |
621 } | 621 } |
622 resource.allocated = true; | 622 resource.allocated = true; |
623 resource.mailbox = mailbox; | 623 resource.mailbox = mailbox; |
624 resource.release_callback_impl = | 624 resource.release_callback_impl = |
625 base::Bind(&SingleReleaseCallbackImpl::Run, | 625 base::Bind(&SingleReleaseCallbackImpl::Run, |
626 base::Owned(release_callback_impl.release())); | 626 base::Owned(release_callback_impl.release())); |
627 resource.allow_overlay = mailbox.allow_overlay(); | 627 resource.allow_overlay = mailbox.allow_overlay(); |
628 return id; | 628 return id; |
629 } | 629 } |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1328 blocking_main_thread_task_runner_); | 1328 blocking_main_thread_task_runner_); |
1329 continue; | 1329 continue; |
1330 } | 1330 } |
1331 | 1331 |
1332 ResourceId local_id = next_id_++; | 1332 ResourceId local_id = next_id_++; |
1333 Resource& resource = resources_[local_id]; | 1333 Resource& resource = resources_[local_id]; |
1334 if (it->is_software) { | 1334 if (it->is_software) { |
1335 resource = Resource(it->mailbox_holder.mailbox, | 1335 resource = Resource(it->mailbox_holder.mailbox, |
1336 it->size, | 1336 it->size, |
1337 Resource::Delegated, | 1337 Resource::Delegated, |
1338 GL_LINEAR, | 1338 it->filter, |
1339 it->is_repeated ? GL_REPEAT : GL_CLAMP_TO_EDGE); | 1339 it->is_repeated ? GL_REPEAT : GL_CLAMP_TO_EDGE); |
1340 } else { | 1340 } else { |
1341 resource = Resource(0, | 1341 resource = Resource(0, |
1342 it->size, | 1342 it->size, |
1343 Resource::Delegated, | 1343 Resource::Delegated, |
1344 it->mailbox_holder.texture_target, | 1344 it->mailbox_holder.texture_target, |
1345 it->filter, | 1345 it->filter, |
1346 0, | 1346 0, |
1347 it->is_repeated ? GL_REPEAT : GL_CLAMP_TO_EDGE, | 1347 it->is_repeated ? GL_REPEAT : GL_CLAMP_TO_EDGE, |
1348 TextureHintImmutable, | 1348 TextureHintDefault, |
piman
2014/10/28 05:09:50
And this
jackhou1
2014/10/29 00:12:25
Done.
| |
1349 it->format); | 1349 it->format); |
1350 resource.mailbox = TextureMailbox(it->mailbox_holder.mailbox, | 1350 resource.mailbox = TextureMailbox(it->mailbox_holder.mailbox, |
1351 it->mailbox_holder.texture_target, | 1351 it->mailbox_holder.texture_target, |
1352 it->mailbox_holder.sync_point); | 1352 it->mailbox_holder.sync_point); |
1353 } | 1353 } |
1354 resource.child_id = child; | 1354 resource.child_id = child; |
1355 // Don't allocate a texture for a child. | 1355 // Don't allocate a texture for a child. |
1356 resource.allocated = true; | 1356 resource.allocated = true; |
1357 resource.imported_count = 1; | 1357 resource.imported_count = 1; |
1358 resource.allow_overlay = it->allow_overlay; | 1358 resource.allow_overlay = it->allow_overlay; |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2064 ContextProvider* context_provider = output_surface_->context_provider(); | 2064 ContextProvider* context_provider = output_surface_->context_provider(); |
2065 return context_provider ? context_provider->ContextGL() : NULL; | 2065 return context_provider ? context_provider->ContextGL() : NULL; |
2066 } | 2066 } |
2067 | 2067 |
2068 class GrContext* ResourceProvider::GrContext() const { | 2068 class GrContext* ResourceProvider::GrContext() const { |
2069 ContextProvider* context_provider = output_surface_->context_provider(); | 2069 ContextProvider* context_provider = output_surface_->context_provider(); |
2070 return context_provider ? context_provider->GrContext() : NULL; | 2070 return context_provider ? context_provider->GrContext() : NULL; |
2071 } | 2071 } |
2072 | 2072 |
2073 } // namespace cc | 2073 } // namespace cc |
OLD | NEW |