Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: cc/gl_renderer.cc

Issue 11644008: Migrate from MathUtil::inverse() to gfx::Transform::GetInverse() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Partially addressed uninvertible cases Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = MathUtil::to2dTransform(frame.windo wMatrix * frame.projectionMatrix * quadRectMatrix);
523 523
524 // Can only draw surface if device matrix is invertible. 524 // Can only draw surface if device matrix is invertible.
525 if (!contentsDeviceTransform.IsInvertible()) 525 gfx::Transform contentsDeviceTransformInverse(gfx::Transform::kSkipInitializ ation);
526 if (!contentsDeviceTransform.GetInverse(&contentsDeviceTransformInverse))
526 return; 527 return;
527 528
528 gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDe viceTransform);
529 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( 529 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
530 frame, quad, contentsDeviceTransform, contentsDeviceTransformInverse); 530 frame, quad, contentsDeviceTransform, contentsDeviceTransformInverse);
531 531
532 // 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.
533 // Apply filters to the contents texture. 533 // Apply filters to the contents texture.
534 SkBitmap filterBitmap; 534 SkBitmap filterBitmap;
535 if (quad->filter) { 535 if (quad->filter) {
536 filterBitmap = applyImageFilter(this, quad->filter.get(), contentsTextur e, m_client->hasImplThread()); 536 filterBitmap = applyImageFilter(this, quad->filter.get(), contentsTextur e, m_client->hasImplThread());
537 } else { 537 } else {
538 filterBitmap = applyFilters(this, quad->filters, contentsTexture, m_clie nt->hasImplThread()); 538 filterBitmap = applyFilters(this, quad->filters, contentsTexture, m_clie nt->hasImplThread());
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; 855 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1;
856 bottomEdge.scale(sign); 856 bottomEdge.scale(sign);
857 leftEdge.scale(sign); 857 leftEdge.scale(sign);
858 topEdge.scale(sign); 858 topEdge.scale(sign);
859 rightEdge.scale(sign); 859 rightEdge.scale(sign);
860 860
861 // Create device space quad. 861 // Create device space quad.
862 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); 862 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge);
863 863
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. 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.
865 gfx::Transform deviceTransformInverse = MathUtil::inverse(deviceTransfor m); 865 // We should have already checked that the transform was uninvertible ab ove.
866 localQuad = MathUtil::mapQuad(deviceTransformInverse, deviceQuad.ToQuadF (), clipped); 866 gfx::Transform inverseDeviceTransform(gfx::Transform::kSkipInitializatio n);
867 bool didInvert = deviceTransform.GetInverse(&inverseDeviceTransform);
868 DCHECK(didInvert);
869 localQuad = MathUtil::mapQuad(inverseDeviceTransform, deviceQuad.ToQuadF (), clipped);
867 870
868 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become 871 // We should not DCHECK(!clipped) here, because anti-aliasing inflation may cause deviceQuad to become
869 // clipped. To our knowledge this scenario does not need to be handled d ifferently than the unclipped case. 872 // clipped. To our knowledge this scenario does not need to be handled d ifferently than the unclipped case.
870 } else { 873 } else {
871 // Move fragment shader transform to vertex shader. We can do this while 874 // Move fragment shader transform to vertex shader. We can do this while
872 // still producing correct results as fragmentTexTransformLocation 875 // still producing correct results as fragmentTexTransformLocation
873 // should always be non-negative when tiles are transformed in a way 876 // should always be non-negative when tiles are transformed in a way
874 // that could result in sampling outside the layer. 877 // that could result in sampling outside the layer.
875 vertexTexScaleX *= fragmentTexScaleX; 878 vertexTexScaleX *= fragmentTexScaleX;
876 vertexTexScaleY *= fragmentTexScaleY; 879 vertexTexScaleY *= fragmentTexScaleY;
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« cc/direct_renderer.cc ('K') | « cc/direct_renderer.cc ('k') | cc/layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698