mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Camera and editor improvements
This commit is contained in:
parent
ceaa808fad
commit
fc999d8042
@ -1200,6 +1200,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
|||||||
.opacity(controlsAreVisible ? 1.0 : 0.0)
|
.opacity(controlsAreVisible ? 1.0 : 0.0)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var additionalBottomInset: CGFloat = 0.0
|
||||||
|
if component.sourceHint == .storyEditor {
|
||||||
|
additionalBottomInset = max(0.0, previewBottomInset - environment.safeInsets.bottom - 49.0)
|
||||||
|
}
|
||||||
|
|
||||||
if let textEntity = state.selectedEntity as? DrawingTextEntity {
|
if let textEntity = state.selectedEntity as? DrawingTextEntity {
|
||||||
let textSettings = textSettings.update(
|
let textSettings = textSettings.update(
|
||||||
component: TextSettingsComponent(
|
component: TextSettingsComponent(
|
||||||
@ -1277,7 +1282,7 @@ private final class DrawingScreenComponent: CombinedComponent {
|
|||||||
transition: context.transition
|
transition: context.transition
|
||||||
)
|
)
|
||||||
context.add(textSettings
|
context.add(textSettings
|
||||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - environment.safeInsets.bottom - textSettings.size.height / 2.0 - 89.0))
|
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - environment.safeInsets.bottom - textSettings.size.height / 2.0 - 89.0 - additionalBottomInset))
|
||||||
.appear(Transition.Appear({ _, view, transition in
|
.appear(Transition.Appear({ _, view, transition in
|
||||||
if let view = view as? TextSettingsComponent.View, !transition.animation.isImmediate {
|
if let view = view as? TextSettingsComponent.View, !transition.animation.isImmediate {
|
||||||
view.animateIn()
|
view.animateIn()
|
||||||
@ -1293,11 +1298,6 @@ private final class DrawingScreenComponent: CombinedComponent {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var additionalBottomInset: CGFloat = 0.0
|
|
||||||
if component.sourceHint == .storyEditor {
|
|
||||||
additionalBottomInset = max(0.0, previewBottomInset - environment.safeInsets.bottom - 49.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
let rightButtonPosition = rightEdge - 24.0
|
let rightButtonPosition = rightEdge - 24.0
|
||||||
var offsetX: CGFloat = leftEdge + 24.0
|
var offsetX: CGFloat = leftEdge + 24.0
|
||||||
let delta: CGFloat = (rightButtonPosition - offsetX) / 7.0
|
let delta: CGFloat = (rightButtonPosition - offsetX) / 7.0
|
||||||
|
@ -4,6 +4,30 @@
|
|||||||
|
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
|
|
||||||
|
static inline
|
||||||
|
float sRGB_nonLinearNormToLinear(float normV)
|
||||||
|
{
|
||||||
|
if (normV <= 0.04045f) {
|
||||||
|
normV *= (1.0f / 12.92f);
|
||||||
|
} else {
|
||||||
|
const float a = 0.055f;
|
||||||
|
const float gamma = 2.4f;
|
||||||
|
//const float gamma = 1.0f / (1.0f / 2.4f);
|
||||||
|
normV = (normV + a) * (1.0f / (1.0f + a));
|
||||||
|
normV = pow(normV, gamma);
|
||||||
|
}
|
||||||
|
|
||||||
|
return normV;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline
|
||||||
|
float4 sRGB_gamma_decode(const float4 rgba) {
|
||||||
|
rgba.r = sRGB_nonLinearNormToLinear(rgba.r);
|
||||||
|
rgba.g = sRGB_nonLinearNormToLinear(rgba.g);
|
||||||
|
rgba.b = sRGB_nonLinearNormToLinear(rgba.b);
|
||||||
|
return rgba;
|
||||||
|
}
|
||||||
|
|
||||||
static inline float4 BT709_decode(const float Y, const float Cb, const float Cr) {
|
static inline float4 BT709_decode(const float Y, const float Cb, const float Cr) {
|
||||||
float Yn = Y;
|
float Yn = Y;
|
||||||
|
|
||||||
@ -13,8 +37,8 @@ static inline float4 BT709_decode(const float Y, const float Cb, const float Cr)
|
|||||||
float3 YCbCr = float3(Yn, Cbn, Crn);
|
float3 YCbCr = float3(Yn, Cbn, Crn);
|
||||||
|
|
||||||
const float3x3 kColorConversion709 = float3x3(float3(1.0, 1.0, 1.0),
|
const float3x3 kColorConversion709 = float3x3(float3(1.0, 1.0, 1.0),
|
||||||
float3(0.0f, -0.1873, 1.8556),
|
float3(0.0f, -0.18732, 1.8556),
|
||||||
float3(1.5748, -0.4681, 0.0));
|
float3(1.5748, -0.46812, 0.0));
|
||||||
|
|
||||||
float3 rgb = kColorConversion709 * YCbCr;
|
float3 rgb = kColorConversion709 * YCbCr;
|
||||||
|
|
||||||
@ -23,7 +47,6 @@ static inline float4 BT709_decode(const float Y, const float Cb, const float Cr)
|
|||||||
return float4(rgb.r, rgb.g, rgb.b, 1.0f);
|
return float4(rgb.r, rgb.g, rgb.b, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fragment float4 bt709ToRGBFragmentShader(RasterizerData in [[stage_in]],
|
fragment float4 bt709ToRGBFragmentShader(RasterizerData in [[stage_in]],
|
||||||
texture2d<half, access::sample> inYTexture [[texture(0)]],
|
texture2d<half, access::sample> inYTexture [[texture(0)]],
|
||||||
texture2d<half, access::sample> inUVTexture [[texture(1)]]
|
texture2d<half, access::sample> inUVTexture [[texture(1)]]
|
||||||
@ -38,5 +61,7 @@ fragment float4 bt709ToRGBFragmentShader(RasterizerData in [[stage_in]],
|
|||||||
float Cr = float(uvSamples[1]);
|
float Cr = float(uvSamples[1]);
|
||||||
|
|
||||||
float4 pixel = BT709_decode(Y, Cb, Cr);
|
float4 pixel = BT709_decode(Y, Cb, Cr);
|
||||||
|
pixel = sRGB_gamma_decode(pixel);
|
||||||
|
pixel.rgb = pow(pixel.rgb, 1.0 / 2.2);
|
||||||
return pixel;
|
return pixel;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ final class VideoInputPass: DefaultRenderPass {
|
|||||||
textureDescriptor.textureType = .type2D
|
textureDescriptor.textureType = .type2D
|
||||||
textureDescriptor.width = outputWidth
|
textureDescriptor.width = outputWidth
|
||||||
textureDescriptor.height = outputHeight
|
textureDescriptor.height = outputHeight
|
||||||
textureDescriptor.pixelFormat = .bgra8Unorm
|
textureDescriptor.pixelFormat = self.pixelFormat
|
||||||
textureDescriptor.storageMode = .private
|
textureDescriptor.storageMode = .private
|
||||||
textureDescriptor.usage = [.shaderRead, .shaderWrite, .renderTarget]
|
textureDescriptor.usage = [.shaderRead, .shaderWrite, .renderTarget]
|
||||||
if let texture = device.makeTexture(descriptor: textureDescriptor) {
|
if let texture = device.makeTexture(descriptor: textureDescriptor) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user