| OLD | NEW |
| 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 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 int u_texture_location = -1; | 2140 int u_texture_location = -1; |
| 2141 int v_texture_location = -1; | 2141 int v_texture_location = -1; |
| 2142 int uv_texture_location = -1; | 2142 int uv_texture_location = -1; |
| 2143 int a_texture_location = -1; | 2143 int a_texture_location = -1; |
| 2144 int lut_texture_location = -1; | 2144 int lut_texture_location = -1; |
| 2145 int yuv_matrix_location = -1; | 2145 int yuv_matrix_location = -1; |
| 2146 int yuv_adj_location = -1; | 2146 int yuv_adj_location = -1; |
| 2147 int alpha_location = -1; | 2147 int alpha_location = -1; |
| 2148 int resource_multiplier_location = -1; | 2148 int resource_multiplier_location = -1; |
| 2149 int resource_offset_location = -1; | 2149 int resource_offset_location = -1; |
| 2150 const VideoYUVProgram* program = GetVideoYUVProgram( | 2150 const Program* program = GetProgram(ProgramKey::YUVVideo( |
| 2151 tex_coord_precision, sampler, use_alpha_plane, use_nv12, use_color_lut); | 2151 tex_coord_precision, sampler, use_alpha_plane, use_nv12, use_color_lut)); |
| 2152 DCHECK(program && (program->initialized() || IsContextLost())); | 2152 DCHECK(program && (program->initialized() || IsContextLost())); |
| 2153 SetUseProgram(program->program()); | 2153 SetUseProgram(program->program()); |
| 2154 matrix_location = program->matrix_location(); | 2154 matrix_location = program->matrix_location(); |
| 2155 ya_tex_scale_location = program->ya_tex_scale_location(); | 2155 ya_tex_scale_location = program->ya_tex_scale_location(); |
| 2156 ya_tex_offset_location = program->ya_tex_offset_location(); | 2156 ya_tex_offset_location = program->ya_tex_offset_location(); |
| 2157 uv_tex_scale_location = program->uv_tex_scale_location(); | 2157 uv_tex_scale_location = program->uv_tex_scale_location(); |
| 2158 uv_tex_offset_location = program->uv_tex_offset_location(); | 2158 uv_tex_offset_location = program->uv_tex_offset_location(); |
| 2159 y_texture_location = program->fragment_shader().y_texture_location(); | 2159 y_texture_location = program->y_texture_location(); |
| 2160 u_texture_location = program->fragment_shader().u_texture_location(); | 2160 u_texture_location = program->u_texture_location(); |
| 2161 v_texture_location = program->fragment_shader().v_texture_location(); | 2161 v_texture_location = program->v_texture_location(); |
| 2162 uv_texture_location = program->fragment_shader().uv_texture_location(); | 2162 uv_texture_location = program->uv_texture_location(); |
| 2163 a_texture_location = program->fragment_shader().a_texture_location(); | 2163 a_texture_location = program->a_texture_location(); |
| 2164 lut_texture_location = program->fragment_shader().lut_texture_location(); | 2164 lut_texture_location = program->lut_texture_location(); |
| 2165 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); | 2165 yuv_matrix_location = program->yuv_matrix_location(); |
| 2166 yuv_adj_location = program->fragment_shader().yuv_adj_location(); | 2166 yuv_adj_location = program->yuv_adj_location(); |
| 2167 ya_clamp_rect_location = program->fragment_shader().ya_clamp_rect_location(); | 2167 ya_clamp_rect_location = program->ya_clamp_rect_location(); |
| 2168 uv_clamp_rect_location = program->fragment_shader().uv_clamp_rect_location(); | 2168 uv_clamp_rect_location = program->uv_clamp_rect_location(); |
| 2169 alpha_location = program->fragment_shader().alpha_location(); | 2169 alpha_location = program->alpha_location(); |
| 2170 resource_multiplier_location = | 2170 resource_multiplier_location = program->resource_multiplier_location(); |
| 2171 program->fragment_shader().resource_multiplier_location(); | 2171 resource_offset_location = program->resource_offset_location(); |
| 2172 resource_offset_location = | |
| 2173 program->fragment_shader().resource_offset_location(); | |
| 2174 | 2172 |
| 2175 gfx::SizeF ya_tex_scale(1.0f, 1.0f); | 2173 gfx::SizeF ya_tex_scale(1.0f, 1.0f); |
| 2176 gfx::SizeF uv_tex_scale(1.0f, 1.0f); | 2174 gfx::SizeF uv_tex_scale(1.0f, 1.0f); |
| 2177 if (sampler != SAMPLER_TYPE_2D_RECT) { | 2175 if (sampler != SAMPLER_TYPE_2D_RECT) { |
| 2178 DCHECK(!quad->ya_tex_size.IsEmpty()); | 2176 DCHECK(!quad->ya_tex_size.IsEmpty()); |
| 2179 DCHECK(!quad->uv_tex_size.IsEmpty()); | 2177 DCHECK(!quad->uv_tex_size.IsEmpty()); |
| 2180 ya_tex_scale = gfx::SizeF(1.0f / quad->ya_tex_size.width(), | 2178 ya_tex_scale = gfx::SizeF(1.0f / quad->ya_tex_size.width(), |
| 2181 1.0f / quad->ya_tex_size.height()); | 2179 1.0f / quad->ya_tex_size.height()); |
| 2182 uv_tex_scale = gfx::SizeF(1.0f / quad->uv_tex_size.width(), | 2180 uv_tex_scale = gfx::SizeF(1.0f / quad->uv_tex_size.width(), |
| 2183 1.0f / quad->uv_tex_size.height()); | 2181 1.0f / quad->uv_tex_size.height()); |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3107 break; | 3105 break; |
| 3108 case CLIPPED_BINDING: | 3106 case CLIPPED_BINDING: |
| 3109 clipped_geometry_->PrepareForDraw(); | 3107 clipped_geometry_->PrepareForDraw(); |
| 3110 break; | 3108 break; |
| 3111 case NO_BINDING: | 3109 case NO_BINDING: |
| 3112 break; | 3110 break; |
| 3113 } | 3111 } |
| 3114 bound_geometry_ = binding; | 3112 bound_geometry_ = binding; |
| 3115 } | 3113 } |
| 3116 | 3114 |
| 3117 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( | |
| 3118 TexCoordPrecision precision, | |
| 3119 SamplerType sampler, | |
| 3120 bool use_alpha_plane, | |
| 3121 bool use_nv12, | |
| 3122 bool use_color_lut) { | |
| 3123 DCHECK_GE(precision, 0); | |
| 3124 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | |
| 3125 DCHECK_GE(sampler, 0); | |
| 3126 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3127 VideoYUVProgram* program = | |
| 3128 &video_yuv_program_[precision][sampler][use_alpha_plane][use_nv12] | |
| 3129 [use_color_lut]; | |
| 3130 if (!program->initialized()) { | |
| 3131 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | |
| 3132 program->InitializeVideoYUV(output_surface_->context_provider(), precision, | |
| 3133 sampler, use_alpha_plane, use_nv12, | |
| 3134 use_color_lut); | |
| 3135 } | |
| 3136 return program; | |
| 3137 } | |
| 3138 | |
| 3139 const Program* GLRenderer::GetProgram(const ProgramKey& desc) { | 3115 const Program* GLRenderer::GetProgram(const ProgramKey& desc) { |
| 3140 std::unique_ptr<Program>& program = program_cache_[desc]; | 3116 std::unique_ptr<Program>& program = program_cache_[desc]; |
| 3141 if (!program) { | 3117 if (!program) { |
| 3142 program.reset(new Program); | 3118 program.reset(new Program); |
| 3143 program->Initialize(output_surface_->context_provider(), desc); | 3119 program->Initialize(output_surface_->context_provider(), desc); |
| 3144 } | 3120 } |
| 3145 return program.get(); | 3121 return program.get(); |
| 3146 } | 3122 } |
| 3147 | 3123 |
| 3148 const Program* GLRenderer::GetProgramIfInitialized( | 3124 const Program* GLRenderer::GetProgramIfInitialized( |
| 3149 const ProgramKey& desc) const { | 3125 const ProgramKey& desc) const { |
| 3150 const auto found = program_cache_.find(desc); | 3126 const auto found = program_cache_.find(desc); |
| 3151 if (found == program_cache_.end()) | 3127 if (found == program_cache_.end()) |
| 3152 return nullptr; | 3128 return nullptr; |
| 3153 return found->second.get(); | 3129 return found->second.get(); |
| 3154 } | 3130 } |
| 3155 | 3131 |
| 3156 void GLRenderer::CleanupSharedObjects() { | 3132 void GLRenderer::CleanupSharedObjects() { |
| 3157 shared_geometry_ = nullptr; | 3133 shared_geometry_ = nullptr; |
| 3158 | 3134 |
| 3159 for (int i = 0; i <= LAST_TEX_COORD_PRECISION; ++i) { | |
| 3160 for (int j = 0; j <= LAST_SAMPLER_TYPE; ++j) { | |
| 3161 for (int k = 0; k < 2; k++) { | |
| 3162 for (int l = 0; l < 2; l++) { | |
| 3163 for (int m = 0; m < 2; m++) { | |
| 3164 video_yuv_program_[i][j][k][l][m].Cleanup(gl_); | |
| 3165 } | |
| 3166 } | |
| 3167 } | |
| 3168 } | |
| 3169 } | |
| 3170 for (auto& iter : program_cache_) | 3135 for (auto& iter : program_cache_) |
| 3171 iter.second->Cleanup(gl_); | 3136 iter.second->Cleanup(gl_); |
| 3172 program_cache_.clear(); | 3137 program_cache_.clear(); |
| 3173 | 3138 |
| 3174 if (offscreen_framebuffer_id_) | 3139 if (offscreen_framebuffer_id_) |
| 3175 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_); | 3140 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_); |
| 3176 | 3141 |
| 3177 ReleaseRenderPassTextures(); | 3142 ReleaseRenderPassTextures(); |
| 3178 } | 3143 } |
| 3179 | 3144 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3500 // The alpha has already been applied when copying the RPDQ to an IOSurface. | 3465 // The alpha has already been applied when copying the RPDQ to an IOSurface. |
| 3501 GLfloat alpha = 1; | 3466 GLfloat alpha = 1; |
| 3502 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, | 3467 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, |
| 3503 sorting_context_id, gl_transform); | 3468 sorting_context_id, gl_transform); |
| 3504 gl_->ScheduleCALayerCHROMIUM( | 3469 gl_->ScheduleCALayerCHROMIUM( |
| 3505 texture_id, contents_rect, ca_layer_overlay->background_color, | 3470 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 3506 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 3471 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 3507 } | 3472 } |
| 3508 | 3473 |
| 3509 } // namespace cc | 3474 } // namespace cc |
| OLD | NEW |