blob: 0a6fb88c2b6218f5c397e72c9c0e6126e91c67de [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COLOR_GLSL_
#define COLOR_GLSL_
#include <impeller/branching.glsl>
/// Convert a premultiplied color (a color which has its color components
/// multiplied with its alpha value) to an unpremultiplied color.
///
/// Returns (0, 0, 0, 0) if the alpha component is 0.
vec4 IPUnpremultiply(vec4 color) {
if (color.a == 0) {
return vec4(0);
}
return vec4(color.rgb / color.a, color.a);
}
#endif