/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.graphics; import android.annotation.NonNull; import android.annotation.Nullable; public enum BlendMode { /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = 0\)
*\(C_{out} = 0\)
*/ CLEAR(0), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src}\)
*\(C_{out} = C_{src}\)
*/ SRC(1), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{dst}\)
*\(C_{out} = C_{dst}\)
*/ DST(2), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} + (1 - \alpha_{src}) * \alpha_{dst}\)
*\(C_{out} = C_{src} + (1 - \alpha_{src}) * C_{dst}\)
*/ SRC_OVER(3), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{dst} + (1 - \alpha_{dst}) * \alpha_{src}\)
*\(C_{out} = C_{dst} + (1 - \alpha_{dst}) * C_{src}\)
*/ DST_OVER(4), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} * \alpha_{dst}\)
*\(C_{out} = C_{src} * \alpha_{dst}\)
*/ SRC_IN(5), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} * \alpha_{dst}\)
*\(C_{out} = C_{dst} * \alpha_{src}\)
*/ DST_IN(6), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = (1 - \alpha_{dst}) * \alpha_{src}\)
*\(C_{out} = (1 - \alpha_{dst}) * C_{src}\)
*/ SRC_OUT(7), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = (1 - \alpha_{src}) * \alpha_{dst}\)
*\(C_{out} = (1 - \alpha_{src}) * C_{dst}\)
*/ DST_OUT(8), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{dst}\)
*\(C_{out} = \alpha_{dst} * C_{src} + (1 - \alpha_{src}) * C_{dst}\)
*/ SRC_ATOP(9), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src}\)
*\(C_{out} = \alpha_{src} * C_{dst} + (1 - \alpha_{dst}) * C_{src}\)
*/ DST_ATOP(10), /** * {@usesMathJax} * *
*
*
* \(\alpha_{out} = (1 - \alpha_{dst}) * \alpha_{src} + (1 - \alpha_{src}) * \alpha_{dst}\) *
*\(C_{out} = (1 - \alpha_{dst}) * C_{src} + (1 - \alpha_{src}) * C_{dst}\)
*/ XOR(11), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = max(0, min(\alpha_{src} + \alpha_{dst}, 1))\)
*\(C_{out} = max(0, min(C_{src} + C_{dst}, 1))\)
*/ PLUS(12), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} * \alpha_{dst}\)
*\(C_{out} = C_{src} * C_{dst}\)
* */ MODULATE(13), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\)
*\(C_{out} = C_{src} + C_{dst} - C_{src} * C_{dst}\)
*/ SCREEN(14), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\)
*\(\begin{equation} * C_{out} = \begin{cases} 2 * C_{src} * C_{dst} & 2 * C_{dst} \lt \alpha_{dst} \\ * \alpha_{src} * \alpha_{dst} - 2 (\alpha_{dst} - C_{src}) (\alpha_{src} - C_{dst}) & * otherwise \end{cases} * \end{equation}\)
*/ OVERLAY(15), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\)
** \(C_{out} = * (1 - \alpha_{dst}) * C_{src} + (1 - \alpha_{src}) * C_{dst} + min(C_{src}, C_{dst})\) *
*/ DARKEN(16), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\)
** \(C_{out} = * (1 - \alpha_{dst}) * C_{src} + (1 - \alpha_{src}) * C_{dst} + max(C_{src}, C_{dst})\) *
*/ LIGHTEN(17), /** * {@usesMathJax} * *
*
*
* \(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\) *
** \begin{equation} * C_{out} = * \begin{cases} * C_{src} * (1 - \alpha_{dst}) & C_{dst} = 0 \\ * C_{src} + \alpha_{dst}*(1 - \alpha_{src}) & C_{src} = \alpha_{src} \\ * \alpha_{src} * min(\alpha_{dst}, C_{dst} * \alpha_{src}/(\alpha_{src} - C_{src})) * + C_{src} *(1 - \alpha_{dst} + \alpha_{dst}*(1 - \alpha_{src}) & otherwise * \end{cases} * \end{equation} *
*/ COLOR_DODGE(18), /** * {@usesMathJax} * *
*
*
* \(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\) *
** \begin{equation} * C_{out} = * \begin{cases} * C_{dst} + C_{src}*(1 - \alpha_{dst}) & C_{dst} = \alpha_{dst} \\ * \alpha_{dst}*(1 - \alpha_{src}) & C_{src} = 0 \\ * \alpha_{src}*(\alpha_{dst} - min(\alpha_{dst}, (\alpha_{dst} * - C_{dst})*\alpha_{src}/C_{src})) * + C_{src} * (1 - \alpha_{dst}) + \alpha_{dst}*(1-\alpha_{src}) & otherwise * \end{cases} * \end{equation} *
*/ COLOR_BURN(19), /** * {@usesMathJax} * *
*
*
* \(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\) *
** \begin{equation} * C_{out} = * \begin{cases} * 2*C_{src}*C_{dst} & C_{src}*(1-\alpha_{dst}) + C_{dst}*(1-\alpha_{src}) + 2*C_{src} * \leq \alpha_{src} \\ * \alpha_{src}*\alpha_{dst}- 2*(\alpha_{dst} - C_{dst})*(\alpha_{src} - C_{src}) * & otherwise * \end{cases} * \end{equation} *
*/ HARD_LIGHT(20), /** * {@usesMathJax} * *
*
*
* Where * \begin{equation} * m = * \begin{cases} * C_{dst} / \alpha_{dst} & \alpha_{dst} \gt 0 \\ * 0 & otherwise * \end{cases} * \end{equation} *
** \begin{equation} * g = * \begin{cases} * (16 * m * m + 4 * m) * (m - 1) + 7 * m & 4 * C_{dst} \leq \alpha_{dst} \\ * \sqrt m - m & otherwise * \end{cases} * \end{equation} *
** \begin{equation} * f = * \begin{cases} * C_{dst} * (\alpha_{src} + (2 * C_{src} - \alpha_{src}) * (1 - m)) * & 2 * C_{src} \leq \alpha_{src} \\ * C_{dst} * \alpha_{src} + \alpha_{dst} * (2 * C_{src} - \alpha_{src}) * g * & otherwise * \end{cases} * \end{equation} *
** \begin{equation} * \alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst} * \end{equation} * \begin{equation} * C_{out} = C_{src} / \alpha_{dst} + C_{dst} / \alpha_{src} + f * \end{equation} *
*/ SOFT_LIGHT(21), /** * {@usesMathJax} * *
*
*
* \begin{equation} * \alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst} * \end{equation} *
** \begin{equation} * C_{out} = C_{src} + C_{dst} - 2 * min(C_{src} * * \alpha_{dst}, C_{dst} * \alpha_{src}) * \end{equation} *
*/ DIFFERENCE(22), /** * {@usesMathJax} * *
*
*
* \begin{equation} * \alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst} * \end{equation} *
** \begin{equation} * C_{out} = C_{src} + C_{dst} - 2 * C_{src} * C_{dst} * \end{equation} *
*/ EXCLUSION(23), /** * {@usesMathJax} * *
*
*
\(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\)
*\(C_{out} = * C_{src} * (1 - \alpha_{dst}) + C_{dst} * (1 - \alpha_{src}) + (C_{src} * C_{dst})\) *
*/ MULTIPLY(24), /** * {@usesMathJax} * *
*
*
*
*
*
*
*
*