2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Flora License, Version 1.1 (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
8 * http://floralicense.org/license/
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.
17 #include "vdrawhelper.h"
21 dest = s * ca + d * cia
23 void comp_func_solid_Source(uint32_t *dest, int length, uint32_t color,
28 if (const_alpha == 255) {
29 memfill32(dest, color, length);
31 ialpha = 255 - const_alpha;
32 color = BYTE_MUL(color, const_alpha);
33 for (i = 0; i < length; ++i)
34 dest[i] = color + BYTE_MUL(dest[i], ialpha);
40 dest = r * ca + d * cia
41 = (s + d * sia) * ca + d * cia
42 = s * ca + d * (sia * ca + cia)
43 = s * ca + d * (1 - sa*ca)
46 void comp_func_solid_SourceOver(uint32_t *dest, int length, uint32_t color,
51 if (const_alpha != 255) color = BYTE_MUL(color, const_alpha);
52 ialpha = 255 - vAlpha(color);
53 for (i = 0; i < length; ++i) dest[i] = color + BYTE_MUL(dest[i], ialpha);
56 void comp_func_Source(uint32_t *dest, const uint32_t *src, int length,
59 if (const_alpha == 255) {
60 memcpy(dest, src, size_t(length) * sizeof(uint));
62 uint ialpha = 255 - const_alpha;
63 for (int i = 0; i < length; ++i) {
65 INTERPOLATE_PIXEL_255(src[i], const_alpha, dest[i], ialpha);
71 * d' = s' + d (1 - s'a)
73 void comp_func_SourceOver(uint32_t *dest, const uint32_t *src, int length,
78 if (const_alpha == 255) {
79 for (int i = 0; i < length; ++i) {
85 dest[i] = s + BYTE_MUL(dest[i], sia);
89 /* source' = source * const_alpha
90 * dest = source' + dest ( 1- source'a)
92 for (int i = 0; i < length; ++i) {
93 uint s = BYTE_MUL(src[i], const_alpha);
95 dest[i] = s + BYTE_MUL(dest[i], sia);
100 CompositionFunctionSolid COMP_functionForModeSolid_C[] = {
101 comp_func_solid_Source, comp_func_solid_SourceOver};
103 CompositionFunction COMP_functionForMode_C[] = {comp_func_Source,
104 comp_func_SourceOver};
106 void vInitBlendFunctions() {}