OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fxge/dib/dib_int.h" | 7 #include "core/fxge/dib/dib_int.h" |
8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
9 #include "core/include/fxge/fx_ge.h" | 9 #include "core/include/fxge/fx_ge.h" |
10 | 10 |
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 int back_alpha = *dest_alpha_scan; | 2142 int back_alpha = *dest_alpha_scan; |
2143 uint8_t dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; | 2143 uint8_t dest_alpha = back_alpha + src_alpha - back_alpha * src_alpha / 255; |
2144 *dest_alpha_scan++ = dest_alpha; | 2144 *dest_alpha_scan++ = dest_alpha; |
2145 int alpha_ratio = src_alpha * 255 / dest_alpha; | 2145 int alpha_ratio = src_alpha * 255 / dest_alpha; |
2146 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); | 2146 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); |
2147 dest_scan++; | 2147 dest_scan++; |
2148 } | 2148 } |
2149 } | 2149 } |
2150 inline void _CompositeRow_8bppRgb2Rgb_NoBlend(uint8_t* dest_scan, | 2150 inline void _CompositeRow_8bppRgb2Rgb_NoBlend(uint8_t* dest_scan, |
2151 const uint8_t* src_scan, | 2151 const uint8_t* src_scan, |
2152 FX_DWORD* pPalette, | 2152 uint32_t* pPalette, |
2153 int pixel_count, | 2153 int pixel_count, |
2154 int DestBpp, | 2154 int DestBpp, |
2155 const uint8_t* clip_scan, | 2155 const uint8_t* clip_scan, |
2156 const uint8_t* src_alpha_scan) { | 2156 const uint8_t* src_alpha_scan) { |
2157 if (src_alpha_scan) { | 2157 if (src_alpha_scan) { |
2158 int dest_gap = DestBpp - 3; | 2158 int dest_gap = DestBpp - 3; |
2159 FX_ARGB argb = 0; | 2159 FX_ARGB argb = 0; |
2160 for (int col = 0; col < pixel_count; col++) { | 2160 for (int col = 0; col < pixel_count; col++) { |
2161 argb = pPalette[*src_scan]; | 2161 argb = pPalette[*src_scan]; |
2162 int src_r = FXARGB_R(argb); | 2162 int src_r = FXARGB_R(argb); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 if (DestBpp == 4) { | 2210 if (DestBpp == 4) { |
2211 dest_scan++; | 2211 dest_scan++; |
2212 } | 2212 } |
2213 src_scan++; | 2213 src_scan++; |
2214 } | 2214 } |
2215 } | 2215 } |
2216 } | 2216 } |
2217 inline void _CompositeRow_1bppRgb2Rgb_NoBlend(uint8_t* dest_scan, | 2217 inline void _CompositeRow_1bppRgb2Rgb_NoBlend(uint8_t* dest_scan, |
2218 const uint8_t* src_scan, | 2218 const uint8_t* src_scan, |
2219 int src_left, | 2219 int src_left, |
2220 FX_DWORD* pPalette, | 2220 uint32_t* pPalette, |
2221 int pixel_count, | 2221 int pixel_count, |
2222 int DestBpp, | 2222 int DestBpp, |
2223 const uint8_t* clip_scan) { | 2223 const uint8_t* clip_scan) { |
2224 int reset_r, reset_g, reset_b; | 2224 int reset_r, reset_g, reset_b; |
2225 int set_r, set_g, set_b; | 2225 int set_r, set_g, set_b; |
2226 reset_r = FXARGB_R(pPalette[0]); | 2226 reset_r = FXARGB_R(pPalette[0]); |
2227 reset_g = FXARGB_G(pPalette[0]); | 2227 reset_g = FXARGB_G(pPalette[0]); |
2228 reset_b = FXARGB_B(pPalette[0]); | 2228 reset_b = FXARGB_B(pPalette[0]); |
2229 set_r = FXARGB_R(pPalette[1]); | 2229 set_r = FXARGB_R(pPalette[1]); |
2230 set_g = FXARGB_G(pPalette[1]); | 2230 set_g = FXARGB_G(pPalette[1]); |
(...skipping 22 matching lines...) Expand all Loading... |
2253 *dest_scan++ = src_r; | 2253 *dest_scan++ = src_r; |
2254 } | 2254 } |
2255 if (DestBpp == 4) { | 2255 if (DestBpp == 4) { |
2256 dest_scan++; | 2256 dest_scan++; |
2257 } | 2257 } |
2258 } | 2258 } |
2259 } | 2259 } |
2260 inline void _CompositeRow_8bppRgb2Argb_NoBlend(uint8_t* dest_scan, | 2260 inline void _CompositeRow_8bppRgb2Argb_NoBlend(uint8_t* dest_scan, |
2261 const uint8_t* src_scan, | 2261 const uint8_t* src_scan, |
2262 int width, | 2262 int width, |
2263 FX_DWORD* pPalette, | 2263 uint32_t* pPalette, |
2264 const uint8_t* clip_scan, | 2264 const uint8_t* clip_scan, |
2265 const uint8_t* src_alpha_scan) { | 2265 const uint8_t* src_alpha_scan) { |
2266 if (src_alpha_scan) { | 2266 if (src_alpha_scan) { |
2267 for (int col = 0; col < width; col++) { | 2267 for (int col = 0; col < width; col++) { |
2268 FX_ARGB argb = pPalette[*src_scan]; | 2268 FX_ARGB argb = pPalette[*src_scan]; |
2269 src_scan++; | 2269 src_scan++; |
2270 int src_r = FXARGB_R(argb); | 2270 int src_r = FXARGB_R(argb); |
2271 int src_g = FXARGB_G(argb); | 2271 int src_g = FXARGB_G(argb); |
2272 int src_b = FXARGB_B(argb); | 2272 int src_b = FXARGB_B(argb); |
2273 uint8_t back_alpha = dest_scan[3]; | 2273 uint8_t back_alpha = dest_scan[3]; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2338 dest_scan++; | 2338 dest_scan++; |
2339 dest_scan++; | 2339 dest_scan++; |
2340 src_scan++; | 2340 src_scan++; |
2341 } | 2341 } |
2342 } | 2342 } |
2343 } | 2343 } |
2344 | 2344 |
2345 void _CompositeRow_8bppRgb2Rgba_NoBlend(uint8_t* dest_scan, | 2345 void _CompositeRow_8bppRgb2Rgba_NoBlend(uint8_t* dest_scan, |
2346 const uint8_t* src_scan, | 2346 const uint8_t* src_scan, |
2347 int width, | 2347 int width, |
2348 FX_DWORD* pPalette, | 2348 uint32_t* pPalette, |
2349 const uint8_t* clip_scan, | 2349 const uint8_t* clip_scan, |
2350 uint8_t* dest_alpha_scan, | 2350 uint8_t* dest_alpha_scan, |
2351 const uint8_t* src_alpha_scan) { | 2351 const uint8_t* src_alpha_scan) { |
2352 if (src_alpha_scan) { | 2352 if (src_alpha_scan) { |
2353 for (int col = 0; col < width; col++) { | 2353 for (int col = 0; col < width; col++) { |
2354 FX_ARGB argb = pPalette[*src_scan]; | 2354 FX_ARGB argb = pPalette[*src_scan]; |
2355 src_scan++; | 2355 src_scan++; |
2356 int src_r = FXARGB_R(argb); | 2356 int src_r = FXARGB_R(argb); |
2357 int src_g = FXARGB_G(argb); | 2357 int src_g = FXARGB_G(argb); |
2358 int src_b = FXARGB_B(argb); | 2358 int src_b = FXARGB_B(argb); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 dest_scan++; | 2426 dest_scan++; |
2427 src_scan++; | 2427 src_scan++; |
2428 } | 2428 } |
2429 } | 2429 } |
2430 } | 2430 } |
2431 | 2431 |
2432 inline void _CompositeRow_1bppRgb2Argb_NoBlend(uint8_t* dest_scan, | 2432 inline void _CompositeRow_1bppRgb2Argb_NoBlend(uint8_t* dest_scan, |
2433 const uint8_t* src_scan, | 2433 const uint8_t* src_scan, |
2434 int src_left, | 2434 int src_left, |
2435 int width, | 2435 int width, |
2436 FX_DWORD* pPalette, | 2436 uint32_t* pPalette, |
2437 const uint8_t* clip_scan) { | 2437 const uint8_t* clip_scan) { |
2438 int reset_r, reset_g, reset_b; | 2438 int reset_r, reset_g, reset_b; |
2439 int set_r, set_g, set_b; | 2439 int set_r, set_g, set_b; |
2440 reset_r = FXARGB_R(pPalette[0]); | 2440 reset_r = FXARGB_R(pPalette[0]); |
2441 reset_g = FXARGB_G(pPalette[0]); | 2441 reset_g = FXARGB_G(pPalette[0]); |
2442 reset_b = FXARGB_B(pPalette[0]); | 2442 reset_b = FXARGB_B(pPalette[0]); |
2443 set_r = FXARGB_R(pPalette[1]); | 2443 set_r = FXARGB_R(pPalette[1]); |
2444 set_g = FXARGB_G(pPalette[1]); | 2444 set_g = FXARGB_G(pPalette[1]); |
2445 set_b = FXARGB_B(pPalette[1]); | 2445 set_b = FXARGB_B(pPalette[1]); |
2446 for (int col = 0; col < width; col++) { | 2446 for (int col = 0; col < width; col++) { |
(...skipping 29 matching lines...) Expand all Loading... |
2476 dest_scan++; | 2476 dest_scan++; |
2477 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); | 2477 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio); |
2478 dest_scan++; | 2478 dest_scan++; |
2479 dest_scan++; | 2479 dest_scan++; |
2480 } | 2480 } |
2481 } | 2481 } |
2482 void _CompositeRow_1bppRgb2Rgba_NoBlend(uint8_t* dest_scan, | 2482 void _CompositeRow_1bppRgb2Rgba_NoBlend(uint8_t* dest_scan, |
2483 const uint8_t* src_scan, | 2483 const uint8_t* src_scan, |
2484 int src_left, | 2484 int src_left, |
2485 int width, | 2485 int width, |
2486 FX_DWORD* pPalette, | 2486 uint32_t* pPalette, |
2487 const uint8_t* clip_scan, | 2487 const uint8_t* clip_scan, |
2488 uint8_t* dest_alpha_scan) { | 2488 uint8_t* dest_alpha_scan) { |
2489 int reset_r, reset_g, reset_b; | 2489 int reset_r, reset_g, reset_b; |
2490 int set_r, set_g, set_b; | 2490 int set_r, set_g, set_b; |
2491 reset_r = FXARGB_R(pPalette[0]); | 2491 reset_r = FXARGB_R(pPalette[0]); |
2492 reset_g = FXARGB_G(pPalette[0]); | 2492 reset_g = FXARGB_G(pPalette[0]); |
2493 reset_b = FXARGB_B(pPalette[0]); | 2493 reset_b = FXARGB_B(pPalette[0]); |
2494 set_r = FXARGB_R(pPalette[1]); | 2494 set_r = FXARGB_R(pPalette[1]); |
2495 set_g = FXARGB_G(pPalette[1]); | 2495 set_g = FXARGB_G(pPalette[1]); |
2496 set_b = FXARGB_B(pPalette[1]); | 2496 set_b = FXARGB_B(pPalette[1]); |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3952 dest_scan[1] = FX_GAMMA_INVERSE( | 3952 dest_scan[1] = FX_GAMMA_INVERSE( |
3953 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[1]), src_g, src_alpha)); | 3953 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[1]), src_g, src_alpha)); |
3954 dest_scan[0] = FX_GAMMA_INVERSE( | 3954 dest_scan[0] = FX_GAMMA_INVERSE( |
3955 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[0]), src_r, src_alpha)); | 3955 FXDIB_ALPHA_MERGE(FX_GAMMA(dest_scan[0]), src_r, src_alpha)); |
3956 } | 3956 } |
3957 dest_scan += Bpp; | 3957 dest_scan += Bpp; |
3958 } | 3958 } |
3959 } | 3959 } |
3960 inline FX_BOOL _ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, | 3960 inline FX_BOOL _ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, |
3961 int alpha_flag, | 3961 int alpha_flag, |
3962 FX_DWORD mask_color, | 3962 uint32_t mask_color, |
3963 int& mask_alpha, | 3963 int& mask_alpha, |
3964 int& mask_red, | 3964 int& mask_red, |
3965 int& mask_green, | 3965 int& mask_green, |
3966 int& mask_blue, | 3966 int& mask_blue, |
3967 int& mask_black, | 3967 int& mask_black, |
3968 void* icc_module, | 3968 void* icc_module, |
3969 void* pIccTransform) { | 3969 void* pIccTransform) { |
3970 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; | 3970 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; |
3971 if (alpha_flag >> 8) { | 3971 if (alpha_flag >> 8) { |
3972 mask_alpha = alpha_flag & 0xff; | 3972 mask_alpha = alpha_flag & 0xff; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4019 mask_color_p[0]); | 4019 mask_color_p[0]); |
4020 mask_red = mask_color_p[2]; | 4020 mask_red = mask_color_p[2]; |
4021 mask_green = mask_color_p[1]; | 4021 mask_green = mask_color_p[1]; |
4022 mask_blue = mask_color_p[0]; | 4022 mask_blue = mask_color_p[0]; |
4023 } | 4023 } |
4024 } | 4024 } |
4025 return TRUE; | 4025 return TRUE; |
4026 } | 4026 } |
4027 inline void _ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format, | 4027 inline void _ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format, |
4028 FXDIB_Format dest_format, | 4028 FXDIB_Format dest_format, |
4029 FX_DWORD*& pDestPalette, | 4029 uint32_t*& pDestPalette, |
4030 FX_DWORD* pSrcPalette, | 4030 uint32_t* pSrcPalette, |
4031 void* icc_module, | 4031 void* icc_module, |
4032 void* pIccTransform) { | 4032 void* pIccTransform) { |
4033 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; | 4033 ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module; |
4034 FX_BOOL isSrcCmyk = !!(src_format & 0x0400); | 4034 FX_BOOL isSrcCmyk = !!(src_format & 0x0400); |
4035 FX_BOOL isDstCmyk = !!(dest_format & 0x0400); | 4035 FX_BOOL isDstCmyk = !!(dest_format & 0x0400); |
4036 pDestPalette = NULL; | 4036 pDestPalette = NULL; |
4037 if (pIccTransform) { | 4037 if (pIccTransform) { |
4038 if (pSrcPalette) { | 4038 if (pSrcPalette) { |
4039 if ((dest_format & 0xff) == 8) { | 4039 if ((dest_format & 0xff) == 8) { |
4040 int pal_count = 1 << (src_format & 0xff); | 4040 int pal_count = 1 << (src_format & 0xff); |
4041 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); | 4041 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); |
4042 pDestPalette = (FX_DWORD*)gray_pal; | 4042 pDestPalette = (uint32_t*)gray_pal; |
4043 for (int i = 0; i < pal_count; i++) { | 4043 for (int i = 0; i < pal_count; i++) { |
4044 FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) | 4044 uint32_t color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) |
4045 : FXARGB_TODIB(pSrcPalette[i]); | 4045 : FXARGB_TODIB(pSrcPalette[i]); |
4046 pIccModule->TranslateScanline(pIccTransform, gray_pal, | 4046 pIccModule->TranslateScanline(pIccTransform, gray_pal, |
4047 (const uint8_t*)&color, 1); | 4047 (const uint8_t*)&color, 1); |
4048 gray_pal++; | 4048 gray_pal++; |
4049 } | 4049 } |
4050 } else { | 4050 } else { |
4051 int palsize = 1 << (src_format & 0xff); | 4051 int palsize = 1 << (src_format & 0xff); |
4052 pDestPalette = FX_Alloc(FX_DWORD, palsize); | 4052 pDestPalette = FX_Alloc(uint32_t, palsize); |
4053 for (int i = 0; i < palsize; i++) { | 4053 for (int i = 0; i < palsize; i++) { |
4054 FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) | 4054 uint32_t color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) |
4055 : FXARGB_TODIB(pSrcPalette[i]); | 4055 : FXARGB_TODIB(pSrcPalette[i]); |
4056 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, | 4056 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, |
4057 (const uint8_t*)&color, 1); | 4057 (const uint8_t*)&color, 1); |
4058 pDestPalette[i] = | 4058 pDestPalette[i] = |
4059 isDstCmyk ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); | 4059 isDstCmyk ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
4060 } | 4060 } |
4061 } | 4061 } |
4062 } else { | 4062 } else { |
4063 int pal_count = 1 << (src_format & 0xff); | 4063 int pal_count = 1 << (src_format & 0xff); |
4064 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); | 4064 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); |
4065 if (pal_count == 2) { | 4065 if (pal_count == 2) { |
4066 gray_pal[0] = 0; | 4066 gray_pal[0] = 0; |
4067 gray_pal[1] = 255; | 4067 gray_pal[1] = 255; |
4068 } else { | 4068 } else { |
4069 for (int i = 0; i < pal_count; i++) { | 4069 for (int i = 0; i < pal_count; i++) { |
4070 gray_pal[i] = i; | 4070 gray_pal[i] = i; |
4071 } | 4071 } |
4072 } | 4072 } |
4073 if ((dest_format & 0xff) == 8) { | 4073 if ((dest_format & 0xff) == 8) { |
4074 pIccModule->TranslateScanline(pIccTransform, gray_pal, gray_pal, | 4074 pIccModule->TranslateScanline(pIccTransform, gray_pal, gray_pal, |
4075 pal_count); | 4075 pal_count); |
4076 pDestPalette = (FX_DWORD*)gray_pal; | 4076 pDestPalette = (uint32_t*)gray_pal; |
4077 } else { | 4077 } else { |
4078 pDestPalette = FX_Alloc(FX_DWORD, pal_count); | 4078 pDestPalette = FX_Alloc(uint32_t, pal_count); |
4079 for (int i = 0; i < pal_count; i++) { | 4079 for (int i = 0; i < pal_count; i++) { |
4080 pIccModule->TranslateScanline( | 4080 pIccModule->TranslateScanline( |
4081 pIccTransform, (uint8_t*)&pDestPalette[i], &gray_pal[i], 1); | 4081 pIccTransform, (uint8_t*)&pDestPalette[i], &gray_pal[i], 1); |
4082 pDestPalette[i] = isDstCmyk ? FXCMYK_TODIB(pDestPalette[i]) | 4082 pDestPalette[i] = isDstCmyk ? FXCMYK_TODIB(pDestPalette[i]) |
4083 : FXARGB_TODIB(pDestPalette[i]); | 4083 : FXARGB_TODIB(pDestPalette[i]); |
4084 } | 4084 } |
4085 FX_Free(gray_pal); | 4085 FX_Free(gray_pal); |
4086 } | 4086 } |
4087 } | 4087 } |
4088 } else { | 4088 } else { |
4089 if (pSrcPalette) { | 4089 if (pSrcPalette) { |
4090 if ((dest_format & 0xff) == 8) { | 4090 if ((dest_format & 0xff) == 8) { |
4091 int pal_count = 1 << (src_format & 0xff); | 4091 int pal_count = 1 << (src_format & 0xff); |
4092 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); | 4092 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); |
4093 pDestPalette = (FX_DWORD*)gray_pal; | 4093 pDestPalette = (uint32_t*)gray_pal; |
4094 if (isSrcCmyk) { | 4094 if (isSrcCmyk) { |
4095 for (int i = 0; i < pal_count; i++) { | 4095 for (int i = 0; i < pal_count; i++) { |
4096 FX_CMYK cmyk = pSrcPalette[i]; | 4096 FX_CMYK cmyk = pSrcPalette[i]; |
4097 uint8_t r, g, b; | 4097 uint8_t r, g, b; |
4098 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), | 4098 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), |
4099 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, | 4099 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, |
4100 g, b); | 4100 g, b); |
4101 *gray_pal++ = FXRGB2GRAY(r, g, b); | 4101 *gray_pal++ = FXRGB2GRAY(r, g, b); |
4102 } | 4102 } |
4103 } else { | 4103 } else { |
4104 for (int i = 0; i < pal_count; i++) { | 4104 for (int i = 0; i < pal_count; i++) { |
4105 FX_ARGB argb = pSrcPalette[i]; | 4105 FX_ARGB argb = pSrcPalette[i]; |
4106 *gray_pal++ = | 4106 *gray_pal++ = |
4107 FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb)); | 4107 FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb)); |
4108 } | 4108 } |
4109 } | 4109 } |
4110 } else { | 4110 } else { |
4111 int palsize = 1 << (src_format & 0xff); | 4111 int palsize = 1 << (src_format & 0xff); |
4112 pDestPalette = FX_Alloc(FX_DWORD, palsize); | 4112 pDestPalette = FX_Alloc(uint32_t, palsize); |
4113 if (isDstCmyk == isSrcCmyk) { | 4113 if (isDstCmyk == isSrcCmyk) { |
4114 FXSYS_memcpy(pDestPalette, pSrcPalette, palsize * sizeof(FX_DWORD)); | 4114 FXSYS_memcpy(pDestPalette, pSrcPalette, palsize * sizeof(uint32_t)); |
4115 } else { | 4115 } else { |
4116 for (int i = 0; i < palsize; i++) { | 4116 for (int i = 0; i < palsize; i++) { |
4117 FX_CMYK cmyk = pSrcPalette[i]; | 4117 FX_CMYK cmyk = pSrcPalette[i]; |
4118 uint8_t r, g, b; | 4118 uint8_t r, g, b; |
4119 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), | 4119 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), |
4120 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, | 4120 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, |
4121 g, b); | 4121 g, b); |
4122 pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); | 4122 pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); |
4123 } | 4123 } |
4124 } | 4124 } |
4125 } | 4125 } |
4126 } else { | 4126 } else { |
4127 if ((dest_format & 0xff) == 8) { | 4127 if ((dest_format & 0xff) == 8) { |
4128 int pal_count = 1 << (src_format & 0xff); | 4128 int pal_count = 1 << (src_format & 0xff); |
4129 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); | 4129 uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); |
4130 if (pal_count == 2) { | 4130 if (pal_count == 2) { |
4131 gray_pal[0] = 0; | 4131 gray_pal[0] = 0; |
4132 gray_pal[1] = 255; | 4132 gray_pal[1] = 255; |
4133 } else { | 4133 } else { |
4134 for (int i = 0; i < pal_count; i++) { | 4134 for (int i = 0; i < pal_count; i++) { |
4135 gray_pal[i] = i; | 4135 gray_pal[i] = i; |
4136 } | 4136 } |
4137 } | 4137 } |
4138 pDestPalette = (FX_DWORD*)gray_pal; | 4138 pDestPalette = (uint32_t*)gray_pal; |
4139 } else { | 4139 } else { |
4140 int palsize = 1 << (src_format & 0xff); | 4140 int palsize = 1 << (src_format & 0xff); |
4141 pDestPalette = FX_Alloc(FX_DWORD, palsize); | 4141 pDestPalette = FX_Alloc(uint32_t, palsize); |
4142 if (palsize == 2) { | 4142 if (palsize == 2) { |
4143 pDestPalette[0] = isSrcCmyk ? 255 : 0xff000000; | 4143 pDestPalette[0] = isSrcCmyk ? 255 : 0xff000000; |
4144 pDestPalette[1] = isSrcCmyk ? 0 : 0xffffffff; | 4144 pDestPalette[1] = isSrcCmyk ? 0 : 0xffffffff; |
4145 } else { | 4145 } else { |
4146 for (int i = 0; i < palsize; i++) { | 4146 for (int i = 0; i < palsize; i++) { |
4147 pDestPalette[i] = isSrcCmyk ? FX_CCOLOR(i) : (i * 0x10101); | 4147 pDestPalette[i] = isSrcCmyk ? FX_CCOLOR(i) : (i * 0x10101); |
4148 } | 4148 } |
4149 } | 4149 } |
4150 if (isSrcCmyk != isDstCmyk) { | 4150 if (isSrcCmyk != isDstCmyk) { |
4151 for (int i = 0; i < palsize; i++) { | 4151 for (int i = 0; i < palsize; i++) { |
(...skipping 16 matching lines...) Expand all Loading... |
4168 m_bRgbByteOrder = FALSE; | 4168 m_bRgbByteOrder = FALSE; |
4169 m_BlendType = FXDIB_BLEND_NORMAL; | 4169 m_BlendType = FXDIB_BLEND_NORMAL; |
4170 } | 4170 } |
4171 CFX_ScanlineCompositor::~CFX_ScanlineCompositor() { | 4171 CFX_ScanlineCompositor::~CFX_ScanlineCompositor() { |
4172 FX_Free(m_pSrcPalette); | 4172 FX_Free(m_pSrcPalette); |
4173 FX_Free(m_pCacheScanline); | 4173 FX_Free(m_pCacheScanline); |
4174 } | 4174 } |
4175 FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, | 4175 FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, |
4176 FXDIB_Format src_format, | 4176 FXDIB_Format src_format, |
4177 int32_t width, | 4177 int32_t width, |
4178 FX_DWORD* pSrcPalette, | 4178 uint32_t* pSrcPalette, |
4179 FX_DWORD mask_color, | 4179 uint32_t mask_color, |
4180 int blend_type, | 4180 int blend_type, |
4181 FX_BOOL bClip, | 4181 FX_BOOL bClip, |
4182 FX_BOOL bRgbByteOrder, | 4182 FX_BOOL bRgbByteOrder, |
4183 int alpha_flag, | 4183 int alpha_flag, |
4184 void* pIccTransform) { | 4184 void* pIccTransform) { |
4185 m_SrcFormat = src_format; | 4185 m_SrcFormat = src_format; |
4186 m_DestFormat = dest_format; | 4186 m_DestFormat = dest_format; |
4187 m_BlendType = blend_type; | 4187 m_BlendType = blend_type; |
4188 m_bRgbByteOrder = bRgbByteOrder; | 4188 m_bRgbByteOrder = bRgbByteOrder; |
4189 ICodec_IccModule* pIccModule = NULL; | 4189 ICodec_IccModule* pIccModule = NULL; |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4699 dst_scan_extra_alpha); | 4699 dst_scan_extra_alpha); |
4700 } | 4700 } |
4701 } | 4701 } |
4702 return TRUE; | 4702 return TRUE; |
4703 } | 4703 } |
4704 FX_BOOL CFX_DIBitmap::CompositeMask(int dest_left, | 4704 FX_BOOL CFX_DIBitmap::CompositeMask(int dest_left, |
4705 int dest_top, | 4705 int dest_top, |
4706 int width, | 4706 int width, |
4707 int height, | 4707 int height, |
4708 const CFX_DIBSource* pMask, | 4708 const CFX_DIBSource* pMask, |
4709 FX_DWORD color, | 4709 uint32_t color, |
4710 int src_left, | 4710 int src_left, |
4711 int src_top, | 4711 int src_top, |
4712 int blend_type, | 4712 int blend_type, |
4713 const CFX_ClipRgn* pClipRgn, | 4713 const CFX_ClipRgn* pClipRgn, |
4714 FX_BOOL bRgbByteOrder, | 4714 FX_BOOL bRgbByteOrder, |
4715 int alpha_flag, | 4715 int alpha_flag, |
4716 void* pIccTransform) { | 4716 void* pIccTransform) { |
4717 if (!m_pBuffer) { | 4717 if (!m_pBuffer) { |
4718 return FALSE; | 4718 return FALSE; |
4719 } | 4719 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4768 compositor.CompositeByteMaskLine(dest_scan, src_scan + src_left, width, | 4768 compositor.CompositeByteMaskLine(dest_scan, src_scan + src_left, width, |
4769 clip_scan, dst_scan_extra_alpha); | 4769 clip_scan, dst_scan_extra_alpha); |
4770 } | 4770 } |
4771 } | 4771 } |
4772 return TRUE; | 4772 return TRUE; |
4773 } | 4773 } |
4774 FX_BOOL CFX_DIBitmap::CompositeRect(int left, | 4774 FX_BOOL CFX_DIBitmap::CompositeRect(int left, |
4775 int top, | 4775 int top, |
4776 int width, | 4776 int width, |
4777 int height, | 4777 int height, |
4778 FX_DWORD color, | 4778 uint32_t color, |
4779 int alpha_flag, | 4779 int alpha_flag, |
4780 void* pIccTransform) { | 4780 void* pIccTransform) { |
4781 if (!m_pBuffer) { | 4781 if (!m_pBuffer) { |
4782 return FALSE; | 4782 return FALSE; |
4783 } | 4783 } |
4784 int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color); | 4784 int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color); |
4785 if (src_alpha == 0) { | 4785 if (src_alpha == 0) { |
4786 return TRUE; | 4786 return TRUE; |
4787 } | 4787 } |
4788 FX_RECT rect(left, top, left + width, top + height); | 4788 FX_RECT rect(left, top, left + width, top + height); |
4789 rect.Intersect(0, 0, m_Width, m_Height); | 4789 rect.Intersect(0, 0, m_Width, m_Height); |
4790 if (rect.IsEmpty()) { | 4790 if (rect.IsEmpty()) { |
4791 return TRUE; | 4791 return TRUE; |
4792 } | 4792 } |
4793 width = rect.Width(); | 4793 width = rect.Width(); |
4794 FX_DWORD dst_color; | 4794 uint32_t dst_color; |
4795 if (alpha_flag >> 8) { | 4795 if (alpha_flag >> 8) { |
4796 dst_color = FXCMYK_TODIB(color); | 4796 dst_color = FXCMYK_TODIB(color); |
4797 } else { | 4797 } else { |
4798 dst_color = FXARGB_TODIB(color); | 4798 dst_color = FXARGB_TODIB(color); |
4799 } | 4799 } |
4800 uint8_t* color_p = (uint8_t*)&dst_color; | 4800 uint8_t* color_p = (uint8_t*)&dst_color; |
4801 if (m_bpp == 8) { | 4801 if (m_bpp == 8) { |
4802 uint8_t gray = 255; | 4802 uint8_t gray = 255; |
4803 if (!IsAlphaMask()) { | 4803 if (!IsAlphaMask()) { |
4804 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && | 4804 if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4898 if (src_alpha == 255) { | 4898 if (src_alpha == 255) { |
4899 for (int row = rect.top; row < rect.bottom; row++) { | 4899 for (int row = rect.top; row < rect.bottom; row++) { |
4900 uint8_t* dest_scan = m_pBuffer + row * m_Pitch + rect.left * Bpp; | 4900 uint8_t* dest_scan = m_pBuffer + row * m_Pitch + rect.left * Bpp; |
4901 uint8_t* dest_scan_alpha = | 4901 uint8_t* dest_scan_alpha = |
4902 m_pAlphaMask ? (uint8_t*)m_pAlphaMask->GetScanline(row) + rect.left | 4902 m_pAlphaMask ? (uint8_t*)m_pAlphaMask->GetScanline(row) + rect.left |
4903 : NULL; | 4903 : NULL; |
4904 if (dest_scan_alpha) { | 4904 if (dest_scan_alpha) { |
4905 FXSYS_memset(dest_scan_alpha, 0xff, width); | 4905 FXSYS_memset(dest_scan_alpha, 0xff, width); |
4906 } | 4906 } |
4907 if (Bpp == 4) { | 4907 if (Bpp == 4) { |
4908 FX_DWORD* scan = (FX_DWORD*)dest_scan; | 4908 uint32_t* scan = (uint32_t*)dest_scan; |
4909 for (int col = 0; col < width; col++) { | 4909 for (int col = 0; col < width; col++) { |
4910 *scan++ = dst_color; | 4910 *scan++ = dst_color; |
4911 } | 4911 } |
4912 } else { | 4912 } else { |
4913 for (int col = 0; col < width; col++) { | 4913 for (int col = 0; col < width; col++) { |
4914 *dest_scan++ = color_p[0]; | 4914 *dest_scan++ = color_p[0]; |
4915 *dest_scan++ = color_p[1]; | 4915 *dest_scan++ = color_p[1]; |
4916 *dest_scan++ = color_p[2]; | 4916 *dest_scan++ = color_p[2]; |
4917 } | 4917 } |
4918 } | 4918 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4989 } | 4989 } |
4990 CFX_BitmapComposer::~CFX_BitmapComposer() { | 4990 CFX_BitmapComposer::~CFX_BitmapComposer() { |
4991 FX_Free(m_pScanlineV); | 4991 FX_Free(m_pScanlineV); |
4992 FX_Free(m_pScanlineAlphaV); | 4992 FX_Free(m_pScanlineAlphaV); |
4993 FX_Free(m_pClipScanV); | 4993 FX_Free(m_pClipScanV); |
4994 FX_Free(m_pAddClipScan); | 4994 FX_Free(m_pAddClipScan); |
4995 } | 4995 } |
4996 void CFX_BitmapComposer::Compose(CFX_DIBitmap* pDest, | 4996 void CFX_BitmapComposer::Compose(CFX_DIBitmap* pDest, |
4997 const CFX_ClipRgn* pClipRgn, | 4997 const CFX_ClipRgn* pClipRgn, |
4998 int bitmap_alpha, | 4998 int bitmap_alpha, |
4999 FX_DWORD mask_color, | 4999 uint32_t mask_color, |
5000 FX_RECT& dest_rect, | 5000 FX_RECT& dest_rect, |
5001 FX_BOOL bVertical, | 5001 FX_BOOL bVertical, |
5002 FX_BOOL bFlipX, | 5002 FX_BOOL bFlipX, |
5003 FX_BOOL bFlipY, | 5003 FX_BOOL bFlipY, |
5004 FX_BOOL bRgbByteOrder, | 5004 FX_BOOL bRgbByteOrder, |
5005 int alpha_flag, | 5005 int alpha_flag, |
5006 void* pIccTransform, | 5006 void* pIccTransform, |
5007 int blend_type) { | 5007 int blend_type) { |
5008 m_pBitmap = pDest; | 5008 m_pBitmap = pDest; |
5009 m_pClipRgn = pClipRgn; | 5009 m_pClipRgn = pClipRgn; |
(...skipping 11 matching lines...) Expand all Loading... |
5021 m_bFlipX = bFlipX; | 5021 m_bFlipX = bFlipX; |
5022 m_bFlipY = bFlipY; | 5022 m_bFlipY = bFlipY; |
5023 m_AlphaFlag = alpha_flag; | 5023 m_AlphaFlag = alpha_flag; |
5024 m_pIccTransform = pIccTransform; | 5024 m_pIccTransform = pIccTransform; |
5025 m_bRgbByteOrder = bRgbByteOrder; | 5025 m_bRgbByteOrder = bRgbByteOrder; |
5026 m_BlendType = blend_type; | 5026 m_BlendType = blend_type; |
5027 } | 5027 } |
5028 FX_BOOL CFX_BitmapComposer::SetInfo(int width, | 5028 FX_BOOL CFX_BitmapComposer::SetInfo(int width, |
5029 int height, | 5029 int height, |
5030 FXDIB_Format src_format, | 5030 FXDIB_Format src_format, |
5031 FX_DWORD* pSrcPalette) { | 5031 uint32_t* pSrcPalette) { |
5032 m_SrcFormat = src_format; | 5032 m_SrcFormat = src_format; |
5033 if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, width, pSrcPalette, | 5033 if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, width, pSrcPalette, |
5034 m_MaskColor, FXDIB_BLEND_NORMAL, | 5034 m_MaskColor, FXDIB_BLEND_NORMAL, |
5035 m_pClipMask != NULL || (m_BitmapAlpha < 255), | 5035 m_pClipMask != NULL || (m_BitmapAlpha < 255), |
5036 m_bRgbByteOrder, m_AlphaFlag, m_pIccTransform)) { | 5036 m_bRgbByteOrder, m_AlphaFlag, m_pIccTransform)) { |
5037 return FALSE; | 5037 return FALSE; |
5038 } | 5038 } |
5039 if (m_bVertical) { | 5039 if (m_bVertical) { |
5040 m_pScanlineV = FX_Alloc(uint8_t, m_pBitmap->GetBPP() / 8 * width + 4); | 5040 m_pScanlineV = FX_Alloc(uint8_t, m_pBitmap->GetBPP() / 8 * width + 4); |
5041 m_pClipScanV = FX_Alloc(uint8_t, m_pBitmap->GetHeight()); | 5041 m_pClipScanV = FX_Alloc(uint8_t, m_pBitmap->GetHeight()); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5171 } | 5171 } |
5172 src_alpha_scan = m_pScanlineAlphaV; | 5172 src_alpha_scan = m_pScanlineAlphaV; |
5173 dest_alpha_scan = dest_alpha_buf; | 5173 dest_alpha_scan = dest_alpha_buf; |
5174 if (dest_alpha_scan) { | 5174 if (dest_alpha_scan) { |
5175 for (i = 0; i < m_DestHeight; i++) { | 5175 for (i = 0; i < m_DestHeight; i++) { |
5176 *dest_alpha_scan = *src_alpha_scan++; | 5176 *dest_alpha_scan = *src_alpha_scan++; |
5177 dest_alpha_scan += y_alpha_step; | 5177 dest_alpha_scan += y_alpha_step; |
5178 } | 5178 } |
5179 } | 5179 } |
5180 } | 5180 } |
OLD | NEW |