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 fragment_tex_translate_x /= texture_size.width(); | |
kaanb
2013/11/23 02:02:20
consider checking if width() and/or height() could
reveman
2013/11/23 10:29:12
Done.
| |
1385 fragment_tex_translate_y /= texture_size.height(); | |
1386 fragment_tex_scale_x /= texture_size.width(); | |
1387 fragment_tex_scale_y /= texture_size.height(); | |
1388 } | |
1389 | |
1357 TileProgramUniforms uniforms; | 1390 TileProgramUniforms uniforms; |
1358 if (use_aa) { | 1391 if (use_aa) { |
1359 if (quad->swizzle_contents) { | 1392 if (quad->swizzle_contents) { |
1360 TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision), | 1393 TileUniformLocation( |
1394 GetTileProgramSwizzleAA(tex_coord_precision, sampler), | |
1395 &uniforms); | |
kaanb
2013/11/23 02:02:20
fits previous line? also check other sites below
| |
1396 } else { | |
1397 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler), | |
1361 &uniforms); | 1398 &uniforms); |
1362 } else { | |
1363 TileUniformLocation(GetTileProgramAA(tex_coord_precision), &uniforms); | |
1364 } | 1399 } |
1365 } else { | 1400 } else { |
1366 if (quad->ShouldDrawWithBlending()) { | 1401 if (quad->ShouldDrawWithBlending()) { |
1367 if (quad->swizzle_contents) { | 1402 if (quad->swizzle_contents) { |
1368 TileUniformLocation(GetTileProgramSwizzle(tex_coord_precision), | 1403 TileUniformLocation( |
1404 GetTileProgramSwizzle(tex_coord_precision, sampler), | |
1405 &uniforms); | |
1406 } else { | |
1407 TileUniformLocation(GetTileProgram(tex_coord_precision, sampler), | |
1369 &uniforms); | 1408 &uniforms); |
1370 } else { | |
1371 TileUniformLocation(GetTileProgram(tex_coord_precision), &uniforms); | |
1372 } | 1409 } |
1373 } else { | 1410 } else { |
1374 if (quad->swizzle_contents) { | 1411 if (quad->swizzle_contents) { |
1375 TileUniformLocation(GetTileProgramSwizzleOpaque(tex_coord_precision), | 1412 TileUniformLocation( |
1376 &uniforms); | 1413 GetTileProgramSwizzleOpaque(tex_coord_precision, sampler), |
1414 &uniforms); | |
1377 } else { | 1415 } else { |
1378 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision), | 1416 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision, sampler), |
1379 &uniforms); | 1417 &uniforms); |
1380 } | 1418 } |
1381 } | 1419 } |
1382 } | 1420 } |
1383 | 1421 |
1384 SetUseProgram(uniforms.program); | 1422 SetUseProgram(uniforms.program); |
1385 GLC(Context(), Context()->uniform1i(uniforms.sampler_location, 0)); | 1423 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 | 1424 |
1394 if (use_aa) { | 1425 if (use_aa) { |
1395 float viewport[4] = { | 1426 float viewport[4] = { |
1396 static_cast<float>(viewport_.x()), | 1427 static_cast<float>(viewport_.x()), |
1397 static_cast<float>(viewport_.y()), | 1428 static_cast<float>(viewport_.y()), |
1398 static_cast<float>(viewport_.width()), | 1429 static_cast<float>(viewport_.width()), |
1399 static_cast<float>(viewport_.height()), | 1430 static_cast<float>(viewport_.height()), |
1400 }; | 1431 }; |
1401 GLC(Context(), | 1432 GLC(Context(), |
1402 Context()->uniform4fv(uniforms.viewport_location, 1, viewport)); | 1433 Context()->uniform4fv(uniforms.viewport_location, 1, viewport)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1461 | 1492 |
1462 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1493 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
1463 context_, &highp_threshold_cache_, highp_threshold_min_, | 1494 context_, &highp_threshold_cache_, highp_threshold_min_, |
1464 quad->shared_quad_state->visible_content_rect.bottom_right()); | 1495 quad->shared_quad_state->visible_content_rect.bottom_right()); |
1465 | 1496 |
1466 bool use_alpha_plane = quad->a_plane_resource_id != 0; | 1497 bool use_alpha_plane = quad->a_plane_resource_id != 0; |
1467 | 1498 |
1468 ResourceProvider::ScopedSamplerGL y_plane_lock( | 1499 ResourceProvider::ScopedSamplerGL y_plane_lock( |
1469 resource_provider_, | 1500 resource_provider_, |
1470 quad->y_plane_resource_id, | 1501 quad->y_plane_resource_id, |
1471 GL_TEXTURE_2D, | |
1472 GL_TEXTURE1, | 1502 GL_TEXTURE1, |
1473 GL_LINEAR); | 1503 GL_LINEAR); |
1504 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), y_plane_lock.target()); | |
1474 ResourceProvider::ScopedSamplerGL u_plane_lock( | 1505 ResourceProvider::ScopedSamplerGL u_plane_lock( |
1475 resource_provider_, | 1506 resource_provider_, |
1476 quad->u_plane_resource_id, | 1507 quad->u_plane_resource_id, |
1477 GL_TEXTURE_2D, | |
1478 GL_TEXTURE2, | 1508 GL_TEXTURE2, |
1479 GL_LINEAR); | 1509 GL_LINEAR); |
1510 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), u_plane_lock.target()); | |
1480 ResourceProvider::ScopedSamplerGL v_plane_lock( | 1511 ResourceProvider::ScopedSamplerGL v_plane_lock( |
1481 resource_provider_, | 1512 resource_provider_, |
1482 quad->v_plane_resource_id, | 1513 quad->v_plane_resource_id, |
1483 GL_TEXTURE_2D, | |
1484 GL_TEXTURE3, | 1514 GL_TEXTURE3, |
1485 GL_LINEAR); | 1515 GL_LINEAR); |
1516 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), v_plane_lock.target()); | |
1486 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; | 1517 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; |
1487 if (use_alpha_plane) { | 1518 if (use_alpha_plane) { |
1488 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( | 1519 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( |
1489 resource_provider_, | 1520 resource_provider_, |
1490 quad->a_plane_resource_id, | 1521 quad->a_plane_resource_id, |
1491 GL_TEXTURE_2D, | |
1492 GL_TEXTURE4, | 1522 GL_TEXTURE4, |
1493 GL_LINEAR)); | 1523 GL_LINEAR)); |
1524 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); | |
1494 } | 1525 } |
1495 | 1526 |
1496 int tex_scale_location = -1; | 1527 int tex_scale_location = -1; |
1497 int matrix_location = -1; | 1528 int matrix_location = -1; |
1498 int y_texture_location = -1; | 1529 int y_texture_location = -1; |
1499 int u_texture_location = -1; | 1530 int u_texture_location = -1; |
1500 int v_texture_location = -1; | 1531 int v_texture_location = -1; |
1501 int a_texture_location = -1; | 1532 int a_texture_location = -1; |
1502 int yuv_matrix_location = -1; | 1533 int yuv_matrix_location = -1; |
1503 int yuv_adj_location = -1; | 1534 int yuv_adj_location = -1; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1659 SkBitmap::kARGB_8888_Config, | 1690 SkBitmap::kARGB_8888_Config, |
1660 quad->texture_size.width(), | 1691 quad->texture_size.width(), |
1661 quad->texture_size.height()); | 1692 quad->texture_size.height()); |
1662 on_demand_tile_raster_bitmap_.allocPixels(); | 1693 on_demand_tile_raster_bitmap_.allocPixels(); |
1663 | 1694 |
1664 if (on_demand_tile_raster_resource_id_) | 1695 if (on_demand_tile_raster_resource_id_) |
1665 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 1696 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
1666 | 1697 |
1667 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( | 1698 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
1668 quad->texture_size, | 1699 quad->texture_size, |
1700 GL_TEXTURE_2D, | |
1669 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1701 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
1670 GL_CLAMP_TO_EDGE, | 1702 GL_CLAMP_TO_EDGE, |
1671 ResourceProvider::TextureUsageAny, | 1703 ResourceProvider::TextureUsageAny, |
1672 quad->texture_format); | 1704 quad->texture_format); |
1673 } | 1705 } |
1674 | 1706 |
1675 SkBitmapDevice device(on_demand_tile_raster_bitmap_); | 1707 SkBitmapDevice device(on_demand_tile_raster_bitmap_); |
1676 SkCanvas canvas(&device); | 1708 SkCanvas canvas(&device); |
1677 | 1709 |
1678 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, | 1710 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())); | 2551 new GeometryBinding(context_, QuadVertexRect())); |
2520 | 2552 |
2521 return true; | 2553 return true; |
2522 } | 2554 } |
2523 | 2555 |
2524 const GLRenderer::TileCheckerboardProgram* | 2556 const GLRenderer::TileCheckerboardProgram* |
2525 GLRenderer::GetTileCheckerboardProgram() { | 2557 GLRenderer::GetTileCheckerboardProgram() { |
2526 if (!tile_checkerboard_program_.initialized()) { | 2558 if (!tile_checkerboard_program_.initialized()) { |
2527 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); | 2559 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); |
2528 tile_checkerboard_program_.Initialize( | 2560 tile_checkerboard_program_.Initialize( |
2529 output_surface_->context_provider(), TexCoordPrecisionNA); | 2561 output_surface_->context_provider(), |
2562 TexCoordPrecisionNA, | |
2563 SamplerTypeNA); | |
2530 } | 2564 } |
2531 return &tile_checkerboard_program_; | 2565 return &tile_checkerboard_program_; |
2532 } | 2566 } |
2533 | 2567 |
2534 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { | 2568 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { |
2535 if (!debug_border_program_.initialized()) { | 2569 if (!debug_border_program_.initialized()) { |
2536 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); | 2570 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); |
2537 debug_border_program_.Initialize( | 2571 debug_border_program_.Initialize( |
2538 output_surface_->context_provider(), TexCoordPrecisionNA); | 2572 output_surface_->context_provider(), |
2573 TexCoordPrecisionNA, | |
2574 SamplerTypeNA); | |
2539 } | 2575 } |
2540 return &debug_border_program_; | 2576 return &debug_border_program_; |
2541 } | 2577 } |
2542 | 2578 |
2543 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { | 2579 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { |
2544 if (!solid_color_program_.initialized()) { | 2580 if (!solid_color_program_.initialized()) { |
2545 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); | 2581 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); |
2546 solid_color_program_.Initialize( | 2582 solid_color_program_.Initialize( |
2547 output_surface_->context_provider(), TexCoordPrecisionNA); | 2583 output_surface_->context_provider(), |
2584 TexCoordPrecisionNA, | |
2585 SamplerTypeNA); | |
2548 } | 2586 } |
2549 return &solid_color_program_; | 2587 return &solid_color_program_; |
2550 } | 2588 } |
2551 | 2589 |
2552 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { | 2590 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { |
2553 if (!solid_color_program_aa_.initialized()) { | 2591 if (!solid_color_program_aa_.initialized()) { |
2554 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); | 2592 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); |
2555 solid_color_program_aa_.Initialize( | 2593 solid_color_program_aa_.Initialize( |
2556 output_surface_->context_provider(), TexCoordPrecisionNA); | 2594 output_surface_->context_provider(), |
2595 TexCoordPrecisionNA, | |
2596 SamplerTypeNA); | |
2557 } | 2597 } |
2558 return &solid_color_program_aa_; | 2598 return &solid_color_program_aa_; |
2559 } | 2599 } |
2560 | 2600 |
2561 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( | 2601 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( |
2562 TexCoordPrecision precision) { | 2602 TexCoordPrecision precision) { |
2563 RenderPassProgram* program = | 2603 RenderPassProgram* program = &render_pass_program_[precision]; |
2564 (precision == TexCoordPrecisionHigh) ? &render_pass_program_highp_ | |
2565 : &render_pass_program_; | |
2566 if (!program->initialized()) { | 2604 if (!program->initialized()) { |
2567 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); | 2605 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); |
2568 program->Initialize(output_surface_->context_provider(), precision); | 2606 program->Initialize( |
2607 output_surface_->context_provider(), precision, SamplerType2D); | |
2569 } | 2608 } |
2570 return program; | 2609 return program; |
2571 } | 2610 } |
2572 | 2611 |
2573 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( | 2612 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( |
2574 TexCoordPrecision precision) { | 2613 TexCoordPrecision precision) { |
2575 RenderPassProgramAA* program = | 2614 RenderPassProgramAA* program = &render_pass_program_aa_[precision]; |
2576 (precision == TexCoordPrecisionHigh) ? &render_pass_program_aa_highp_ | |
2577 : &render_pass_program_aa_; | |
2578 if (!program->initialized()) { | 2615 if (!program->initialized()) { |
2579 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); | 2616 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); |
2580 program->Initialize(output_surface_->context_provider(), precision); | 2617 program->Initialize( |
2618 output_surface_->context_provider(), precision, SamplerType2D); | |
2581 } | 2619 } |
2582 return program; | 2620 return program; |
2583 } | 2621 } |
2584 | 2622 |
2585 const GLRenderer::RenderPassMaskProgram* | 2623 const GLRenderer::RenderPassMaskProgram* |
2586 GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { | 2624 GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { |
2587 RenderPassMaskProgram* program = | 2625 RenderPassMaskProgram* program = &render_pass_mask_program_[precision]; |
2588 (precision == TexCoordPrecisionHigh) ? &render_pass_mask_program_highp_ | |
2589 : &render_pass_mask_program_; | |
2590 if (!program->initialized()) { | 2626 if (!program->initialized()) { |
2591 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); | 2627 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); |
2592 program->Initialize(output_surface_->context_provider(), precision); | 2628 program->Initialize( |
2629 output_surface_->context_provider(), precision, SamplerType2D); | |
2593 } | 2630 } |
2594 return program; | 2631 return program; |
2595 } | 2632 } |
2596 | 2633 |
2597 const GLRenderer::RenderPassMaskProgramAA* | 2634 const GLRenderer::RenderPassMaskProgramAA* |
2598 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { | 2635 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { |
2599 RenderPassMaskProgramAA* program = | 2636 RenderPassMaskProgramAA* program = &render_pass_mask_program_aa_[precision]; |
2600 (precision == TexCoordPrecisionHigh) ? &render_pass_mask_program_aa_highp_ | |
2601 : &render_pass_mask_program_aa_; | |
2602 if (!program->initialized()) { | 2637 if (!program->initialized()) { |
2603 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); | 2638 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); |
2604 program->Initialize(output_surface_->context_provider(), precision); | 2639 program->Initialize( |
2640 output_surface_->context_provider(), precision, SamplerType2D); | |
2605 } | 2641 } |
2606 return program; | 2642 return program; |
2607 } | 2643 } |
2608 | 2644 |
2609 const GLRenderer::RenderPassColorMatrixProgram* | 2645 const GLRenderer::RenderPassColorMatrixProgram* |
2610 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { | 2646 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { |
2611 RenderPassColorMatrixProgram* program = | 2647 RenderPassColorMatrixProgram* program = |
2612 (precision == TexCoordPrecisionHigh) ? | 2648 &render_pass_color_matrix_program_[precision]; |
2613 &render_pass_color_matrix_program_highp_ : | |
2614 &render_pass_color_matrix_program_; | |
2615 if (!program->initialized()) { | 2649 if (!program->initialized()) { |
2616 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); | 2650 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); |
2617 program->Initialize(output_surface_->context_provider(), precision); | 2651 program->Initialize( |
2652 output_surface_->context_provider(), precision, SamplerType2D); | |
2618 } | 2653 } |
2619 return program; | 2654 return program; |
2620 } | 2655 } |
2621 | 2656 |
2622 const GLRenderer::RenderPassColorMatrixProgramAA* | 2657 const GLRenderer::RenderPassColorMatrixProgramAA* |
2623 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { | 2658 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { |
2624 RenderPassColorMatrixProgramAA* program = | 2659 RenderPassColorMatrixProgramAA* program = |
2625 (precision == TexCoordPrecisionHigh) ? | 2660 &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()) { | 2661 if (!program->initialized()) { |
2629 TRACE_EVENT0("cc", | 2662 TRACE_EVENT0("cc", |
2630 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); | 2663 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); |
2631 program->Initialize(output_surface_->context_provider(), precision); | 2664 program->Initialize( |
2665 output_surface_->context_provider(), precision, SamplerType2D); | |
2632 } | 2666 } |
2633 return program; | 2667 return program; |
2634 } | 2668 } |
2635 | 2669 |
2636 const GLRenderer::RenderPassMaskColorMatrixProgram* | 2670 const GLRenderer::RenderPassMaskColorMatrixProgram* |
2637 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { | 2671 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { |
2638 RenderPassMaskColorMatrixProgram* program = | 2672 RenderPassMaskColorMatrixProgram* program = |
2639 (precision == TexCoordPrecisionHigh) ? | 2673 &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()) { | 2674 if (!program->initialized()) { |
2643 TRACE_EVENT0("cc", | 2675 TRACE_EVENT0("cc", |
2644 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); | 2676 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); |
2645 program->Initialize(output_surface_->context_provider(), precision); | 2677 program->Initialize( |
2678 output_surface_->context_provider(), precision, SamplerType2D); | |
2646 } | 2679 } |
2647 return program; | 2680 return program; |
2648 } | 2681 } |
2649 | 2682 |
2650 const GLRenderer::RenderPassMaskColorMatrixProgramAA* | 2683 const GLRenderer::RenderPassMaskColorMatrixProgramAA* |
2651 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { | 2684 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { |
2652 RenderPassMaskColorMatrixProgramAA* program = | 2685 RenderPassMaskColorMatrixProgramAA* program = |
2653 (precision == TexCoordPrecisionHigh) ? | 2686 &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()) { | 2687 if (!program->initialized()) { |
2657 TRACE_EVENT0("cc", | 2688 TRACE_EVENT0("cc", |
2658 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); | 2689 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); |
2659 program->Initialize(output_surface_->context_provider(), precision); | 2690 program->Initialize( |
2691 output_surface_->context_provider(), precision, SamplerType2D); | |
2660 } | 2692 } |
2661 return program; | 2693 return program; |
2662 } | 2694 } |
2663 | 2695 |
2664 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( | 2696 const GLRenderer::TileProgram* GLRenderer::GetTileProgram( |
2665 TexCoordPrecision precision) { | 2697 TexCoordPrecision precision, SamplerType sampler) { |
2666 TileProgram* program = | 2698 TileProgram* program = &tile_program_[precision][sampler]; |
2667 (precision == TexCoordPrecisionHigh) ? &tile_program_highp_ | |
2668 : &tile_program_; | |
2669 if (!program->initialized()) { | 2699 if (!program->initialized()) { |
2670 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); | 2700 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); |
2671 program->Initialize(output_surface_->context_provider(), precision); | 2701 program->Initialize( |
2702 output_surface_->context_provider(), precision, sampler); | |
2672 } | 2703 } |
2673 return program; | 2704 return program; |
2674 } | 2705 } |
2675 | 2706 |
2676 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( | 2707 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque( |
2677 TexCoordPrecision precision) { | 2708 TexCoordPrecision precision, SamplerType sampler) { |
2678 TileProgramOpaque* program = | 2709 TileProgramOpaque* program = &tile_program_opaque_[precision][sampler]; |
2679 (precision == TexCoordPrecisionHigh) ? &tile_program_opaque_highp_ | |
2680 : &tile_program_opaque_; | |
2681 DCHECK(program); | |
2682 if (!program->initialized()) { | 2710 if (!program->initialized()) { |
2683 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); | 2711 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); |
2684 program->Initialize(output_surface_->context_provider(), precision); | 2712 program->Initialize( |
2713 output_surface_->context_provider(), precision, sampler); | |
2685 } | 2714 } |
2686 return program; | 2715 return program; |
2687 } | 2716 } |
2688 | 2717 |
2689 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( | 2718 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA( |
2690 TexCoordPrecision precision) { | 2719 TexCoordPrecision precision, SamplerType sampler) { |
2691 TileProgramAA* program = | 2720 TileProgramAA* program = &tile_program_aa_[precision][sampler]; |
2692 (precision == TexCoordPrecisionHigh) ? &tile_program_aa_highp_ | |
2693 : &tile_program_aa_; | |
2694 if (!program->initialized()) { | 2721 if (!program->initialized()) { |
2695 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); | 2722 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); |
2696 program->Initialize(output_surface_->context_provider(), precision); | 2723 program->Initialize( |
2724 output_surface_->context_provider(), precision, sampler); | |
2697 } | 2725 } |
2698 return program; | 2726 return program; |
2699 } | 2727 } |
2700 | 2728 |
2701 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( | 2729 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle( |
2702 TexCoordPrecision precision) { | 2730 TexCoordPrecision precision, SamplerType sampler) { |
2703 TileProgramSwizzle* program = | 2731 TileProgramSwizzle* program = &tile_program_swizzle_[precision][sampler]; |
2704 (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_highp_ | |
2705 : &tile_program_swizzle_; | |
2706 if (!program->initialized()) { | 2732 if (!program->initialized()) { |
2707 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); | 2733 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); |
2708 program->Initialize(output_surface_->context_provider(), precision); | 2734 program->Initialize( |
2735 output_surface_->context_provider(), precision, sampler); | |
2709 } | 2736 } |
2710 return program; | 2737 return program; |
2711 } | 2738 } |
2712 | 2739 |
2713 const GLRenderer::TileProgramSwizzleOpaque* | 2740 const GLRenderer::TileProgramSwizzleOpaque* |
2714 GLRenderer::GetTileProgramSwizzleOpaque(TexCoordPrecision precision) { | 2741 GLRenderer::GetTileProgramSwizzleOpaque( |
2742 TexCoordPrecision precision, SamplerType sampler) { | |
2715 TileProgramSwizzleOpaque* program = | 2743 TileProgramSwizzleOpaque* program = |
2716 (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_opaque_highp_ | 2744 &tile_program_swizzle_opaque_[precision][sampler]; |
2717 : &tile_program_swizzle_opaque_; | |
2718 if (!program->initialized()) { | 2745 if (!program->initialized()) { |
2719 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); | 2746 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); |
2720 program->Initialize(output_surface_->context_provider(), precision); | 2747 program->Initialize( |
2748 output_surface_->context_provider(), precision, sampler); | |
2721 } | 2749 } |
2722 return program; | 2750 return program; |
2723 } | 2751 } |
2724 | 2752 |
2725 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( | 2753 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA( |
2726 TexCoordPrecision precision) { | 2754 TexCoordPrecision precision, SamplerType sampler) { |
2727 TileProgramSwizzleAA* program = | 2755 TileProgramSwizzleAA* program = |
2728 (precision == TexCoordPrecisionHigh) ? &tile_program_swizzle_aa_highp_ | 2756 &tile_program_swizzle_aa_[precision][sampler]; |
2729 : &tile_program_swizzle_aa_; | |
2730 if (!program->initialized()) { | 2757 if (!program->initialized()) { |
2731 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); | 2758 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); |
2732 program->Initialize(output_surface_->context_provider(), precision); | 2759 program->Initialize( |
2760 output_surface_->context_provider(), precision, sampler); | |
2733 } | 2761 } |
2734 return program; | 2762 return program; |
2735 } | 2763 } |
2736 | 2764 |
2737 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( | 2765 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( |
2738 TexCoordPrecision precision) { | 2766 TexCoordPrecision precision) { |
2739 TextureProgram* program = | 2767 TextureProgram* program = &texture_program_[precision]; |
2740 (precision == TexCoordPrecisionHigh) ? &texture_program_highp_ | |
2741 : &texture_program_; | |
2742 if (!program->initialized()) { | 2768 if (!program->initialized()) { |
2743 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 2769 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
2744 program->Initialize(output_surface_->context_provider(), precision); | 2770 program->Initialize( |
2771 output_surface_->context_provider(), precision, SamplerType2D); | |
2745 } | 2772 } |
2746 return program; | 2773 return program; |
2747 } | 2774 } |
2748 | 2775 |
2749 const GLRenderer::NonPremultipliedTextureProgram* | 2776 const GLRenderer::NonPremultipliedTextureProgram* |
2750 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) { | 2777 GLRenderer::GetNonPremultipliedTextureProgram(TexCoordPrecision precision) { |
2751 NonPremultipliedTextureProgram* program = | 2778 NonPremultipliedTextureProgram* program = |
2752 (precision == TexCoordPrecisionHigh) ? | 2779 &nonpremultiplied_texture_program_[precision]; |
2753 &nonpremultiplied_texture_program_highp_ : | |
2754 &nonpremultiplied_texture_program_; | |
2755 if (!program->initialized()) { | 2780 if (!program->initialized()) { |
2756 TRACE_EVENT0("cc", | 2781 TRACE_EVENT0("cc", |
2757 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | 2782 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); |
2758 program->Initialize(output_surface_->context_provider(), precision); | 2783 program->Initialize( |
2784 output_surface_->context_provider(), precision, SamplerType2D); | |
2759 } | 2785 } |
2760 return program; | 2786 return program; |
2761 } | 2787 } |
2762 | 2788 |
2763 const GLRenderer::TextureBackgroundProgram* | 2789 const GLRenderer::TextureBackgroundProgram* |
2764 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision) { | 2790 GLRenderer::GetTextureBackgroundProgram(TexCoordPrecision precision) { |
2765 TextureBackgroundProgram* program = | 2791 TextureBackgroundProgram* program = &texture_background_program_[precision]; |
2766 (precision == TexCoordPrecisionHigh) ? &texture_background_program_highp_ | |
2767 : &texture_background_program_; | |
2768 if (!program->initialized()) { | 2792 if (!program->initialized()) { |
2769 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 2793 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
2770 program->Initialize(output_surface_->context_provider(), precision); | 2794 program->Initialize( |
2795 output_surface_->context_provider(), precision, SamplerType2D); | |
2771 } | 2796 } |
2772 return program; | 2797 return program; |
2773 } | 2798 } |
2774 | 2799 |
2775 const GLRenderer::NonPremultipliedTextureBackgroundProgram* | 2800 const GLRenderer::NonPremultipliedTextureBackgroundProgram* |
2776 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( | 2801 GLRenderer::GetNonPremultipliedTextureBackgroundProgram( |
2777 TexCoordPrecision precision) { | 2802 TexCoordPrecision precision) { |
2778 NonPremultipliedTextureBackgroundProgram* program = | 2803 NonPremultipliedTextureBackgroundProgram* program = |
2779 (precision == TexCoordPrecisionHigh) ? | 2804 &nonpremultiplied_texture_background_program_[precision]; |
2780 &nonpremultiplied_texture_background_program_highp_ : | |
2781 &nonpremultiplied_texture_background_program_; | |
2782 if (!program->initialized()) { | 2805 if (!program->initialized()) { |
2783 TRACE_EVENT0("cc", | 2806 TRACE_EVENT0("cc", |
2784 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); | 2807 "GLRenderer::NonPremultipliedTextureProgram::Initialize"); |
2785 program->Initialize(output_surface_->context_provider(), precision); | 2808 program->Initialize( |
2809 output_surface_->context_provider(), precision, SamplerType2D); | |
2786 } | 2810 } |
2787 return program; | 2811 return program; |
2788 } | 2812 } |
2789 | 2813 |
2790 const GLRenderer::TextureIOSurfaceProgram* | 2814 const GLRenderer::TextureProgram* |
2791 GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { | 2815 GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { |
2792 TextureIOSurfaceProgram* program = | 2816 TextureProgram* program = &texture_io_surface_program_[precision]; |
2793 (precision == TexCoordPrecisionHigh) ? &texture_io_surface_program_highp_ | |
2794 : &texture_io_surface_program_; | |
2795 if (!program->initialized()) { | 2817 if (!program->initialized()) { |
2796 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); | 2818 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); |
2797 program->Initialize(output_surface_->context_provider(), precision); | 2819 program->Initialize( |
2820 output_surface_->context_provider(), precision, SamplerType2DRect); | |
2798 } | 2821 } |
2799 return program; | 2822 return program; |
2800 } | 2823 } |
2801 | 2824 |
2802 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( | 2825 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( |
2803 TexCoordPrecision precision) { | 2826 TexCoordPrecision precision) { |
2804 VideoYUVProgram* program = | 2827 VideoYUVProgram* program = &video_yuv_program_[precision]; |
2805 (precision == TexCoordPrecisionHigh) ? &video_yuv_program_highp_ | |
2806 : &video_yuv_program_; | |
2807 if (!program->initialized()) { | 2828 if (!program->initialized()) { |
2808 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | 2829 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); |
2809 program->Initialize(output_surface_->context_provider(), precision); | 2830 program->Initialize( |
2831 output_surface_->context_provider(), precision, SamplerType2D); | |
2810 } | 2832 } |
2811 return program; | 2833 return program; |
2812 } | 2834 } |
2813 | 2835 |
2814 const GLRenderer::VideoYUVAProgram* GLRenderer::GetVideoYUVAProgram( | 2836 const GLRenderer::VideoYUVAProgram* GLRenderer::GetVideoYUVAProgram( |
2815 TexCoordPrecision precision) { | 2837 TexCoordPrecision precision) { |
kaanb
2013/11/23 02:02:20
I'm somewhat new to this file but wouldn't it help
| |
2816 VideoYUVAProgram* program = | 2838 VideoYUVAProgram* program = &video_yuva_program_[precision]; |
2817 (precision == TexCoordPrecisionHigh) ? &video_yuva_program_highp_ | |
2818 : &video_yuva_program_; | |
2819 if (!program->initialized()) { | 2839 if (!program->initialized()) { |
2820 TRACE_EVENT0("cc", "GLRenderer::videoYUVAProgram::initialize"); | 2840 TRACE_EVENT0("cc", "GLRenderer::videoYUVAProgram::initialize"); |
2821 program->Initialize(output_surface_->context_provider(), precision); | 2841 program->Initialize( |
2842 output_surface_->context_provider(), precision, SamplerType2D); | |
2822 } | 2843 } |
2823 return program; | 2844 return program; |
2824 } | 2845 } |
2825 | 2846 |
2826 const GLRenderer::VideoStreamTextureProgram* | 2847 const GLRenderer::VideoStreamTextureProgram* |
2827 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { | 2848 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { |
2828 if (!Capabilities().using_egl_image) | 2849 if (!Capabilities().using_egl_image) |
2829 return NULL; | 2850 return NULL; |
2830 VideoStreamTextureProgram* program = (precision == TexCoordPrecisionHigh) | 2851 VideoStreamTextureProgram* program = |
2831 ? &video_stream_texture_program_highp_ | 2852 &video_stream_texture_program_[precision]; |
2832 : &video_stream_texture_program_; | |
2833 if (!program->initialized()) { | 2853 if (!program->initialized()) { |
2834 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); | 2854 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); |
2835 program->Initialize(output_surface_->context_provider(), precision); | 2855 program->Initialize( |
2856 output_surface_->context_provider(), | |
2857 precision, | |
2858 SamplerTypeExternalOES); | |
2836 } | 2859 } |
2837 return program; | 2860 return program; |
2838 } | 2861 } |
2839 | 2862 |
2840 void GLRenderer::CleanupSharedObjects() { | 2863 void GLRenderer::CleanupSharedObjects() { |
2841 MakeContextCurrent(); | 2864 MakeContextCurrent(); |
2842 | 2865 |
2843 shared_geometry_.reset(); | 2866 shared_geometry_.reset(); |
2844 | 2867 |
2845 tile_program_.Cleanup(context_); | 2868 for (int i = 0; i < NumTexCoordPrecisions; ++i) { |
2846 tile_program_opaque_.Cleanup(context_); | 2869 for (int j = 0; j < NumSamplerTypes; ++j) { |
2847 tile_program_swizzle_.Cleanup(context_); | 2870 tile_program_[i][j].Cleanup(context_); |
2848 tile_program_swizzle_opaque_.Cleanup(context_); | 2871 tile_program_opaque_[i][j].Cleanup(context_); |
2849 tile_program_aa_.Cleanup(context_); | 2872 tile_program_swizzle_[i][j].Cleanup(context_); |
2850 tile_program_swizzle_aa_.Cleanup(context_); | 2873 tile_program_swizzle_opaque_[i][j].Cleanup(context_); |
2874 tile_program_aa_[i][j].Cleanup(context_); | |
2875 tile_program_swizzle_aa_[i][j].Cleanup(context_); | |
2876 } | |
2877 | |
2878 render_pass_mask_program_[i].Cleanup(context_); | |
2879 render_pass_program_[i].Cleanup(context_); | |
2880 render_pass_mask_program_aa_[i].Cleanup(context_); | |
2881 render_pass_program_aa_[i].Cleanup(context_); | |
2882 render_pass_color_matrix_program_[i].Cleanup(context_); | |
2883 render_pass_mask_color_matrix_program_aa_[i].Cleanup(context_); | |
2884 render_pass_color_matrix_program_aa_[i].Cleanup(context_); | |
2885 render_pass_mask_color_matrix_program_[i].Cleanup(context_); | |
2886 | |
2887 texture_program_[i].Cleanup(context_); | |
2888 nonpremultiplied_texture_program_[i].Cleanup(context_); | |
2889 texture_background_program_[i].Cleanup(context_); | |
2890 nonpremultiplied_texture_background_program_[i].Cleanup(context_); | |
2891 texture_io_surface_program_[i].Cleanup(context_); | |
2892 | |
2893 video_yuv_program_[i].Cleanup(context_); | |
2894 video_yuva_program_[i].Cleanup(context_); | |
2895 video_stream_texture_program_[i].Cleanup(context_); | |
2896 } | |
2897 | |
2851 tile_checkerboard_program_.Cleanup(context_); | 2898 tile_checkerboard_program_.Cleanup(context_); |
2852 | 2899 |
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_); | 2900 debug_border_program_.Cleanup(context_); |
2899 solid_color_program_.Cleanup(context_); | 2901 solid_color_program_.Cleanup(context_); |
2900 solid_color_program_aa_.Cleanup(context_); | 2902 solid_color_program_aa_.Cleanup(context_); |
2901 | 2903 |
2902 if (offscreen_framebuffer_id_) | 2904 if (offscreen_framebuffer_id_) |
2903 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2905 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
2904 | 2906 |
2905 if (on_demand_tile_raster_resource_id_) | 2907 if (on_demand_tile_raster_resource_id_) |
2906 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2908 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
2907 | 2909 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2952 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 2954 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
2953 // implementation. | 2955 // implementation. |
2954 return gr_context_ && context_->getContextAttributes().stencil; | 2956 return gr_context_ && context_->getContextAttributes().stencil; |
2955 } | 2957 } |
2956 | 2958 |
2957 bool GLRenderer::IsContextLost() { | 2959 bool GLRenderer::IsContextLost() { |
2958 return output_surface_->context_provider()->IsContextLost(); | 2960 return output_surface_->context_provider()->IsContextLost(); |
2959 } | 2961 } |
2960 | 2962 |
2961 } // namespace cc | 2963 } // namespace cc |
OLD | NEW |