| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } | 512 } |
| 513 | 513 |
| 514 void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
d* quad) | 514 void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
d* quad) |
| 515 { | 515 { |
| 516 CachedResource* contentsTexture = m_renderPassTextures.get(quad->render_pass
_id); | 516 CachedResource* contentsTexture = m_renderPassTextures.get(quad->render_pass
_id); |
| 517 if (!contentsTexture || !contentsTexture->id()) | 517 if (!contentsTexture || !contentsTexture->id()) |
| 518 return; | 518 return; |
| 519 | 519 |
| 520 gfx::Transform quadRectMatrix; | 520 gfx::Transform quadRectMatrix; |
| 521 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); | 521 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); |
| 522 gfx::Transform contentsDeviceTransform = MathUtil::to2dTransform(frame.windo
wMatrix * frame.projectionMatrix * quadRectMatrix); | 522 gfx::Transform contentsDeviceTransform = frame.windowMatrix * frame.projecti
onMatrix * quadRectMatrix; |
| 523 contentsDeviceTransform.FlattenTo2d(); |
| 523 | 524 |
| 524 // Can only draw surface if device matrix is invertible. | 525 // Can only draw surface if device matrix is invertible. |
| 525 gfx::Transform contentsDeviceTransformInverse(gfx::Transform::kSkipInitializ
ation); | 526 gfx::Transform contentsDeviceTransformInverse(gfx::Transform::kSkipInitializ
ation); |
| 526 if (!contentsDeviceTransform.GetInverse(&contentsDeviceTransformInverse)) | 527 if (!contentsDeviceTransform.GetInverse(&contentsDeviceTransformInverse)) |
| 527 return; | 528 return; |
| 528 | 529 |
| 529 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( | 530 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( |
| 530 frame, quad, contentsDeviceTransform, contentsDeviceTransformInverse); | 531 frame, quad, contentsDeviceTransform, contentsDeviceTransformInverse); |
| 531 | 532 |
| 532 // FIXME: Cache this value so that we don't have to do it for both the surfa
ce and its replica. | 533 // FIXME: Cache this value so that we don't have to do it for both the surfa
ce and its replica. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 GLC(context(), context()->activeTexture(GL_TEXTURE0)); | 659 GLC(context(), context()->activeTexture(GL_TEXTURE0)); |
| 659 } | 660 } |
| 660 | 661 |
| 661 if (shaderEdgeLocation != -1) { | 662 if (shaderEdgeLocation != -1) { |
| 662 float edge[24]; | 663 float edge[24]; |
| 663 deviceLayerEdges.toFloatArray(edge); | 664 deviceLayerEdges.toFloatArray(edge); |
| 664 deviceLayerBounds.toFloatArray(&edge[12]); | 665 deviceLayerBounds.toFloatArray(&edge[12]); |
| 665 GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge)); | 666 GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge)); |
| 666 } | 667 } |
| 667 | 668 |
| 668 // Map device space quad to surface space. contentsDeviceTransform has no 3d
component since it was generated with to2dTransform() so we don't need to proje
ct. | 669 // Map device space quad to surface space. contentsDeviceTransform has no 3d
component since it was flattened, so we don't need to project. |
| 669 gfx::QuadF surfaceQuad = MathUtil::mapQuad(contentsDeviceTransformInverse, d
eviceLayerEdges.ToQuadF(), clipped); | 670 gfx::QuadF surfaceQuad = MathUtil::mapQuad(contentsDeviceTransformInverse, d
eviceLayerEdges.ToQuadF(), clipped); |
| 670 DCHECK(!clipped); | 671 DCHECK(!clipped); |
| 671 | 672 |
| 672 setShaderOpacity(quad->opacity(), shaderAlphaLocation); | 673 setShaderOpacity(quad->opacity(), shaderAlphaLocation); |
| 673 setShaderQuadF(surfaceQuad, shaderQuadLocation); | 674 setShaderQuadF(surfaceQuad, shaderQuadLocation); |
| 674 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, shaderMatrixLocat
ion); | 675 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, shaderMatrixLocat
ion); |
| 675 | 676 |
| 676 // Flush the compositor context before the filter bitmap goes out of | 677 // Flush the compositor context before the filter bitmap goes out of |
| 677 // scope, so the draw gets processed before the filter texture gets deleted. | 678 // scope, so the draw gets processed before the filter texture gets deleted. |
| 678 if (filterBitmap.getTexture()) | 679 if (filterBitmap.getTexture()) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 764 |
| 764 // Map to normalized texture coordinates. | 765 // Map to normalized texture coordinates. |
| 765 const gfx::Size& textureSize = quad->texture_size; | 766 const gfx::Size& textureSize = quad->texture_size; |
| 766 float fragmentTexTranslateX = clampTexRect.x() / textureSize.width(); | 767 float fragmentTexTranslateX = clampTexRect.x() / textureSize.width(); |
| 767 float fragmentTexTranslateY = clampTexRect.y() / textureSize.height(); | 768 float fragmentTexTranslateY = clampTexRect.y() / textureSize.height(); |
| 768 float fragmentTexScaleX = clampTexRect.width() / textureSize.width(); | 769 float fragmentTexScaleX = clampTexRect.width() / textureSize.width(); |
| 769 float fragmentTexScaleY = clampTexRect.height() / textureSize.height(); | 770 float fragmentTexScaleY = clampTexRect.height() / textureSize.height(); |
| 770 | 771 |
| 771 | 772 |
| 772 gfx::QuadF localQuad; | 773 gfx::QuadF localQuad; |
| 773 gfx::Transform deviceTransform = MathUtil::to2dTransform(frame.windowMatrix
* frame.projectionMatrix * quad->quadTransform()); | 774 gfx::Transform deviceTransform = frame.windowMatrix * frame.projectionMatrix
* quad->quadTransform(); |
| 775 deviceTransform.FlattenTo2d(); |
| 774 if (!deviceTransform.IsInvertible()) | 776 if (!deviceTransform.IsInvertible()) |
| 775 return; | 777 return; |
| 776 | 778 |
| 777 bool clipped = false; | 779 bool clipped = false; |
| 778 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q
uad->visibleContentRect()), clipped); | 780 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q
uad->visibleContentRect()), clipped); |
| 779 DCHECK(!clipped); | 781 DCHECK(!clipped); |
| 780 | 782 |
| 781 TileProgramUniforms uniforms; | 783 TileProgramUniforms uniforms; |
| 782 // For now, we simply skip anti-aliasing with the quad is clipped. This only
happens | 784 // For now, we simply skip anti-aliasing with the quad is clipped. This only
happens |
| 783 // on perspective transformed layers that go partially behind the camera. | 785 // on perspective transformed layers that go partially behind the camera. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 | 856 |
| 855 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; | 857 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; |
| 856 bottomEdge.scale(sign); | 858 bottomEdge.scale(sign); |
| 857 leftEdge.scale(sign); | 859 leftEdge.scale(sign); |
| 858 topEdge.scale(sign); | 860 topEdge.scale(sign); |
| 859 rightEdge.scale(sign); | 861 rightEdge.scale(sign); |
| 860 | 862 |
| 861 // Create device space quad. | 863 // Create device space quad. |
| 862 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); | 864 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); |
| 863 | 865 |
| 864 // Map device space quad to local space. deviceTransform has no 3d compo
nent since it was generated with to2dTransform() so we don't need to project. | 866 // Map device space quad to local space. deviceTransform has no 3d compo
nent since it was flattened, so we don't need to project. |
| 865 // We should have already checked that the transform was uninvertible ab
ove. | 867 // We should have already checked that the transform was uninvertible ab
ove. |
| 866 gfx::Transform inverseDeviceTransform(gfx::Transform::kSkipInitializatio
n); | 868 gfx::Transform inverseDeviceTransform(gfx::Transform::kSkipInitializatio
n); |
| 867 bool didInvert = deviceTransform.GetInverse(&inverseDeviceTransform); | 869 bool didInvert = deviceTransform.GetInverse(&inverseDeviceTransform); |
| 868 DCHECK(didInvert); | 870 DCHECK(didInvert); |
| 869 localQuad = MathUtil::mapQuad(inverseDeviceTransform, deviceQuad.ToQuadF
(), clipped); | 871 localQuad = MathUtil::mapQuad(inverseDeviceTransform, deviceQuad.ToQuadF
(), clipped); |
| 870 | 872 |
| 871 // We should not DCHECK(!clipped) here, because anti-aliasing inflation
may cause deviceQuad to become | 873 // We should not DCHECK(!clipped) here, because anti-aliasing inflation
may cause deviceQuad to become |
| 872 // clipped. To our knowledge this scenario does not need to be handled d
ifferently than the unclipped case. | 874 // clipped. To our knowledge this scenario does not need to be handled d
ifferently than the unclipped case. |
| 873 } else { | 875 } else { |
| 874 // Move fragment shader transform to vertex shader. We can do this while | 876 // Move fragment shader transform to vertex shader. We can do this while |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 | 1797 |
| 1796 releaseRenderPassTextures(); | 1798 releaseRenderPassTextures(); |
| 1797 } | 1799 } |
| 1798 | 1800 |
| 1799 bool GLRenderer::isContextLost() | 1801 bool GLRenderer::isContextLost() |
| 1800 { | 1802 { |
| 1801 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1803 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 1802 } | 1804 } |
| 1803 | 1805 |
| 1804 } // namespace cc | 1806 } // namespace cc |
| OLD | NEW |