| 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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 | 1009 |
| 1010 ApplyBlendModeUsingBlendFunc(blend_mode); | 1010 ApplyBlendModeUsingBlendFunc(blend_mode); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1013 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 1014 gl_, | 1014 gl_, |
| 1015 &highp_threshold_cache_, | 1015 &highp_threshold_cache_, |
| 1016 highp_threshold_min_, | 1016 highp_threshold_min_, |
| 1017 quad->shared_quad_state->visible_content_rect.bottom_right()); | 1017 quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1018 | 1018 |
| 1019 int shader_quad_location = -1; | 1019 ShaderLocations locations; |
| 1020 int shader_edge_location = -1; | |
| 1021 int shader_viewport_location = -1; | |
| 1022 int shader_mask_sampler_location = -1; | |
| 1023 int shader_mask_tex_coord_scale_location = -1; | |
| 1024 int shader_mask_tex_coord_offset_location = -1; | |
| 1025 int shader_matrix_location = -1; | |
| 1026 int shader_alpha_location = -1; | |
| 1027 int shader_color_matrix_location = -1; | |
| 1028 int shader_color_offset_location = -1; | |
| 1029 int shader_tex_transform_location = -1; | |
| 1030 int shader_backdrop_location = -1; | |
| 1031 int shader_backdrop_rect_location = -1; | |
| 1032 | 1020 |
| 1033 DCHECK_EQ(background_texture || background_image, use_shaders_for_blending); | 1021 DCHECK_EQ(background_texture || background_image, use_shaders_for_blending); |
| 1034 BlendMode shader_blend_mode = use_shaders_for_blending | 1022 BlendMode shader_blend_mode = use_shaders_for_blending |
| 1035 ? BlendModeFromSkXfermode(blend_mode) | 1023 ? BlendModeFromSkXfermode(blend_mode) |
| 1036 : BLEND_MODE_NONE; | 1024 : BLEND_MODE_NONE; |
| 1037 | 1025 |
| 1038 if (use_aa && mask_texture_id && !use_color_matrix) { | 1026 if (use_aa && mask_texture_id && !use_color_matrix) { |
| 1039 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA( | 1027 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA( |
| 1040 tex_coord_precision, mask_sampler, shader_blend_mode); | 1028 tex_coord_precision, mask_sampler, shader_blend_mode); |
| 1041 SetUseProgram(program->program()); | 1029 SetUseProgram(program->program()); |
| 1042 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1030 program->vertex_shader().FillLocations(&locations); |
| 1043 | 1031 program->fragment_shader().FillLocations(&locations); |
| 1044 shader_quad_location = program->vertex_shader().quad_location(); | 1032 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1045 shader_edge_location = program->vertex_shader().edge_location(); | |
| 1046 shader_viewport_location = program->vertex_shader().viewport_location(); | |
| 1047 shader_mask_sampler_location = | |
| 1048 program->fragment_shader().mask_sampler_location(); | |
| 1049 shader_mask_tex_coord_scale_location = | |
| 1050 program->fragment_shader().mask_tex_coord_scale_location(); | |
| 1051 shader_mask_tex_coord_offset_location = | |
| 1052 program->fragment_shader().mask_tex_coord_offset_location(); | |
| 1053 shader_matrix_location = program->vertex_shader().matrix_location(); | |
| 1054 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1055 shader_tex_transform_location = | |
| 1056 program->vertex_shader().tex_transform_location(); | |
| 1057 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1058 shader_backdrop_rect_location = | |
| 1059 program->fragment_shader().backdrop_rect_location(); | |
| 1060 } else if (!use_aa && mask_texture_id && !use_color_matrix) { | 1033 } else if (!use_aa && mask_texture_id && !use_color_matrix) { |
| 1061 const RenderPassMaskProgram* program = GetRenderPassMaskProgram( | 1034 const RenderPassMaskProgram* program = GetRenderPassMaskProgram( |
| 1062 tex_coord_precision, mask_sampler, shader_blend_mode); | 1035 tex_coord_precision, mask_sampler, shader_blend_mode); |
| 1063 SetUseProgram(program->program()); | 1036 SetUseProgram(program->program()); |
| 1064 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1037 program->vertex_shader().FillLocations(&locations); |
| 1065 | 1038 program->fragment_shader().FillLocations(&locations); |
| 1066 shader_mask_sampler_location = | 1039 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1067 program->fragment_shader().mask_sampler_location(); | |
| 1068 shader_mask_tex_coord_scale_location = | |
| 1069 program->fragment_shader().mask_tex_coord_scale_location(); | |
| 1070 shader_mask_tex_coord_offset_location = | |
| 1071 program->fragment_shader().mask_tex_coord_offset_location(); | |
| 1072 shader_matrix_location = program->vertex_shader().matrix_location(); | |
| 1073 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1074 shader_tex_transform_location = | |
| 1075 program->vertex_shader().tex_transform_location(); | |
| 1076 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1077 shader_backdrop_rect_location = | |
| 1078 program->fragment_shader().backdrop_rect_location(); | |
| 1079 } else if (use_aa && !mask_texture_id && !use_color_matrix) { | 1040 } else if (use_aa && !mask_texture_id && !use_color_matrix) { |
| 1080 const RenderPassProgramAA* program = | 1041 const RenderPassProgramAA* program = |
| 1081 GetRenderPassProgramAA(tex_coord_precision, shader_blend_mode); | 1042 GetRenderPassProgramAA(tex_coord_precision, shader_blend_mode); |
| 1082 SetUseProgram(program->program()); | 1043 SetUseProgram(program->program()); |
| 1083 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1044 program->vertex_shader().FillLocations(&locations); |
| 1084 | 1045 program->fragment_shader().FillLocations(&locations); |
| 1085 shader_quad_location = program->vertex_shader().quad_location(); | 1046 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1086 shader_edge_location = program->vertex_shader().edge_location(); | |
| 1087 shader_viewport_location = program->vertex_shader().viewport_location(); | |
| 1088 shader_matrix_location = program->vertex_shader().matrix_location(); | |
| 1089 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1090 shader_tex_transform_location = | |
| 1091 program->vertex_shader().tex_transform_location(); | |
| 1092 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1093 shader_backdrop_rect_location = | |
| 1094 program->fragment_shader().backdrop_rect_location(); | |
| 1095 } else if (use_aa && mask_texture_id && use_color_matrix) { | 1047 } else if (use_aa && mask_texture_id && use_color_matrix) { |
| 1096 const RenderPassMaskColorMatrixProgramAA* program = | 1048 const RenderPassMaskColorMatrixProgramAA* program = |
| 1097 GetRenderPassMaskColorMatrixProgramAA( | 1049 GetRenderPassMaskColorMatrixProgramAA( |
| 1098 tex_coord_precision, mask_sampler, shader_blend_mode); | 1050 tex_coord_precision, mask_sampler, shader_blend_mode); |
| 1099 SetUseProgram(program->program()); | 1051 SetUseProgram(program->program()); |
| 1100 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1052 program->vertex_shader().FillLocations(&locations); |
| 1101 | 1053 program->fragment_shader().FillLocations(&locations); |
| 1102 shader_matrix_location = program->vertex_shader().matrix_location(); | 1054 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1103 shader_quad_location = program->vertex_shader().quad_location(); | |
| 1104 shader_tex_transform_location = | |
| 1105 program->vertex_shader().tex_transform_location(); | |
| 1106 shader_edge_location = program->vertex_shader().edge_location(); | |
| 1107 shader_viewport_location = program->vertex_shader().viewport_location(); | |
| 1108 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1109 shader_mask_sampler_location = | |
| 1110 program->fragment_shader().mask_sampler_location(); | |
| 1111 shader_mask_tex_coord_scale_location = | |
| 1112 program->fragment_shader().mask_tex_coord_scale_location(); | |
| 1113 shader_mask_tex_coord_offset_location = | |
| 1114 program->fragment_shader().mask_tex_coord_offset_location(); | |
| 1115 shader_color_matrix_location = | |
| 1116 program->fragment_shader().color_matrix_location(); | |
| 1117 shader_color_offset_location = | |
| 1118 program->fragment_shader().color_offset_location(); | |
| 1119 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1120 shader_backdrop_rect_location = | |
| 1121 program->fragment_shader().backdrop_rect_location(); | |
| 1122 } else if (use_aa && !mask_texture_id && use_color_matrix) { | 1055 } else if (use_aa && !mask_texture_id && use_color_matrix) { |
| 1123 const RenderPassColorMatrixProgramAA* program = | 1056 const RenderPassColorMatrixProgramAA* program = |
| 1124 GetRenderPassColorMatrixProgramAA(tex_coord_precision, | 1057 GetRenderPassColorMatrixProgramAA(tex_coord_precision, |
| 1125 shader_blend_mode); | 1058 shader_blend_mode); |
| 1126 SetUseProgram(program->program()); | 1059 SetUseProgram(program->program()); |
| 1127 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1060 program->vertex_shader().FillLocations(&locations); |
| 1128 | 1061 program->fragment_shader().FillLocations(&locations); |
| 1129 shader_matrix_location = program->vertex_shader().matrix_location(); | 1062 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1130 shader_quad_location = program->vertex_shader().quad_location(); | |
| 1131 shader_tex_transform_location = | |
| 1132 program->vertex_shader().tex_transform_location(); | |
| 1133 shader_edge_location = program->vertex_shader().edge_location(); | |
| 1134 shader_viewport_location = program->vertex_shader().viewport_location(); | |
| 1135 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1136 shader_color_matrix_location = | |
| 1137 program->fragment_shader().color_matrix_location(); | |
| 1138 shader_color_offset_location = | |
| 1139 program->fragment_shader().color_offset_location(); | |
| 1140 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1141 shader_backdrop_rect_location = | |
| 1142 program->fragment_shader().backdrop_rect_location(); | |
| 1143 } else if (!use_aa && mask_texture_id && use_color_matrix) { | 1063 } else if (!use_aa && mask_texture_id && use_color_matrix) { |
| 1144 const RenderPassMaskColorMatrixProgram* program = | 1064 const RenderPassMaskColorMatrixProgram* program = |
| 1145 GetRenderPassMaskColorMatrixProgram( | 1065 GetRenderPassMaskColorMatrixProgram( |
| 1146 tex_coord_precision, mask_sampler, shader_blend_mode); | 1066 tex_coord_precision, mask_sampler, shader_blend_mode); |
| 1147 SetUseProgram(program->program()); | 1067 SetUseProgram(program->program()); |
| 1148 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1068 program->vertex_shader().FillLocations(&locations); |
| 1149 | 1069 program->fragment_shader().FillLocations(&locations); |
| 1150 shader_matrix_location = program->vertex_shader().matrix_location(); | 1070 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1151 shader_tex_transform_location = | |
| 1152 program->vertex_shader().tex_transform_location(); | |
| 1153 shader_mask_sampler_location = | |
| 1154 program->fragment_shader().mask_sampler_location(); | |
| 1155 shader_mask_tex_coord_scale_location = | |
| 1156 program->fragment_shader().mask_tex_coord_scale_location(); | |
| 1157 shader_mask_tex_coord_offset_location = | |
| 1158 program->fragment_shader().mask_tex_coord_offset_location(); | |
| 1159 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1160 shader_color_matrix_location = | |
| 1161 program->fragment_shader().color_matrix_location(); | |
| 1162 shader_color_offset_location = | |
| 1163 program->fragment_shader().color_offset_location(); | |
| 1164 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1165 shader_backdrop_rect_location = | |
| 1166 program->fragment_shader().backdrop_rect_location(); | |
| 1167 } else if (!use_aa && !mask_texture_id && use_color_matrix) { | 1071 } else if (!use_aa && !mask_texture_id && use_color_matrix) { |
| 1168 const RenderPassColorMatrixProgram* program = | 1072 const RenderPassColorMatrixProgram* program = |
| 1169 GetRenderPassColorMatrixProgram(tex_coord_precision, shader_blend_mode); | 1073 GetRenderPassColorMatrixProgram(tex_coord_precision, shader_blend_mode); |
| 1170 SetUseProgram(program->program()); | 1074 SetUseProgram(program->program()); |
| 1171 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1075 program->vertex_shader().FillLocations(&locations); |
| 1172 | 1076 program->fragment_shader().FillLocations(&locations); |
| 1173 shader_matrix_location = program->vertex_shader().matrix_location(); | 1077 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1174 shader_tex_transform_location = | |
| 1175 program->vertex_shader().tex_transform_location(); | |
| 1176 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1177 shader_color_matrix_location = | |
| 1178 program->fragment_shader().color_matrix_location(); | |
| 1179 shader_color_offset_location = | |
| 1180 program->fragment_shader().color_offset_location(); | |
| 1181 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1182 shader_backdrop_rect_location = | |
| 1183 program->fragment_shader().backdrop_rect_location(); | |
| 1184 } else { | 1078 } else { |
| 1185 const RenderPassProgram* program = | 1079 const RenderPassProgram* program = |
| 1186 GetRenderPassProgram(tex_coord_precision, shader_blend_mode); | 1080 GetRenderPassProgram(tex_coord_precision, shader_blend_mode); |
| 1187 SetUseProgram(program->program()); | 1081 SetUseProgram(program->program()); |
| 1188 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1082 program->vertex_shader().FillLocations(&locations); |
| 1189 | 1083 program->fragment_shader().FillLocations(&locations); |
| 1190 shader_matrix_location = program->vertex_shader().matrix_location(); | 1084 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); |
| 1191 shader_alpha_location = program->fragment_shader().alpha_location(); | |
| 1192 shader_tex_transform_location = | |
| 1193 program->vertex_shader().tex_transform_location(); | |
| 1194 shader_backdrop_location = program->fragment_shader().backdrop_location(); | |
| 1195 shader_backdrop_rect_location = | |
| 1196 program->fragment_shader().backdrop_rect_location(); | |
| 1197 } | 1085 } |
| 1198 float tex_scale_x = | 1086 float tex_scale_x = |
| 1199 quad->rect.width() / static_cast<float>(contents_texture->size().width()); | 1087 quad->rect.width() / static_cast<float>(contents_texture->size().width()); |
| 1200 float tex_scale_y = quad->rect.height() / | 1088 float tex_scale_y = quad->rect.height() / |
| 1201 static_cast<float>(contents_texture->size().height()); | 1089 static_cast<float>(contents_texture->size().height()); |
| 1202 DCHECK_LE(tex_scale_x, 1.0f); | 1090 DCHECK_LE(tex_scale_x, 1.0f); |
| 1203 DCHECK_LE(tex_scale_y, 1.0f); | 1091 DCHECK_LE(tex_scale_y, 1.0f); |
| 1204 | 1092 |
| 1205 DCHECK(shader_tex_transform_location != -1 || IsContextLost()); | 1093 DCHECK(locations.tex_transform != -1 || IsContextLost()); |
| 1206 // Flip the content vertically in the shader, as the RenderPass input | 1094 // Flip the content vertically in the shader, as the RenderPass input |
| 1207 // texture is already oriented the same way as the framebuffer, but the | 1095 // texture is already oriented the same way as the framebuffer, but the |
| 1208 // projection transform does a flip. | 1096 // projection transform does a flip. |
| 1209 GLC(gl_, | 1097 GLC(gl_, |
| 1210 gl_->Uniform4f(shader_tex_transform_location, | 1098 gl_->Uniform4f(locations.tex_transform, |
| 1211 0.0f, | 1099 0.0f, |
| 1212 tex_scale_y, | 1100 tex_scale_y, |
| 1213 tex_scale_x, | 1101 tex_scale_x, |
| 1214 -tex_scale_y)); | 1102 -tex_scale_y)); |
| 1215 | 1103 |
| 1216 GLint last_texture_unit = 0; | 1104 GLint last_texture_unit = 0; |
| 1217 if (shader_mask_sampler_location != -1) { | 1105 if (locations.mask_sampler != -1) { |
| 1218 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); | 1106 DCHECK_NE(locations.mask_tex_coord_scale, 1); |
| 1219 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); | 1107 DCHECK_NE(locations.mask_tex_coord_offset, 1); |
| 1220 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); | 1108 GLC(gl_, gl_->Uniform1i(locations.mask_sampler, 1)); |
| 1221 | 1109 |
| 1222 gfx::RectF mask_uv_rect = quad->MaskUVRect(); | 1110 gfx::RectF mask_uv_rect = quad->MaskUVRect(); |
| 1223 if (mask_sampler != SAMPLER_TYPE_2D) { | 1111 if (mask_sampler != SAMPLER_TYPE_2D) { |
| 1224 mask_uv_rect.Scale(quad->mask_texture_size.width(), | 1112 mask_uv_rect.Scale(quad->mask_texture_size.width(), |
| 1225 quad->mask_texture_size.height()); | 1113 quad->mask_texture_size.height()); |
| 1226 } | 1114 } |
| 1227 | 1115 |
| 1228 // Mask textures are oriented vertically flipped relative to the framebuffer | 1116 // Mask textures are oriented vertically flipped relative to the framebuffer |
| 1229 // and the RenderPass contents texture, so we flip the tex coords from the | 1117 // and the RenderPass contents texture, so we flip the tex coords from the |
| 1230 // RenderPass texture to find the mask texture coords. | 1118 // RenderPass texture to find the mask texture coords. |
| 1231 GLC(gl_, | 1119 GLC(gl_, |
| 1232 gl_->Uniform2f(shader_mask_tex_coord_offset_location, | 1120 gl_->Uniform2f(locations.mask_tex_coord_offset, |
| 1233 mask_uv_rect.x(), | 1121 mask_uv_rect.x(), |
| 1234 mask_uv_rect.bottom())); | 1122 mask_uv_rect.bottom())); |
| 1235 GLC(gl_, | 1123 GLC(gl_, |
| 1236 gl_->Uniform2f(shader_mask_tex_coord_scale_location, | 1124 gl_->Uniform2f(locations.mask_tex_coord_scale, |
| 1237 mask_uv_rect.width() / tex_scale_x, | 1125 mask_uv_rect.width() / tex_scale_x, |
| 1238 -mask_uv_rect.height() / tex_scale_y)); | 1126 -mask_uv_rect.height() / tex_scale_y)); |
| 1239 | 1127 |
| 1240 last_texture_unit = 1; | 1128 last_texture_unit = 1; |
| 1241 } | 1129 } |
| 1242 | 1130 |
| 1243 if (shader_edge_location != -1) | 1131 if (locations.edge != -1) |
| 1244 GLC(gl_, gl_->Uniform3fv(shader_edge_location, 8, edge)); | 1132 GLC(gl_, gl_->Uniform3fv(locations.edge, 8, edge)); |
| 1245 | 1133 |
| 1246 if (shader_viewport_location != -1) { | 1134 if (locations.viewport != -1) { |
| 1247 float viewport[4] = {static_cast<float>(viewport_.x()), | 1135 float viewport[4] = {static_cast<float>(viewport_.x()), |
| 1248 static_cast<float>(viewport_.y()), | 1136 static_cast<float>(viewport_.y()), |
| 1249 static_cast<float>(viewport_.width()), | 1137 static_cast<float>(viewport_.width()), |
| 1250 static_cast<float>(viewport_.height()), }; | 1138 static_cast<float>(viewport_.height()), }; |
| 1251 GLC(gl_, gl_->Uniform4fv(shader_viewport_location, 1, viewport)); | 1139 GLC(gl_, gl_->Uniform4fv(locations.viewport, 1, viewport)); |
| 1252 } | 1140 } |
| 1253 | 1141 |
| 1254 if (shader_color_matrix_location != -1) { | 1142 if (locations.color_matrix != -1) { |
| 1255 float matrix[16]; | 1143 float matrix[16]; |
| 1256 for (int i = 0; i < 4; ++i) { | 1144 for (int i = 0; i < 4; ++i) { |
| 1257 for (int j = 0; j < 4; ++j) | 1145 for (int j = 0; j < 4; ++j) |
| 1258 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]); | 1146 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]); |
| 1259 } | 1147 } |
| 1260 GLC(gl_, | 1148 GLC(gl_, |
| 1261 gl_->UniformMatrix4fv(shader_color_matrix_location, 1, false, matrix)); | 1149 gl_->UniformMatrix4fv(locations.color_matrix, 1, false, matrix)); |
| 1262 } | 1150 } |
| 1263 static const float kScale = 1.0f / 255.0f; | 1151 static const float kScale = 1.0f / 255.0f; |
| 1264 if (shader_color_offset_location != -1) { | 1152 if (locations.color_offset != -1) { |
| 1265 float offset[4]; | 1153 float offset[4]; |
| 1266 for (int i = 0; i < 4; ++i) | 1154 for (int i = 0; i < 4; ++i) |
| 1267 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; | 1155 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; |
| 1268 | 1156 |
| 1269 GLC(gl_, gl_->Uniform4fv(shader_color_offset_location, 1, offset)); | 1157 GLC(gl_, gl_->Uniform4fv(locations.color_offset, 1, offset)); |
| 1270 } | 1158 } |
| 1271 | 1159 |
| 1272 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_background_sampler_lock; | 1160 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_background_sampler_lock; |
| 1273 if (shader_backdrop_location != -1) { | 1161 if (locations.backdrop != -1) { |
| 1274 DCHECK(background_texture || background_image); | 1162 DCHECK(background_texture || background_image); |
| 1275 DCHECK_NE(shader_backdrop_location, 0); | 1163 DCHECK_NE(locations.backdrop, 0); |
| 1276 DCHECK_NE(shader_backdrop_rect_location, 0); | 1164 DCHECK_NE(locations.backdrop_rect, 0); |
| 1277 | 1165 |
| 1278 GLC(gl_, gl_->Uniform1i(shader_backdrop_location, ++last_texture_unit)); | 1166 GLC(gl_, gl_->Uniform1i(locations.backdrop, ++last_texture_unit)); |
| 1279 | 1167 |
| 1280 GLC(gl_, | 1168 GLC(gl_, |
| 1281 gl_->Uniform4f(shader_backdrop_rect_location, | 1169 gl_->Uniform4f(locations.backdrop_rect, |
| 1282 background_rect.x(), | 1170 background_rect.x(), |
| 1283 background_rect.y(), | 1171 background_rect.y(), |
| 1284 background_rect.width(), | 1172 background_rect.width(), |
| 1285 background_rect.height())); | 1173 background_rect.height())); |
| 1286 | 1174 |
| 1287 if (background_image) { | 1175 if (background_image) { |
| 1288 GrTexture* texture = background_image->getTexture(); | 1176 GrTexture* texture = background_image->getTexture(); |
| 1289 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit)); | 1177 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit)); |
| 1290 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 1178 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); |
| 1291 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); | 1179 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); |
| 1292 } else { | 1180 } else { |
| 1293 shader_background_sampler_lock = make_scoped_ptr( | 1181 shader_background_sampler_lock = make_scoped_ptr( |
| 1294 new ResourceProvider::ScopedSamplerGL(resource_provider_, | 1182 new ResourceProvider::ScopedSamplerGL(resource_provider_, |
| 1295 background_texture->id(), | 1183 background_texture->id(), |
| 1296 GL_TEXTURE0 + last_texture_unit, | 1184 GL_TEXTURE0 + last_texture_unit, |
| 1297 GL_LINEAR)); | 1185 GL_LINEAR)); |
| 1298 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1186 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1299 shader_background_sampler_lock->target()); | 1187 shader_background_sampler_lock->target()); |
| 1300 } | 1188 } |
| 1301 } | 1189 } |
| 1302 | 1190 |
| 1303 SetShaderOpacity(quad->opacity(), shader_alpha_location); | 1191 SetShaderOpacity(quad->opacity(), locations.alpha); |
| 1304 SetShaderQuadF(surface_quad, shader_quad_location); | 1192 SetShaderQuadF(surface_quad, locations.quad); |
| 1305 DrawQuadGeometry( | 1193 DrawQuadGeometry( |
| 1306 frame, quad->quadTransform(), quad->rect, shader_matrix_location); | 1194 frame, quad->quadTransform(), quad->rect, locations.matrix); |
| 1307 | 1195 |
| 1308 // Flush the compositor context before the filter bitmap goes out of | 1196 // Flush the compositor context before the filter bitmap goes out of |
| 1309 // scope, so the draw gets processed before the filter texture gets deleted. | 1197 // scope, so the draw gets processed before the filter texture gets deleted. |
| 1310 if (filter_image) | 1198 if (filter_image) |
| 1311 GLC(gl_, gl_->Flush()); | 1199 GLC(gl_, gl_->Flush()); |
| 1312 | 1200 |
| 1313 if (!use_shaders_for_blending) | 1201 if (!use_shaders_for_blending) |
| 1314 RestoreBlendFuncToDefault(blend_mode); | 1202 RestoreBlendFuncToDefault(blend_mode); |
| 1315 } | 1203 } |
| 1316 | 1204 |
| (...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3255 context_support_->ScheduleOverlayPlane( | 3143 context_support_->ScheduleOverlayPlane( |
| 3256 overlay.plane_z_order, | 3144 overlay.plane_z_order, |
| 3257 overlay.transform, | 3145 overlay.transform, |
| 3258 pending_overlay_resources_.back()->texture_id(), | 3146 pending_overlay_resources_.back()->texture_id(), |
| 3259 overlay.display_rect, | 3147 overlay.display_rect, |
| 3260 overlay.uv_rect); | 3148 overlay.uv_rect); |
| 3261 } | 3149 } |
| 3262 } | 3150 } |
| 3263 | 3151 |
| 3264 } // namespace cc | 3152 } // namespace cc |
| OLD | NEW |