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