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

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

Issue 1271843005: cc: Remove code for drawing checkerboard quads, it's not used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rm-checkers: sizes Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 const gfx::QuadF* clip_region) { 511 const gfx::QuadF* clip_region) {
512 DCHECK(quad->rect.Contains(quad->visible_rect)); 512 DCHECK(quad->rect.Contains(quad->visible_rect));
513 if (quad->material != DrawQuad::TEXTURE_CONTENT) { 513 if (quad->material != DrawQuad::TEXTURE_CONTENT) {
514 FlushTextureQuadCache(SHARED_BINDING); 514 FlushTextureQuadCache(SHARED_BINDING);
515 } 515 }
516 516
517 switch (quad->material) { 517 switch (quad->material) {
518 case DrawQuad::INVALID: 518 case DrawQuad::INVALID:
519 NOTREACHED(); 519 NOTREACHED();
520 break; 520 break;
521 case DrawQuad::CHECKERBOARD:
522 DrawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad),
523 clip_region);
524 break;
525 case DrawQuad::DEBUG_BORDER: 521 case DrawQuad::DEBUG_BORDER:
526 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad)); 522 DrawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad));
527 break; 523 break;
528 case DrawQuad::IO_SURFACE_CONTENT: 524 case DrawQuad::IO_SURFACE_CONTENT:
529 DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad), 525 DrawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad),
530 clip_region); 526 clip_region);
531 break; 527 break;
532 case DrawQuad::PICTURE_CONTENT: 528 case DrawQuad::PICTURE_CONTENT:
533 // PictureDrawQuad should only be used for resourceless software draws. 529 // PictureDrawQuad should only be used for resourceless software draws.
534 NOTREACHED(); 530 NOTREACHED();
(...skipping 22 matching lines...) Expand all
557 case DrawQuad::TILED_CONTENT: 553 case DrawQuad::TILED_CONTENT:
558 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad), clip_region); 554 DrawTileQuad(frame, TileDrawQuad::MaterialCast(quad), clip_region);
559 break; 555 break;
560 case DrawQuad::YUV_VIDEO_CONTENT: 556 case DrawQuad::YUV_VIDEO_CONTENT:
561 DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad), 557 DrawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad),
562 clip_region); 558 clip_region);
563 break; 559 break;
564 } 560 }
565 } 561 }
566 562
567 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame* frame,
568 const CheckerboardDrawQuad* quad,
569 const gfx::QuadF* clip_region) {
570 // TODO(enne) For now since checkerboards shouldn't be part of a 3D
571 // context, clipping regions aren't supported so we skip drawing them
572 // if this becomes the case.
573 if (clip_region) {
574 return;
575 }
576 SetBlendEnabled(quad->ShouldDrawWithBlending());
577
578 const TileCheckerboardProgram* program = GetTileCheckerboardProgram();
579 DCHECK(program && (program->initialized() || IsContextLost()));
580 SetUseProgram(program->program());
581
582 SkColor color = quad->color;
583 gl_->Uniform4f(program->fragment_shader().color_location(),
584 SkColorGetR(color) * (1.0f / 255.0f),
585 SkColorGetG(color) * (1.0f / 255.0f),
586 SkColorGetB(color) * (1.0f / 255.0f), 1);
587
588 const int kCheckerboardWidth = 16;
589 float frequency = 1.0f / kCheckerboardWidth;
590
591 gfx::Rect tile_rect = quad->rect;
592 float tex_offset_x =
593 static_cast<int>(tile_rect.x() / quad->scale) % kCheckerboardWidth;
594 float tex_offset_y =
595 static_cast<int>(tile_rect.y() / quad->scale) % kCheckerboardWidth;
596 float tex_scale_x = tile_rect.width() / quad->scale;
597 float tex_scale_y = tile_rect.height() / quad->scale;
598 gl_->Uniform4f(program->fragment_shader().tex_transform_location(),
599 tex_offset_x, tex_offset_y, tex_scale_x, tex_scale_y);
600
601 gl_->Uniform1f(program->fragment_shader().frequency_location(), frequency);
602
603 SetShaderOpacity(quad->shared_quad_state->opacity,
604 program->fragment_shader().alpha_location());
605 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
606 quad->rect, program->vertex_shader().matrix_location());
607 }
608
609 // This function does not handle 3D sorting right now, since the debug border 563 // This function does not handle 3D sorting right now, since the debug border
610 // quads are just drawn as their original quads and not in split pieces. This 564 // quads are just drawn as their original quads and not in split pieces. This
611 // results in some debug border quads drawing over foreground quads. 565 // results in some debug border quads drawing over foreground quads.
612 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, 566 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
613 const DebugBorderDrawQuad* quad) { 567 const DebugBorderDrawQuad* quad) {
614 SetBlendEnabled(quad->ShouldDrawWithBlending()); 568 SetBlendEnabled(quad->ShouldDrawWithBlending());
615 569
616 static float gl_matrix[16]; 570 static float gl_matrix[16];
617 const DebugBorderProgram* program = GetDebugBorderProgram(); 571 const DebugBorderProgram* program = GetDebugBorderProgram();
618 DCHECK(program && (program->initialized() || IsContextLost())); 572 DCHECK(program && (program->initialized() || IsContextLost()));
(...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3020 break; 2974 break;
3021 case CLIPPED_BINDING: 2975 case CLIPPED_BINDING:
3022 clipped_geometry_->PrepareForDraw(); 2976 clipped_geometry_->PrepareForDraw();
3023 break; 2977 break;
3024 case NO_BINDING: 2978 case NO_BINDING:
3025 break; 2979 break;
3026 } 2980 }
3027 bound_geometry_ = binding; 2981 bound_geometry_ = binding;
3028 } 2982 }
3029 2983
3030 const GLRenderer::TileCheckerboardProgram*
3031 GLRenderer::GetTileCheckerboardProgram() {
3032 if (!tile_checkerboard_program_.initialized()) {
3033 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize");
3034 tile_checkerboard_program_.Initialize(output_surface_->context_provider(),
3035 TEX_COORD_PRECISION_NA,
3036 SAMPLER_TYPE_NA);
3037 }
3038 return &tile_checkerboard_program_;
3039 }
3040
3041 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { 2984 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() {
3042 if (!debug_border_program_.initialized()) { 2985 if (!debug_border_program_.initialized()) {
3043 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); 2986 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize");
3044 debug_border_program_.Initialize(output_surface_->context_provider(), 2987 debug_border_program_.Initialize(output_surface_->context_provider(),
3045 TEX_COORD_PRECISION_NA, SAMPLER_TYPE_NA); 2988 TEX_COORD_PRECISION_NA, SAMPLER_TYPE_NA);
3046 } 2989 }
3047 return &debug_border_program_; 2990 return &debug_border_program_;
3048 } 2991 }
3049 2992
3050 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { 2993 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() {
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
3492 texture_program_[i][j].Cleanup(gl_); 3435 texture_program_[i][j].Cleanup(gl_);
3493 nonpremultiplied_texture_program_[i][j].Cleanup(gl_); 3436 nonpremultiplied_texture_program_[i][j].Cleanup(gl_);
3494 texture_background_program_[i][j].Cleanup(gl_); 3437 texture_background_program_[i][j].Cleanup(gl_);
3495 nonpremultiplied_texture_background_program_[i][j].Cleanup(gl_); 3438 nonpremultiplied_texture_background_program_[i][j].Cleanup(gl_);
3496 } 3439 }
3497 texture_io_surface_program_[i].Cleanup(gl_); 3440 texture_io_surface_program_[i].Cleanup(gl_);
3498 3441
3499 video_stream_texture_program_[i].Cleanup(gl_); 3442 video_stream_texture_program_[i].Cleanup(gl_);
3500 } 3443 }
3501 3444
3502 tile_checkerboard_program_.Cleanup(gl_);
3503
3504 debug_border_program_.Cleanup(gl_); 3445 debug_border_program_.Cleanup(gl_);
3505 solid_color_program_.Cleanup(gl_); 3446 solid_color_program_.Cleanup(gl_);
3506 solid_color_program_aa_.Cleanup(gl_); 3447 solid_color_program_aa_.Cleanup(gl_);
3507 3448
3508 if (offscreen_framebuffer_id_) 3449 if (offscreen_framebuffer_id_)
3509 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_); 3450 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_);
3510 3451
3511 if (on_demand_tile_raster_resource_id_) 3452 if (on_demand_tile_raster_resource_id_)
3512 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 3453 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
3513 3454
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3588 context_support_->ScheduleOverlayPlane( 3529 context_support_->ScheduleOverlayPlane(
3589 overlay.plane_z_order, 3530 overlay.plane_z_order,
3590 overlay.transform, 3531 overlay.transform,
3591 pending_overlay_resources_.back()->texture_id(), 3532 pending_overlay_resources_.back()->texture_id(),
3592 ToNearestRect(overlay.display_rect), 3533 ToNearestRect(overlay.display_rect),
3593 overlay.uv_rect); 3534 overlay.uv_rect);
3594 } 3535 }
3595 } 3536 }
3596 3537
3597 } // namespace cc 3538 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698