Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(459)

Side by Side Diff: cc/resources/resource_provider.cc

Issue 1195473003: cc: Set read lock fences required for YUV native video frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enable read lock fences for all the native planes. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/video_resource_updater.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 DCHECK(gl); 543 DCHECK(gl);
544 gl->BindTexture(GL_TEXTURE_RECTANGLE_ARB, resource->gl_id); 544 gl->BindTexture(GL_TEXTURE_RECTANGLE_ARB, resource->gl_id);
545 gl->TexImageIOSurface2DCHROMIUM( 545 gl->TexImageIOSurface2DCHROMIUM(
546 GL_TEXTURE_RECTANGLE_ARB, size.width(), size.height(), io_surface_id, 0); 546 GL_TEXTURE_RECTANGLE_ARB, size.width(), size.height(), io_surface_id, 0);
547 resource->allocated = true; 547 resource->allocated = true;
548 return id; 548 return id;
549 } 549 }
550 550
551 ResourceId ResourceProvider::CreateResourceFromTextureMailbox( 551 ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
552 const TextureMailbox& mailbox, 552 const TextureMailbox& mailbox,
553 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl) { 553 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl,
554 bool read_lock_fences_enabled) {
554 DCHECK(thread_checker_.CalledOnValidThread()); 555 DCHECK(thread_checker_.CalledOnValidThread());
555 // Just store the information. Mailbox will be consumed in LockForRead(). 556 // Just store the information. Mailbox will be consumed in LockForRead().
556 ResourceId id = next_id_++; 557 ResourceId id = next_id_++;
557 DCHECK(mailbox.IsValid()); 558 DCHECK(mailbox.IsValid());
558 Resource* resource = nullptr; 559 Resource* resource = nullptr;
559 if (mailbox.IsTexture()) { 560 if (mailbox.IsTexture()) {
560 resource = InsertResource( 561 resource = InsertResource(
561 id, Resource(0, gfx::Size(), Resource::EXTERNAL, mailbox.target(), 562 id, Resource(0, gfx::Size(), Resource::EXTERNAL, mailbox.target(),
562 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR, 0, 563 mailbox.nearest_neighbor() ? GL_NEAREST : GL_LINEAR, 0,
563 GL_CLAMP_TO_EDGE, TEXTURE_HINT_IMMUTABLE, RGBA_8888)); 564 GL_CLAMP_TO_EDGE, TEXTURE_HINT_IMMUTABLE, RGBA_8888));
564 } else { 565 } else {
565 DCHECK(mailbox.IsSharedMemory()); 566 DCHECK(mailbox.IsSharedMemory());
566 SharedBitmap* shared_bitmap = mailbox.shared_bitmap(); 567 SharedBitmap* shared_bitmap = mailbox.shared_bitmap();
567 uint8_t* pixels = shared_bitmap->pixels(); 568 uint8_t* pixels = shared_bitmap->pixels();
568 DCHECK(pixels); 569 DCHECK(pixels);
569 resource = InsertResource( 570 resource = InsertResource(
570 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(), 571 id, Resource(pixels, shared_bitmap, mailbox.size_in_pixels(),
571 Resource::EXTERNAL, GL_LINEAR, GL_CLAMP_TO_EDGE)); 572 Resource::EXTERNAL, GL_LINEAR, GL_CLAMP_TO_EDGE));
572 } 573 }
573 resource->allocated = true; 574 resource->allocated = true;
574 resource->mailbox = mailbox; 575 resource->mailbox = mailbox;
575 resource->release_callback_impl = 576 resource->release_callback_impl =
576 base::Bind(&SingleReleaseCallbackImpl::Run, 577 base::Bind(&SingleReleaseCallbackImpl::Run,
577 base::Owned(release_callback_impl.release())); 578 base::Owned(release_callback_impl.release()));
579 resource->read_lock_fences_enabled = read_lock_fences_enabled;
578 return id; 580 return id;
579 } 581 }
580 582
583 ResourceId ResourceProvider::CreateResourceFromTextureMailbox(
584 const TextureMailbox& mailbox,
585 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl) {
586 return CreateResourceFromTextureMailbox(mailbox, release_callback_impl.Pass(),
587 false);
588 }
589
581 void ResourceProvider::DeleteResource(ResourceId id) { 590 void ResourceProvider::DeleteResource(ResourceId id) {
582 DCHECK(thread_checker_.CalledOnValidThread()); 591 DCHECK(thread_checker_.CalledOnValidThread());
583 ResourceMap::iterator it = resources_.find(id); 592 ResourceMap::iterator it = resources_.find(id);
584 CHECK(it != resources_.end()); 593 CHECK(it != resources_.end());
585 Resource* resource = &it->second; 594 Resource* resource = &it->second;
586 DCHECK(!resource->marked_for_deletion); 595 DCHECK(!resource->marked_for_deletion);
587 DCHECK_EQ(resource->imported_count, 0); 596 DCHECK_EQ(resource->imported_count, 0);
588 DCHECK(resource->pending_set_pixels || !resource->locked_for_write); 597 DCHECK(resource->pending_set_pixels || !resource->locked_for_write);
589 598
590 if (resource->exported_count > 0 || resource->lock_for_read_count > 0) { 599 if (resource->exported_count > 0 || resource->lock_for_read_count > 0) {
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 } 2056 }
2048 2057
2049 class GrContext* ResourceProvider::GrContext(bool worker_context) const { 2058 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
2050 ContextProvider* context_provider = 2059 ContextProvider* context_provider =
2051 worker_context ? output_surface_->worker_context_provider() 2060 worker_context ? output_surface_->worker_context_provider()
2052 : output_surface_->context_provider(); 2061 : output_surface_->context_provider();
2053 return context_provider ? context_provider->GrContext() : NULL; 2062 return context_provider ? context_provider->GrContext() : NULL;
2054 } 2063 }
2055 2064
2056 } // namespace cc 2065 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/video_resource_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698