Chromium Code Reviews| 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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1300 (params->quad->ShouldDrawWithBlending() || | 1300 (params->quad->ShouldDrawWithBlending() || |
| 1301 !IsDefaultBlendMode(blend_mode))); | 1301 !IsDefaultBlendMode(blend_mode))); |
| 1302 if (!params->use_shaders_for_blending) { | 1302 if (!params->use_shaders_for_blending) { |
| 1303 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) | 1303 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) |
| 1304 gl_->BlendBarrierKHR(); | 1304 gl_->BlendBarrierKHR(); |
| 1305 | 1305 |
| 1306 ApplyBlendModeUsingBlendFunc(blend_mode); | 1306 ApplyBlendModeUsingBlendFunc(blend_mode); |
| 1307 } | 1307 } |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params) { | 1310 void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params) { |
|
ccameron
2017/01/11 09:46:39
I ended up leaving this untouched in this patch --
| |
| 1311 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1311 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 1312 gl_, &highp_threshold_cache_, highp_threshold_min_, | 1312 gl_, &highp_threshold_cache_, highp_threshold_min_, |
| 1313 params->quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); | 1313 params->quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); |
| 1314 | 1314 |
| 1315 BlendMode shader_blend_mode = | 1315 BlendMode shader_blend_mode = |
| 1316 params->use_shaders_for_blending | 1316 params->use_shaders_for_blending |
| 1317 ? BlendModeFromSkXfermode(params->quad->shared_quad_state->blend_mode) | 1317 ? BlendModeFromSkXfermode(params->quad->shared_quad_state->blend_mode) |
| 1318 : BLEND_MODE_NONE; | 1318 : BLEND_MODE_NONE; |
| 1319 | 1319 |
| 1320 unsigned mask_texture_id = 0; | 1320 unsigned mask_texture_id = 0; |
| (...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3279 case CLIPPED_BINDING: | 3279 case CLIPPED_BINDING: |
| 3280 clipped_geometry_->PrepareForDraw(); | 3280 clipped_geometry_->PrepareForDraw(); |
| 3281 break; | 3281 break; |
| 3282 case NO_BINDING: | 3282 case NO_BINDING: |
| 3283 break; | 3283 break; |
| 3284 } | 3284 } |
| 3285 bound_geometry_ = binding; | 3285 bound_geometry_ = binding; |
| 3286 } | 3286 } |
| 3287 | 3287 |
| 3288 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { | 3288 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { |
| 3289 if (!debug_border_program_.initialized()) { | 3289 return GetProgram(ProgramKey::DebugBorder()); |
| 3290 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); | |
| 3291 debug_border_program_.Initialize(output_surface_->context_provider(), | |
| 3292 ProgramKey::DebugBorder()); | |
| 3293 } | |
| 3294 return &debug_border_program_; | |
| 3295 } | 3290 } |
| 3296 | 3291 |
| 3297 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { | 3292 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { |
| 3298 if (!solid_color_program_.initialized()) { | 3293 return GetProgram(ProgramKey::SolidColor(NO_AA)); |
| 3299 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); | |
| 3300 solid_color_program_.Initialize(output_surface_->context_provider(), | |
| 3301 ProgramKey::SolidColor(NO_AA)); | |
| 3302 } | |
| 3303 return &solid_color_program_; | |
| 3304 } | 3294 } |
| 3305 | 3295 |
| 3306 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { | 3296 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { |
| 3307 if (!solid_color_program_aa_.initialized()) { | 3297 return GetProgram(ProgramKey::SolidColor(USE_AA)); |
| 3308 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); | |
| 3309 solid_color_program_aa_.Initialize(output_surface_->context_provider(), | |
| 3310 ProgramKey::SolidColor(USE_AA)); | |
| 3311 } | |
| 3312 return &solid_color_program_aa_; | |
| 3313 } | 3298 } |
| 3314 | 3299 |
| 3315 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( | 3300 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( |
| 3316 TexCoordPrecision precision, | 3301 TexCoordPrecision precision, |
| 3317 BlendMode blend_mode) { | 3302 BlendMode blend_mode) { |
| 3318 DCHECK_GE(precision, 0); | 3303 return GetProgram(ProgramKey::RenderPass( |
| 3319 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3304 precision, SAMPLER_TYPE_2D, blend_mode, NO_AA, NO_MASK, false, false)); |
| 3320 DCHECK_GE(blend_mode, 0); | |
| 3321 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3322 RenderPassProgram* program = &render_pass_program_[precision][blend_mode]; | |
| 3323 if (!program->initialized()) { | |
| 3324 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); | |
| 3325 program->Initialize( | |
| 3326 output_surface_->context_provider(), | |
| 3327 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, NO_AA, | |
| 3328 NO_MASK, false, false)); | |
| 3329 } | |
| 3330 return program; | |
| 3331 } | 3305 } |
| 3332 | 3306 |
| 3333 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( | 3307 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( |
| 3334 TexCoordPrecision precision, | 3308 TexCoordPrecision precision, |
| 3335 BlendMode blend_mode) { | 3309 BlendMode blend_mode) { |
| 3336 DCHECK_GE(precision, 0); | 3310 return GetProgram(ProgramKey::RenderPass( |
| 3337 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3311 precision, SAMPLER_TYPE_2D, blend_mode, USE_AA, NO_MASK, false, false)); |
| 3338 DCHECK_GE(blend_mode, 0); | |
| 3339 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3340 RenderPassProgramAA* program = | |
| 3341 &render_pass_program_aa_[precision][blend_mode]; | |
| 3342 if (!program->initialized()) { | |
| 3343 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); | |
| 3344 program->Initialize( | |
| 3345 output_surface_->context_provider(), | |
| 3346 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, USE_AA, | |
| 3347 NO_MASK, false, false)); | |
| 3348 } | |
| 3349 return program; | |
| 3350 } | 3312 } |
| 3351 | 3313 |
| 3352 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( | 3314 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( |
| 3353 TexCoordPrecision precision, | 3315 TexCoordPrecision precision, |
| 3354 SamplerType sampler, | 3316 SamplerType sampler, |
| 3355 BlendMode blend_mode, | 3317 BlendMode blend_mode, |
| 3356 bool mask_for_background) { | 3318 bool mask_for_background) { |
| 3357 DCHECK_GE(precision, 0); | 3319 return GetProgram(ProgramKey::RenderPass(precision, sampler, blend_mode, |
| 3358 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3320 NO_AA, HAS_MASK, mask_for_background, |
| 3359 DCHECK_GE(sampler, 0); | 3321 false)); |
| 3360 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3361 DCHECK_GE(blend_mode, 0); | |
| 3362 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3363 RenderPassMaskProgram* program = | |
| 3364 &render_pass_mask_program_[precision][sampler][blend_mode] | |
| 3365 [mask_for_background ? HAS_MASK : NO_MASK]; | |
| 3366 if (!program->initialized()) { | |
| 3367 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); | |
| 3368 program->Initialize( | |
| 3369 output_surface_->context_provider(), | |
| 3370 ProgramKey::RenderPass(precision, sampler, blend_mode, NO_AA, HAS_MASK, | |
| 3371 mask_for_background, false)); | |
| 3372 } | |
| 3373 return program; | |
| 3374 } | 3322 } |
| 3375 | 3323 |
| 3376 const GLRenderer::RenderPassMaskProgramAA* | 3324 const GLRenderer::RenderPassMaskProgramAA* |
| 3377 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision, | 3325 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision, |
| 3378 SamplerType sampler, | 3326 SamplerType sampler, |
| 3379 BlendMode blend_mode, | 3327 BlendMode blend_mode, |
| 3380 bool mask_for_background) { | 3328 bool mask_for_background) { |
| 3381 DCHECK_GE(precision, 0); | 3329 return GetProgram(ProgramKey::RenderPass(precision, sampler, blend_mode, |
| 3382 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3330 USE_AA, HAS_MASK, |
| 3383 DCHECK_GE(sampler, 0); | 3331 mask_for_background, false)); |
| 3384 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3385 DCHECK_GE(blend_mode, 0); | |
| 3386 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3387 RenderPassMaskProgramAA* program = | |
| 3388 &render_pass_mask_program_aa_[precision][sampler][blend_mode] | |
| 3389 [mask_for_background ? HAS_MASK : NO_MASK]; | |
| 3390 if (!program->initialized()) { | |
| 3391 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); | |
| 3392 program->Initialize( | |
| 3393 output_surface_->context_provider(), | |
| 3394 ProgramKey::RenderPass(precision, sampler, blend_mode, USE_AA, HAS_MASK, | |
| 3395 mask_for_background, false)); | |
| 3396 } | |
| 3397 return program; | |
| 3398 } | 3332 } |
| 3399 | 3333 |
| 3400 const GLRenderer::RenderPassColorMatrixProgram* | 3334 const GLRenderer::RenderPassColorMatrixProgram* |
| 3401 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision, | 3335 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision, |
| 3402 BlendMode blend_mode) { | 3336 BlendMode blend_mode) { |
| 3403 DCHECK_GE(precision, 0); | 3337 return GetProgram(ProgramKey::RenderPass( |
| 3404 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3338 precision, SAMPLER_TYPE_2D, blend_mode, NO_AA, NO_MASK, false, true)); |
| 3405 DCHECK_GE(blend_mode, 0); | |
| 3406 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3407 RenderPassColorMatrixProgram* program = | |
| 3408 &render_pass_color_matrix_program_[precision][blend_mode]; | |
| 3409 if (!program->initialized()) { | |
| 3410 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); | |
| 3411 program->Initialize( | |
| 3412 output_surface_->context_provider(), | |
| 3413 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, NO_AA, | |
| 3414 NO_MASK, false, true)); | |
| 3415 } | |
| 3416 return program; | |
| 3417 } | 3339 } |
| 3418 | 3340 |
| 3419 const GLRenderer::RenderPassColorMatrixProgramAA* | 3341 const GLRenderer::RenderPassColorMatrixProgramAA* |
| 3420 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision, | 3342 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision, |
| 3421 BlendMode blend_mode) { | 3343 BlendMode blend_mode) { |
| 3422 DCHECK_GE(precision, 0); | 3344 return GetProgram(ProgramKey::RenderPass( |
| 3423 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3345 precision, SAMPLER_TYPE_2D, blend_mode, USE_AA, NO_MASK, false, true)); |
| 3424 DCHECK_GE(blend_mode, 0); | |
| 3425 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3426 RenderPassColorMatrixProgramAA* program = | |
| 3427 &render_pass_color_matrix_program_aa_[precision][blend_mode]; | |
| 3428 if (!program->initialized()) { | |
| 3429 TRACE_EVENT0("cc", | |
| 3430 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); | |
| 3431 program->Initialize( | |
| 3432 output_surface_->context_provider(), | |
| 3433 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, USE_AA, | |
| 3434 NO_MASK, false, true)); | |
| 3435 } | |
| 3436 return program; | |
| 3437 } | 3346 } |
| 3438 | 3347 |
| 3439 const GLRenderer::RenderPassMaskColorMatrixProgram* | 3348 const GLRenderer::RenderPassMaskColorMatrixProgram* |
| 3440 GLRenderer::GetRenderPassMaskColorMatrixProgram( | 3349 GLRenderer::GetRenderPassMaskColorMatrixProgram( |
| 3441 TexCoordPrecision precision, | 3350 TexCoordPrecision precision, |
| 3442 SamplerType sampler, | 3351 SamplerType sampler, |
| 3443 BlendMode blend_mode, | 3352 BlendMode blend_mode, |
| 3444 bool mask_for_background) { | 3353 bool mask_for_background) { |
| 3445 DCHECK_GE(precision, 0); | 3354 return GetProgram(ProgramKey::RenderPass(precision, sampler, blend_mode, |
| 3446 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3355 NO_AA, HAS_MASK, mask_for_background, |
| 3447 DCHECK_GE(sampler, 0); | 3356 true)); |
| 3448 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3449 DCHECK_GE(blend_mode, 0); | |
| 3450 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3451 RenderPassMaskColorMatrixProgram* program = | |
| 3452 &render_pass_mask_color_matrix_program_[precision][sampler][blend_mode] | |
| 3453 [mask_for_background ? HAS_MASK : NO_MASK]; | |
| 3454 if (!program->initialized()) { | |
| 3455 TRACE_EVENT0("cc", | |
| 3456 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); | |
| 3457 program->Initialize( | |
| 3458 output_surface_->context_provider(), | |
| 3459 ProgramKey::RenderPass(precision, sampler, blend_mode, NO_AA, HAS_MASK, | |
| 3460 mask_for_background, true)); | |
| 3461 } | |
| 3462 return program; | |
| 3463 } | 3357 } |
| 3464 | 3358 |
| 3465 const GLRenderer::RenderPassMaskColorMatrixProgramAA* | 3359 const GLRenderer::RenderPassMaskColorMatrixProgramAA* |
| 3466 GLRenderer::GetRenderPassMaskColorMatrixProgramAA( | 3360 GLRenderer::GetRenderPassMaskColorMatrixProgramAA( |
| 3467 TexCoordPrecision precision, | 3361 TexCoordPrecision precision, |
| 3468 SamplerType sampler, | 3362 SamplerType sampler, |
| 3469 BlendMode blend_mode, | 3363 BlendMode blend_mode, |
| 3470 bool mask_for_background) { | 3364 bool mask_for_background) { |
| 3471 DCHECK_GE(precision, 0); | 3365 return GetProgram(ProgramKey::RenderPass(precision, sampler, blend_mode, |
| 3472 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3366 USE_AA, HAS_MASK, |
| 3473 DCHECK_GE(sampler, 0); | 3367 mask_for_background, true)); |
| 3474 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3475 DCHECK_GE(blend_mode, 0); | |
| 3476 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | |
| 3477 RenderPassMaskColorMatrixProgramAA* program = | |
| 3478 &render_pass_mask_color_matrix_program_aa_[precision][sampler][blend_mode] | |
| 3479 [mask_for_background ? HAS_MASK : NO_MASK]; | |
| 3480 if (!program->initialized()) { | |
| 3481 TRACE_EVENT0("cc", | |
| 3482 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); | |
| 3483 program->Initialize( | |
| 3484 output_surface_->context_provider(), | |
| 3485 ProgramKey::RenderPass(precision, sampler, blend_mode, USE_AA, HAS_MASK, | |
| 3486 mask_for_background, true)); | |
| 3487 } | |
| 3488 return program; | |
| 3489 } | 3368 } |
| 3490 | 3369 |
| 3491 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( | 3370 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( |
| 3492 TexCoordPrecision precision, | 3371 TexCoordPrecision precision, |
| 3493 SamplerType sampler) { | 3372 SamplerType sampler) { |
| 3494 DCHECK_GE(precision, 0); | 3373 return GetProgram( |
| 3495 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3374 ProgramKey::Tile(precision, sampler, NO_AA, NO_SWIZZLE, false)); |
| 3496 DCHECK_GE(sampler, 0); | |
| 3497 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3498 TileProgram* program = &tile_program_[precision][sampler]; | |
| 3499 if (!program->initialized()) { | |
| 3500 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); | |
| 3501 program->Initialize( | |
| 3502 output_surface_->context_provider(), | |
| 3503 ProgramKey::Tile(precision, sampler, NO_AA, NO_SWIZZLE, false)); | |
| 3504 } | |
| 3505 return program; | |
| 3506 } | 3375 } |
| 3507 | 3376 |
| 3508 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( | 3377 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( |
| 3509 TexCoordPrecision precision, | 3378 TexCoordPrecision precision, |
| 3510 SamplerType sampler) { | 3379 SamplerType sampler) { |
| 3511 DCHECK_GE(precision, 0); | 3380 return GetProgram( |
| 3512 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3381 ProgramKey::Tile(precision, sampler, NO_AA, NO_SWIZZLE, true)); |
| 3513 DCHECK_GE(sampler, 0); | |
| 3514 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3515 TileProgramOpaque* program = &tile_program_opaque_[precision][sampler]; | |
| 3516 if (!program->initialized()) { | |
| 3517 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); | |
| 3518 program->Initialize( | |
| 3519 output_surface_->context_provider(), | |
| 3520 ProgramKey::Tile(precision, sampler, NO_AA, NO_SWIZZLE, true)); | |
| 3521 } | |
| 3522 return program; | |
| 3523 } | 3382 } |
| 3524 | 3383 |
| 3525 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( | 3384 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( |
| 3526 TexCoordPrecision precision, | 3385 TexCoordPrecision precision, |
| 3527 SamplerType sampler) { | 3386 SamplerType sampler) { |
| 3528 DCHECK_GE(precision, 0); | 3387 return GetProgram( |
| 3529 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3388 ProgramKey::Tile(precision, sampler, USE_AA, NO_SWIZZLE, false)); |
| 3530 DCHECK_GE(sampler, 0); | |
| 3531 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3532 TileProgramAA* program = &tile_program_aa_[precision][sampler]; | |
| 3533 if (!program->initialized()) { | |
| 3534 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); | |
| 3535 program->Initialize( | |
| 3536 output_surface_->context_provider(), | |
| 3537 ProgramKey::Tile(precision, sampler, USE_AA, NO_SWIZZLE, false)); | |
| 3538 } | |
| 3539 return program; | |
| 3540 } | 3389 } |
| 3541 | 3390 |
| 3542 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( | 3391 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( |
| 3543 TexCoordPrecision precision, | 3392 TexCoordPrecision precision, |
| 3544 SamplerType sampler) { | 3393 SamplerType sampler) { |
| 3545 DCHECK_GE(precision, 0); | 3394 return GetProgram( |
| 3546 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3395 ProgramKey::Tile(precision, sampler, NO_AA, DO_SWIZZLE, false)); |
| 3547 DCHECK_GE(sampler, 0); | |
| 3548 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3549 TileProgramSwizzle* program = &tile_program_swizzle_[precision][sampler]; | |
| 3550 if (!program->initialized()) { | |
| 3551 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); | |
| 3552 program->Initialize( | |
| 3553 output_surface_->context_provider(), | |
| 3554 ProgramKey::Tile(precision, sampler, NO_AA, DO_SWIZZLE, false)); | |
| 3555 } | |
| 3556 return program; | |
| 3557 } | 3396 } |
| 3558 | 3397 |
| 3559 const GLRenderer::TileProgramSwizzleOpaque* | 3398 const GLRenderer::TileProgramSwizzleOpaque* |
| 3560 GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision, | 3399 GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision, |
| 3561 SamplerType sampler) { | 3400 SamplerType sampler) { |
| 3562 DCHECK_GE(precision, 0); | 3401 return GetProgram( |
| 3563 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3402 ProgramKey::Tile(precision, sampler, NO_AA, DO_SWIZZLE, true)); |
| 3564 DCHECK_GE(sampler, 0); | |
| 3565 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3566 TileProgramSwizzleOpaque* program = | |
| 3567 &tile_program_swizzle_opaque_[precision][sampler]; | |
| 3568 if (!program->initialized()) { | |
| 3569 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); | |
| 3570 program->Initialize( | |
| 3571 output_surface_->context_provider(), | |
| 3572 ProgramKey::Tile(precision, sampler, NO_AA, DO_SWIZZLE, true)); | |
| 3573 } | |
| 3574 return program; | |
| 3575 } | 3403 } |
| 3576 | 3404 |
| 3577 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( | 3405 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( |
| 3578 TexCoordPrecision precision, | 3406 TexCoordPrecision precision, |
| 3579 SamplerType sampler) { | 3407 SamplerType sampler) { |
| 3580 DCHECK_GE(precision, 0); | 3408 return GetProgram( |
| 3581 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3409 ProgramKey::Tile(precision, sampler, USE_AA, DO_SWIZZLE, false)); |
| 3582 DCHECK_GE(sampler, 0); | |
| 3583 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3584 TileProgramSwizzleAA* program = &tile_program_swizzle_aa_[precision][sampler]; | |
| 3585 if (!program->initialized()) { | |
| 3586 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); | |
| 3587 program->Initialize( | |
| 3588 output_surface_->context_provider(), | |
| 3589 ProgramKey::Tile(precision, sampler, USE_AA, DO_SWIZZLE, false)); | |
| 3590 } | |
| 3591 return program; | |
| 3592 } | 3410 } |
| 3593 | 3411 |
| 3594 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( | 3412 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( |
| 3595 TexCoordPrecision precision, | 3413 TexCoordPrecision precision, |
| 3596 SamplerType sampler) { | 3414 SamplerType sampler) { |
| 3597 DCHECK_GE(precision, 0); | 3415 return GetProgram( |
| 3598 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3416 ProgramKey::Texture(precision, sampler, PREMULTIPLIED_ALPHA, false)); |
| 3599 DCHECK_GE(sampler, 0); | |
| 3600 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3601 TextureProgram* program = &texture_program_[precision][sampler]; | |
| 3602 if (!program->initialized()) { | |
| 3603 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | |
| 3604 program->Initialize( | |
| 3605 output_surface_->context_provider(), | |
| 3606 ProgramKey::Texture(precision, sampler, PREMULTIPLIED_ALPHA, false)); | |
| 3607 } | |
| 3608 return program; | |
| 3609 } | 3417 } |
| 3610 | 3418 |
| 3611 const GLRenderer::NonPremultipliedTextureProgram* | 3419 const GLRenderer::NonPremultipliedTextureProgram* |
| 3612 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision, | 3420 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision, |
| 3613 SamplerType sampler) { | 3421 SamplerType sampler) { |
| 3614 DCHECK_GE(precision, 0); | 3422 return GetProgram( |
| 3615 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3423 ProgramKey::Texture(precision, sampler, NON_PREMULTIPLIED_ALPHA, false)); |
| 3616 DCHECK_GE(sampler, 0); | |
| 3617 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3618 NonPremultipliedTextureProgram* program = | |
| 3619 &nonpremultiplied_texture_program_[precision][sampler]; | |
| 3620 if (!program->initialized()) { | |
| 3621 TRACE_EVENT0("cc", | |
| 3622 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | |
| 3623 program->Initialize(output_surface_->context_provider(), | |
| 3624 ProgramKey::Texture(precision, sampler, | |
| 3625 NON_PREMULTIPLIED_ALPHA, false)); | |
| 3626 } | |
| 3627 return program; | |
| 3628 } | 3424 } |
| 3629 | 3425 |
| 3630 const GLRenderer::TextureBackgroundProgram* | 3426 const GLRenderer::TextureBackgroundProgram* |
| 3631 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision, | 3427 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision, |
| 3632 SamplerType sampler) { | 3428 SamplerType sampler) { |
| 3633 DCHECK_GE(precision, 0); | 3429 return GetProgram( |
| 3634 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3430 ProgramKey::Texture(precision, sampler, PREMULTIPLIED_ALPHA, true)); |
| 3635 DCHECK_GE(sampler, 0); | |
| 3636 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3637 TextureBackgroundProgram* program = | |
| 3638 &texture_background_program_[precision][sampler]; | |
| 3639 if (!program->initialized()) { | |
| 3640 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | |
| 3641 program->Initialize( | |
| 3642 output_surface_->context_provider(), | |
| 3643 ProgramKey::Texture(precision, sampler, PREMULTIPLIED_ALPHA, true)); | |
| 3644 } | |
| 3645 return program; | |
| 3646 } | 3431 } |
| 3647 | 3432 |
| 3648 const GLRenderer::NonPremultipliedTextureBackgroundProgram* | 3433 const GLRenderer::NonPremultipliedTextureBackgroundProgram* |
| 3649 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( | 3434 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( |
| 3650 TexCoordPrecision precision, | 3435 TexCoordPrecision precision, |
| 3651 SamplerType sampler) { | 3436 SamplerType sampler) { |
| 3652 DCHECK_GE(precision, 0); | 3437 return GetProgram( |
| 3653 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3438 ProgramKey::Texture(precision, sampler, NON_PREMULTIPLIED_ALPHA, true)); |
| 3654 DCHECK_GE(sampler, 0); | |
| 3655 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | |
| 3656 NonPremultipliedTextureBackgroundProgram* program = | |
| 3657 &nonpremultiplied_texture_background_program_[precision][sampler]; | |
| 3658 if (!program->initialized()) { | |
| 3659 TRACE_EVENT0("cc", | |
| 3660 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | |
| 3661 program->Initialize( | |
| 3662 output_surface_->context_provider(), | |
| 3663 ProgramKey::Texture(precision, sampler, NON_PREMULTIPLIED_ALPHA, true)); | |
| 3664 } | |
| 3665 return program; | |
| 3666 } | 3439 } |
| 3667 | 3440 |
| 3668 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( | 3441 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( |
| 3669 TexCoordPrecision precision, | 3442 TexCoordPrecision precision, |
| 3670 SamplerType sampler, | 3443 SamplerType sampler, |
| 3671 bool use_alpha_plane, | 3444 bool use_alpha_plane, |
| 3672 bool use_nv12, | 3445 bool use_nv12, |
| 3673 bool use_color_lut) { | 3446 bool use_color_lut) { |
| 3674 DCHECK_GE(precision, 0); | 3447 DCHECK_GE(precision, 0); |
| 3675 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3448 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3676 DCHECK_GE(sampler, 0); | 3449 DCHECK_GE(sampler, 0); |
| 3677 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3450 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3678 VideoYUVProgram* program = | 3451 VideoYUVProgram* program = |
| 3679 &video_yuv_program_[precision][sampler][use_alpha_plane][use_nv12] | 3452 &video_yuv_program_[precision][sampler][use_alpha_plane][use_nv12] |
| 3680 [use_color_lut]; | 3453 [use_color_lut]; |
| 3681 if (!program->initialized()) { | 3454 if (!program->initialized()) { |
| 3682 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | 3455 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); |
| 3683 program->InitializeVideoYUV(output_surface_->context_provider(), precision, | 3456 program->InitializeVideoYUV(output_surface_->context_provider(), precision, |
| 3684 sampler, use_alpha_plane, use_nv12, | 3457 sampler, use_alpha_plane, use_nv12, |
| 3685 use_color_lut); | 3458 use_color_lut); |
| 3686 } | 3459 } |
| 3687 return program; | 3460 return program; |
| 3688 } | 3461 } |
| 3689 | 3462 |
| 3690 const GLRenderer::VideoStreamTextureProgram* | 3463 const GLRenderer::VideoStreamTextureProgram* |
| 3691 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { | 3464 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { |
| 3692 DCHECK_GE(precision, 0); | 3465 return GetProgram(ProgramKey::VideoStream(precision)); |
| 3693 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3466 } |
| 3694 VideoStreamTextureProgram* program = | 3467 |
| 3695 &video_stream_texture_program_[precision]; | 3468 const Program* GLRenderer::GetProgram(const ProgramKey& desc) { |
| 3696 if (!program->initialized()) { | 3469 std::unique_ptr<Program>& program = program_cache_[desc]; |
| 3697 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); | 3470 if (!program) { |
| 3698 program->Initialize(output_surface_->context_provider(), | 3471 program.reset(new Program); |
| 3699 ProgramKey::VideoStream(precision)); | 3472 program->Initialize(output_surface_->context_provider(), desc); |
| 3700 } | 3473 } |
| 3701 return program; | 3474 return program.get(); |
| 3475 } | |
| 3476 | |
| 3477 const Program* GLRenderer::GetProgramForTesting(const ProgramKey& desc) const { | |
| 3478 const auto found = program_cache_.find(desc); | |
| 3479 if (found == program_cache_.end()) | |
| 3480 return nullptr; | |
| 3481 return found->second.get(); | |
| 3702 } | 3482 } |
| 3703 | 3483 |
| 3704 void GLRenderer::CleanupSharedObjects() { | 3484 void GLRenderer::CleanupSharedObjects() { |
| 3705 shared_geometry_ = nullptr; | 3485 shared_geometry_ = nullptr; |
| 3706 | 3486 |
| 3707 for (int i = 0; i <= LAST_TEX_COORD_PRECISION; ++i) { | 3487 for (int i = 0; i <= LAST_TEX_COORD_PRECISION; ++i) { |
| 3708 for (int j = 0; j <= LAST_SAMPLER_TYPE; ++j) { | 3488 for (int j = 0; j <= LAST_SAMPLER_TYPE; ++j) { |
| 3709 tile_program_[i][j].Cleanup(gl_); | |
| 3710 tile_program_opaque_[i][j].Cleanup(gl_); | |
| 3711 tile_program_swizzle_[i][j].Cleanup(gl_); | |
| 3712 tile_program_swizzle_opaque_[i][j].Cleanup(gl_); | |
| 3713 tile_program_aa_[i][j].Cleanup(gl_); | |
| 3714 tile_program_swizzle_aa_[i][j].Cleanup(gl_); | |
| 3715 | |
| 3716 for (int k = 0; k <= LAST_BLEND_MODE; k++) { | |
| 3717 for (int l = 0; l <= LAST_MASK_VALUE; ++l) { | |
| 3718 render_pass_mask_program_[i][j][k][l].Cleanup(gl_); | |
| 3719 render_pass_mask_program_aa_[i][j][k][l].Cleanup(gl_); | |
| 3720 render_pass_mask_color_matrix_program_aa_[i][j][k][l].Cleanup(gl_); | |
| 3721 render_pass_mask_color_matrix_program_[i][j][k][l].Cleanup(gl_); | |
| 3722 } | |
| 3723 } | |
| 3724 | |
| 3725 for (int k = 0; k < 2; k++) { | 3489 for (int k = 0; k < 2; k++) { |
| 3726 for (int l = 0; l < 2; l++) { | 3490 for (int l = 0; l < 2; l++) { |
| 3727 for (int m = 0; m < 2; m++) { | 3491 for (int m = 0; m < 2; m++) { |
| 3728 video_yuv_program_[i][j][k][l][m].Cleanup(gl_); | 3492 video_yuv_program_[i][j][k][l][m].Cleanup(gl_); |
| 3729 } | 3493 } |
| 3730 } | 3494 } |
| 3731 } | 3495 } |
| 3732 } | 3496 } |
| 3733 for (int j = 0; j <= LAST_BLEND_MODE; j++) { | |
| 3734 render_pass_program_[i][j].Cleanup(gl_); | |
| 3735 render_pass_program_aa_[i][j].Cleanup(gl_); | |
| 3736 render_pass_color_matrix_program_[i][j].Cleanup(gl_); | |
| 3737 render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_); | |
| 3738 } | |
| 3739 | |
| 3740 for (int j = 0; j <= LAST_SAMPLER_TYPE; ++j) { | |
| 3741 texture_program_[i][j].Cleanup(gl_); | |
| 3742 nonpremultiplied_texture_program_[i][j].Cleanup(gl_); | |
| 3743 texture_background_program_[i][j].Cleanup(gl_); | |
| 3744 nonpremultiplied_texture_background_program_[i][j].Cleanup(gl_); | |
| 3745 } | |
| 3746 | |
| 3747 video_stream_texture_program_[i].Cleanup(gl_); | |
| 3748 } | 3497 } |
| 3749 | 3498 for (auto& iter : program_cache_) |
| 3750 debug_border_program_.Cleanup(gl_); | 3499 iter.second->Cleanup(gl_); |
| 3751 solid_color_program_.Cleanup(gl_); | 3500 program_cache_.clear(); |
| 3752 solid_color_program_aa_.Cleanup(gl_); | |
| 3753 | 3501 |
| 3754 if (offscreen_framebuffer_id_) | 3502 if (offscreen_framebuffer_id_) |
| 3755 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_); | 3503 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_); |
| 3756 | 3504 |
| 3757 ReleaseRenderPassTextures(); | 3505 ReleaseRenderPassTextures(); |
| 3758 } | 3506 } |
| 3759 | 3507 |
| 3760 void GLRenderer::ReinitializeGLState() { | 3508 void GLRenderer::ReinitializeGLState() { |
| 3761 is_scissor_enabled_ = false; | 3509 is_scissor_enabled_ = false; |
| 3762 scissor_rect_ = gfx::Rect(); | 3510 scissor_rect_ = gfx::Rect(); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4080 // The alpha has already been applied when copying the RPDQ to an IOSurface. | 3828 // The alpha has already been applied when copying the RPDQ to an IOSurface. |
| 4081 GLfloat alpha = 1; | 3829 GLfloat alpha = 1; |
| 4082 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, | 3830 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, |
| 4083 sorting_context_id, gl_transform); | 3831 sorting_context_id, gl_transform); |
| 4084 gl_->ScheduleCALayerCHROMIUM( | 3832 gl_->ScheduleCALayerCHROMIUM( |
| 4085 texture_id, contents_rect, ca_layer_overlay->background_color, | 3833 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4086 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 3834 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4087 } | 3835 } |
| 4088 | 3836 |
| 4089 } // namespace cc | 3837 } // namespace cc |
| OLD | NEW |