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

Side by Side Diff: cc/gl_renderer.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: inlines Created 8 years, 1 month 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 "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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 // Clamp texture coordinates to avoid sampling outside the layer 685 // Clamp texture coordinates to avoid sampling outside the layer
686 // by deflating the tile region half a texel or half a texel 686 // by deflating the tile region half a texel or half a texel
687 // minus epsilon for one pixel layers. The resulting clamp region 687 // minus epsilon for one pixel layers. The resulting clamp region
688 // is mapped to the unit square by the vertex shader and mapped 688 // is mapped to the unit square by the vertex shader and mapped
689 // back to normalized texture coordinates by the fragment shader 689 // back to normalized texture coordinates by the fragment shader
690 // after being clamped to 0-1 range. 690 // after being clamped to 0-1 range.
691 const float epsilon = 1 / 1024.0f; 691 const float epsilon = 1 / 1024.0f;
692 float clampX = min(0.5, clampRect.width() / 2.0 - epsilon); 692 float clampX = min(0.5, clampRect.width() / 2.0 - epsilon);
693 float clampY = min(0.5, clampRect.height() / 2.0 - epsilon); 693 float clampY = min(0.5, clampRect.height() / 2.0 - epsilon);
694 clampRect.Inset(clampX, clampY, clampX, clampY); 694 clampRect.Inset(clampX, clampY, clampX, clampY);
695 gfx::PointF clampOffset = clampRect.origin() - tileRect.origin();
696 695
697 gfx::PointF textureOffset = quad->textureOffset() + clampOffset + 696 gfx::PointF textureOffset = quad->textureOffset() + clampRect.OffsetFromOrig in() - quad->quadRect().OffsetFromOrigin();
Peter Kasting 2012/10/29 23:06:33 Nit: 80 columns
danakj 2012/10/29 23:21:41 Heh, we're not doing that in cc/ yet, it was prett
698 (tileRect.origin() - quad->quadRect().origin());
699 697
700 // Map clamping rectangle to unit square. 698 // Map clamping rectangle to unit square.
701 float vertexTexTranslateX = -clampRect.x() / clampRect.width(); 699 float vertexTexTranslateX = -clampRect.x() / clampRect.width();
702 float vertexTexTranslateY = -clampRect.y() / clampRect.height(); 700 float vertexTexTranslateY = -clampRect.y() / clampRect.height();
703 float vertexTexScaleX = tileRect.width() / clampRect.width(); 701 float vertexTexScaleX = tileRect.width() / clampRect.width();
704 float vertexTexScaleY = tileRect.height() / clampRect.height(); 702 float vertexTexScaleY = tileRect.height() / clampRect.height();
705 703
706 // Map to normalized texture coordinates. 704 // Map to normalized texture coordinates.
707 const gfx::Size& textureSize = quad->textureSize(); 705 const gfx::Size& textureSize = quad->textureSize();
708 float fragmentTexTranslateX = textureOffset.x() / textureSize.width(); 706 float fragmentTexTranslateX = textureOffset.x() / textureSize.width();
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 1590
1593 releaseRenderPassTextures(); 1591 releaseRenderPassTextures();
1594 } 1592 }
1595 1593
1596 bool GLRenderer::isContextLost() 1594 bool GLRenderer::isContextLost()
1597 { 1595 {
1598 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1596 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1599 } 1597 }
1600 1598
1601 } // namespace cc 1599 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698