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

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

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

Powered by Google App Engine
This is Rietveld 408576698