Warning, /frameworks/kdeclarative/src/qmlcontrols/graphicaleffects/preserveaspect_core.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 0015 in highp vec4 qt_Vertex; 0016 in highp vec2 qt_MultiTexCoord0; 0017 0018 out highp vec2 qt_TexCoord0; 0019 0020 void main() { 0021 highp float scale = min(targetSize.x / sourceSize.x, targetSize.y / sourceSize.y); 0022 0023 highp vec2 newSize = sourceSize * scale; 0024 highp vec2 newOffset = (targetSize - newSize) / 2.0; 0025 highp vec2 uvOffset = (1.0 / newSize) * newOffset; 0026 0027 qt_TexCoord0 = -uvOffset + (targetSize / newSize) * qt_MultiTexCoord0; 0028 gl_Position = qt_Matrix * qt_Vertex; 0029 }