Warning, /frameworks/kdeclarative/src/qmlcontrols/graphicaleffects/preserveaspect.vert is written in an unsupported language. File is not indexed.

0001 /*
0002 SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiemstra@heimr.nl>
0003 
0004 SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 // This shader performs UV coordinates that account for the aspect ratio of some
0008 // source as specified by the sourceSize uniform. The effective result is that
0009 // this results in behaviour similar to the "PreserveAspectFit" mode of QML Image.
0010 
0011 uniform highp mat4 qt_Matrix;
0012 
0013 uniform highp vec2 sourceSize;
0014 uniform highp vec2 targetSize;
0015 
0016 attribute highp vec4 qt_Vertex;
0017 attribute highp vec2 qt_MultiTexCoord0;
0018 
0019 varying highp vec2 qt_TexCoord0;
0020 
0021 void main() {
0022     highp float scale = min(targetSize.x / sourceSize.x, targetSize.y / sourceSize.y);
0023 
0024     highp vec2 newSize = sourceSize * scale;
0025     highp vec2 newOffset = (targetSize - newSize) / 2.0;
0026     highp vec2 uvOffset = (1.0 / newSize) * newOffset;
0027 
0028     qt_TexCoord0 = -uvOffset + (targetSize / newSize) * qt_MultiTexCoord0;
0029     gl_Position = qt_Matrix * qt_Vertex;
0030 }