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/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "cc/damage_tracker.h" | 12 #include "cc/damage_tracker.h" |
13 #include "cc/geometry.h" | |
14 #include "cc/geometry_binding.h" | 13 #include "cc/geometry_binding.h" |
15 #include "cc/layer_quad.h" | 14 #include "cc/layer_quad.h" |
16 #include "cc/math_util.h" | 15 #include "cc/math_util.h" |
17 #include "cc/platform_color.h" | 16 #include "cc/platform_color.h" |
18 #include "cc/priority_calculator.h" | 17 #include "cc/priority_calculator.h" |
19 #include "cc/proxy.h" | 18 #include "cc/proxy.h" |
20 #include "cc/render_pass.h" | 19 #include "cc/render_pass.h" |
21 #include "cc/render_surface_filters.h" | 20 #include "cc/render_surface_filters.h" |
22 #include "cc/scoped_resource.h" | 21 #include "cc/scoped_resource.h" |
23 #include "cc/single_thread_proxy.h" | 22 #include "cc/single_thread_proxy.h" |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 699 |
701 gfx::RectF texCoordRect = quad->texCoordRect(); | 700 gfx::RectF texCoordRect = quad->texCoordRect(); |
702 float texToGeomScaleX = quad->rect.width() / texCoordRect.width(); | 701 float texToGeomScaleX = quad->rect.width() / texCoordRect.width(); |
703 float texToGeomScaleY = quad->rect.height() / texCoordRect.height(); | 702 float texToGeomScaleY = quad->rect.height() / texCoordRect.height(); |
704 | 703 |
705 // texCoordRect corresponds to quadRect, but quadVisibleRect may be | 704 // texCoordRect corresponds to quadRect, but quadVisibleRect may be |
706 // smaller than quadRect due to occlusion or clipping. Adjust | 705 // smaller than quadRect due to occlusion or clipping. Adjust |
707 // texCoordRect to match. | 706 // texCoordRect to match. |
708 gfx::Vector2d topLeftDiff = tileRect.origin() - quad->rect.origin(); | 707 gfx::Vector2d topLeftDiff = tileRect.origin() - quad->rect.origin(); |
709 gfx::Vector2d bottomRightDiff = | 708 gfx::Vector2d bottomRightDiff = |
710 BottomRight(tileRect) - BottomRight(quad->rect); | 709 tileRect.bottom_right() - quad->rect.bottom_right(); |
711 texCoordRect.Inset(topLeftDiff.x() / texToGeomScaleX, | 710 texCoordRect.Inset(topLeftDiff.x() / texToGeomScaleX, |
712 topLeftDiff.y() / texToGeomScaleY, | 711 topLeftDiff.y() / texToGeomScaleY, |
713 -bottomRightDiff.x() / texToGeomScaleX, | 712 -bottomRightDiff.x() / texToGeomScaleX, |
714 -bottomRightDiff.y() / texToGeomScaleY); | 713 -bottomRightDiff.y() / texToGeomScaleY); |
715 | 714 |
716 gfx::RectF clampGeomRect(tileRect); | 715 gfx::RectF clampGeomRect(tileRect); |
717 gfx::RectF clampTexRect(texCoordRect); | 716 gfx::RectF clampTexRect(texCoordRect); |
718 // Clamp texture coordinates to avoid sampling outside the layer | 717 // Clamp texture coordinates to avoid sampling outside the layer |
719 // by deflating the tile region half a texel or half a texel | 718 // by deflating the tile region half a texel or half a texel |
720 // minus epsilon for one pixel layers. The resulting clamp region | 719 // minus epsilon for one pixel layers. The resulting clamp region |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 deviceLayerEdges.inflateAntiAliasingDistance(); | 789 deviceLayerEdges.inflateAntiAliasingDistance(); |
791 | 790 |
792 float edge[24]; | 791 float edge[24]; |
793 deviceLayerEdges.toFloatArray(edge); | 792 deviceLayerEdges.toFloatArray(edge); |
794 deviceLayerBounds.toFloatArray(&edge[12]); | 793 deviceLayerBounds.toFloatArray(&edge[12]); |
795 GLC(context(), context()->uniform3fv(uniforms.edgeLocation, 8, edge)); | 794 GLC(context(), context()->uniform3fv(uniforms.edgeLocation, 8, edge)); |
796 | 795 |
797 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation,
vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); | 796 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation,
vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); |
798 GLC(context(), context()->uniform4f(uniforms.fragmentTexTransformLocatio
n, fragmentTexTranslateX, fragmentTexTranslateY, fragmentTexScaleX, fragmentTexS
caleY)); | 797 GLC(context(), context()->uniform4f(uniforms.fragmentTexTransformLocatio
n, fragmentTexTranslateX, fragmentTexTranslateY, fragmentTexScaleX, fragmentTexS
caleY)); |
799 | 798 |
800 gfx::PointF bottomRight(tileRect.right(), tileRect.bottom()); | 799 gfx::PointF bottomRight = tileRect.bottom_right(); |
801 gfx::PointF bottomLeft(tileRect.x(), tileRect.bottom()); | 800 gfx::PointF bottomLeft = tileRect.bottom_left(); |
802 gfx::PointF topLeft(tileRect.x(), tileRect.y()); | 801 gfx::PointF topLeft = tileRect.origin(); |
803 gfx::PointF topRight(tileRect.right(), tileRect.y()); | 802 gfx::PointF topRight = tileRect.top_right(); |
804 | 803 |
805 // Map points to device space. | 804 // Map points to device space. |
806 bottomRight = MathUtil::mapPoint(deviceTransform, bottomRight, clipped); | 805 bottomRight = MathUtil::mapPoint(deviceTransform, bottomRight, clipped); |
807 DCHECK(!clipped); | 806 DCHECK(!clipped); |
808 bottomLeft = MathUtil::mapPoint(deviceTransform, bottomLeft, clipped); | 807 bottomLeft = MathUtil::mapPoint(deviceTransform, bottomLeft, clipped); |
809 DCHECK(!clipped); | 808 DCHECK(!clipped); |
810 topLeft = MathUtil::mapPoint(deviceTransform, topLeft, clipped); | 809 topLeft = MathUtil::mapPoint(deviceTransform, topLeft, clipped); |
811 DCHECK(!clipped); | 810 DCHECK(!clipped); |
812 topRight = MathUtil::mapPoint(deviceTransform, topRight, clipped); | 811 topRight = MathUtil::mapPoint(deviceTransform, topRight, clipped); |
813 DCHECK(!clipped); | 812 DCHECK(!clipped); |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 | 1611 |
1613 releaseRenderPassTextures(); | 1612 releaseRenderPassTextures(); |
1614 } | 1613 } |
1615 | 1614 |
1616 bool GLRenderer::isContextLost() | 1615 bool GLRenderer::isContextLost() |
1617 { | 1616 { |
1618 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1617 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1619 } | 1618 } |
1620 | 1619 |
1621 } // namespace cc | 1620 } // namespace cc |
OLD | NEW |