1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.compose.ui.graphics.colorspace 18 19 import androidx.compose.runtime.Immutable 20 21 /** 22 * A render intent determines how a [connector][Connector] maps colors from one color space to 23 * another. The choice of mapping is important when the source color space has a larger color gamut 24 * than the destination color space. 25 * 26 * @see ColorSpace.connect 27 */ 28 @Immutable 29 @kotlin.jvm.JvmInline 30 value class RenderIntent internal constructor(@Suppress("unused") internal val value: Int) { 31 companion object { 32 /** 33 * Compresses the source gamut into the destination gamut. This render intent affects all 34 * colors, inside and outside of destination gamut. The goal of this render intent is to 35 * preserve the visual relationship between colors. 36 * 37 * This render intent is currently not implemented and behaves like [Relative]. 38 */ 39 val Perceptual = RenderIntent(0) 40 41 /** 42 * Similar to the [Absolute] render intent, this render intent matches the closest color in 43 * the destination gamut but makes adjustments for the destination white point. 44 */ 45 val Relative = RenderIntent(1) 46 47 /** 48 * Attempts to maintain the relative saturation of colors from the source gamut to the 49 * destination gamut, to keep highly saturated colors as saturated as possible. 50 * 51 * This render intent is currently not implemented and behaves like [Relative]. 52 */ 53 val Saturation = RenderIntent(2) 54 55 /** 56 * Colors that are in the destination gamut are left unchanged. Colors that fall outside of 57 * the destination gamut are mapped to the closest possible color within the gamut of the 58 * destination color space (they are clipped). 59 */ 60 val Absolute = RenderIntent(3) 61 } 62 toStringnull63 override fun toString() = 64 when (this) { 65 Perceptual -> "Perceptual" 66 Relative -> "Relative" 67 Saturation -> "Saturation" 68 Absolute -> "Absolute" 69 else -> "Unknown" 70 } 71 } 72