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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = MathUtil::to2dTransform(frame.windo
wMatrix * frame.projectionMatrix * quadRectMatrix); |
522 | 522 |
523 // Can only draw surface if device matrix is invertible. | 523 // Can only draw surface if device matrix is invertible. |
524 if (!contentsDeviceTransform.IsInvertible()) | 524 gfx::Transform contentsDeviceTransformInverse(gfx::Transform::kSkipInitializ
ation); |
| 525 if (!contentsDeviceTransform.GetInverse(&contentsDeviceTransformInverse)) |
525 return; | 526 return; |
526 | 527 |
527 gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDe
viceTransform); | |
528 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( | 528 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( |
529 frame, quad, contentsDeviceTransform, contentsDeviceTransformInverse); | 529 frame, quad, contentsDeviceTransform, contentsDeviceTransformInverse); |
530 | 530 |
531 // FIXME: Cache this value so that we don't have to do it for both the surfa
ce and its replica. | 531 // FIXME: Cache this value so that we don't have to do it for both the surfa
ce and its replica. |
532 // Apply filters to the contents texture. | 532 // Apply filters to the contents texture. |
533 SkBitmap filterBitmap; | 533 SkBitmap filterBitmap; |
534 if (quad->filter) { | 534 if (quad->filter) { |
535 filterBitmap = applyImageFilter(this, quad->filter.get(), contentsTextur
e, m_client->hasImplThread()); | 535 filterBitmap = applyImageFilter(this, quad->filter.get(), contentsTextur
e, m_client->hasImplThread()); |
536 } else { | 536 } else { |
537 filterBitmap = applyFilters(this, quad->filters, contentsTexture, m_clie
nt->hasImplThread()); | 537 filterBitmap = applyFilters(this, quad->filters, contentsTexture, m_clie
nt->hasImplThread()); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; | 854 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; |
855 bottomEdge.scale(sign); | 855 bottomEdge.scale(sign); |
856 leftEdge.scale(sign); | 856 leftEdge.scale(sign); |
857 topEdge.scale(sign); | 857 topEdge.scale(sign); |
858 rightEdge.scale(sign); | 858 rightEdge.scale(sign); |
859 | 859 |
860 // Create device space quad. | 860 // Create device space quad. |
861 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); | 861 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); |
862 | 862 |
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. | 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. |
864 gfx::Transform deviceTransformInverse = MathUtil::inverse(deviceTransfor
m); | 864 // We should have already checked that the transform was uninvertible ab
ove. |
865 localQuad = MathUtil::mapQuad(deviceTransformInverse, deviceQuad.ToQuadF
(), clipped); | 865 gfx::Transform inverseDeviceTransform(gfx::Transform::kSkipInitializatio
n); |
| 866 bool didInvert = deviceTransform.GetInverse(&inverseDeviceTransform); |
| 867 DCHECK(didInvert); |
| 868 localQuad = MathUtil::mapQuad(inverseDeviceTransform, deviceQuad.ToQuadF
(), clipped); |
866 | 869 |
867 // We should not DCHECK(!clipped) here, because anti-aliasing inflation
may cause deviceQuad to become | 870 // We should not DCHECK(!clipped) here, because anti-aliasing inflation
may cause deviceQuad to become |
868 // clipped. To our knowledge this scenario does not need to be handled d
ifferently than the unclipped case. | 871 // clipped. To our knowledge this scenario does not need to be handled d
ifferently than the unclipped case. |
869 } else { | 872 } else { |
870 // Move fragment shader transform to vertex shader. We can do this while | 873 // Move fragment shader transform to vertex shader. We can do this while |
871 // still producing correct results as fragmentTexTransformLocation | 874 // still producing correct results as fragmentTexTransformLocation |
872 // should always be non-negative when tiles are transformed in a way | 875 // should always be non-negative when tiles are transformed in a way |
873 // that could result in sampling outside the layer. | 876 // that could result in sampling outside the layer. |
874 vertexTexScaleX *= fragmentTexScaleX; | 877 vertexTexScaleX *= fragmentTexScaleX; |
875 vertexTexScaleY *= fragmentTexScaleY; | 878 vertexTexScaleY *= fragmentTexScaleY; |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 | 1794 |
1792 releaseRenderPassTextures(); | 1795 releaseRenderPassTextures(); |
1793 } | 1796 } |
1794 | 1797 |
1795 bool GLRenderer::isContextLost() | 1798 bool GLRenderer::isContextLost() |
1796 { | 1799 { |
1797 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1800 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1798 } | 1801 } |
1799 | 1802 |
1800 } // namespace cc | 1803 } // namespace cc |
OLD | NEW |