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

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

Issue 2735943002: cc: Clarify that color spaces are for raster (Closed)
Patch Set: Rebase (a few times) Created 3 years, 9 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/test/fake_tile_manager_client.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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 : marked_for_deletion(false), needs_sync_tokens(true) {} 400 : marked_for_deletion(false), needs_sync_tokens(true) {}
401 401
402 ResourceProvider::Child::Child(const Child& other) = default; 402 ResourceProvider::Child::Child(const Child& other) = default;
403 403
404 ResourceProvider::Child::~Child() {} 404 ResourceProvider::Child::~Child() {}
405 405
406 ResourceProvider::Settings::Settings( 406 ResourceProvider::Settings::Settings(
407 ContextProvider* compositor_context_provider, 407 ContextProvider* compositor_context_provider,
408 bool delegated_sync_points_required, 408 bool delegated_sync_points_required,
409 bool use_gpu_memory_buffer_resources, 409 bool use_gpu_memory_buffer_resources,
410 bool enable_color_correct_rendering) 410 bool enable_color_correct_rasterization)
411 : default_resource_type(use_gpu_memory_buffer_resources 411 : default_resource_type(use_gpu_memory_buffer_resources
412 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER 412 ? RESOURCE_TYPE_GPU_MEMORY_BUFFER
413 : RESOURCE_TYPE_GL_TEXTURE), 413 : RESOURCE_TYPE_GL_TEXTURE),
414 enable_color_correct_rendering(enable_color_correct_rendering), 414 enable_color_correct_rasterization(enable_color_correct_rasterization),
415 delegated_sync_points_required(delegated_sync_points_required) { 415 delegated_sync_points_required(delegated_sync_points_required) {
416 if (!compositor_context_provider) { 416 if (!compositor_context_provider) {
417 default_resource_type = RESOURCE_TYPE_BITMAP; 417 default_resource_type = RESOURCE_TYPE_BITMAP;
418 // Pick an arbitrary limit here similar to what hardware might. 418 // Pick an arbitrary limit here similar to what hardware might.
419 max_texture_size = 16 * 1024; 419 max_texture_size = 16 * 1024;
420 best_texture_format = RGBA_8888; 420 best_texture_format = RGBA_8888;
421 return; 421 return;
422 } 422 }
423 423
424 DCHECK(IsGpuResourceType(default_resource_type)); 424 DCHECK(IsGpuResourceType(default_resource_type));
(...skipping 22 matching lines...) Expand all
447 } 447 }
448 448
449 ResourceProvider::ResourceProvider( 449 ResourceProvider::ResourceProvider(
450 ContextProvider* compositor_context_provider, 450 ContextProvider* compositor_context_provider,
451 SharedBitmapManager* shared_bitmap_manager, 451 SharedBitmapManager* shared_bitmap_manager,
452 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 452 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
453 BlockingTaskRunner* blocking_main_thread_task_runner, 453 BlockingTaskRunner* blocking_main_thread_task_runner,
454 size_t id_allocation_chunk_size, 454 size_t id_allocation_chunk_size,
455 bool delegated_sync_points_required, 455 bool delegated_sync_points_required,
456 bool use_gpu_memory_buffer_resources, 456 bool use_gpu_memory_buffer_resources,
457 bool enable_color_correct_rendering, 457 bool enable_color_correct_rasterization,
458 const BufferToTextureTargetMap& buffer_to_texture_target_map) 458 const BufferToTextureTargetMap& buffer_to_texture_target_map)
459 : settings_(compositor_context_provider, 459 : settings_(compositor_context_provider,
460 delegated_sync_points_required, 460 delegated_sync_points_required,
461 use_gpu_memory_buffer_resources, 461 use_gpu_memory_buffer_resources,
462 enable_color_correct_rendering), 462 enable_color_correct_rasterization),
463 compositor_context_provider_(compositor_context_provider), 463 compositor_context_provider_(compositor_context_provider),
464 shared_bitmap_manager_(shared_bitmap_manager), 464 shared_bitmap_manager_(shared_bitmap_manager),
465 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 465 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
466 blocking_main_thread_task_runner_(blocking_main_thread_task_runner), 466 blocking_main_thread_task_runner_(blocking_main_thread_task_runner),
467 lost_context_provider_(false), 467 lost_context_provider_(false),
468 next_id_(1), 468 next_id_(1),
469 next_child_(1), 469 next_child_(1),
470 buffer_to_texture_target_map_(buffer_to_texture_target_map), 470 buffer_to_texture_target_map_(buffer_to_texture_target_map),
471 tracing_id_(g_next_resource_provider_tracing_id.GetNext()) { 471 tracing_id_(g_next_resource_provider_tracing_id.GetNext()) {
472 DCHECK(id_allocation_chunk_size); 472 DCHECK(id_allocation_chunk_size);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 return true; 875 return true;
876 } 876 }
877 } 877 }
878 878
879 ResourceProvider::TextureHint ResourceProvider::GetTextureHint(ResourceId id) { 879 ResourceProvider::TextureHint ResourceProvider::GetTextureHint(ResourceId id) {
880 return GetResource(id)->hint; 880 return GetResource(id)->hint;
881 } 881 }
882 882
883 sk_sp<SkColorSpace> ResourceProvider::GetResourceSkColorSpace( 883 sk_sp<SkColorSpace> ResourceProvider::GetResourceSkColorSpace(
884 const Resource* resource) const { 884 const Resource* resource) const {
885 if (!settings_.enable_color_correct_rendering) 885 if (!settings_.enable_color_correct_rasterization)
886 return nullptr; 886 return nullptr;
887 // Returning the nonlinear blended color space matches the expectation of the 887 // Returning the nonlinear blended color space matches the expectation of the
888 // web that colors are blended in the output color space, not in a 888 // web that colors are blended in the output color space, not in a
889 // physically-based linear space. 889 // physically-based linear space.
890 return resource->color_space.ToNonlinearBlendedSkColorSpace(); 890 return resource->color_space.ToNonlinearBlendedSkColorSpace();
891 } 891 }
892 892
893 void ResourceProvider::CopyToResource(ResourceId id, 893 void ResourceProvider::CopyToResource(ResourceId id,
894 const uint8_t* image, 894 const uint8_t* image,
895 const gfx::Size& image_size) { 895 const gfx::Size& image_size) {
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 gpu_memory_buffer_ = std::move(resource->gpu_memory_buffer); 1356 gpu_memory_buffer_ = std::move(resource->gpu_memory_buffer);
1357 resource->gpu_memory_buffer = nullptr; 1357 resource->gpu_memory_buffer = nullptr;
1358 } 1358 }
1359 1359
1360 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: 1360 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::
1361 ~ScopedWriteLockGpuMemoryBuffer() { 1361 ~ScopedWriteLockGpuMemoryBuffer() {
1362 DCHECK(thread_checker_.CalledOnValidThread()); 1362 DCHECK(thread_checker_.CalledOnValidThread());
1363 Resource* resource = resource_provider_->GetResource(resource_id_); 1363 Resource* resource = resource_provider_->GetResource(resource_id_);
1364 DCHECK(resource); 1364 DCHECK(resource);
1365 if (gpu_memory_buffer_) { 1365 if (gpu_memory_buffer_) {
1366 if (resource_provider_->settings_.enable_color_correct_rendering) 1366 // Note that this impacts overlay compositing, not rasterization.
1367 if (resource_provider_->settings_.enable_color_correct_rasterization)
1367 gpu_memory_buffer_->SetColorSpaceForScanout(resource->color_space); 1368 gpu_memory_buffer_->SetColorSpaceForScanout(resource->color_space);
1368 DCHECK(!resource->gpu_memory_buffer); 1369 DCHECK(!resource->gpu_memory_buffer);
1369 resource_provider_->LazyCreate(resource); 1370 resource_provider_->LazyCreate(resource);
1370 resource->gpu_memory_buffer = std::move(gpu_memory_buffer_); 1371 resource->gpu_memory_buffer = std::move(gpu_memory_buffer_);
1371 resource->allocated = true; 1372 resource->allocated = true;
1372 resource_provider_->LazyCreateImage(resource); 1373 resource_provider_->LazyCreateImage(resource);
1373 resource->dirty_image = true; 1374 resource->dirty_image = true;
1374 resource->is_overlay_candidate = true; 1375 resource->is_overlay_candidate = true;
1375 // GpuMemoryBuffer provides direct access to the memory used by the GPU. 1376 // GpuMemoryBuffer provides direct access to the memory used by the GPU.
1376 // Read lock fences are required to ensure that we're not trying to map a 1377 // Read lock fences are required to ensure that we're not trying to map a
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 resource->allocated = true; 1984 resource->allocated = true;
1984 GLES2Interface* gl = ContextGL(); 1985 GLES2Interface* gl = ContextGL();
1985 gfx::Size& size = resource->size; 1986 gfx::Size& size = resource->size;
1986 ResourceFormat format = resource->format; 1987 ResourceFormat format = resource->format;
1987 gl->BindTexture(resource->target, resource->gl_id); 1988 gl->BindTexture(resource->target, resource->gl_id);
1988 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) { 1989 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) {
1989 resource->gpu_memory_buffer = 1990 resource->gpu_memory_buffer =
1990 gpu_memory_buffer_manager_->CreateGpuMemoryBuffer( 1991 gpu_memory_buffer_manager_->CreateGpuMemoryBuffer(
1991 size, BufferFormat(format), resource->usage, 1992 size, BufferFormat(format), resource->usage,
1992 gpu::kNullSurfaceHandle); 1993 gpu::kNullSurfaceHandle);
1994 // Note that this impacts overlay compositing, not rasterization.
1993 if (resource->gpu_memory_buffer && 1995 if (resource->gpu_memory_buffer &&
1994 settings_.enable_color_correct_rendering) { 1996 settings_.enable_color_correct_rasterization) {
1995 resource->gpu_memory_buffer->SetColorSpaceForScanout( 1997 resource->gpu_memory_buffer->SetColorSpaceForScanout(
1996 resource->color_space); 1998 resource->color_space);
1997 } 1999 }
1998 2000
1999 LazyCreateImage(resource); 2001 LazyCreateImage(resource);
2000 resource->dirty_image = true; 2002 resource->dirty_image = true;
2001 resource->is_overlay_candidate = true; 2003 resource->is_overlay_candidate = true;
2002 // GpuMemoryBuffer provides direct access to the memory used by the GPU. 2004 // GpuMemoryBuffer provides direct access to the memory used by the GPU.
2003 // Read lock fences are required to ensure that we're not trying to map a 2005 // Read lock fences are required to ensure that we're not trying to map a
2004 // buffer that is currently in-use by the GPU. 2006 // buffer that is currently in-use by the GPU.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 2177
2176 const int kImportance = 2; 2178 const int kImportance = 2;
2177 pmd->CreateSharedGlobalAllocatorDump(guid); 2179 pmd->CreateSharedGlobalAllocatorDump(guid);
2178 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2180 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2179 } 2181 }
2180 2182
2181 return true; 2183 return true;
2182 } 2184 }
2183 2185
2184 } // namespace cc 2186 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/test/fake_tile_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698