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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" | 42 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" |
43 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" | 43 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
44 #include "ui/gfx/geometry/quad_f.h" | 44 #include "ui/gfx/geometry/quad_f.h" |
45 #include "ui/gfx/geometry/rect_conversions.h" | 45 #include "ui/gfx/geometry/rect_conversions.h" |
46 | 46 |
47 using gpu::gles2::GLES2Interface; | 47 using gpu::gles2::GLES2Interface; |
48 | 48 |
49 namespace cc { | 49 namespace cc { |
50 namespace { | 50 namespace { |
51 | 51 |
52 class FallbackFence : public ResourceProvider::Fence { | |
53 public: | |
54 explicit FallbackFence(gpu::gles2::GLES2Interface* gl) | |
55 : gl_(gl), has_passed_(true) {} | |
56 | |
57 // Overridden from ResourceProvider::Fence: | |
58 void Set() override { has_passed_ = false; } | |
59 bool HasPassed() override { | |
60 if (!has_passed_) { | |
61 has_passed_ = true; | |
62 Synchronize(); | |
63 } | |
64 return true; | |
65 } | |
66 | |
67 private: | |
68 ~FallbackFence() override {} | |
69 | |
70 void Synchronize() { | |
71 TRACE_EVENT0("cc", "FallbackFence::Synchronize"); | |
72 gl_->Finish(); | |
73 } | |
74 | |
75 gpu::gles2::GLES2Interface* gl_; | |
76 bool has_passed_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(FallbackFence); | |
79 }; | |
80 | |
81 bool NeedsIOSurfaceReadbackWorkaround() { | 52 bool NeedsIOSurfaceReadbackWorkaround() { |
82 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
83 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, | 54 // This isn't strictly required in DumpRenderTree-mode when Mesa is used, |
84 // but it doesn't seem to hurt. | 55 // but it doesn't seem to hurt. |
85 return true; | 56 return true; |
86 #else | 57 #else |
87 return false; | 58 return false; |
88 #endif | 59 #endif |
89 } | 60 } |
90 | 61 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 public: | 257 public: |
287 explicit Fence(base::WeakPtr<GLRenderer::SyncQuery> query) | 258 explicit Fence(base::WeakPtr<GLRenderer::SyncQuery> query) |
288 : query_(query) {} | 259 : query_(query) {} |
289 | 260 |
290 // Overridden from ResourceProvider::Fence: | 261 // Overridden from ResourceProvider::Fence: |
291 void Set() override { | 262 void Set() override { |
292 DCHECK(query_); | 263 DCHECK(query_); |
293 query_->Set(); | 264 query_->Set(); |
294 } | 265 } |
295 bool HasPassed() override { return !query_ || !query_->IsPending(); } | 266 bool HasPassed() override { return !query_ || !query_->IsPending(); } |
| 267 void Wait() override { |
| 268 if (query_) |
| 269 query_->Wait(); |
| 270 } |
296 | 271 |
297 private: | 272 private: |
298 ~Fence() override {} | 273 ~Fence() override {} |
299 | 274 |
300 base::WeakPtr<SyncQuery> query_; | 275 base::WeakPtr<SyncQuery> query_; |
301 | 276 |
302 DISALLOW_COPY_AND_ASSIGN(Fence); | 277 DISALLOW_COPY_AND_ASSIGN(Fence); |
303 }; | 278 }; |
304 | 279 |
305 gpu::gles2::GLES2Interface* gl_; | 280 gpu::gles2::GLES2Interface* gl_; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 } | 433 } |
459 | 434 |
460 static ResourceProvider::ResourceId WaitOnResourceSyncPoints( | 435 static ResourceProvider::ResourceId WaitOnResourceSyncPoints( |
461 ResourceProvider* resource_provider, | 436 ResourceProvider* resource_provider, |
462 ResourceProvider::ResourceId resource_id) { | 437 ResourceProvider::ResourceId resource_id) { |
463 resource_provider->WaitSyncPointIfNeeded(resource_id); | 438 resource_provider->WaitSyncPointIfNeeded(resource_id); |
464 return resource_id; | 439 return resource_id; |
465 } | 440 } |
466 | 441 |
467 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 442 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
468 if (frame->device_viewport_rect.IsEmpty()) | |
469 return; | |
470 | |
471 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); | 443 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); |
472 | 444 |
473 scoped_refptr<ResourceProvider::Fence> read_lock_fence; | 445 scoped_refptr<ResourceProvider::Fence> read_lock_fence; |
474 if (use_sync_query_) { | 446 if (use_sync_query_) { |
475 // Block until oldest sync query has passed if the number of pending queries | 447 // Block until oldest sync query has passed if the number of pending queries |
476 // ever reach kMaxPendingSyncQueries. | 448 // ever reach kMaxPendingSyncQueries. |
477 if (pending_sync_queries_.size() >= kMaxPendingSyncQueries) { | 449 if (pending_sync_queries_.size() >= kMaxPendingSyncQueries) { |
478 LOG(ERROR) << "Reached limit of pending sync queries."; | 450 LOG(ERROR) << "Reached limit of pending sync queries."; |
479 | 451 |
480 pending_sync_queries_.front()->Wait(); | 452 pending_sync_queries_.front()->Wait(); |
481 DCHECK(!pending_sync_queries_.front()->IsPending()); | 453 DCHECK(!pending_sync_queries_.front()->IsPending()); |
482 } | 454 } |
483 | 455 |
484 while (!pending_sync_queries_.empty()) { | 456 while (!pending_sync_queries_.empty()) { |
485 if (pending_sync_queries_.front()->IsPending()) | 457 if (pending_sync_queries_.front()->IsPending()) |
486 break; | 458 break; |
487 | 459 |
488 available_sync_queries_.push_back(pending_sync_queries_.take_front()); | 460 available_sync_queries_.push_back(pending_sync_queries_.take_front()); |
489 } | 461 } |
490 | 462 |
491 current_sync_query_ = available_sync_queries_.empty() | 463 current_sync_query_ = available_sync_queries_.empty() |
492 ? make_scoped_ptr(new SyncQuery(gl_)) | 464 ? make_scoped_ptr(new SyncQuery(gl_)) |
493 : available_sync_queries_.take_front(); | 465 : available_sync_queries_.take_front(); |
494 | 466 |
495 read_lock_fence = current_sync_query_->Begin(); | 467 read_lock_fence = current_sync_query_->Begin(); |
496 } else { | 468 } else { |
497 read_lock_fence = make_scoped_refptr(new FallbackFence(gl_)); | 469 read_lock_fence = |
| 470 make_scoped_refptr(new ResourceProvider::SynchronousFence(gl_)); |
498 } | 471 } |
499 resource_provider_->SetReadLockFence(read_lock_fence.get()); | 472 resource_provider_->SetReadLockFence(read_lock_fence.get()); |
500 | 473 |
501 // Insert WaitSyncPointCHROMIUM on quad resources prior to drawing the frame, | 474 // Insert WaitSyncPointCHROMIUM on quad resources prior to drawing the frame, |
502 // so that drawing can proceed without GL context switching interruptions. | 475 // so that drawing can proceed without GL context switching interruptions. |
503 DrawQuad::ResourceIteratorCallback wait_on_resource_syncpoints_callback = | 476 DrawQuad::ResourceIteratorCallback wait_on_resource_syncpoints_callback = |
504 base::Bind(&WaitOnResourceSyncPoints, resource_provider_); | 477 base::Bind(&WaitOnResourceSyncPoints, resource_provider_); |
505 | 478 |
506 for (size_t i = 0; i < frame->render_passes_in_draw_order->size(); ++i) { | 479 for (const auto& pass : *frame->render_passes_in_draw_order) { |
507 RenderPass* pass = frame->render_passes_in_draw_order->at(i); | 480 for (const auto& quad : pass->quad_list) |
508 for (auto& quad : pass->quad_list) | 481 quad->IterateResources(wait_on_resource_syncpoints_callback); |
509 quad.IterateResources(wait_on_resource_syncpoints_callback); | |
510 } | 482 } |
511 | 483 |
512 // TODO(enne): Do we need to reinitialize all of this state per frame? | 484 // TODO(enne): Do we need to reinitialize all of this state per frame? |
513 ReinitializeGLState(); | 485 ReinitializeGLState(); |
514 } | 486 } |
515 | 487 |
516 void GLRenderer::DoNoOp() { | 488 void GLRenderer::DoNoOp() { |
517 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); | 489 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); |
518 GLC(gl_, gl_->Flush()); | 490 GLC(gl_, gl_->Flush()); |
519 } | 491 } |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 int shader_tex_transform_location = -1; | 1148 int shader_tex_transform_location = -1; |
1177 int shader_backdrop_location = -1; | 1149 int shader_backdrop_location = -1; |
1178 int shader_backdrop_rect_location = -1; | 1150 int shader_backdrop_rect_location = -1; |
1179 | 1151 |
1180 BlendMode shader_blend_mode = ((background_texture || background_image) && | 1152 BlendMode shader_blend_mode = ((background_texture || background_image) && |
1181 !CanApplyBlendModeUsingBlendFunc(blend_mode)) | 1153 !CanApplyBlendModeUsingBlendFunc(blend_mode)) |
1182 ? BlendModeFromSkXfermode(blend_mode) | 1154 ? BlendModeFromSkXfermode(blend_mode) |
1183 : BlendModeNormal; | 1155 : BlendModeNormal; |
1184 | 1156 |
1185 if (use_aa && mask_texture_id && !use_color_matrix) { | 1157 if (use_aa && mask_texture_id && !use_color_matrix) { |
1186 const RenderPassMaskProgramAA* program = | 1158 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA( |
1187 GetRenderPassMaskProgramAA(tex_coord_precision, shader_blend_mode); | 1159 tex_coord_precision, mask_sampler, shader_blend_mode); |
1188 SetUseProgram(program->program()); | 1160 SetUseProgram(program->program()); |
1189 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1161 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
1190 | 1162 |
1191 shader_quad_location = program->vertex_shader().quad_location(); | 1163 shader_quad_location = program->vertex_shader().quad_location(); |
1192 shader_edge_location = program->vertex_shader().edge_location(); | 1164 shader_edge_location = program->vertex_shader().edge_location(); |
1193 shader_viewport_location = program->vertex_shader().viewport_location(); | 1165 shader_viewport_location = program->vertex_shader().viewport_location(); |
1194 shader_mask_sampler_location = | 1166 shader_mask_sampler_location = |
1195 program->fragment_shader().mask_sampler_location(); | 1167 program->fragment_shader().mask_sampler_location(); |
1196 shader_mask_tex_coord_scale_location = | 1168 shader_mask_tex_coord_scale_location = |
1197 program->fragment_shader().mask_tex_coord_scale_location(); | 1169 program->fragment_shader().mask_tex_coord_scale_location(); |
1198 shader_mask_tex_coord_offset_location = | 1170 shader_mask_tex_coord_offset_location = |
1199 program->fragment_shader().mask_tex_coord_offset_location(); | 1171 program->fragment_shader().mask_tex_coord_offset_location(); |
1200 shader_matrix_location = program->vertex_shader().matrix_location(); | 1172 shader_matrix_location = program->vertex_shader().matrix_location(); |
1201 shader_alpha_location = program->fragment_shader().alpha_location(); | 1173 shader_alpha_location = program->fragment_shader().alpha_location(); |
1202 shader_tex_transform_location = | 1174 shader_tex_transform_location = |
1203 program->vertex_shader().tex_transform_location(); | 1175 program->vertex_shader().tex_transform_location(); |
1204 shader_backdrop_location = program->fragment_shader().backdrop_location(); | 1176 shader_backdrop_location = program->fragment_shader().backdrop_location(); |
1205 shader_backdrop_rect_location = | 1177 shader_backdrop_rect_location = |
1206 program->fragment_shader().backdrop_rect_location(); | 1178 program->fragment_shader().backdrop_rect_location(); |
1207 } else if (!use_aa && mask_texture_id && !use_color_matrix) { | 1179 } else if (!use_aa && mask_texture_id && !use_color_matrix) { |
1208 const RenderPassMaskProgram* program = | 1180 const RenderPassMaskProgram* program = GetRenderPassMaskProgram( |
1209 GetRenderPassMaskProgram(tex_coord_precision, shader_blend_mode); | 1181 tex_coord_precision, mask_sampler, shader_blend_mode); |
1210 SetUseProgram(program->program()); | 1182 SetUseProgram(program->program()); |
1211 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1183 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
1212 | 1184 |
1213 shader_mask_sampler_location = | 1185 shader_mask_sampler_location = |
1214 program->fragment_shader().mask_sampler_location(); | 1186 program->fragment_shader().mask_sampler_location(); |
1215 shader_mask_tex_coord_scale_location = | 1187 shader_mask_tex_coord_scale_location = |
1216 program->fragment_shader().mask_tex_coord_scale_location(); | 1188 program->fragment_shader().mask_tex_coord_scale_location(); |
1217 shader_mask_tex_coord_offset_location = | 1189 shader_mask_tex_coord_offset_location = |
1218 program->fragment_shader().mask_tex_coord_offset_location(); | 1190 program->fragment_shader().mask_tex_coord_offset_location(); |
1219 shader_matrix_location = program->vertex_shader().matrix_location(); | 1191 shader_matrix_location = program->vertex_shader().matrix_location(); |
(...skipping 14 matching lines...) Expand all Loading... |
1234 shader_viewport_location = program->vertex_shader().viewport_location(); | 1206 shader_viewport_location = program->vertex_shader().viewport_location(); |
1235 shader_matrix_location = program->vertex_shader().matrix_location(); | 1207 shader_matrix_location = program->vertex_shader().matrix_location(); |
1236 shader_alpha_location = program->fragment_shader().alpha_location(); | 1208 shader_alpha_location = program->fragment_shader().alpha_location(); |
1237 shader_tex_transform_location = | 1209 shader_tex_transform_location = |
1238 program->vertex_shader().tex_transform_location(); | 1210 program->vertex_shader().tex_transform_location(); |
1239 shader_backdrop_location = program->fragment_shader().backdrop_location(); | 1211 shader_backdrop_location = program->fragment_shader().backdrop_location(); |
1240 shader_backdrop_rect_location = | 1212 shader_backdrop_rect_location = |
1241 program->fragment_shader().backdrop_rect_location(); | 1213 program->fragment_shader().backdrop_rect_location(); |
1242 } else if (use_aa && mask_texture_id && use_color_matrix) { | 1214 } else if (use_aa && mask_texture_id && use_color_matrix) { |
1243 const RenderPassMaskColorMatrixProgramAA* program = | 1215 const RenderPassMaskColorMatrixProgramAA* program = |
1244 GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision, | 1216 GetRenderPassMaskColorMatrixProgramAA( |
1245 shader_blend_mode); | 1217 tex_coord_precision, mask_sampler, shader_blend_mode); |
1246 SetUseProgram(program->program()); | 1218 SetUseProgram(program->program()); |
1247 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1219 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
1248 | 1220 |
1249 shader_matrix_location = program->vertex_shader().matrix_location(); | 1221 shader_matrix_location = program->vertex_shader().matrix_location(); |
1250 shader_quad_location = program->vertex_shader().quad_location(); | 1222 shader_quad_location = program->vertex_shader().quad_location(); |
1251 shader_tex_transform_location = | 1223 shader_tex_transform_location = |
1252 program->vertex_shader().tex_transform_location(); | 1224 program->vertex_shader().tex_transform_location(); |
1253 shader_edge_location = program->vertex_shader().edge_location(); | 1225 shader_edge_location = program->vertex_shader().edge_location(); |
1254 shader_viewport_location = program->vertex_shader().viewport_location(); | 1226 shader_viewport_location = program->vertex_shader().viewport_location(); |
1255 shader_alpha_location = program->fragment_shader().alpha_location(); | 1227 shader_alpha_location = program->fragment_shader().alpha_location(); |
(...skipping 26 matching lines...) Expand all Loading... |
1282 shader_alpha_location = program->fragment_shader().alpha_location(); | 1254 shader_alpha_location = program->fragment_shader().alpha_location(); |
1283 shader_color_matrix_location = | 1255 shader_color_matrix_location = |
1284 program->fragment_shader().color_matrix_location(); | 1256 program->fragment_shader().color_matrix_location(); |
1285 shader_color_offset_location = | 1257 shader_color_offset_location = |
1286 program->fragment_shader().color_offset_location(); | 1258 program->fragment_shader().color_offset_location(); |
1287 shader_backdrop_location = program->fragment_shader().backdrop_location(); | 1259 shader_backdrop_location = program->fragment_shader().backdrop_location(); |
1288 shader_backdrop_rect_location = | 1260 shader_backdrop_rect_location = |
1289 program->fragment_shader().backdrop_rect_location(); | 1261 program->fragment_shader().backdrop_rect_location(); |
1290 } else if (!use_aa && mask_texture_id && use_color_matrix) { | 1262 } else if (!use_aa && mask_texture_id && use_color_matrix) { |
1291 const RenderPassMaskColorMatrixProgram* program = | 1263 const RenderPassMaskColorMatrixProgram* program = |
1292 GetRenderPassMaskColorMatrixProgram(tex_coord_precision, | 1264 GetRenderPassMaskColorMatrixProgram( |
1293 shader_blend_mode); | 1265 tex_coord_precision, mask_sampler, shader_blend_mode); |
1294 SetUseProgram(program->program()); | 1266 SetUseProgram(program->program()); |
1295 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1267 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
1296 | 1268 |
1297 shader_matrix_location = program->vertex_shader().matrix_location(); | 1269 shader_matrix_location = program->vertex_shader().matrix_location(); |
1298 shader_tex_transform_location = | 1270 shader_tex_transform_location = |
1299 program->vertex_shader().tex_transform_location(); | 1271 program->vertex_shader().tex_transform_location(); |
1300 shader_mask_sampler_location = | 1272 shader_mask_sampler_location = |
1301 program->fragment_shader().mask_sampler_location(); | 1273 program->fragment_shader().mask_sampler_location(); |
1302 shader_mask_tex_coord_scale_location = | 1274 shader_mask_tex_coord_scale_location = |
1303 program->fragment_shader().mask_tex_coord_scale_location(); | 1275 program->fragment_shader().mask_tex_coord_scale_location(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 // texture is already oriented the same way as the framebuffer, but the | 1326 // texture is already oriented the same way as the framebuffer, but the |
1355 // projection transform does a flip. | 1327 // projection transform does a flip. |
1356 GLC(gl_, | 1328 GLC(gl_, |
1357 gl_->Uniform4f(shader_tex_transform_location, | 1329 gl_->Uniform4f(shader_tex_transform_location, |
1358 0.0f, | 1330 0.0f, |
1359 tex_scale_y, | 1331 tex_scale_y, |
1360 tex_scale_x, | 1332 tex_scale_x, |
1361 -tex_scale_y)); | 1333 -tex_scale_y)); |
1362 | 1334 |
1363 GLint last_texture_unit = 0; | 1335 GLint last_texture_unit = 0; |
1364 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; | |
1365 if (shader_mask_sampler_location != -1) { | 1336 if (shader_mask_sampler_location != -1) { |
1366 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); | 1337 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); |
1367 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); | 1338 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); |
1368 DCHECK_EQ(SamplerType2D, mask_sampler); | |
1369 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); | 1339 GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); |
1370 | 1340 |
1371 gfx::RectF mask_uv_rect = quad->MaskUVRect(); | 1341 gfx::RectF mask_uv_rect = quad->MaskUVRect(); |
| 1342 if (mask_sampler != SamplerType2D) { |
| 1343 mask_uv_rect.Scale(quad->mask_texture_size.width(), |
| 1344 quad->mask_texture_size.height()); |
| 1345 } |
1372 | 1346 |
1373 // Mask textures are oriented vertically flipped relative to the framebuffer | 1347 // Mask textures are oriented vertically flipped relative to the framebuffer |
1374 // and the RenderPass contents texture, so we flip the tex coords from the | 1348 // and the RenderPass contents texture, so we flip the tex coords from the |
1375 // RenderPass texture to find the mask texture coords. | 1349 // RenderPass texture to find the mask texture coords. |
1376 GLC(gl_, | 1350 GLC(gl_, |
1377 gl_->Uniform2f(shader_mask_tex_coord_offset_location, | 1351 gl_->Uniform2f(shader_mask_tex_coord_offset_location, |
1378 mask_uv_rect.x(), | 1352 mask_uv_rect.x(), |
1379 mask_uv_rect.bottom())); | 1353 mask_uv_rect.bottom())); |
1380 GLC(gl_, | 1354 GLC(gl_, |
1381 gl_->Uniform2f(shader_mask_tex_coord_scale_location, | 1355 gl_->Uniform2f(shader_mask_tex_coord_scale_location, |
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2906 program->Initialize(output_surface_->context_provider(), | 2880 program->Initialize(output_surface_->context_provider(), |
2907 precision, | 2881 precision, |
2908 SamplerType2D, | 2882 SamplerType2D, |
2909 blend_mode); | 2883 blend_mode); |
2910 } | 2884 } |
2911 return program; | 2885 return program; |
2912 } | 2886 } |
2913 | 2887 |
2914 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( | 2888 const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( |
2915 TexCoordPrecision precision, | 2889 TexCoordPrecision precision, |
| 2890 SamplerType sampler, |
2916 BlendMode blend_mode) { | 2891 BlendMode blend_mode) { |
2917 DCHECK_GE(precision, 0); | 2892 DCHECK_GE(precision, 0); |
2918 DCHECK_LT(precision, NumTexCoordPrecisions); | 2893 DCHECK_LT(precision, NumTexCoordPrecisions); |
| 2894 DCHECK_GE(sampler, 0); |
| 2895 DCHECK_LT(sampler, NumSamplerTypes); |
2919 DCHECK_GE(blend_mode, 0); | 2896 DCHECK_GE(blend_mode, 0); |
2920 DCHECK_LT(blend_mode, NumBlendModes); | 2897 DCHECK_LT(blend_mode, NumBlendModes); |
2921 RenderPassMaskProgram* program = | 2898 RenderPassMaskProgram* program = |
2922 &render_pass_mask_program_[precision][blend_mode]; | 2899 &render_pass_mask_program_[precision][sampler][blend_mode]; |
2923 if (!program->initialized()) { | 2900 if (!program->initialized()) { |
2924 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); | 2901 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); |
2925 program->Initialize(output_surface_->context_provider(), | 2902 program->Initialize( |
2926 precision, | 2903 output_surface_->context_provider(), precision, sampler, blend_mode); |
2927 SamplerType2D, | |
2928 blend_mode); | |
2929 } | 2904 } |
2930 return program; | 2905 return program; |
2931 } | 2906 } |
2932 | 2907 |
2933 const GLRenderer::RenderPassMaskProgramAA* | 2908 const GLRenderer::RenderPassMaskProgramAA* |
2934 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision, | 2909 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision, |
| 2910 SamplerType sampler, |
2935 BlendMode blend_mode) { | 2911 BlendMode blend_mode) { |
2936 DCHECK_GE(precision, 0); | 2912 DCHECK_GE(precision, 0); |
2937 DCHECK_LT(precision, NumTexCoordPrecisions); | 2913 DCHECK_LT(precision, NumTexCoordPrecisions); |
| 2914 DCHECK_GE(sampler, 0); |
| 2915 DCHECK_LT(sampler, NumSamplerTypes); |
2938 DCHECK_GE(blend_mode, 0); | 2916 DCHECK_GE(blend_mode, 0); |
2939 DCHECK_LT(blend_mode, NumBlendModes); | 2917 DCHECK_LT(blend_mode, NumBlendModes); |
2940 RenderPassMaskProgramAA* program = | 2918 RenderPassMaskProgramAA* program = |
2941 &render_pass_mask_program_aa_[precision][blend_mode]; | 2919 &render_pass_mask_program_aa_[precision][sampler][blend_mode]; |
2942 if (!program->initialized()) { | 2920 if (!program->initialized()) { |
2943 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); | 2921 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); |
2944 program->Initialize(output_surface_->context_provider(), | 2922 program->Initialize( |
2945 precision, | 2923 output_surface_->context_provider(), precision, sampler, blend_mode); |
2946 SamplerType2D, | |
2947 blend_mode); | |
2948 } | 2924 } |
2949 return program; | 2925 return program; |
2950 } | 2926 } |
2951 | 2927 |
2952 const GLRenderer::RenderPassColorMatrixProgram* | 2928 const GLRenderer::RenderPassColorMatrixProgram* |
2953 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision, | 2929 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision, |
2954 BlendMode blend_mode) { | 2930 BlendMode blend_mode) { |
2955 DCHECK_GE(precision, 0); | 2931 DCHECK_GE(precision, 0); |
2956 DCHECK_LT(precision, NumTexCoordPrecisions); | 2932 DCHECK_LT(precision, NumTexCoordPrecisions); |
2957 DCHECK_GE(blend_mode, 0); | 2933 DCHECK_GE(blend_mode, 0); |
(...skipping 25 matching lines...) Expand all Loading... |
2983 program->Initialize(output_surface_->context_provider(), | 2959 program->Initialize(output_surface_->context_provider(), |
2984 precision, | 2960 precision, |
2985 SamplerType2D, | 2961 SamplerType2D, |
2986 blend_mode); | 2962 blend_mode); |
2987 } | 2963 } |
2988 return program; | 2964 return program; |
2989 } | 2965 } |
2990 | 2966 |
2991 const GLRenderer::RenderPassMaskColorMatrixProgram* | 2967 const GLRenderer::RenderPassMaskColorMatrixProgram* |
2992 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision, | 2968 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision, |
| 2969 SamplerType sampler, |
2993 BlendMode blend_mode) { | 2970 BlendMode blend_mode) { |
2994 DCHECK_GE(precision, 0); | 2971 DCHECK_GE(precision, 0); |
2995 DCHECK_LT(precision, NumTexCoordPrecisions); | 2972 DCHECK_LT(precision, NumTexCoordPrecisions); |
| 2973 DCHECK_GE(sampler, 0); |
| 2974 DCHECK_LT(sampler, NumSamplerTypes); |
2996 DCHECK_GE(blend_mode, 0); | 2975 DCHECK_GE(blend_mode, 0); |
2997 DCHECK_LT(blend_mode, NumBlendModes); | 2976 DCHECK_LT(blend_mode, NumBlendModes); |
2998 RenderPassMaskColorMatrixProgram* program = | 2977 RenderPassMaskColorMatrixProgram* program = |
2999 &render_pass_mask_color_matrix_program_[precision][blend_mode]; | 2978 &render_pass_mask_color_matrix_program_[precision][sampler][blend_mode]; |
3000 if (!program->initialized()) { | 2979 if (!program->initialized()) { |
3001 TRACE_EVENT0("cc", | 2980 TRACE_EVENT0("cc", |
3002 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); | 2981 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); |
3003 program->Initialize(output_surface_->context_provider(), | 2982 program->Initialize( |
3004 precision, | 2983 output_surface_->context_provider(), precision, sampler, blend_mode); |
3005 SamplerType2D, | |
3006 blend_mode); | |
3007 } | 2984 } |
3008 return program; | 2985 return program; |
3009 } | 2986 } |
3010 | 2987 |
3011 const GLRenderer::RenderPassMaskColorMatrixProgramAA* | 2988 const GLRenderer::RenderPassMaskColorMatrixProgramAA* |
3012 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision, | 2989 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision, |
| 2990 SamplerType sampler, |
3013 BlendMode blend_mode) { | 2991 BlendMode blend_mode) { |
3014 DCHECK_GE(precision, 0); | 2992 DCHECK_GE(precision, 0); |
3015 DCHECK_LT(precision, NumTexCoordPrecisions); | 2993 DCHECK_LT(precision, NumTexCoordPrecisions); |
| 2994 DCHECK_GE(sampler, 0); |
| 2995 DCHECK_LT(sampler, NumSamplerTypes); |
3016 DCHECK_GE(blend_mode, 0); | 2996 DCHECK_GE(blend_mode, 0); |
3017 DCHECK_LT(blend_mode, NumBlendModes); | 2997 DCHECK_LT(blend_mode, NumBlendModes); |
3018 RenderPassMaskColorMatrixProgramAA* program = | 2998 RenderPassMaskColorMatrixProgramAA* program = |
3019 &render_pass_mask_color_matrix_program_aa_[precision][blend_mode]; | 2999 &render_pass_mask_color_matrix_program_aa_[precision][sampler] |
| 3000 [blend_mode]; |
3020 if (!program->initialized()) { | 3001 if (!program->initialized()) { |
3021 TRACE_EVENT0("cc", | 3002 TRACE_EVENT0("cc", |
3022 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); | 3003 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); |
3023 program->Initialize(output_surface_->context_provider(), | 3004 program->Initialize( |
3024 precision, | 3005 output_surface_->context_provider(), precision, sampler, blend_mode); |
3025 SamplerType2D, | |
3026 blend_mode); | |
3027 } | 3006 } |
3028 return program; | 3007 return program; |
3029 } | 3008 } |
3030 | 3009 |
3031 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( | 3010 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( |
3032 TexCoordPrecision precision, | 3011 TexCoordPrecision precision, |
3033 SamplerType sampler) { | 3012 SamplerType sampler) { |
3034 DCHECK_GE(precision, 0); | 3013 DCHECK_GE(precision, 0); |
3035 DCHECK_LT(precision, NumTexCoordPrecisions); | 3014 DCHECK_LT(precision, NumTexCoordPrecisions); |
3036 DCHECK_GE(sampler, 0); | 3015 DCHECK_GE(sampler, 0); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3241 shared_geometry_ = nullptr; | 3220 shared_geometry_ = nullptr; |
3242 | 3221 |
3243 for (int i = 0; i < NumTexCoordPrecisions; ++i) { | 3222 for (int i = 0; i < NumTexCoordPrecisions; ++i) { |
3244 for (int j = 0; j < NumSamplerTypes; ++j) { | 3223 for (int j = 0; j < NumSamplerTypes; ++j) { |
3245 tile_program_[i][j].Cleanup(gl_); | 3224 tile_program_[i][j].Cleanup(gl_); |
3246 tile_program_opaque_[i][j].Cleanup(gl_); | 3225 tile_program_opaque_[i][j].Cleanup(gl_); |
3247 tile_program_swizzle_[i][j].Cleanup(gl_); | 3226 tile_program_swizzle_[i][j].Cleanup(gl_); |
3248 tile_program_swizzle_opaque_[i][j].Cleanup(gl_); | 3227 tile_program_swizzle_opaque_[i][j].Cleanup(gl_); |
3249 tile_program_aa_[i][j].Cleanup(gl_); | 3228 tile_program_aa_[i][j].Cleanup(gl_); |
3250 tile_program_swizzle_aa_[i][j].Cleanup(gl_); | 3229 tile_program_swizzle_aa_[i][j].Cleanup(gl_); |
| 3230 |
| 3231 for (int k = 0; k < NumBlendModes; k++) { |
| 3232 render_pass_mask_program_[i][j][k].Cleanup(gl_); |
| 3233 render_pass_mask_program_aa_[i][j][k].Cleanup(gl_); |
| 3234 render_pass_mask_color_matrix_program_aa_[i][j][k].Cleanup(gl_); |
| 3235 render_pass_mask_color_matrix_program_[i][j][k].Cleanup(gl_); |
| 3236 } |
3251 } | 3237 } |
3252 for (int j = 0; j < NumBlendModes; j++) { | 3238 for (int j = 0; j < NumBlendModes; j++) { |
3253 render_pass_mask_program_[i][j].Cleanup(gl_); | |
3254 render_pass_program_[i][j].Cleanup(gl_); | 3239 render_pass_program_[i][j].Cleanup(gl_); |
3255 render_pass_mask_program_aa_[i][j].Cleanup(gl_); | |
3256 render_pass_program_aa_[i][j].Cleanup(gl_); | 3240 render_pass_program_aa_[i][j].Cleanup(gl_); |
3257 render_pass_color_matrix_program_[i][j].Cleanup(gl_); | 3241 render_pass_color_matrix_program_[i][j].Cleanup(gl_); |
3258 render_pass_mask_color_matrix_program_aa_[i][j].Cleanup(gl_); | |
3259 render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_); | 3242 render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_); |
3260 render_pass_mask_color_matrix_program_[i][j].Cleanup(gl_); | |
3261 } | 3243 } |
3262 | 3244 |
3263 texture_program_[i].Cleanup(gl_); | 3245 texture_program_[i].Cleanup(gl_); |
3264 nonpremultiplied_texture_program_[i].Cleanup(gl_); | 3246 nonpremultiplied_texture_program_[i].Cleanup(gl_); |
3265 texture_background_program_[i].Cleanup(gl_); | 3247 texture_background_program_[i].Cleanup(gl_); |
3266 nonpremultiplied_texture_background_program_[i].Cleanup(gl_); | 3248 nonpremultiplied_texture_background_program_[i].Cleanup(gl_); |
3267 texture_io_surface_program_[i].Cleanup(gl_); | 3249 texture_io_surface_program_[i].Cleanup(gl_); |
3268 | 3250 |
3269 video_yuv_program_[i].Cleanup(gl_); | 3251 video_yuv_program_[i].Cleanup(gl_); |
3270 video_yuva_program_[i].Cleanup(gl_); | 3252 video_yuva_program_[i].Cleanup(gl_); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3360 context_support_->ScheduleOverlayPlane( | 3342 context_support_->ScheduleOverlayPlane( |
3361 overlay.plane_z_order, | 3343 overlay.plane_z_order, |
3362 overlay.transform, | 3344 overlay.transform, |
3363 pending_overlay_resources_.back()->texture_id(), | 3345 pending_overlay_resources_.back()->texture_id(), |
3364 overlay.display_rect, | 3346 overlay.display_rect, |
3365 overlay.uv_rect); | 3347 overlay.uv_rect); |
3366 } | 3348 } |
3367 } | 3349 } |
3368 | 3350 |
3369 } // namespace cc | 3351 } // namespace cc |
OLD | NEW |