| 1 | /* alphaover.cpp |
| 2 | * Copyright (C) 2005 Jean-Sebastien Senecal ([email protected]) |
| 3 | * This file is a Frei0r plugin. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "frei0r.hpp"cxx . . $ `<file>/include/frei0r.hpp`/ |
| 21 | #include "frei0r/math.h"cxx . . $ `<file>/include/frei0r/math.h`/ |
| 22 | |
| 23 | #include <algorithm> |
| 24 | |
| 25 | class alphaovercxx . . $ alphaover# : public frei0rcxx . . $ frei0r/::mixer2cxx . . $ frei0r/mixer2# |
| 26 | { |
| 27 | public: |
| 28 | alphaovercxx . . $ alphaover#alphaover(b4d55b1286ff73e8).(unsigned int width, unsigned int height) |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | void updatecxx . . $ alphaover#update(aea6c563decfb03a).(double time, |
| 33 | uint32_t* out, |
| 34 | const uint32_t* in1, |
| 35 | const uint32_t* in2) |
| 36 | { |
| 37 | uint8_t *dst = reinterpret_cast<uint8_t*>(out); |
| 38 | const uint8_t *src1 = reinterpret_cast<const uint8_t*>(in1); |
| 39 | const uint8_t *src2 = reinterpret_cast<const uint8_t*>(in2); |
| 40 | |
| 41 | for (unsigned int i=0; i<sizecxx . . $ frei0r/fx#size.; ++i) |
| 42 | { |
| 43 | uint32_t tmp1, tmp2; |
| 44 | uint8_t alpha_src1 = src1[3]; |
| 45 | uint8_t alpha_src2 = src2[3]; |
| 46 | uint8_t alpha_dst; |
| 47 | uint8_t w2 = 0xff ^ alpha_src1; // w2 = 255 - alpha_1 |
| 48 | |
| 49 | // compute destination alpha |
| 50 | alpha_dst = dst[3] = INT_MULTcxx . . $ `include/frei0r/math.h:31:9`!(alpha_src1, alpha_src1, tmp1) + INT_MULT3cxx . . $ `include/frei0r/math.h:38:9`!(alpha_src2, alpha_src2, w2, tmp2); |
| 51 | |
| 52 | // compute destination values |
| 53 | if (alpha_dst == 0) |
| 54 | for (int b=0; b<3; ++b) |
| 55 | dst[b] = 0; |
| 56 | else |
| 57 | for (int b=0; b<3; ++b) |
| 58 | dst[b] = CLAMP0255cxx . . $ CLAMP0255(bc0fba5608a0bfe7).( (uint32_t)( (uint32_t) (src1[b] * alpha_src1 + INT_MULTcxx . . $ `include/frei0r/math.h:31:9`!(src2[b], alpha_src2, tmp1) * w2) / alpha_dst) ); |
| 59 | |
| 60 | src1 += 4; |
| 61 | src2 += 4; |
| 62 | dst += 4; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | }; |
| 67 | |
| 68 | |
| 69 | frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<alphaovercxx . . $ alphaover#> plugincxx . . $ plugin.("alphaover"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 70 | "the alpha OVER operation"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 71 | "Jean-Sebastien Senecal"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 72 | 0,2, |
| 73 | F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!); |
| 74 |