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

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

Issue 2235623003: cc: Add gfx::ColorSpace to cc::ResourceProvider resource creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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/video_resource_updater.h ('k') | cc/test/fake_ui_resource_layer_tree_host_impl.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 VideoResourceUpdater::~VideoResourceUpdater() { 169 VideoResourceUpdater::~VideoResourceUpdater() {
170 for (const PlaneResource& plane_resource : all_resources_) 170 for (const PlaneResource& plane_resource : all_resources_)
171 resource_provider_->DeleteResource(plane_resource.resource_id()); 171 resource_provider_->DeleteResource(plane_resource.resource_id());
172 } 172 }
173 173
174 VideoResourceUpdater::ResourceList::iterator 174 VideoResourceUpdater::ResourceList::iterator
175 VideoResourceUpdater::AllocateResource(const gfx::Size& plane_size, 175 VideoResourceUpdater::AllocateResource(const gfx::Size& plane_size,
176 ResourceFormat format, 176 ResourceFormat format,
177 const gfx::ColorSpace& color_space,
177 bool has_mailbox, 178 bool has_mailbox,
178 bool immutable_hint) { 179 bool immutable_hint) {
179 // TODO(danakj): Abstract out hw/sw resource create/delete from 180 // TODO(danakj): Abstract out hw/sw resource create/delete from
180 // ResourceProvider and stop using ResourceProvider in this class. 181 // ResourceProvider and stop using ResourceProvider in this class.
181 const ResourceId resource_id = resource_provider_->CreateResource( 182 const ResourceId resource_id = resource_provider_->CreateResource(
182 plane_size, immutable_hint ? ResourceProvider::TEXTURE_HINT_IMMUTABLE 183 plane_size, immutable_hint ? ResourceProvider::TEXTURE_HINT_IMMUTABLE
183 : ResourceProvider::TEXTURE_HINT_DEFAULT, 184 : ResourceProvider::TEXTURE_HINT_DEFAULT,
184 format); 185 format, color_space);
185 if (resource_id == 0) 186 if (resource_id == 0)
186 return all_resources_.end(); 187 return all_resources_.end();
187 188
188 gpu::Mailbox mailbox; 189 gpu::Mailbox mailbox;
189 if (has_mailbox) { 190 if (has_mailbox) {
190 DCHECK(context_provider_); 191 DCHECK(context_provider_);
191 192
192 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); 193 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
193 194
194 gl->GenMailboxCHROMIUM(mailbox.name); 195 gl->GenMailboxCHROMIUM(mailbox.name);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (!it->has_refs() && !in_use) { 350 if (!it->has_refs() && !in_use) {
350 // We found a resource with the correct size that we can overwrite. 351 // We found a resource with the correct size that we can overwrite.
351 resource_it = it; 352 resource_it = it;
352 } 353 }
353 } 354 }
354 } 355 }
355 356
356 // Check if we need to allocate a new resource. 357 // Check if we need to allocate a new resource.
357 if (resource_it == all_resources_.end()) { 358 if (resource_it == all_resources_.end()) {
358 const bool is_immutable = true; 359 const bool is_immutable = true;
359 resource_it = 360 resource_it = AllocateResource(
360 AllocateResource(output_plane_resource_size, output_resource_format, 361 output_plane_resource_size, output_resource_format,
361 !software_compositor, is_immutable); 362 video_frame->ColorSpace(), !software_compositor, is_immutable);
362 } 363 }
363 if (resource_it == all_resources_.end()) 364 if (resource_it == all_resources_.end())
364 break; 365 break;
365 366
366 resource_it->add_ref(); 367 resource_it->add_ref();
367 plane_resources.push_back(resource_it); 368 plane_resources.push_back(resource_it);
368 } 369 }
369 370
370 if (plane_resources.size() != output_plane_count) { 371 if (plane_resources.size() != output_plane_count) {
371 // Allocation failed, nothing will be returned so restore reference counts. 372 // Allocation failed, nothing will be returned so restore reference counts.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 ResourceProvider::TEXTURE_HINT_IMMUTABLE) { 577 ResourceProvider::TEXTURE_HINT_IMMUTABLE) {
577 resource = it; 578 resource = it;
578 break; 579 break;
579 } 580 }
580 } 581 }
581 582
582 // Otherwise allocate a new resource. 583 // Otherwise allocate a new resource.
583 if (resource == all_resources_.end()) { 584 if (resource == all_resources_.end()) {
584 const bool is_immutable = false; 585 const bool is_immutable = false;
585 resource = AllocateResource(output_plane_resource_size, copy_target_format, 586 resource = AllocateResource(output_plane_resource_size, copy_target_format,
586 true, is_immutable); 587 video_frame->ColorSpace(), true, is_immutable);
587 } 588 }
588 589
589 resource->add_ref(); 590 resource->add_ref();
590 591
591 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 592 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
592 resource->resource_id(), false); 593 resource->resource_id(), false);
593 DCHECK_EQ( 594 DCHECK_EQ(
594 resource_provider_->GetResourceTextureTarget(resource->resource_id()), 595 resource_provider_->GetResourceTextureTarget(resource->resource_id()),
595 (GLenum)GL_TEXTURE_2D); 596 (GLenum)GL_TEXTURE_2D);
596 597
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 if (lost_resource) { 696 if (lost_resource) {
696 resource_it->clear_refs(); 697 resource_it->clear_refs();
697 updater->DeleteResource(resource_it); 698 updater->DeleteResource(resource_it);
698 return; 699 return;
699 } 700 }
700 701
701 resource_it->remove_ref(); 702 resource_it->remove_ref();
702 } 703 }
703 704
704 } // namespace cc 705 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/test/fake_ui_resource_layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698