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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/gl_renderer.h" | 7 #include "cc/gl_renderer.h" |
8 | 8 |
9 #include "FloatQuad.h" | 9 #include "FloatQuad.h" |
10 #include "NotImplemented.h" | 10 #include "NotImplemented.h" |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 // Clamp texture coordinates to avoid sampling outside the layer | 691 // Clamp texture coordinates to avoid sampling outside the layer |
692 // by deflating the tile region half a texel or half a texel | 692 // by deflating the tile region half a texel or half a texel |
693 // minus epsilon for one pixel layers. The resulting clamp region | 693 // minus epsilon for one pixel layers. The resulting clamp region |
694 // is mapped to the unit square by the vertex shader and mapped | 694 // is mapped to the unit square by the vertex shader and mapped |
695 // back to normalized texture coordinates by the fragment shader | 695 // back to normalized texture coordinates by the fragment shader |
696 // after being clamped to 0-1 range. | 696 // after being clamped to 0-1 range. |
697 const float epsilon = 1 / 1024.0f; | 697 const float epsilon = 1 / 1024.0f; |
698 float clampX = min(0.5, clampRect.width() / 2.0 - epsilon); | 698 float clampX = min(0.5, clampRect.width() / 2.0 - epsilon); |
699 float clampY = min(0.5, clampRect.height() / 2.0 - epsilon); | 699 float clampY = min(0.5, clampRect.height() / 2.0 - epsilon); |
700 clampRect.Inset(clampX, clampY, clampX, clampY); | 700 clampRect.Inset(clampX, clampY, clampX, clampY); |
701 gfx::PointF clampOffset = clampRect.origin() - tileRect.origin(); | |
702 | 701 |
703 gfx::PointF textureOffset = quad->textureOffset() + clampOffset + | 702 gfx::PointF textureOffset = quad->textureOffset() + clampRect.OffsetFromOrig
in() - quad->quadRect().OffsetFromOrigin(); |
704 (tileRect.origin() - quad->quadRect().origin()); | |
705 | 703 |
706 // Map clamping rectangle to unit square. | 704 // Map clamping rectangle to unit square. |
707 float vertexTexTranslateX = -clampRect.x() / clampRect.width(); | 705 float vertexTexTranslateX = -clampRect.x() / clampRect.width(); |
708 float vertexTexTranslateY = -clampRect.y() / clampRect.height(); | 706 float vertexTexTranslateY = -clampRect.y() / clampRect.height(); |
709 float vertexTexScaleX = tileRect.width() / clampRect.width(); | 707 float vertexTexScaleX = tileRect.width() / clampRect.width(); |
710 float vertexTexScaleY = tileRect.height() / clampRect.height(); | 708 float vertexTexScaleY = tileRect.height() / clampRect.height(); |
711 | 709 |
712 // Map to normalized texture coordinates. | 710 // Map to normalized texture coordinates. |
713 const gfx::Size& textureSize = quad->textureSize(); | 711 const gfx::Size& textureSize = quad->textureSize(); |
714 float fragmentTexTranslateX = textureOffset.x() / textureSize.width(); | 712 float fragmentTexTranslateX = textureOffset.x() / textureSize.width(); |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 | 1626 |
1629 releaseRenderPassTextures(); | 1627 releaseRenderPassTextures(); |
1630 } | 1628 } |
1631 | 1629 |
1632 bool GLRenderer::isContextLost() | 1630 bool GLRenderer::isContextLost() |
1633 { | 1631 { |
1634 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1632 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1635 } | 1633 } |
1636 | 1634 |
1637 } // namespace cc | 1635 } // namespace cc |
OLD | NEW |