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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 Float4 result = { { | 105 Float4 result = { { |
106 SkColorGetR(color) * factor * alpha, | 106 SkColorGetR(color) * factor * alpha, |
107 SkColorGetG(color) * factor * alpha, | 107 SkColorGetG(color) * factor * alpha, |
108 SkColorGetB(color) * factor * alpha, | 108 SkColorGetB(color) * factor * alpha, |
109 alpha | 109 alpha |
110 } }; | 110 } }; |
111 return result; | 111 return result; |
112 } | 112 } |
113 | 113 |
| 114 SamplerType SamplerTypeFromTextureTarget(GLenum target) { |
| 115 switch (target) { |
| 116 case GL_TEXTURE_2D: |
| 117 return SamplerType2D; |
| 118 case GL_TEXTURE_RECTANGLE_ARB: |
| 119 return SamplerType2DRect; |
| 120 case GL_TEXTURE_EXTERNAL_OES: |
| 121 return SamplerTypeExternalOES; |
| 122 default: |
| 123 NOTREACHED(); |
| 124 return SamplerType2D; |
| 125 } |
| 126 } |
| 127 |
114 // Smallest unit that impact anti-aliasing output. We use this to | 128 // Smallest unit that impact anti-aliasing output. We use this to |
115 // determine when anti-aliasing is unnecessary. | 129 // determine when anti-aliasing is unnecessary. |
116 const float kAntiAliasingEpsilon = 1.0f / 1024.0f; | 130 const float kAntiAliasingEpsilon = 1.0f / 1024.0f; |
117 | 131 |
118 } // anonymous namespace | 132 } // anonymous namespace |
119 | 133 |
120 struct GLRenderer::PendingAsyncReadPixels { | 134 struct GLRenderer::PendingAsyncReadPixels { |
121 PendingAsyncReadPixels() : buffer(0) {} | 135 PendingAsyncReadPixels() : buffer(0) {} |
122 | 136 |
123 scoped_ptr<CopyOutputRequest> copy_request; | 137 scoped_ptr<CopyOutputRequest> copy_request; |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 unsigned mask_texture_id = 0; | 820 unsigned mask_texture_id = 0; |
807 if (quad->mask_resource_id) { | 821 if (quad->mask_resource_id) { |
808 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( | 822 mask_resource_lock.reset(new ResourceProvider::ScopedReadLockGL( |
809 resource_provider_, quad->mask_resource_id)); | 823 resource_provider_, quad->mask_resource_id)); |
810 mask_texture_id = mask_resource_lock->texture_id(); | 824 mask_texture_id = mask_resource_lock->texture_id(); |
811 } | 825 } |
812 | 826 |
813 // TODO(danakj): use the background_texture and blend the background in with | 827 // TODO(danakj): use the background_texture and blend the background in with |
814 // this draw instead of having a separate copy of the background texture. | 828 // this draw instead of having a separate copy of the background texture. |
815 | 829 |
816 scoped_ptr<ResourceProvider::ScopedReadLockGL> contents_resource_lock; | 830 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; |
817 if (filter_bitmap.getTexture()) { | 831 if (filter_bitmap.getTexture()) { |
818 GrTexture* texture = | 832 GrTexture* texture = |
819 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); | 833 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); |
820 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); | 834 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); |
821 Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 835 Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); |
822 } else { | 836 } else { |
823 contents_resource_lock = make_scoped_ptr( | 837 contents_resource_lock = make_scoped_ptr( |
824 new ResourceProvider::ScopedSamplerGL(resource_provider_, | 838 new ResourceProvider::ScopedSamplerGL(resource_provider_, |
825 contents_texture->id(), | 839 contents_texture->id(), |
826 GL_TEXTURE_2D, | |
827 GL_LINEAR)); | 840 GL_LINEAR)); |
| 841 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 842 contents_resource_lock->target()); |
828 } | 843 } |
829 | 844 |
830 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 845 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
831 context_, &highp_threshold_cache_, highp_threshold_min_, | 846 context_, &highp_threshold_cache_, highp_threshold_min_, |
832 quad->shared_quad_state->visible_content_rect.bottom_right()); | 847 quad->shared_quad_state->visible_content_rect.bottom_right()); |
833 | 848 |
834 int shader_quad_location = -1; | 849 int shader_quad_location = -1; |
835 int shader_edge_location = -1; | 850 int shader_edge_location = -1; |
836 int shader_viewport_location = -1; | 851 int shader_viewport_location = -1; |
837 int shader_mask_sampler_location = -1; | 852 int shader_mask_sampler_location = -1; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 DCHECK(shader_tex_transform_location != -1 || IsContextLost()); | 1009 DCHECK(shader_tex_transform_location != -1 || IsContextLost()); |
995 // Flip the content vertically in the shader, as the RenderPass input | 1010 // Flip the content vertically in the shader, as the RenderPass input |
996 // texture is already oriented the same way as the framebuffer, but the | 1011 // texture is already oriented the same way as the framebuffer, but the |
997 // projection transform does a flip. | 1012 // projection transform does a flip. |
998 GLC(Context(), Context()->uniform4f(shader_tex_transform_location, | 1013 GLC(Context(), Context()->uniform4f(shader_tex_transform_location, |
999 0.0f, | 1014 0.0f, |
1000 tex_scale_y, | 1015 tex_scale_y, |
1001 tex_scale_x, | 1016 tex_scale_x, |
1002 -tex_scale_y)); | 1017 -tex_scale_y)); |
1003 | 1018 |
1004 scoped_ptr<ResourceProvider::ScopedReadLockGL> shader_mask_sampler_lock; | 1019 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; |
1005 if (shader_mask_sampler_location != -1) { | 1020 if (shader_mask_sampler_location != -1) { |
1006 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); | 1021 DCHECK_NE(shader_mask_tex_coord_scale_location, 1); |
1007 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); | 1022 DCHECK_NE(shader_mask_tex_coord_offset_location, 1); |
1008 GLC(Context(), Context()->uniform1i(shader_mask_sampler_location, 1)); | 1023 GLC(Context(), Context()->uniform1i(shader_mask_sampler_location, 1)); |
1009 | 1024 |
1010 float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x; | 1025 float mask_tex_scale_x = quad->mask_uv_rect.width() / tex_scale_x; |
1011 float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y; | 1026 float mask_tex_scale_y = quad->mask_uv_rect.height() / tex_scale_y; |
1012 | 1027 |
1013 // Mask textures are oriented vertically flipped relative to the framebuffer | 1028 // Mask textures are oriented vertically flipped relative to the framebuffer |
1014 // and the RenderPass contents texture, so we flip the tex coords from the | 1029 // and the RenderPass contents texture, so we flip the tex coords from the |
1015 // RenderPass texture to find the mask texture coords. | 1030 // RenderPass texture to find the mask texture coords. |
1016 GLC(Context(), | 1031 GLC(Context(), |
1017 Context()->uniform2f( | 1032 Context()->uniform2f( |
1018 shader_mask_tex_coord_offset_location, | 1033 shader_mask_tex_coord_offset_location, |
1019 quad->mask_uv_rect.x(), | 1034 quad->mask_uv_rect.x(), |
1020 quad->mask_uv_rect.y() + quad->mask_uv_rect.height())); | 1035 quad->mask_uv_rect.y() + quad->mask_uv_rect.height())); |
1021 GLC(Context(), | 1036 GLC(Context(), |
1022 Context()->uniform2f(shader_mask_tex_coord_scale_location, | 1037 Context()->uniform2f(shader_mask_tex_coord_scale_location, |
1023 mask_tex_scale_x, | 1038 mask_tex_scale_x, |
1024 -mask_tex_scale_y)); | 1039 -mask_tex_scale_y)); |
1025 shader_mask_sampler_lock = make_scoped_ptr( | 1040 shader_mask_sampler_lock = make_scoped_ptr( |
1026 new ResourceProvider::ScopedSamplerGL(resource_provider_, | 1041 new ResourceProvider::ScopedSamplerGL(resource_provider_, |
1027 quad->mask_resource_id, | 1042 quad->mask_resource_id, |
1028 GL_TEXTURE_2D, | |
1029 GL_TEXTURE1, | 1043 GL_TEXTURE1, |
1030 GL_LINEAR)); | 1044 GL_LINEAR)); |
| 1045 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1046 shader_mask_sampler_lock->target()); |
1031 } | 1047 } |
1032 | 1048 |
1033 if (shader_edge_location != -1) { | 1049 if (shader_edge_location != -1) { |
1034 float edge[24]; | 1050 float edge[24]; |
1035 device_layer_edges.ToFloatArray(edge); | 1051 device_layer_edges.ToFloatArray(edge); |
1036 device_layer_bounds.ToFloatArray(&edge[12]); | 1052 device_layer_bounds.ToFloatArray(&edge[12]); |
1037 GLC(Context(), Context()->uniform3fv(shader_edge_location, 8, edge)); | 1053 GLC(Context(), Context()->uniform3fv(shader_edge_location, 8, edge)); |
1038 } | 1054 } |
1039 | 1055 |
1040 if (shader_viewport_location != -1) { | 1056 if (shader_viewport_location != -1) { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); | 1345 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); |
1330 float vertex_tex_translate_y = | 1346 float vertex_tex_translate_y = |
1331 -clamp_geom_rect.y() / clamp_geom_rect.height(); | 1347 -clamp_geom_rect.y() / clamp_geom_rect.height(); |
1332 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); | 1348 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); |
1333 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); | 1349 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); |
1334 | 1350 |
1335 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1351 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
1336 context_, &highp_threshold_cache_, highp_threshold_min_, | 1352 context_, &highp_threshold_cache_, highp_threshold_min_, |
1337 quad->texture_size); | 1353 quad->texture_size); |
1338 | 1354 |
1339 // Map to normalized texture coordinates. | |
1340 gfx::Size texture_size = quad->texture_size; | |
1341 float fragment_tex_translate_x = clamp_tex_rect.x() / texture_size.width(); | |
1342 float fragment_tex_translate_y = clamp_tex_rect.y() / texture_size.height(); | |
1343 float fragment_tex_scale_x = clamp_tex_rect.width() / texture_size.width(); | |
1344 float fragment_tex_scale_y = clamp_tex_rect.height() / texture_size.height(); | |
1345 | |
1346 gfx::Transform device_transform = | 1355 gfx::Transform device_transform = |
1347 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); | 1356 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); |
1348 device_transform.FlattenTo2d(); | 1357 device_transform.FlattenTo2d(); |
1349 if (!device_transform.IsInvertible()) | 1358 if (!device_transform.IsInvertible()) |
1350 return; | 1359 return; |
1351 | 1360 |
1352 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); | 1361 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); |
1353 float edge[24]; | 1362 float edge[24]; |
1354 bool use_aa = settings_->allow_antialiasing && SetupQuadForAntialiasing( | 1363 bool use_aa = settings_->allow_antialiasing && SetupQuadForAntialiasing( |
1355 device_transform, quad, &local_quad, edge); | 1364 device_transform, quad, &local_quad, edge); |
1356 | 1365 |
| 1366 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); |
| 1367 GLenum filter = (use_aa || scaled || |
| 1368 !quad->quadTransform().IsIdentityOrIntegerTranslation()) |
| 1369 ? GL_LINEAR |
| 1370 : GL_NEAREST; |
| 1371 ResourceProvider::ScopedSamplerGL quad_resource_lock( |
| 1372 resource_provider_, resource_id, filter); |
| 1373 SamplerType sampler = SamplerTypeFromTextureTarget( |
| 1374 quad_resource_lock.target()); |
| 1375 |
| 1376 float fragment_tex_translate_x = clamp_tex_rect.x(); |
| 1377 float fragment_tex_translate_y = clamp_tex_rect.y(); |
| 1378 float fragment_tex_scale_x = clamp_tex_rect.width(); |
| 1379 float fragment_tex_scale_y = clamp_tex_rect.height(); |
| 1380 |
| 1381 // Map to normalized texture coordinates. |
| 1382 if (sampler != SamplerType2DRect) { |
| 1383 gfx::Size texture_size = quad->texture_size; |
| 1384 DCHECK(!texture_size.IsEmpty()); |
| 1385 fragment_tex_translate_x /= texture_size.width(); |
| 1386 fragment_tex_translate_y /= texture_size.height(); |
| 1387 fragment_tex_scale_x /= texture_size.width(); |
| 1388 fragment_tex_scale_y /= texture_size.height(); |
| 1389 } |
| 1390 |
1357 TileProgramUniforms uniforms; | 1391 TileProgramUniforms uniforms; |
1358 if (use_aa) { | 1392 if (use_aa) { |
1359 if (quad->swizzle_contents) { | 1393 if (quad->swizzle_contents) { |
1360 TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision), | 1394 TileUniformLocation( |
| 1395 GetTileProgramSwizzleAA(tex_coord_precision, sampler), |
| 1396 &uniforms); |
| 1397 } else { |
| 1398 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler), |
1361 &uniforms); | 1399 &uniforms); |
1362 } else { | |
1363 TileUniformLocation(GetTileProgramAA(tex_coord_precision), &uniforms); | |
1364 } | 1400 } |
1365 } else { | 1401 } else { |
1366 if (quad->ShouldDrawWithBlending()) { | 1402 if (quad->ShouldDrawWithBlending()) { |
1367 if (quad->swizzle_contents) { | 1403 if (quad->swizzle_contents) { |
1368 TileUniformLocation(GetTileProgramSwizzle(tex_coord_precision), | 1404 TileUniformLocation( |
| 1405 GetTileProgramSwizzle(tex_coord_precision, sampler), |
| 1406 &uniforms); |
| 1407 } else { |
| 1408 TileUniformLocation(GetTileProgram(tex_coord_precision, sampler), |
1369 &uniforms); | 1409 &uniforms); |
1370 } else { | |
1371 TileUniformLocation(GetTileProgram(tex_coord_precision), &uniforms); | |
1372 } | 1410 } |
1373 } else { | 1411 } else { |
1374 if (quad->swizzle_contents) { | 1412 if (quad->swizzle_contents) { |
1375 TileUniformLocation(GetTileProgramSwizzleOpaque(tex_coord_precision), | 1413 TileUniformLocation( |
1376 &uniforms); | 1414 GetTileProgramSwizzleOpaque(tex_coord_precision, sampler), |
| 1415 &uniforms); |
1377 } else { | 1416 } else { |
1378 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision), | 1417 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision, sampler), |
1379 &uniforms); | 1418 &uniforms); |
1380 } | 1419 } |
1381 } | 1420 } |
1382 } | 1421 } |
1383 | 1422 |
1384 SetUseProgram(uniforms.program); | 1423 SetUseProgram(uniforms.program); |
1385 GLC(Context(), Context()->uniform1i(uniforms.sampler_location, 0)); | 1424 GLC(Context(), Context()->uniform1i(uniforms.sampler_location, 0)); |
1386 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); | |
1387 GLenum filter = (use_aa || scaled || | |
1388 !quad->quadTransform().IsIdentityOrIntegerTranslation()) | |
1389 ? GL_LINEAR | |
1390 : GL_NEAREST; | |
1391 ResourceProvider::ScopedSamplerGL quad_resource_lock( | |
1392 resource_provider_, resource_id, GL_TEXTURE_2D, filter); | |
1393 | 1425 |
1394 if (use_aa) { | 1426 if (use_aa) { |
1395 float viewport[4] = { | 1427 float viewport[4] = { |
1396 static_cast<float>(viewport_.x()), | 1428 static_cast<float>(viewport_.x()), |
1397 static_cast<float>(viewport_.y()), | 1429 static_cast<float>(viewport_.y()), |
1398 static_cast<float>(viewport_.width()), | 1430 static_cast<float>(viewport_.width()), |
1399 static_cast<float>(viewport_.height()), | 1431 static_cast<float>(viewport_.height()), |
1400 }; | 1432 }; |
1401 GLC(Context(), | 1433 GLC(Context(), |
1402 Context()->uniform4fv(uniforms.viewport_location, 1, viewport)); | 1434 Context()->uniform4fv(uniforms.viewport_location, 1, viewport)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 | 1493 |
1462 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1494 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
1463 context_, &highp_threshold_cache_, highp_threshold_min_, | 1495 context_, &highp_threshold_cache_, highp_threshold_min_, |
1464 quad->shared_quad_state->visible_content_rect.bottom_right()); | 1496 quad->shared_quad_state->visible_content_rect.bottom_right()); |
1465 | 1497 |
1466 bool use_alpha_plane = quad->a_plane_resource_id != 0; | 1498 bool use_alpha_plane = quad->a_plane_resource_id != 0; |
1467 | 1499 |
1468 ResourceProvider::ScopedSamplerGL y_plane_lock( | 1500 ResourceProvider::ScopedSamplerGL y_plane_lock( |
1469 resource_provider_, | 1501 resource_provider_, |
1470 quad->y_plane_resource_id, | 1502 quad->y_plane_resource_id, |
1471 GL_TEXTURE_2D, | |
1472 GL_TEXTURE1, | 1503 GL_TEXTURE1, |
1473 GL_LINEAR); | 1504 GL_LINEAR); |
| 1505 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), y_plane_lock.target()); |
1474 ResourceProvider::ScopedSamplerGL u_plane_lock( | 1506 ResourceProvider::ScopedSamplerGL u_plane_lock( |
1475 resource_provider_, | 1507 resource_provider_, |
1476 quad->u_plane_resource_id, | 1508 quad->u_plane_resource_id, |
1477 GL_TEXTURE_2D, | |
1478 GL_TEXTURE2, | 1509 GL_TEXTURE2, |
1479 GL_LINEAR); | 1510 GL_LINEAR); |
| 1511 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), u_plane_lock.target()); |
1480 ResourceProvider::ScopedSamplerGL v_plane_lock( | 1512 ResourceProvider::ScopedSamplerGL v_plane_lock( |
1481 resource_provider_, | 1513 resource_provider_, |
1482 quad->v_plane_resource_id, | 1514 quad->v_plane_resource_id, |
1483 GL_TEXTURE_2D, | |
1484 GL_TEXTURE3, | 1515 GL_TEXTURE3, |
1485 GL_LINEAR); | 1516 GL_LINEAR); |
| 1517 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), v_plane_lock.target()); |
1486 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; | 1518 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; |
1487 if (use_alpha_plane) { | 1519 if (use_alpha_plane) { |
1488 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( | 1520 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( |
1489 resource_provider_, | 1521 resource_provider_, |
1490 quad->a_plane_resource_id, | 1522 quad->a_plane_resource_id, |
1491 GL_TEXTURE_2D, | |
1492 GL_TEXTURE4, | 1523 GL_TEXTURE4, |
1493 GL_LINEAR)); | 1524 GL_LINEAR)); |
| 1525 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); |
1494 } | 1526 } |
1495 | 1527 |
1496 int tex_scale_location = -1; | 1528 int tex_scale_location = -1; |
1497 int matrix_location = -1; | 1529 int matrix_location = -1; |
1498 int y_texture_location = -1; | 1530 int y_texture_location = -1; |
1499 int u_texture_location = -1; | 1531 int u_texture_location = -1; |
1500 int v_texture_location = -1; | 1532 int v_texture_location = -1; |
1501 int a_texture_location = -1; | 1533 int a_texture_location = -1; |
1502 int yuv_matrix_location = -1; | 1534 int yuv_matrix_location = -1; |
1503 int yuv_adj_location = -1; | 1535 int yuv_adj_location = -1; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 SkBitmap::kARGB_8888_Config, | 1691 SkBitmap::kARGB_8888_Config, |
1660 quad->texture_size.width(), | 1692 quad->texture_size.width(), |
1661 quad->texture_size.height()); | 1693 quad->texture_size.height()); |
1662 on_demand_tile_raster_bitmap_.allocPixels(); | 1694 on_demand_tile_raster_bitmap_.allocPixels(); |
1663 | 1695 |
1664 if (on_demand_tile_raster_resource_id_) | 1696 if (on_demand_tile_raster_resource_id_) |
1665 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 1697 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
1666 | 1698 |
1667 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( | 1699 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
1668 quad->texture_size, | 1700 quad->texture_size, |
| 1701 GL_TEXTURE_2D, |
1669 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1702 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
1670 GL_CLAMP_TO_EDGE, | 1703 GL_CLAMP_TO_EDGE, |
1671 ResourceProvider::TextureUsageAny, | 1704 ResourceProvider::TextureUsageAny, |
1672 quad->texture_format); | 1705 quad->texture_format); |
1673 } | 1706 } |
1674 | 1707 |
1675 SkBitmapDevice device(on_demand_tile_raster_bitmap_); | 1708 SkBitmapDevice device(on_demand_tile_raster_bitmap_); |
1676 SkCanvas canvas(&device); | 1709 SkCanvas canvas(&device); |
1677 | 1710 |
1678 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, | 1711 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 new GeometryBinding(context_, QuadVertexRect())); | 2552 new GeometryBinding(context_, QuadVertexRect())); |
2520 | 2553 |
2521 return true; | 2554 return true; |
2522 } | 2555 } |
2523 | 2556 |
2524 const GLRenderer::TileCheckerboardProgram* | 2557 const GLRenderer::TileCheckerboardProgram* |
2525 GLRenderer::GetTileCheckerboardProgram() { | 2558 GLRenderer::GetTileCheckerboardProgram() { |
2526 if (!tile_checkerboard_program_.initialized()) { | 2559 if (!tile_checkerboard_program_.initialized()) { |
2527 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); | 2560 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); |
2528 tile_checkerboard_program_.Initialize( | 2561 tile_checkerboard_program_.Initialize( |
2529 output_surface_->context_provider(), TexCoordPrecisionNA); | 2562 output_surface_->context_provider(), |
| 2563 TexCoordPrecisionNA, |
| 2564 SamplerTypeNA); |
2530 } | 2565 } |
2531 return &tile_checkerboard_program_; | 2566 return &tile_checkerboard_program_; |
2532 } | 2567 } |
2533 | 2568 |
2534 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { | 2569 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { |
2535 if (!debug_border_program_.initialized()) { | 2570 if (!debug_border_program_.initialized()) { |
2536 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); | 2571 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); |
2537 debug_border_program_.Initialize( | 2572 debug_border_program_.Initialize( |
2538 output_surface_->context_provider(), TexCoordPrecisionNA); | 2573 output_surface_->context_provider(), |
| 2574 TexCoordPrecisionNA, |
| 2575 SamplerTypeNA); |
2539 } | 2576 } |
2540 return &debug_border_program_; | 2577 return &debug_border_program_; |
2541 } | 2578 } |
2542 | 2579 |
2543 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { | 2580 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { |
2544 if (!solid_color_program_.initialized()) { | 2581 if (!solid_color_program_.initialized()) { |
2545 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); | 2582 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); |
2546 solid_color_program_.Initialize( | 2583 solid_color_program_.Initialize( |
2547 output_surface_->context_provider(), TexCoordPrecisionNA); | 2584 output_surface_->context_provider(), |
| 2585 TexCoordPrecisionNA, |
| 2586 SamplerTypeNA); |
2548 } | 2587 } |
2549 return &solid_color_program_; | 2588 return &solid_color_program_; |
2550 } | 2589 } |
2551 | 2590 |
2552 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { | 2591 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { |
2553 if (!solid_color_program_aa_.initialized()) { | 2592 if (!solid_color_program_aa_.initialized()) { |
2554 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); | 2593 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); |
2555 solid_color_program_aa_.Initialize( | 2594 solid_color_program_aa_.Initialize( |
2556 output_surface_->context_provider(), TexCoordPrecisionNA); | 2595 output_surface_->context_provider(), |
| 2596 TexCoordPrecisionNA, |
| 2597 SamplerTypeNA); |
2557 } | 2598 } |
2558 return &solid_color_program_aa_; | 2599 return &solid_color_program_aa_; |
2559 } | 2600 } |
2560 | 2601 |
2561 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( | 2602 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( |
2562 TexCoordPrecision precision) { | 2603 TexCoordPrecision precision) { |
2563 RenderPassProgram* program = | 2604 DCHECK_GE(precision, 0); |
2564 (precision == TexCoordPrecisionHigh) ? &render_pass_program_highp_ | 2605 DCHECK_LT(precision, NumTexCoordPrecisions); |
2565 : &render_pass_program_; | 2606 RenderPassProgram* program = &render_pass_program_[precision]; |
2566 if (!program->initialized()) { | 2607 if (!program->initialized()) { |
2567 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); | 2608 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); |
2568 program->Initialize(output_surface_->context_provider(), precision); | 2609 program->Initialize( |
| 2610 output_surface_->context_provider(), precision, SamplerType2D); |
2569 } | 2611 } |
2570 return program; | 2612 return program; |
2571 } | 2613 } |
2572 | 2614 |
2573 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( | 2615 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( |
2574 TexCoordPrecision precision) { | 2616 TexCoordPrecision precision) { |
2575 RenderPassProgramAA* program = | 2617 DCHECK_GE(precision, 0); |
2576 (precision == TexCoordPrecisionHigh) ? &render_pass_program_aa_highp_ | 2618 DCHECK_LT(precision, NumTexCoordPrecisions); |
2577 : &render_pass_program_aa_; | 2619 RenderPassProgramAA* program = &render_pass_program_aa_[precision]; |
2578 if (!program->initialized()) { | 2620 if (!program->initialized()) { |
2579 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); | 2621 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); |
2580 program->Initialize(output_surface_->context_provider(), precision); | 2622 program->Initialize( |
| 2623 output_surface_->context_provider(), precision, SamplerType2D); |
2581 } | 2624 } |
2582 return program; | 2625 return program; |
2583 } | 2626 } |
2584 | 2627 |
2585 const GLRenderer::RenderPassMaskProgram* | 2628 const GLRenderer::RenderPassMaskProgram* |
2586 GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { | 2629 GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { |
2587 RenderPassMaskProgram* program = | 2630 DCHECK_GE(precision, 0); |
2588 (precision == TexCoordPrecisionHigh) ? &render_pass_mask_program_highp_ | 2631 DCHECK_LT(precision, NumTexCoordPrecisions); |
2589 : &render_pass_mask_program_; | 2632 RenderPassMaskProgram* program = &render_pass_mask_program_[precision]; |
2590 if (!program->initialized()) { | 2633 if (!program->initialized()) { |
2591 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); | 2634 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); |
2592 program->Initialize(output_surface_->context_provider(), precision); | 2635 program->Initialize( |
| 2636 output_surface_->context_provider(), precision, SamplerType2D); |
2593 } | 2637 } |
2594 return program; | 2638 return program; |
2595 } | 2639 } |
2596 | 2640 |
2597 const GLRenderer::RenderPassMaskProgramAA* | 2641 const GLRenderer::RenderPassMaskProgramAA* |
2598 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { | 2642 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { |
2599 RenderPassMaskProgramAA* program = | 2643 DCHECK_GE(precision, 0); |
2600 (precision == TexCoordPrecisionHigh) ? &render_pass_mask_program_aa_highp_ | 2644 DCHECK_LT(precision, NumTexCoordPrecisions); |
2601 : &render_pass_mask_program_aa_; | 2645 RenderPassMaskProgramAA* program = &render_pass_mask_program_aa_[precision]; |
2602 if (!program->initialized()) { | 2646 if (!program->initialized()) { |
2603 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); | 2647 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); |
2604 program->Initialize(output_surface_->context_provider(), precision); | 2648 program->Initialize( |
| 2649 output_surface_->context_provider(), precision, SamplerType2D); |
2605 } | 2650 } |
2606 return program; | 2651 return program; |
2607 } | 2652 } |
2608 | 2653 |
2609 const GLRenderer::RenderPassColorMatrixProgram* | 2654 const GLRenderer::RenderPassColorMatrixProgram* |
2610 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { | 2655 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { |
| 2656 DCHECK_GE(precision, 0); |
| 2657 DCHECK_LT(precision, NumTexCoordPrecisions); |
2611 RenderPassColorMatrixProgram* program = | 2658 RenderPassColorMatrixProgram* program = |
2612 (precision == TexCoordPrecisionHigh) ? | 2659 &render_pass_color_matrix_program_[precision]; |
2613 &render_pass_color_matrix_program_highp_ : | |
2614 &render_pass_color_matrix_program_; | |
2615 if (!program->initialized()) { | 2660 if (!program->initialized()) { |
2616 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); | 2661 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); |
2617 program->Initialize(output_surface_->context_provider(), precision); | 2662 program->Initialize( |
| 2663 output_surface_->context_provider(), precision, SamplerType2D); |
2618 } | 2664 } |
2619 return program; | 2665 return program; |
2620 } | 2666 } |
2621 | 2667 |
2622 const GLRenderer::RenderPassColorMatrixProgramAA* | 2668 const GLRenderer::RenderPassColorMatrixProgramAA* |
2623 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { | 2669 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { |
| 2670 DCHECK_GE(precision, 0); |
| 2671 DCHECK_LT(precision, NumTexCoordPrecisions); |
2624 RenderPassColorMatrixProgramAA* program = | 2672 RenderPassColorMatrixProgramAA* program = |
2625 (precision == TexCoordPrecisionHigh) ? | 2673 &render_pass_color_matrix_program_aa_[precision]; |
2626 &render_pass_color_matrix_program_aa_highp_ : | |
2627 &render_pass_color_matrix_program_aa_; | |
2628 if (!program->initialized()) { | 2674 if (!program->initialized()) { |
2629 TRACE_EVENT0("cc", | 2675 TRACE_EVENT0("cc", |
2630 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); | 2676 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); |
2631 program->Initialize(output_surface_->context_provider(), precision); | 2677 program->Initialize( |
| 2678 output_surface_->context_provider(), precision, SamplerType2D); |
2632 } | 2679 } |
2633 return program; | 2680 return program; |
2634 } | 2681 } |
2635 | 2682 |
2636 const GLRenderer::RenderPassMaskColorMatrixProgram* | 2683 const GLRenderer::RenderPassMaskColorMatrixProgram* |
2637 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { | 2684 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { |
| 2685 DCHECK_GE(precision, 0); |
| 2686 DCHECK_LT(precision, NumTexCoordPrecisions); |
2638 RenderPassMaskColorMatrixProgram* program = | 2687 RenderPassMaskColorMatrixProgram* program = |
2639 (precision == TexCoordPrecisionHigh) ? | 2688 &render_pass_mask_color_matrix_program_[precision]; |
2640 &render_pass_mask_color_matrix_program_highp_ : | |
2641 &render_pass_mask_color_matrix_program_; | |
2642 if (!program->initialized()) { | 2689 if (!program->initialized()) { |
2643 TRACE_EVENT0("cc", | 2690 TRACE_EVENT0("cc", |
2644 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); | 2691 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); |
2645 program->Initialize(output_surface_->context_provider(), precision); | 2692 program->Initialize( |
| 2693 output_surface_->context_provider(), precision, SamplerType2D); |
2646 } | 2694 } |
2647 return program; | 2695 return program; |
2648 } | 2696 } |
2649 | 2697 |
2650 const GLRenderer::RenderPassMaskColorMatrixProgramAA* | 2698 const GLRenderer::RenderPassMaskColorMatrixProgramAA* |
2651 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { | 2699 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { |
| 2700 DCHECK_GE(precision, 0); |
| 2701 DCHECK_LT(precision, NumTexCoordPrecisions); |
2652 RenderPassMaskColorMatrixProgramAA* program = | 2702 RenderPassMaskColorMatrixProgramAA* program = |
2653 (precision == TexCoordPrecisionHigh) ? | 2703 &render_pass_mask_color_matrix_program_aa_[precision]; |
2654 &render_pass_mask_color_matrix_program_aa_highp_ : | |
2655 &render_pass_mask_color_matrix_program_aa_; | |
2656 if (!program->initialized()) { | 2704 if (!program->initialized()) { |
2657 TRACE_EVENT0("cc", | 2705 TRACE_EVENT0("cc", |
2658 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); | 2706 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); |
2659 program->Initialize(output_surface_->context_provider(), precision); | 2707 program->Initialize( |
| 2708 output_surface_->context_provider(), precision, SamplerType2D); |
2660 } | 2709 } |
2661 return program; | 2710 return program; |
2662 } | 2711 } |
2663 | 2712 |
2664 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( | 2713 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( |
2665 TexCoordPrecision precision) { | 2714 TexCoordPrecision precision, SamplerType sampler) { |
2666 TileProgram* program = | 2715 DCHECK_GE(precision, 0); |
2667 (precision == TexCoordPrecisionHigh) ? &tile_program_highp_ | 2716 DCHECK_LT(precision, NumTexCoordPrecisions); |
2668 : &tile_program_; | 2717 DCHECK_GE(sampler, 0); |
| 2718 DCHECK_LT(sampler, NumSamplerTypes); |
| 2719 TileProgram* program = &tile_program_[precision][sampler]; |
2669 if (!program->initialized()) { | 2720 if (!program->initialized()) { |
2670 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); | 2721 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); |
2671 program->Initialize(output_surface_->context_provider(), precision); | 2722 program->Initialize( |
| 2723 output_surface_->context_provider(), precision, sampler); |
2672 } | 2724 } |
2673 return program; | 2725 return program; |
2674 } | 2726 } |
2675 | 2727 |
2676 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( | 2728 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( |
2677 TexCoordPrecision precision) { | 2729 TexCoordPrecision precision, SamplerType sampler) { |
2678 TileProgramOpaque* program = | 2730 DCHECK_GE(precision, 0); |
2679 (precision == TexCoordPrecisionHigh) ? &tile_program_opaque_highp_ | 2731 DCHECK_LT(precision, NumTexCoordPrecisions); |
2680 : &tile_program_opaque_; | 2732 DCHECK_GE(sampler, 0); |
2681 DCHECK(program); | 2733 DCHECK_LT(sampler, NumSamplerTypes); |
| 2734 TileProgramOpaque* program = &tile_program_opaque_[precision][sampler]; |
2682 if (!program->initialized()) { | 2735 if (!program->initialized()) { |
2683 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); | 2736 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); |
2684 program->Initialize(output_surface_->context_provider(), precision); | 2737 program->Initialize( |
| 2738 output_surface_->context_provider(), precision, sampler); |
2685 } | 2739 } |
2686 return program; | 2740 return program; |
2687 } | 2741 } |
2688 | 2742 |
2689 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( | 2743 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( |
2690 TexCoordPrecision precision) { | 2744 TexCoordPrecision precision, SamplerType sampler) { |
2691 TileProgramAA* program = | 2745 DCHECK_GE(precision, 0); |
2692 (precision == TexCoordPrecisionHigh) ? &tile_program_aa_highp_ | 2746 DCHECK_LT(precision, NumTexCoordPrecisions); |
2693 : &tile_program_aa_; | 2747 DCHECK_GE(sampler, 0); |
| 2748 DCHECK_LT(sampler, NumSamplerTypes); |
| 2749 TileProgramAA* program = &tile_program_aa_[precision][sampler]; |
2694 if (!program->initialized()) { | 2750 if (!program->initialized()) { |
2695 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); | 2751 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); |
2696 program->Initialize(output_surface_->context_provider(), precision); | 2752 program->Initialize( |
| 2753 output_surface_->context_provider(), precision, sampler); |
2697 } | 2754 } |
2698 return program; | 2755 return program; |
2699 } | 2756 } |
2700 | 2757 |
2701 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( | 2758 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( |
2702 TexCoordPrecision precision) { | 2759 TexCoordPrecision precision, SamplerType sampler) { |
2703 TileProgramSwizzle* program = | 2760 DCHECK_GE(precision, 0); |
2704 (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_highp_ | 2761 DCHECK_LT(precision, NumTexCoordPrecisions); |
2705 : &tile_program_swizzle_; | 2762 DCHECK_GE(sampler, 0); |
| 2763 DCHECK_LT(sampler, NumSamplerTypes); |
| 2764 TileProgramSwizzle* program = &tile_program_swizzle_[precision][sampler]; |
2706 if (!program->initialized()) { | 2765 if (!program->initialized()) { |
2707 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); | 2766 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); |
2708 program->Initialize(output_surface_->context_provider(), precision); | 2767 program->Initialize( |
| 2768 output_surface_->context_provider(), precision, sampler); |
2709 } | 2769 } |
2710 return program; | 2770 return program; |
2711 } | 2771 } |
2712 | 2772 |
2713 const GLRenderer::TileProgramSwizzleOpaque* | 2773 const GLRenderer::TileProgramSwizzleOpaque* |
2714 GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision) { | 2774 GLRenderer::GetTileProgramSwizzleOpaque( |
| 2775 TexCoordPrecision precision, SamplerType sampler) { |
| 2776 DCHECK_GE(precision, 0); |
| 2777 DCHECK_LT(precision, NumTexCoordPrecisions); |
| 2778 DCHECK_GE(sampler, 0); |
| 2779 DCHECK_LT(sampler, NumSamplerTypes); |
2715 TileProgramSwizzleOpaque* program = | 2780 TileProgramSwizzleOpaque* program = |
2716 (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_opaque_highp_ | 2781 &tile_program_swizzle_opaque_[precision][sampler]; |
2717 : &tile_program_swizzle_opaque_; | |
2718 if (!program->initialized()) { | 2782 if (!program->initialized()) { |
2719 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); | 2783 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); |
2720 program->Initialize(output_surface_->context_provider(), precision); | 2784 program->Initialize( |
| 2785 output_surface_->context_provider(), precision, sampler); |
2721 } | 2786 } |
2722 return program; | 2787 return program; |
2723 } | 2788 } |
2724 | 2789 |
2725 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( | 2790 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( |
2726 TexCoordPrecision precision) { | 2791 TexCoordPrecision precision, SamplerType sampler) { |
| 2792 DCHECK_GE(precision, 0); |
| 2793 DCHECK_LT(precision, NumTexCoordPrecisions); |
| 2794 DCHECK_GE(sampler, 0); |
| 2795 DCHECK_LT(sampler, NumSamplerTypes); |
2727 TileProgramSwizzleAA* program = | 2796 TileProgramSwizzleAA* program = |
2728 (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_aa_highp_ | 2797 &tile_program_swizzle_aa_[precision][sampler]; |
2729 : &tile_program_swizzle_aa_; | |
2730 if (!program->initialized()) { | 2798 if (!program->initialized()) { |
2731 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); | 2799 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); |
2732 program->Initialize(output_surface_->context_provider(), precision); | 2800 program->Initialize( |
| 2801 output_surface_->context_provider(), precision, sampler); |
2733 } | 2802 } |
2734 return program; | 2803 return program; |
2735 } | 2804 } |
2736 | 2805 |
2737 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( | 2806 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( |
2738 TexCoordPrecision precision) { | 2807 TexCoordPrecision precision) { |
2739 TextureProgram* program = | 2808 DCHECK_GE(precision, 0); |
2740 (precision == TexCoordPrecisionHigh) ? &texture_program_highp_ | 2809 DCHECK_LT(precision, NumTexCoordPrecisions); |
2741 : &texture_program_; | 2810 TextureProgram* program = &texture_program_[precision]; |
2742 if (!program->initialized()) { | 2811 if (!program->initialized()) { |
2743 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 2812 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
2744 program->Initialize(output_surface_->context_provider(), precision); | 2813 program->Initialize( |
| 2814 output_surface_->context_provider(), precision, SamplerType2D); |
2745 } | 2815 } |
2746 return program; | 2816 return program; |
2747 } | 2817 } |
2748 | 2818 |
2749 const GLRenderer::NonPremultipliedTextureProgram* | 2819 const GLRenderer::NonPremultipliedTextureProgram* |
2750 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) { | 2820 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) { |
| 2821 DCHECK_GE(precision, 0); |
| 2822 DCHECK_LT(precision, NumTexCoordPrecisions); |
2751 NonPremultipliedTextureProgram* program = | 2823 NonPremultipliedTextureProgram* program = |
2752 (precision == TexCoordPrecisionHigh) ? | 2824 &nonpremultiplied_texture_program_[precision]; |
2753 &nonpremultiplied_texture_program_highp_ : | |
2754 &nonpremultiplied_texture_program_; | |
2755 if (!program->initialized()) { | 2825 if (!program->initialized()) { |
2756 TRACE_EVENT0("cc", | 2826 TRACE_EVENT0("cc", |
2757 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | 2827 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); |
2758 program->Initialize(output_surface_->context_provider(), precision); | 2828 program->Initialize( |
| 2829 output_surface_->context_provider(), precision, SamplerType2D); |
2759 } | 2830 } |
2760 return program; | 2831 return program; |
2761 } | 2832 } |
2762 | 2833 |
2763 const GLRenderer::TextureBackgroundProgram* | 2834 const GLRenderer::TextureBackgroundProgram* |
2764 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision) { | 2835 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision) { |
2765 TextureBackgroundProgram* program = | 2836 DCHECK_GE(precision, 0); |
2766 (precision == TexCoordPrecisionHigh) ? &texture_background_program_highp_ | 2837 DCHECK_LT(precision, NumTexCoordPrecisions); |
2767 : &texture_background_program_; | 2838 TextureBackgroundProgram* program = &texture_background_program_[precision]; |
2768 if (!program->initialized()) { | 2839 if (!program->initialized()) { |
2769 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 2840 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
2770 program->Initialize(output_surface_->context_provider(), precision); | 2841 program->Initialize( |
2771 } | 2842 output_surface_->context_provider(), precision, SamplerType2D); |
2772 return program; | 2843 } |
2773 } | 2844 return program; |
| 2845 } |
2774 | 2846 |
2775 const GLRenderer::NonPremultipliedTextureBackgroundProgram* | 2847 const GLRenderer::NonPremultipliedTextureBackgroundProgram* |
2776 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( | 2848 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( |
2777 TexCoordPrecision precision) { | 2849 TexCoordPrecision precision) { |
| 2850 DCHECK_GE(precision, 0); |
| 2851 DCHECK_LT(precision, NumTexCoordPrecisions); |
2778 NonPremultipliedTextureBackgroundProgram* program = | 2852 NonPremultipliedTextureBackgroundProgram* program = |
2779 (precision == TexCoordPrecisionHigh) ? | 2853 &nonpremultiplied_texture_background_program_[precision]; |
2780 &nonpremultiplied_texture_background_program_highp_ : | |
2781 &nonpremultiplied_texture_background_program_; | |
2782 if (!program->initialized()) { | 2854 if (!program->initialized()) { |
2783 TRACE_EVENT0("cc", | 2855 TRACE_EVENT0("cc", |
2784 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | 2856 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); |
2785 program->Initialize(output_surface_->context_provider(), precision); | 2857 program->Initialize( |
| 2858 output_surface_->context_provider(), precision, SamplerType2D); |
2786 } | 2859 } |
2787 return program; | 2860 return program; |
2788 } | 2861 } |
2789 | 2862 |
2790 const GLRenderer::TextureIOSurfaceProgram* | 2863 const GLRenderer::TextureProgram* |
2791 GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { | 2864 GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { |
2792 TextureIOSurfaceProgram* program = | 2865 DCHECK_GE(precision, 0); |
2793 (precision == TexCoordPrecisionHigh) ? &texture_io_surface_program_highp_ | 2866 DCHECK_LT(precision, NumTexCoordPrecisions); |
2794 : &texture_io_surface_program_; | 2867 TextureProgram* program = &texture_io_surface_program_[precision]; |
2795 if (!program->initialized()) { | 2868 if (!program->initialized()) { |
2796 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); | 2869 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); |
2797 program->Initialize(output_surface_->context_provider(), precision); | 2870 program->Initialize( |
| 2871 output_surface_->context_provider(), precision, SamplerType2DRect); |
2798 } | 2872 } |
2799 return program; | 2873 return program; |
2800 } | 2874 } |
2801 | 2875 |
2802 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( | 2876 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( |
2803 TexCoordPrecision precision) { | 2877 TexCoordPrecision precision) { |
2804 VideoYUVProgram* program = | 2878 DCHECK_GE(precision, 0); |
2805 (precision == TexCoordPrecisionHigh) ? &video_yuv_program_highp_ | 2879 DCHECK_LT(precision, NumTexCoordPrecisions); |
2806 : &video_yuv_program_; | 2880 VideoYUVProgram* program = &video_yuv_program_[precision]; |
2807 if (!program->initialized()) { | 2881 if (!program->initialized()) { |
2808 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | 2882 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); |
2809 program->Initialize(output_surface_->context_provider(), precision); | 2883 program->Initialize( |
| 2884 output_surface_->context_provider(), precision, SamplerType2D); |
2810 } | 2885 } |
2811 return program; | 2886 return program; |
2812 } | 2887 } |
2813 | 2888 |
2814 const GLRenderer::VideoYUVAProgram* GLRenderer::GetVideoYUVAProgram( | 2889 const GLRenderer::VideoYUVAProgram* GLRenderer::GetVideoYUVAProgram( |
2815 TexCoordPrecision precision) { | 2890 TexCoordPrecision precision) { |
2816 VideoYUVAProgram* program = | 2891 DCHECK_GE(precision, 0); |
2817 (precision == TexCoordPrecisionHigh) ? &video_yuva_program_highp_ | 2892 DCHECK_LT(precision, NumTexCoordPrecisions); |
2818 : &video_yuva_program_; | 2893 VideoYUVAProgram* program = &video_yuva_program_[precision]; |
2819 if (!program->initialized()) { | 2894 if (!program->initialized()) { |
2820 TRACE_EVENT0("cc", "GLRenderer::videoYUVAProgram::initialize"); | 2895 TRACE_EVENT0("cc", "GLRenderer::videoYUVAProgram::initialize"); |
2821 program->Initialize(output_surface_->context_provider(), precision); | 2896 program->Initialize( |
| 2897 output_surface_->context_provider(), precision, SamplerType2D); |
2822 } | 2898 } |
2823 return program; | 2899 return program; |
2824 } | 2900 } |
2825 | 2901 |
2826 const GLRenderer::VideoStreamTextureProgram* | 2902 const GLRenderer::VideoStreamTextureProgram* |
2827 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { | 2903 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { |
2828 if (!Capabilities().using_egl_image) | 2904 if (!Capabilities().using_egl_image) |
2829 return NULL; | 2905 return NULL; |
2830 VideoStreamTextureProgram* program = (precision == TexCoordPrecisionHigh) | 2906 DCHECK_GE(precision, 0); |
2831 ? &video_stream_texture_program_highp_ | 2907 DCHECK_LT(precision, NumTexCoordPrecisions); |
2832 : &video_stream_texture_program_; | 2908 VideoStreamTextureProgram* program = |
| 2909 &video_stream_texture_program_[precision]; |
2833 if (!program->initialized()) { | 2910 if (!program->initialized()) { |
2834 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); | 2911 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); |
2835 program->Initialize(output_surface_->context_provider(), precision); | 2912 program->Initialize( |
| 2913 output_surface_->context_provider(), |
| 2914 precision, |
| 2915 SamplerTypeExternalOES); |
2836 } | 2916 } |
2837 return program; | 2917 return program; |
2838 } | 2918 } |
2839 | 2919 |
2840 void GLRenderer::CleanupSharedObjects() { | 2920 void GLRenderer::CleanupSharedObjects() { |
2841 MakeContextCurrent(); | 2921 MakeContextCurrent(); |
2842 | 2922 |
2843 shared_geometry_.reset(); | 2923 shared_geometry_.reset(); |
2844 | 2924 |
2845 tile_program_.Cleanup(context_); | 2925 for (int i = 0; i < NumTexCoordPrecisions; ++i) { |
2846 tile_program_opaque_.Cleanup(context_); | 2926 for (int j = 0; j < NumSamplerTypes; ++j) { |
2847 tile_program_swizzle_.Cleanup(context_); | 2927 tile_program_[i][j].Cleanup(context_); |
2848 tile_program_swizzle_opaque_.Cleanup(context_); | 2928 tile_program_opaque_[i][j].Cleanup(context_); |
2849 tile_program_aa_.Cleanup(context_); | 2929 tile_program_swizzle_[i][j].Cleanup(context_); |
2850 tile_program_swizzle_aa_.Cleanup(context_); | 2930 tile_program_swizzle_opaque_[i][j].Cleanup(context_); |
| 2931 tile_program_aa_[i][j].Cleanup(context_); |
| 2932 tile_program_swizzle_aa_[i][j].Cleanup(context_); |
| 2933 } |
| 2934 |
| 2935 render_pass_mask_program_[i].Cleanup(context_); |
| 2936 render_pass_program_[i].Cleanup(context_); |
| 2937 render_pass_mask_program_aa_[i].Cleanup(context_); |
| 2938 render_pass_program_aa_[i].Cleanup(context_); |
| 2939 render_pass_color_matrix_program_[i].Cleanup(context_); |
| 2940 render_pass_mask_color_matrix_program_aa_[i].Cleanup(context_); |
| 2941 render_pass_color_matrix_program_aa_[i].Cleanup(context_); |
| 2942 render_pass_mask_color_matrix_program_[i].Cleanup(context_); |
| 2943 |
| 2944 texture_program_[i].Cleanup(context_); |
| 2945 nonpremultiplied_texture_program_[i].Cleanup(context_); |
| 2946 texture_background_program_[i].Cleanup(context_); |
| 2947 nonpremultiplied_texture_background_program_[i].Cleanup(context_); |
| 2948 texture_io_surface_program_[i].Cleanup(context_); |
| 2949 |
| 2950 video_yuv_program_[i].Cleanup(context_); |
| 2951 video_yuva_program_[i].Cleanup(context_); |
| 2952 video_stream_texture_program_[i].Cleanup(context_); |
| 2953 } |
| 2954 |
2851 tile_checkerboard_program_.Cleanup(context_); | 2955 tile_checkerboard_program_.Cleanup(context_); |
2852 | 2956 |
2853 tile_program_highp_.Cleanup(context_); | |
2854 tile_program_opaque_highp_.Cleanup(context_); | |
2855 tile_program_swizzle_highp_.Cleanup(context_); | |
2856 tile_program_swizzle_opaque_highp_.Cleanup(context_); | |
2857 tile_program_aa_highp_.Cleanup(context_); | |
2858 tile_program_swizzle_aa_highp_.Cleanup(context_); | |
2859 | |
2860 render_pass_mask_program_.Cleanup(context_); | |
2861 render_pass_program_.Cleanup(context_); | |
2862 render_pass_mask_program_aa_.Cleanup(context_); | |
2863 render_pass_program_aa_.Cleanup(context_); | |
2864 render_pass_color_matrix_program_.Cleanup(context_); | |
2865 render_pass_mask_color_matrix_program_aa_.Cleanup(context_); | |
2866 render_pass_color_matrix_program_aa_.Cleanup(context_); | |
2867 render_pass_mask_color_matrix_program_.Cleanup(context_); | |
2868 | |
2869 render_pass_mask_program_highp_.Cleanup(context_); | |
2870 render_pass_program_highp_.Cleanup(context_); | |
2871 render_pass_mask_program_aa_highp_.Cleanup(context_); | |
2872 render_pass_program_aa_highp_.Cleanup(context_); | |
2873 render_pass_color_matrix_program_highp_.Cleanup(context_); | |
2874 render_pass_mask_color_matrix_program_aa_highp_.Cleanup(context_); | |
2875 render_pass_color_matrix_program_aa_highp_.Cleanup(context_); | |
2876 render_pass_mask_color_matrix_program_highp_.Cleanup(context_); | |
2877 | |
2878 texture_program_.Cleanup(context_); | |
2879 nonpremultiplied_texture_program_.Cleanup(context_); | |
2880 texture_background_program_.Cleanup(context_); | |
2881 nonpremultiplied_texture_background_program_.Cleanup(context_); | |
2882 texture_io_surface_program_.Cleanup(context_); | |
2883 | |
2884 texture_program_highp_.Cleanup(context_); | |
2885 nonpremultiplied_texture_program_highp_.Cleanup(context_); | |
2886 texture_background_program_highp_.Cleanup(context_); | |
2887 nonpremultiplied_texture_background_program_highp_.Cleanup(context_); | |
2888 texture_io_surface_program_highp_.Cleanup(context_); | |
2889 | |
2890 video_yuv_program_.Cleanup(context_); | |
2891 video_yuva_program_.Cleanup(context_); | |
2892 video_stream_texture_program_.Cleanup(context_); | |
2893 | |
2894 video_yuv_program_highp_.Cleanup(context_); | |
2895 video_yuva_program_highp_.Cleanup(context_); | |
2896 video_stream_texture_program_highp_.Cleanup(context_); | |
2897 | |
2898 debug_border_program_.Cleanup(context_); | 2957 debug_border_program_.Cleanup(context_); |
2899 solid_color_program_.Cleanup(context_); | 2958 solid_color_program_.Cleanup(context_); |
2900 solid_color_program_aa_.Cleanup(context_); | 2959 solid_color_program_aa_.Cleanup(context_); |
2901 | 2960 |
2902 if (offscreen_framebuffer_id_) | 2961 if (offscreen_framebuffer_id_) |
2903 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2962 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
2904 | 2963 |
2905 if (on_demand_tile_raster_resource_id_) | 2964 if (on_demand_tile_raster_resource_id_) |
2906 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2965 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
2907 | 2966 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3011 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
2953 // implementation. | 3012 // implementation. |
2954 return gr_context_ && context_->getContextAttributes().stencil; | 3013 return gr_context_ && context_->getContextAttributes().stencil; |
2955 } | 3014 } |
2956 | 3015 |
2957 bool GLRenderer::IsContextLost() { | 3016 bool GLRenderer::IsContextLost() { |
2958 return output_surface_->context_provider()->IsContextLost(); | 3017 return output_surface_->context_provider()->IsContextLost(); |
2959 } | 3018 } |
2960 | 3019 |
2961 } // namespace cc | 3020 } // namespace cc |
OLD | NEW |