| 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 3270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (!debug_border_program_.initialized()) { |
| 3290 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); | 3290 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); |
| 3291 debug_border_program_.Initialize(output_surface_->context_provider(), | 3291 debug_border_program_.InitializeDebugBorderProgram( |
| 3292 TEX_COORD_PRECISION_NA, SAMPLER_TYPE_NA); | 3292 output_surface_->context_provider()); |
| 3293 } | 3293 } |
| 3294 return &debug_border_program_; | 3294 return &debug_border_program_; |
| 3295 } | 3295 } |
| 3296 | 3296 |
| 3297 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { | 3297 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { |
| 3298 if (!solid_color_program_.initialized()) { | 3298 if (!solid_color_program_.initialized()) { |
| 3299 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); | 3299 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); |
| 3300 solid_color_program_.Initialize(output_surface_->context_provider(), | 3300 solid_color_program_.InitializeSolidColorProgram( |
| 3301 TEX_COORD_PRECISION_NA, SAMPLER_TYPE_NA); | 3301 output_surface_->context_provider(), false); |
| 3302 } | 3302 } |
| 3303 return &solid_color_program_; | 3303 return &solid_color_program_; |
| 3304 } | 3304 } |
| 3305 | 3305 |
| 3306 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { | 3306 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { |
| 3307 if (!solid_color_program_aa_.initialized()) { | 3307 if (!solid_color_program_aa_.initialized()) { |
| 3308 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); | 3308 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); |
| 3309 solid_color_program_aa_.Initialize(output_surface_->context_provider(), | 3309 solid_color_program_aa_.InitializeSolidColorProgram( |
| 3310 TEX_COORD_PRECISION_NA, SAMPLER_TYPE_NA); | 3310 output_surface_->context_provider(), true); |
| 3311 } | 3311 } |
| 3312 return &solid_color_program_aa_; | 3312 return &solid_color_program_aa_; |
| 3313 } | 3313 } |
| 3314 | 3314 |
| 3315 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( | 3315 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( |
| 3316 TexCoordPrecision precision, | 3316 TexCoordPrecision precision, |
| 3317 BlendMode blend_mode) { | 3317 BlendMode blend_mode) { |
| 3318 DCHECK_GE(precision, 0); | 3318 DCHECK_GE(precision, 0); |
| 3319 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3319 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3320 DCHECK_GE(blend_mode, 0); | 3320 DCHECK_GE(blend_mode, 0); |
| 3321 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3321 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3322 RenderPassProgram* program = &render_pass_program_[precision][blend_mode]; | 3322 RenderPassProgram* program = &render_pass_program_[precision][blend_mode]; |
| 3323 if (!program->initialized()) { | 3323 if (!program->initialized()) { |
| 3324 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); | 3324 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); |
| 3325 program->Initialize(output_surface_->context_provider(), precision, | 3325 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3326 SAMPLER_TYPE_2D, blend_mode); | 3326 precision, SAMPLER_TYPE_2D, blend_mode, |
| 3327 NO_AA, NO_MASK, false, false); |
| 3327 } | 3328 } |
| 3328 return program; | 3329 return program; |
| 3329 } | 3330 } |
| 3330 | 3331 |
| 3331 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( | 3332 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( |
| 3332 TexCoordPrecision precision, | 3333 TexCoordPrecision precision, |
| 3333 BlendMode blend_mode) { | 3334 BlendMode blend_mode) { |
| 3334 DCHECK_GE(precision, 0); | 3335 DCHECK_GE(precision, 0); |
| 3335 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3336 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3336 DCHECK_GE(blend_mode, 0); | 3337 DCHECK_GE(blend_mode, 0); |
| 3337 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3338 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3338 RenderPassProgramAA* program = | 3339 RenderPassProgramAA* program = |
| 3339 &render_pass_program_aa_[precision][blend_mode]; | 3340 &render_pass_program_aa_[precision][blend_mode]; |
| 3340 if (!program->initialized()) { | 3341 if (!program->initialized()) { |
| 3341 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); | 3342 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); |
| 3342 program->Initialize(output_surface_->context_provider(), precision, | 3343 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3343 SAMPLER_TYPE_2D, blend_mode); | 3344 precision, SAMPLER_TYPE_2D, blend_mode, |
| 3345 USE_AA, NO_MASK, false, false); |
| 3344 } | 3346 } |
| 3345 return program; | 3347 return program; |
| 3346 } | 3348 } |
| 3347 | 3349 |
| 3348 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( | 3350 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( |
| 3349 TexCoordPrecision precision, | 3351 TexCoordPrecision precision, |
| 3350 SamplerType sampler, | 3352 SamplerType sampler, |
| 3351 BlendMode blend_mode, | 3353 BlendMode blend_mode, |
| 3352 bool mask_for_background) { | 3354 bool mask_for_background) { |
| 3353 DCHECK_GE(precision, 0); | 3355 DCHECK_GE(precision, 0); |
| 3354 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3356 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3355 DCHECK_GE(sampler, 0); | 3357 DCHECK_GE(sampler, 0); |
| 3356 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3358 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3357 DCHECK_GE(blend_mode, 0); | 3359 DCHECK_GE(blend_mode, 0); |
| 3358 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3360 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3359 RenderPassMaskProgram* program = | 3361 RenderPassMaskProgram* program = |
| 3360 &render_pass_mask_program_[precision][sampler][blend_mode] | 3362 &render_pass_mask_program_[precision][sampler][blend_mode] |
| 3361 [mask_for_background ? HAS_MASK : NO_MASK]; | 3363 [mask_for_background ? HAS_MASK : NO_MASK]; |
| 3362 if (!program->initialized()) { | 3364 if (!program->initialized()) { |
| 3363 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); | 3365 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); |
| 3364 program->Initialize( | 3366 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3365 output_surface_->context_provider(), precision, | 3367 precision, sampler, blend_mode, NO_AA, |
| 3366 sampler, blend_mode, mask_for_background); | 3368 HAS_MASK, mask_for_background, false); |
| 3367 } | 3369 } |
| 3368 return program; | 3370 return program; |
| 3369 } | 3371 } |
| 3370 | 3372 |
| 3371 const GLRenderer::RenderPassMaskProgramAA* | 3373 const GLRenderer::RenderPassMaskProgramAA* |
| 3372 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision, | 3374 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision, |
| 3373 SamplerType sampler, | 3375 SamplerType sampler, |
| 3374 BlendMode blend_mode, | 3376 BlendMode blend_mode, |
| 3375 bool mask_for_background) { | 3377 bool mask_for_background) { |
| 3376 DCHECK_GE(precision, 0); | 3378 DCHECK_GE(precision, 0); |
| 3377 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3379 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3378 DCHECK_GE(sampler, 0); | 3380 DCHECK_GE(sampler, 0); |
| 3379 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3381 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3380 DCHECK_GE(blend_mode, 0); | 3382 DCHECK_GE(blend_mode, 0); |
| 3381 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3383 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3382 RenderPassMaskProgramAA* program = | 3384 RenderPassMaskProgramAA* program = |
| 3383 &render_pass_mask_program_aa_[precision][sampler][blend_mode] | 3385 &render_pass_mask_program_aa_[precision][sampler][blend_mode] |
| 3384 [mask_for_background ? HAS_MASK : NO_MASK]; | 3386 [mask_for_background ? HAS_MASK : NO_MASK]; |
| 3385 if (!program->initialized()) { | 3387 if (!program->initialized()) { |
| 3386 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); | 3388 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); |
| 3387 program->Initialize( | 3389 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3388 output_surface_->context_provider(), precision, | 3390 precision, sampler, blend_mode, USE_AA, |
| 3389 sampler, blend_mode, mask_for_background); | 3391 HAS_MASK, mask_for_background, false); |
| 3390 } | 3392 } |
| 3391 return program; | 3393 return program; |
| 3392 } | 3394 } |
| 3393 | 3395 |
| 3394 const GLRenderer::RenderPassColorMatrixProgram* | 3396 const GLRenderer::RenderPassColorMatrixProgram* |
| 3395 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision, | 3397 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision, |
| 3396 BlendMode blend_mode) { | 3398 BlendMode blend_mode) { |
| 3397 DCHECK_GE(precision, 0); | 3399 DCHECK_GE(precision, 0); |
| 3398 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3400 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3399 DCHECK_GE(blend_mode, 0); | 3401 DCHECK_GE(blend_mode, 0); |
| 3400 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3402 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3401 RenderPassColorMatrixProgram* program = | 3403 RenderPassColorMatrixProgram* program = |
| 3402 &render_pass_color_matrix_program_[precision][blend_mode]; | 3404 &render_pass_color_matrix_program_[precision][blend_mode]; |
| 3403 if (!program->initialized()) { | 3405 if (!program->initialized()) { |
| 3404 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); | 3406 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); |
| 3405 program->Initialize(output_surface_->context_provider(), precision, | 3407 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3406 SAMPLER_TYPE_2D, blend_mode); | 3408 precision, SAMPLER_TYPE_2D, blend_mode, |
| 3409 NO_AA, NO_MASK, false, true); |
| 3407 } | 3410 } |
| 3408 return program; | 3411 return program; |
| 3409 } | 3412 } |
| 3410 | 3413 |
| 3411 const GLRenderer::RenderPassColorMatrixProgramAA* | 3414 const GLRenderer::RenderPassColorMatrixProgramAA* |
| 3412 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision, | 3415 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision, |
| 3413 BlendMode blend_mode) { | 3416 BlendMode blend_mode) { |
| 3414 DCHECK_GE(precision, 0); | 3417 DCHECK_GE(precision, 0); |
| 3415 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3418 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3416 DCHECK_GE(blend_mode, 0); | 3419 DCHECK_GE(blend_mode, 0); |
| 3417 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3420 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3418 RenderPassColorMatrixProgramAA* program = | 3421 RenderPassColorMatrixProgramAA* program = |
| 3419 &render_pass_color_matrix_program_aa_[precision][blend_mode]; | 3422 &render_pass_color_matrix_program_aa_[precision][blend_mode]; |
| 3420 if (!program->initialized()) { | 3423 if (!program->initialized()) { |
| 3421 TRACE_EVENT0("cc", | 3424 TRACE_EVENT0("cc", |
| 3422 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); | 3425 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); |
| 3423 program->Initialize(output_surface_->context_provider(), precision, | 3426 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3424 SAMPLER_TYPE_2D, blend_mode); | 3427 precision, SAMPLER_TYPE_2D, blend_mode, |
| 3428 USE_AA, NO_MASK, false, true); |
| 3425 } | 3429 } |
| 3426 return program; | 3430 return program; |
| 3427 } | 3431 } |
| 3428 | 3432 |
| 3429 const GLRenderer::RenderPassMaskColorMatrixProgram* | 3433 const GLRenderer::RenderPassMaskColorMatrixProgram* |
| 3430 GLRenderer::GetRenderPassMaskColorMatrixProgram( | 3434 GLRenderer::GetRenderPassMaskColorMatrixProgram( |
| 3431 TexCoordPrecision precision, | 3435 TexCoordPrecision precision, |
| 3432 SamplerType sampler, | 3436 SamplerType sampler, |
| 3433 BlendMode blend_mode, | 3437 BlendMode blend_mode, |
| 3434 bool mask_for_background) { | 3438 bool mask_for_background) { |
| 3435 DCHECK_GE(precision, 0); | 3439 DCHECK_GE(precision, 0); |
| 3436 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3440 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3437 DCHECK_GE(sampler, 0); | 3441 DCHECK_GE(sampler, 0); |
| 3438 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3442 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3439 DCHECK_GE(blend_mode, 0); | 3443 DCHECK_GE(blend_mode, 0); |
| 3440 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3444 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3441 RenderPassMaskColorMatrixProgram* program = | 3445 RenderPassMaskColorMatrixProgram* program = |
| 3442 &render_pass_mask_color_matrix_program_[precision][sampler][blend_mode] | 3446 &render_pass_mask_color_matrix_program_[precision][sampler][blend_mode] |
| 3443 [mask_for_background ? HAS_MASK : NO_MASK]; | 3447 [mask_for_background ? HAS_MASK : NO_MASK]; |
| 3444 if (!program->initialized()) { | 3448 if (!program->initialized()) { |
| 3445 TRACE_EVENT0("cc", | 3449 TRACE_EVENT0("cc", |
| 3446 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); | 3450 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); |
| 3447 program->Initialize( | 3451 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3448 output_surface_->context_provider(), precision, | 3452 precision, sampler, blend_mode, NO_AA, |
| 3449 sampler, blend_mode, mask_for_background); | 3453 HAS_MASK, mask_for_background, true); |
| 3450 } | 3454 } |
| 3451 return program; | 3455 return program; |
| 3452 } | 3456 } |
| 3453 | 3457 |
| 3454 const GLRenderer::RenderPassMaskColorMatrixProgramAA* | 3458 const GLRenderer::RenderPassMaskColorMatrixProgramAA* |
| 3455 GLRenderer::GetRenderPassMaskColorMatrixProgramAA( | 3459 GLRenderer::GetRenderPassMaskColorMatrixProgramAA( |
| 3456 TexCoordPrecision precision, | 3460 TexCoordPrecision precision, |
| 3457 SamplerType sampler, | 3461 SamplerType sampler, |
| 3458 BlendMode blend_mode, | 3462 BlendMode blend_mode, |
| 3459 bool mask_for_background) { | 3463 bool mask_for_background) { |
| 3460 DCHECK_GE(precision, 0); | 3464 DCHECK_GE(precision, 0); |
| 3461 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3465 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3462 DCHECK_GE(sampler, 0); | 3466 DCHECK_GE(sampler, 0); |
| 3463 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3467 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3464 DCHECK_GE(blend_mode, 0); | 3468 DCHECK_GE(blend_mode, 0); |
| 3465 DCHECK_LE(blend_mode, LAST_BLEND_MODE); | 3469 DCHECK_LE(blend_mode, LAST_BLEND_MODE); |
| 3466 RenderPassMaskColorMatrixProgramAA* program = | 3470 RenderPassMaskColorMatrixProgramAA* program = |
| 3467 &render_pass_mask_color_matrix_program_aa_[precision][sampler][blend_mode] | 3471 &render_pass_mask_color_matrix_program_aa_[precision][sampler][blend_mode] |
| 3468 [mask_for_background ? HAS_MASK : NO_MASK]; | 3472 [mask_for_background ? HAS_MASK : NO_MASK]; |
| 3469 if (!program->initialized()) { | 3473 if (!program->initialized()) { |
| 3470 TRACE_EVENT0("cc", | 3474 TRACE_EVENT0("cc", |
| 3471 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); | 3475 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); |
| 3472 program->Initialize( | 3476 program->InitializeRenderPassProgram(output_surface_->context_provider(), |
| 3473 output_surface_->context_provider(), precision, | 3477 precision, sampler, blend_mode, USE_AA, |
| 3474 sampler, blend_mode, mask_for_background); | 3478 HAS_MASK, mask_for_background, true); |
| 3475 } | 3479 } |
| 3476 return program; | 3480 return program; |
| 3477 } | 3481 } |
| 3478 | 3482 |
| 3479 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( | 3483 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( |
| 3480 TexCoordPrecision precision, | 3484 TexCoordPrecision precision, |
| 3481 SamplerType sampler) { | 3485 SamplerType sampler) { |
| 3482 DCHECK_GE(precision, 0); | 3486 DCHECK_GE(precision, 0); |
| 3483 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3487 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3484 DCHECK_GE(sampler, 0); | 3488 DCHECK_GE(sampler, 0); |
| 3485 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3489 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3486 TileProgram* program = &tile_program_[precision][sampler]; | 3490 TileProgram* program = &tile_program_[precision][sampler]; |
| 3487 if (!program->initialized()) { | 3491 if (!program->initialized()) { |
| 3488 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); | 3492 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); |
| 3489 program->Initialize( | 3493 program->InitializeTileProgram(output_surface_->context_provider(), |
| 3490 output_surface_->context_provider(), precision, sampler); | 3494 precision, sampler, NO_AA, NO_SWIZZLE, |
| 3495 NOT_OPAQUE); |
| 3491 } | 3496 } |
| 3492 return program; | 3497 return program; |
| 3493 } | 3498 } |
| 3494 | 3499 |
| 3495 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( | 3500 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( |
| 3496 TexCoordPrecision precision, | 3501 TexCoordPrecision precision, |
| 3497 SamplerType sampler) { | 3502 SamplerType sampler) { |
| 3498 DCHECK_GE(precision, 0); | 3503 DCHECK_GE(precision, 0); |
| 3499 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3504 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3500 DCHECK_GE(sampler, 0); | 3505 DCHECK_GE(sampler, 0); |
| 3501 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3506 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3502 TileProgramOpaque* program = &tile_program_opaque_[precision][sampler]; | 3507 TileProgramOpaque* program = &tile_program_opaque_[precision][sampler]; |
| 3503 if (!program->initialized()) { | 3508 if (!program->initialized()) { |
| 3504 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); | 3509 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); |
| 3505 program->Initialize( | 3510 program->InitializeTileProgram(output_surface_->context_provider(), |
| 3506 output_surface_->context_provider(), precision, sampler); | 3511 precision, sampler, NO_AA, NO_SWIZZLE, |
| 3512 IS_OPAQUE); |
| 3507 } | 3513 } |
| 3508 return program; | 3514 return program; |
| 3509 } | 3515 } |
| 3510 | 3516 |
| 3511 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( | 3517 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( |
| 3512 TexCoordPrecision precision, | 3518 TexCoordPrecision precision, |
| 3513 SamplerType sampler) { | 3519 SamplerType sampler) { |
| 3514 DCHECK_GE(precision, 0); | 3520 DCHECK_GE(precision, 0); |
| 3515 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3521 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3516 DCHECK_GE(sampler, 0); | 3522 DCHECK_GE(sampler, 0); |
| 3517 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3523 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3518 TileProgramAA* program = &tile_program_aa_[precision][sampler]; | 3524 TileProgramAA* program = &tile_program_aa_[precision][sampler]; |
| 3519 if (!program->initialized()) { | 3525 if (!program->initialized()) { |
| 3520 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); | 3526 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); |
| 3521 program->Initialize( | 3527 program->InitializeTileProgram(output_surface_->context_provider(), |
| 3522 output_surface_->context_provider(), precision, sampler); | 3528 precision, sampler, USE_AA, NO_SWIZZLE, |
| 3529 NOT_OPAQUE); |
| 3523 } | 3530 } |
| 3524 return program; | 3531 return program; |
| 3525 } | 3532 } |
| 3526 | 3533 |
| 3527 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( | 3534 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( |
| 3528 TexCoordPrecision precision, | 3535 TexCoordPrecision precision, |
| 3529 SamplerType sampler) { | 3536 SamplerType sampler) { |
| 3530 DCHECK_GE(precision, 0); | 3537 DCHECK_GE(precision, 0); |
| 3531 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3538 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3532 DCHECK_GE(sampler, 0); | 3539 DCHECK_GE(sampler, 0); |
| 3533 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3540 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3534 TileProgramSwizzle* program = &tile_program_swizzle_[precision][sampler]; | 3541 TileProgramSwizzle* program = &tile_program_swizzle_[precision][sampler]; |
| 3535 if (!program->initialized()) { | 3542 if (!program->initialized()) { |
| 3536 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); | 3543 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); |
| 3537 program->Initialize( | 3544 program->InitializeTileProgram(output_surface_->context_provider(), |
| 3538 output_surface_->context_provider(), precision, sampler); | 3545 precision, sampler, NO_AA, DO_SWIZZLE, |
| 3546 NOT_OPAQUE); |
| 3539 } | 3547 } |
| 3540 return program; | 3548 return program; |
| 3541 } | 3549 } |
| 3542 | 3550 |
| 3543 const GLRenderer::TileProgramSwizzleOpaque* | 3551 const GLRenderer::TileProgramSwizzleOpaque* |
| 3544 GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision, | 3552 GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision, |
| 3545 SamplerType sampler) { | 3553 SamplerType sampler) { |
| 3546 DCHECK_GE(precision, 0); | 3554 DCHECK_GE(precision, 0); |
| 3547 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3555 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3548 DCHECK_GE(sampler, 0); | 3556 DCHECK_GE(sampler, 0); |
| 3549 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3557 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3550 TileProgramSwizzleOpaque* program = | 3558 TileProgramSwizzleOpaque* program = |
| 3551 &tile_program_swizzle_opaque_[precision][sampler]; | 3559 &tile_program_swizzle_opaque_[precision][sampler]; |
| 3552 if (!program->initialized()) { | 3560 if (!program->initialized()) { |
| 3553 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); | 3561 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); |
| 3554 program->Initialize( | 3562 program->InitializeTileProgram(output_surface_->context_provider(), |
| 3555 output_surface_->context_provider(), precision, sampler); | 3563 precision, sampler, NO_AA, DO_SWIZZLE, |
| 3564 IS_OPAQUE); |
| 3556 } | 3565 } |
| 3557 return program; | 3566 return program; |
| 3558 } | 3567 } |
| 3559 | 3568 |
| 3560 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( | 3569 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( |
| 3561 TexCoordPrecision precision, | 3570 TexCoordPrecision precision, |
| 3562 SamplerType sampler) { | 3571 SamplerType sampler) { |
| 3563 DCHECK_GE(precision, 0); | 3572 DCHECK_GE(precision, 0); |
| 3564 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3573 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3565 DCHECK_GE(sampler, 0); | 3574 DCHECK_GE(sampler, 0); |
| 3566 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3575 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3567 TileProgramSwizzleAA* program = &tile_program_swizzle_aa_[precision][sampler]; | 3576 TileProgramSwizzleAA* program = &tile_program_swizzle_aa_[precision][sampler]; |
| 3568 if (!program->initialized()) { | 3577 if (!program->initialized()) { |
| 3569 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); | 3578 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); |
| 3570 program->Initialize( | 3579 program->InitializeTileProgram(output_surface_->context_provider(), |
| 3571 output_surface_->context_provider(), precision, sampler); | 3580 precision, sampler, USE_AA, DO_SWIZZLE, |
| 3581 NOT_OPAQUE); |
| 3572 } | 3582 } |
| 3573 return program; | 3583 return program; |
| 3574 } | 3584 } |
| 3575 | 3585 |
| 3576 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( | 3586 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( |
| 3577 TexCoordPrecision precision, | 3587 TexCoordPrecision precision, |
| 3578 SamplerType sampler) { | 3588 SamplerType sampler) { |
| 3579 DCHECK_GE(precision, 0); | 3589 DCHECK_GE(precision, 0); |
| 3580 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3590 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3581 DCHECK_GE(sampler, 0); | 3591 DCHECK_GE(sampler, 0); |
| 3582 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3592 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3583 TextureProgram* program = &texture_program_[precision][sampler]; | 3593 TextureProgram* program = &texture_program_[precision][sampler]; |
| 3584 if (!program->initialized()) { | 3594 if (!program->initialized()) { |
| 3585 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 3595 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
| 3586 program->Initialize(output_surface_->context_provider(), precision, | 3596 program->InitializeTextureProgram(output_surface_->context_provider(), |
| 3587 sampler); | 3597 precision, sampler, PREMULTIPLIED_ALPHA, |
| 3598 false); |
| 3588 } | 3599 } |
| 3589 return program; | 3600 return program; |
| 3590 } | 3601 } |
| 3591 | 3602 |
| 3592 const GLRenderer::NonPremultipliedTextureProgram* | 3603 const GLRenderer::NonPremultipliedTextureProgram* |
| 3593 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision, | 3604 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision, |
| 3594 SamplerType sampler) { | 3605 SamplerType sampler) { |
| 3595 DCHECK_GE(precision, 0); | 3606 DCHECK_GE(precision, 0); |
| 3596 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3607 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3597 DCHECK_GE(sampler, 0); | 3608 DCHECK_GE(sampler, 0); |
| 3598 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3609 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3599 NonPremultipliedTextureProgram* program = | 3610 NonPremultipliedTextureProgram* program = |
| 3600 &nonpremultiplied_texture_program_[precision][sampler]; | 3611 &nonpremultiplied_texture_program_[precision][sampler]; |
| 3601 if (!program->initialized()) { | 3612 if (!program->initialized()) { |
| 3602 TRACE_EVENT0("cc", | 3613 TRACE_EVENT0("cc", |
| 3603 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | 3614 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); |
| 3604 program->Initialize(output_surface_->context_provider(), precision, | 3615 program->InitializeTextureProgram(output_surface_->context_provider(), |
| 3605 sampler); | 3616 precision, sampler, |
| 3617 NON_PREMULTIPLIED_ALPHA, false); |
| 3606 } | 3618 } |
| 3607 return program; | 3619 return program; |
| 3608 } | 3620 } |
| 3609 | 3621 |
| 3610 const GLRenderer::TextureBackgroundProgram* | 3622 const GLRenderer::TextureBackgroundProgram* |
| 3611 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision, | 3623 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision, |
| 3612 SamplerType sampler) { | 3624 SamplerType sampler) { |
| 3613 DCHECK_GE(precision, 0); | 3625 DCHECK_GE(precision, 0); |
| 3614 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3626 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3615 DCHECK_GE(sampler, 0); | 3627 DCHECK_GE(sampler, 0); |
| 3616 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3628 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3617 TextureBackgroundProgram* program = | 3629 TextureBackgroundProgram* program = |
| 3618 &texture_background_program_[precision][sampler]; | 3630 &texture_background_program_[precision][sampler]; |
| 3619 if (!program->initialized()) { | 3631 if (!program->initialized()) { |
| 3620 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 3632 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
| 3621 program->Initialize(output_surface_->context_provider(), precision, | 3633 program->InitializeTextureProgram(output_surface_->context_provider(), |
| 3622 sampler); | 3634 precision, sampler, PREMULTIPLIED_ALPHA, |
| 3635 true); |
| 3623 } | 3636 } |
| 3624 return program; | 3637 return program; |
| 3625 } | 3638 } |
| 3626 | 3639 |
| 3627 const GLRenderer::NonPremultipliedTextureBackgroundProgram* | 3640 const GLRenderer::NonPremultipliedTextureBackgroundProgram* |
| 3628 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( | 3641 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( |
| 3629 TexCoordPrecision precision, | 3642 TexCoordPrecision precision, |
| 3630 SamplerType sampler) { | 3643 SamplerType sampler) { |
| 3631 DCHECK_GE(precision, 0); | 3644 DCHECK_GE(precision, 0); |
| 3632 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3645 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3633 DCHECK_GE(sampler, 0); | 3646 DCHECK_GE(sampler, 0); |
| 3634 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3647 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3635 NonPremultipliedTextureBackgroundProgram* program = | 3648 NonPremultipliedTextureBackgroundProgram* program = |
| 3636 &nonpremultiplied_texture_background_program_[precision][sampler]; | 3649 &nonpremultiplied_texture_background_program_[precision][sampler]; |
| 3637 if (!program->initialized()) { | 3650 if (!program->initialized()) { |
| 3638 TRACE_EVENT0("cc", | 3651 TRACE_EVENT0("cc", |
| 3639 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | 3652 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); |
| 3640 program->Initialize(output_surface_->context_provider(), precision, | 3653 program->InitializeTextureProgram(output_surface_->context_provider(), |
| 3641 sampler); | 3654 precision, sampler, |
| 3655 NON_PREMULTIPLIED_ALPHA, true); |
| 3642 } | 3656 } |
| 3643 return program; | 3657 return program; |
| 3644 } | 3658 } |
| 3645 | 3659 |
| 3646 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( | 3660 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( |
| 3647 TexCoordPrecision precision, | 3661 TexCoordPrecision precision, |
| 3648 SamplerType sampler, | 3662 SamplerType sampler, |
| 3649 bool use_alpha_plane, | 3663 bool use_alpha_plane, |
| 3650 bool use_nv12, | 3664 bool use_nv12, |
| 3651 bool use_color_lut) { | 3665 bool use_color_lut) { |
| 3652 DCHECK_GE(precision, 0); | 3666 DCHECK_GE(precision, 0); |
| 3653 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3667 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3654 DCHECK_GE(sampler, 0); | 3668 DCHECK_GE(sampler, 0); |
| 3655 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); | 3669 DCHECK_LE(sampler, LAST_SAMPLER_TYPE); |
| 3656 VideoYUVProgram* program = | 3670 VideoYUVProgram* program = |
| 3657 &video_yuv_program_[precision][sampler][use_alpha_plane][use_nv12] | 3671 &video_yuv_program_[precision][sampler][use_alpha_plane][use_nv12] |
| 3658 [use_color_lut]; | 3672 [use_color_lut]; |
| 3659 if (!program->initialized()) { | 3673 if (!program->initialized()) { |
| 3660 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | 3674 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); |
| 3661 program->mutable_fragment_shader()->SetFeatures(use_alpha_plane, use_nv12, | 3675 program->InitializeVideoYUVProgram(output_surface_->context_provider(), |
| 3662 use_color_lut); | 3676 precision, sampler, use_alpha_plane, |
| 3663 program->Initialize(output_surface_->context_provider(), precision, | 3677 use_nv12, use_color_lut); |
| 3664 sampler); | |
| 3665 } | 3678 } |
| 3666 return program; | 3679 return program; |
| 3667 } | 3680 } |
| 3668 | 3681 |
| 3669 const GLRenderer::VideoStreamTextureProgram* | 3682 const GLRenderer::VideoStreamTextureProgram* |
| 3670 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { | 3683 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { |
| 3671 DCHECK_GE(precision, 0); | 3684 DCHECK_GE(precision, 0); |
| 3672 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); | 3685 DCHECK_LE(precision, LAST_TEX_COORD_PRECISION); |
| 3673 VideoStreamTextureProgram* program = | 3686 VideoStreamTextureProgram* program = |
| 3674 &video_stream_texture_program_[precision]; | 3687 &video_stream_texture_program_[precision]; |
| 3675 if (!program->initialized()) { | 3688 if (!program->initialized()) { |
| 3676 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); | 3689 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); |
| 3677 program->Initialize(output_surface_->context_provider(), precision, | 3690 program->InitializeVideoStreamProgram(output_surface_->context_provider(), |
| 3678 SAMPLER_TYPE_EXTERNAL_OES); | 3691 precision); |
| 3679 } | 3692 } |
| 3680 return program; | 3693 return program; |
| 3681 } | 3694 } |
| 3682 | 3695 |
| 3683 void GLRenderer::CleanupSharedObjects() { | 3696 void GLRenderer::CleanupSharedObjects() { |
| 3684 shared_geometry_ = nullptr; | 3697 shared_geometry_ = nullptr; |
| 3685 | 3698 |
| 3686 for (int i = 0; i <= LAST_TEX_COORD_PRECISION; ++i) { | 3699 for (int i = 0; i <= LAST_TEX_COORD_PRECISION; ++i) { |
| 3687 for (int j = 0; j <= LAST_SAMPLER_TYPE; ++j) { | 3700 for (int j = 0; j <= LAST_SAMPLER_TYPE; ++j) { |
| 3688 tile_program_[i][j].Cleanup(gl_); | 3701 tile_program_[i][j].Cleanup(gl_); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4059 // The alpha has already been applied when copying the RPDQ to an IOSurface. | 4072 // The alpha has already been applied when copying the RPDQ to an IOSurface. |
| 4060 GLfloat alpha = 1; | 4073 GLfloat alpha = 1; |
| 4061 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, | 4074 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, |
| 4062 sorting_context_id, gl_transform); | 4075 sorting_context_id, gl_transform); |
| 4063 gl_->ScheduleCALayerCHROMIUM( | 4076 gl_->ScheduleCALayerCHROMIUM( |
| 4064 texture_id, contents_rect, ca_layer_overlay->background_color, | 4077 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4065 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4078 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4066 } | 4079 } |
| 4067 | 4080 |
| 4068 } // namespace cc | 4081 } // namespace cc |
| OLD | NEW |