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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2693723002: cc: Move output color space from DrawingFrame to RenderPass (Closed)
Patch Set: Fix typo Created 3 years, 10 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
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 return backdrop_rect; 875 return backdrop_rect;
876 } 876 }
877 877
878 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( 878 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture(
879 const gfx::Rect& bounding_rect) { 879 const gfx::Rect& bounding_rect) {
880 std::unique_ptr<ScopedResource> device_background_texture = 880 std::unique_ptr<ScopedResource> device_background_texture =
881 ScopedResource::Create(resource_provider_); 881 ScopedResource::Create(resource_provider_);
882 // CopyTexImage2D fails when called on a texture having immutable storage. 882 // CopyTexImage2D fails when called on a texture having immutable storage.
883 device_background_texture->Allocate( 883 device_background_texture->Allocate(
884 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, 884 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT,
885 BackbufferFormat(), current_frame()->device_color_space); 885 BackbufferFormat(), current_frame()->current_render_pass->color_space);
886 { 886 {
887 ResourceProvider::ScopedWriteLockGL lock( 887 ResourceProvider::ScopedWriteLockGL lock(
888 resource_provider_, device_background_texture->id(), false); 888 resource_provider_, device_background_texture->id(), false);
889 GetFramebufferTexture(lock.texture_id(), bounding_rect); 889 GetFramebufferTexture(lock.texture_id(), bounding_rect);
890 } 890 }
891 return device_background_texture; 891 return device_background_texture;
892 } 892 }
893 893
894 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( 894 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters(
895 const RenderPassDrawQuad* quad, 895 const RenderPassDrawQuad* quad,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 DrawRenderPassDrawQuadParams params; 1027 DrawRenderPassDrawQuadParams params;
1028 params.quad = quad; 1028 params.quad = quad;
1029 params.clip_region = clip_region; 1029 params.clip_region = clip_region;
1030 params.window_matrix = current_frame()->window_matrix; 1030 params.window_matrix = current_frame()->window_matrix;
1031 params.projection_matrix = current_frame()->projection_matrix; 1031 params.projection_matrix = current_frame()->projection_matrix;
1032 if (bypass != render_pass_bypass_quads_.end()) { 1032 if (bypass != render_pass_bypass_quads_.end()) {
1033 TileDrawQuad* tile_quad = &bypass->second; 1033 TileDrawQuad* tile_quad = &bypass->second;
1034 // RGBA_8888 here is arbitrary and unused. 1034 // RGBA_8888 here is arbitrary and unused.
1035 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size, 1035 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size,
1036 ResourceFormat::RGBA_8888, 1036 ResourceFormat::RGBA_8888,
1037 current_frame()->device_color_space); 1037 current_frame()->current_render_pass->color_space);
1038 // The projection matrix used by GLRenderer has a flip. As tile texture 1038 // The projection matrix used by GLRenderer has a flip. As tile texture
1039 // inputs are oriented opposite to framebuffer outputs, don't flip via 1039 // inputs are oriented opposite to framebuffer outputs, don't flip via
1040 // texture coords and let the projection matrix naturallyd o it. 1040 // texture coords and let the projection matrix naturallyd o it.
1041 params.flip_texture = false; 1041 params.flip_texture = false;
1042 params.contents_texture = &tile_resource; 1042 params.contents_texture = &tile_resource;
1043 DrawRenderPassQuadInternal(&params); 1043 DrawRenderPassQuadInternal(&params);
1044 } else { 1044 } else {
1045 ScopedResource* contents_texture = 1045 ScopedResource* contents_texture =
1046 render_pass_textures_[quad->render_pass_id].get(); 1046 render_pass_textures_[quad->render_pass_id].get();
1047 DCHECK(contents_texture); 1047 DCHECK(contents_texture);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 if (params->mask_resource_lock) { 1302 if (params->mask_resource_lock) {
1303 mask_mode = HAS_MASK; 1303 mask_mode = HAS_MASK;
1304 sampler_type = 1304 sampler_type =
1305 SamplerTypeFromTextureTarget(params->mask_resource_lock->target()); 1305 SamplerTypeFromTextureTarget(params->mask_resource_lock->target());
1306 } 1306 }
1307 1307
1308 SetUseProgram(ProgramKey::RenderPass( 1308 SetUseProgram(ProgramKey::RenderPass(
1309 tex_coord_precision, sampler_type, shader_blend_mode, 1309 tex_coord_precision, sampler_type, shader_blend_mode,
1310 params->use_aa ? USE_AA : NO_AA, mask_mode, 1310 params->use_aa ? USE_AA : NO_AA, mask_mode,
1311 mask_for_background, params->use_color_matrix), 1311 mask_for_background, params->use_color_matrix),
1312 current_frame()->device_color_space); 1312 current_frame()->current_render_pass->color_space);
1313 } 1313 }
1314 1314
1315 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) { 1315 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
1316 gfx::RectF tex_rect(params->src_offset.x(), params->src_offset.y(), 1316 gfx::RectF tex_rect(params->src_offset.x(), params->src_offset.y(),
1317 params->dst_rect.width(), params->dst_rect.height()); 1317 params->dst_rect.width(), params->dst_rect.height());
1318 gfx::Size texture_size; 1318 gfx::Size texture_size;
1319 if (params->filter_image) { 1319 if (params->filter_image) {
1320 texture_size.set_width(params->filter_image->width()); 1320 texture_size.set_width(params->filter_image->width());
1321 texture_size.set_height(params->filter_image->height()); 1321 texture_size.set_height(params->filter_image->height());
1322 } else { 1322 } else {
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 : YUV_NO_ALPHA_TEXTURE; 2085 : YUV_NO_ALPHA_TEXTURE;
2086 UVTextureMode uv_texture_mode = 2086 UVTextureMode uv_texture_mode =
2087 quad->v_plane_resource_id() == quad->u_plane_resource_id() 2087 quad->v_plane_resource_id() == quad->u_plane_resource_id()
2088 ? UV_TEXTURE_MODE_UV 2088 ? UV_TEXTURE_MODE_UV
2089 : UV_TEXTURE_MODE_U_V; 2089 : UV_TEXTURE_MODE_U_V;
2090 2090
2091 // TODO(ccameron): There are currently three sources of the color space: the 2091 // TODO(ccameron): There are currently three sources of the color space: the
2092 // resource, quad->color_space, and quad->video_color_space. Remove two of 2092 // resource, quad->color_space, and quad->video_color_space. Remove two of
2093 // them. 2093 // them.
2094 gfx::ColorSpace src_color_space = quad->video_color_space; 2094 gfx::ColorSpace src_color_space = quad->video_color_space;
2095 gfx::ColorSpace dst_color_space = current_frame()->device_color_space; 2095 gfx::ColorSpace dst_color_space =
2096 current_frame()->current_render_pass->color_space;
2096 if (!base::FeatureList::IsEnabled(media::kVideoColorManagement)) { 2097 if (!base::FeatureList::IsEnabled(media::kVideoColorManagement)) {
2097 if (!settings_->enable_color_correct_rendering) 2098 if (!settings_->enable_color_correct_rendering)
2098 dst_color_space = gfx::ColorSpace(); 2099 dst_color_space = gfx::ColorSpace();
2099 switch (quad->color_space) { 2100 switch (quad->color_space) {
2100 case YUVVideoDrawQuad::REC_601: 2101 case YUVVideoDrawQuad::REC_601:
2101 src_color_space = gfx::ColorSpace::CreateREC601(); 2102 src_color_space = gfx::ColorSpace::CreateREC601();
2102 break; 2103 break;
2103 case YUVVideoDrawQuad::REC_709: 2104 case YUVVideoDrawQuad::REC_709:
2104 src_color_space = gfx::ColorSpace::CreateREC709(); 2105 src_color_space = gfx::ColorSpace::CreateREC709();
2105 break; 2106 break;
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 case NO_BINDING: 3014 case NO_BINDING:
3014 break; 3015 break;
3015 } 3016 }
3016 bound_geometry_ = binding; 3017 bound_geometry_ = binding;
3017 } 3018 }
3018 3019
3019 void GLRenderer::SetUseProgram(const ProgramKey& program_key, 3020 void GLRenderer::SetUseProgram(const ProgramKey& program_key,
3020 const gfx::ColorSpace& src_color_space) { 3021 const gfx::ColorSpace& src_color_space) {
3021 gfx::ColorSpace dst_color_space; 3022 gfx::ColorSpace dst_color_space;
3022 if (settings_->enable_color_correct_rendering) 3023 if (settings_->enable_color_correct_rendering)
3023 dst_color_space = current_frame()->device_color_space; 3024 dst_color_space = current_frame()->current_render_pass->color_space;
3024 SetUseProgram(program_key, src_color_space, dst_color_space); 3025 SetUseProgram(program_key, src_color_space, dst_color_space);
3025 } 3026 }
3026 3027
3027 void GLRenderer::SetUseProgram(const ProgramKey& program_key_no_color, 3028 void GLRenderer::SetUseProgram(const ProgramKey& program_key_no_color,
3028 const gfx::ColorSpace& src_color_space, 3029 const gfx::ColorSpace& src_color_space,
3029 const gfx::ColorSpace& dst_color_space) { 3030 const gfx::ColorSpace& dst_color_space) {
3030 ProgramKey program_key = program_key_no_color; 3031 ProgramKey program_key = program_key_no_color;
3031 if (src_color_space.IsValid() && dst_color_space.IsValid()) 3032 if (src_color_space.IsValid() && dst_color_space.IsValid())
3032 program_key.SetColorConversionMode(COLOR_CONVERSION_MODE_LUT); 3033 program_key.SetColorConversionMode(COLOR_CONVERSION_MODE_LUT);
3033 3034
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3290 // memory fragmentation. https://crbug.com/146070. This also allows IOSurfaces 3291 // memory fragmentation. https://crbug.com/146070. This also allows IOSurfaces
3291 // to be more easily reused during a resize operation. 3292 // to be more easily reused during a resize operation.
3292 uint32_t iosurface_multiple = 64; 3293 uint32_t iosurface_multiple = 64;
3293 uint32_t iosurface_width = MathUtil::UncheckedRoundUp( 3294 uint32_t iosurface_width = MathUtil::UncheckedRoundUp(
3294 static_cast<uint32_t>(updated_dst_rect.width()), iosurface_multiple); 3295 static_cast<uint32_t>(updated_dst_rect.width()), iosurface_multiple);
3295 uint32_t iosurface_height = MathUtil::UncheckedRoundUp( 3296 uint32_t iosurface_height = MathUtil::UncheckedRoundUp(
3296 static_cast<uint32_t>(updated_dst_rect.height()), iosurface_multiple); 3297 static_cast<uint32_t>(updated_dst_rect.height()), iosurface_multiple);
3297 3298
3298 *resource = overlay_resource_pool_->AcquireResource( 3299 *resource = overlay_resource_pool_->AcquireResource(
3299 gfx::Size(iosurface_width, iosurface_height), ResourceFormat::RGBA_8888, 3300 gfx::Size(iosurface_width, iosurface_height), ResourceFormat::RGBA_8888,
3300 current_frame()->device_color_space); 3301 current_frame()->current_render_pass->color_space);
3301 *new_bounds = 3302 *new_bounds =
3302 gfx::RectF(updated_dst_rect.x(), updated_dst_rect.y(), 3303 gfx::RectF(updated_dst_rect.x(), updated_dst_rect.y(),
3303 (*resource)->size().width(), (*resource)->size().height()); 3304 (*resource)->size().width(), (*resource)->size().height());
3304 3305
3305 // Calculate new projection and window matrices for a minimally sized viewport 3306 // Calculate new projection and window matrices for a minimally sized viewport
3306 // using InitializeViewport(). This requires creating a dummy DrawingFrame. 3307 // using InitializeViewport(). This requires creating a dummy DrawingFrame.
3307 { 3308 {
3308 DrawingFrame dummy_frame; 3309 DrawingFrame dummy_frame;
3309 force_drawing_frame_framebuffer_unflipped_ = true; 3310 force_drawing_frame_framebuffer_unflipped_ = true;
3310 gfx::Rect frame_rect = 3311 gfx::Rect frame_rect =
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3526 return; 3527 return;
3527 3528
3528 // Report GPU overdraw as a percentage of |max_result|. 3529 // Report GPU overdraw as a percentage of |max_result|.
3529 TRACE_COUNTER1( 3530 TRACE_COUNTER1(
3530 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3531 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3531 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3532 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3532 max_result); 3533 max_result);
3533 } 3534 }
3534 3535
3535 } // namespace cc 3536 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698