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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1124 static void SolidColorUniformLocation(T program, | 1124 static void SolidColorUniformLocation(T program, |
1125 SolidColorProgramUniforms* uniforms) { | 1125 SolidColorProgramUniforms* uniforms) { |
1126 uniforms->program = program->program(); | 1126 uniforms->program = program->program(); |
1127 uniforms->matrix_location = program->vertex_shader().matrix_location(); | 1127 uniforms->matrix_location = program->vertex_shader().matrix_location(); |
1128 uniforms->viewport_location = program->vertex_shader().viewport_location(); | 1128 uniforms->viewport_location = program->vertex_shader().viewport_location(); |
1129 uniforms->quad_location = program->vertex_shader().quad_location(); | 1129 uniforms->quad_location = program->vertex_shader().quad_location(); |
1130 uniforms->edge_location = program->vertex_shader().edge_location(); | 1130 uniforms->edge_location = program->vertex_shader().edge_location(); |
1131 uniforms->color_location = program->fragment_shader().color_location(); | 1131 uniforms->color_location = program->fragment_shader().color_location(); |
1132 } | 1132 } |
1133 | 1133 |
1134 // static | |
1134 bool GLRenderer::SetupQuadForAntialiasing( | 1135 bool GLRenderer::SetupQuadForAntialiasing( |
1135 const gfx::Transform& device_transform, | 1136 const gfx::Transform& device_transform, |
1136 const DrawQuad* quad, | 1137 const DrawQuad* quad, |
1137 gfx::QuadF* local_quad, | 1138 gfx::QuadF* local_quad, |
1138 float edge[24]) const { | 1139 float edge[24]) { |
1139 gfx::Rect tile_rect = quad->visible_rect; | 1140 gfx::Rect tile_rect = quad->visible_rect; |
1140 | 1141 |
1141 bool clipped = false; | 1142 bool clipped = false; |
1142 gfx::QuadF device_layer_quad = MathUtil::MapQuad( | 1143 gfx::QuadF device_layer_quad = MathUtil::MapQuad( |
1143 device_transform, gfx::QuadF(quad->visibleContentRect()), &clipped); | 1144 device_transform, gfx::QuadF(quad->visibleContentRect()), &clipped); |
1144 | 1145 |
1145 bool is_axis_aligned_in_target = device_layer_quad.IsRectilinear(); | 1146 bool is_axis_aligned_in_target = device_layer_quad.IsRectilinear(); |
1146 bool is_nearest_rect_within_epsilon = is_axis_aligned_in_target && | 1147 bool is_nearest_rect_within_epsilon = is_axis_aligned_in_target && |
1147 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(), | 1148 gfx::IsNearestRectWithinDistance(device_layer_quad.BoundingBox(), |
1148 kAntiAliasingEpsilon); | 1149 kAntiAliasingEpsilon); |
1149 | 1150 // AAing clipped quads is not supported by the code yet. |
1150 bool use_aa = Settings().allow_antialiasing && | 1151 bool use_aa = !clipped && !is_nearest_rect_within_epsilon && quad->IsEdge(); |
1151 !clipped && // code can't handle clipped quads | |
1152 !is_nearest_rect_within_epsilon && | |
1153 quad->IsEdge(); | |
1154 if (!use_aa) | 1152 if (!use_aa) |
1155 return false; | 1153 return false; |
1156 | 1154 |
1157 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox())); | 1155 LayerQuad device_layer_bounds(gfx::QuadF(device_layer_quad.BoundingBox())); |
1158 device_layer_bounds.InflateAntiAliasingDistance(); | 1156 device_layer_bounds.InflateAntiAliasingDistance(); |
1159 | 1157 |
1160 LayerQuad device_layer_edges(device_layer_quad); | 1158 LayerQuad device_layer_edges(device_layer_quad); |
1161 device_layer_edges.InflateAntiAliasingDistance(); | 1159 device_layer_edges.InflateAntiAliasingDistance(); |
1162 | 1160 |
1163 device_layer_edges.ToFloatArray(edge); | 1161 device_layer_edges.ToFloatArray(edge); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1232 return; | 1230 return; |
1233 | 1231 |
1234 gfx::Transform device_transform = | 1232 gfx::Transform device_transform = |
1235 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); | 1233 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); |
1236 device_transform.FlattenTo2d(); | 1234 device_transform.FlattenTo2d(); |
1237 if (!device_transform.IsInvertible()) | 1235 if (!device_transform.IsInvertible()) |
1238 return; | 1236 return; |
1239 | 1237 |
1240 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); | 1238 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); |
1241 float edge[24]; | 1239 float edge[24]; |
1242 bool use_aa = !quad->force_anti_aliasing_off && SetupQuadForAntialiasing( | 1240 bool use_aa = |
1243 device_transform, quad, &local_quad, edge); | 1241 Settings().allow_antialiasing && !quad->force_anti_aliasing_off && |
epennerAtGoogle
2013/09/07 00:00:33
Nice short circuit.
| |
1242 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); | |
1244 | 1243 |
1245 SolidColorProgramUniforms uniforms; | 1244 SolidColorProgramUniforms uniforms; |
1246 if (use_aa) | 1245 if (use_aa) |
1247 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms); | 1246 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms); |
1248 else | 1247 else |
1249 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms); | 1248 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms); |
1250 SetUseProgram(uniforms.program); | 1249 SetUseProgram(uniforms.program); |
1251 | 1250 |
1252 GLC(Context(), | 1251 GLC(Context(), |
1253 Context()->uniform4f(uniforms.color_location, | 1252 Context()->uniform4f(uniforms.color_location, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1371 float fragment_tex_scale_y = clamp_tex_rect.height() / texture_size.height(); | 1370 float fragment_tex_scale_y = clamp_tex_rect.height() / texture_size.height(); |
1372 | 1371 |
1373 gfx::Transform device_transform = | 1372 gfx::Transform device_transform = |
1374 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); | 1373 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); |
1375 device_transform.FlattenTo2d(); | 1374 device_transform.FlattenTo2d(); |
1376 if (!device_transform.IsInvertible()) | 1375 if (!device_transform.IsInvertible()) |
1377 return; | 1376 return; |
1378 | 1377 |
1379 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); | 1378 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); |
1380 float edge[24]; | 1379 float edge[24]; |
1381 bool use_aa = SetupQuadForAntialiasing( | 1380 bool use_aa = Settings().allow_antialiasing && SetupQuadForAntialiasing( |
1382 device_transform, quad, &local_quad, edge); | 1381 device_transform, quad, &local_quad, edge); |
1383 | 1382 |
1384 TileProgramUniforms uniforms; | 1383 TileProgramUniforms uniforms; |
1385 if (use_aa) { | 1384 if (use_aa) { |
1386 if (quad->swizzle_contents) { | 1385 if (quad->swizzle_contents) { |
1387 TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision), | 1386 TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision), |
1388 &uniforms); | 1387 &uniforms); |
1389 } else { | 1388 } else { |
1390 TileUniformLocation(GetTileProgramAA(tex_coord_precision), &uniforms); | 1389 TileUniformLocation(GetTileProgramAA(tex_coord_precision), &uniforms); |
1391 } | 1390 } |
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3150 std::string unique_context_name = base::StringPrintf( | 3149 std::string unique_context_name = base::StringPrintf( |
3151 "%s-Offscreen-%p", | 3150 "%s-Offscreen-%p", |
3152 Settings().compositor_name.c_str(), | 3151 Settings().compositor_name.c_str(), |
3153 context_); | 3152 context_); |
3154 offscreen_context_provider->Context3d()->pushGroupMarkerEXT( | 3153 offscreen_context_provider->Context3d()->pushGroupMarkerEXT( |
3155 unique_context_name.c_str()); | 3154 unique_context_name.c_str()); |
3156 } | 3155 } |
3157 | 3156 |
3158 | 3157 |
3159 } // namespace cc | 3158 } // namespace cc |
OLD | NEW |