summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Abd-El-Malek <jam@chromium.org>2014-06-11 13:34:16 -0700
committerJohn Abd-El-Malek <jam@chromium.org>2014-06-11 13:34:16 -0700
commit3084c79dce15a41c056d4e5c634e09010e7323e0 (patch)
treea1a4ba6a567b0688f257af318eeb1049b0030886
parentd7d52f1b359458d5c90b182af68168bd9349f335 (diff)
downloadpdfium-3084c79dce15a41c056d4e5c634e09010e7323e0.tar.xz
Bring back the Skia files from the old repo.
BUG=11
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.cpp1606
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.h225
-rw-r--r--core/src/fxge/skia/fx_skia_device.cpp527
-rw-r--r--core/src/fxge/skia/fx_skia_device.h86
4 files changed, 2444 insertions, 0 deletions
diff --git a/core/src/fxge/skia/fx_skia_blitter_new.cpp b/core/src/fxge/skia/fx_skia_blitter_new.cpp
new file mode 100644
index 0000000000..5ba6e8a20f
--- /dev/null
+++ b/core/src/fxge/skia/fx_skia_blitter_new.cpp
@@ -0,0 +1,1606 @@
+#include "../../../include/fxge/fx_ge.h"
+//#define _SKIA_SUPPORT_
+#if defined(_SKIA_SUPPORT_)
+#include "../../../include/fxcodec/fx_codec.h"
+#include "SkBlitter.h"
+#include "fx_skia_blitter_new.h"
+ // We use our own renderer here to make it simple
+ void CFX_SkiaRenderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
+ {
+ FXSYS_assert(m_Alpha);
+ if (m_pOriDevice == NULL && composite_span == NULL) return;
+ if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return;
+ while (1)
+ {
+ int width = runs[0];
+ SkASSERT(width >= 0);
+ if (width <= 0)
+ return;
+ unsigned aa = antialias[0];
+ if (aa)
+ (this->*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan);
+ runs += width;
+ antialias += width;
+ x += width;
+ }
+ }
+
+ void CFX_SkiaRenderer::blitH(int x, int y, int width)
+ {
+ FXSYS_assert(m_Alpha && width);
+ if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return;
+ (this->*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan);
+ }
+
+ void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha)
+ {
+ FXSYS_assert(m_Alpha && alpha);
+ if (alpha == 255) {
+ this->blitRect(x, y, 1, height);
+ } else {
+ int16_t runs[2];
+ runs[0] = 1;
+ runs[1] = 0;
+ while (--height >= 0) {
+ if (y >= m_ClipBox.bottom)
+ return;
+ this->blitAntiH(x, y ++, &alpha, runs);
+ }
+ }
+ }
+ void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height)
+ {
+ FXSYS_assert(m_Alpha && width);
+ while (--height >= 0){
+ if (y >= m_ClipBox.bottom)
+ return;
+ blitH(x, y ++, width);
+ }
+ }
+
+ void CFX_SkiaRenderer::blitAntiRect(int x, int y, int width, int height,
+ SkAlpha leftAlpha, SkAlpha rightAlpha)
+ {
+ blitV(x++, y, height, leftAlpha);
+ if (width > 0) {
+ blitRect(x, y, width, height);
+ x += width;
+ }
+ blitV(x, y, height, rightAlpha);
+ }
+ /*---------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpan1bpp_0(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left/8;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start/8;
+
+ int index = 0;
+ if (m_pDevice->GetPalette() == NULL)
+ index = ((FX_BYTE)m_Color == 0xff) ? 1 : 0;
+ else {
+ for (int i = 0; i < 2; i ++)
+ if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
+ index = i;
+ }
+ FX_LPBYTE dest_scan1 = dest_scan;
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ if (src_alpha) {
+ if (!index)
+ *dest_scan1 &= ~(1 << (7 - (col+span_left)%8));
+ else
+ *dest_scan1|= 1 << (7 - (col+span_left)%8);
+ }
+ dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpan1bpp_4(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left/8;
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start/8;
+
+ int index = 0;
+ if (m_pDevice->GetPalette() == NULL)
+ index = ((FX_BYTE)m_Color == 0xff) ? 1 : 0;
+ else {
+ for (int i = 0; i < 2; i ++)
+ if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
+ index = i;
+ }
+ FX_LPBYTE dest_scan1 = dest_scan;
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (src_alpha1) {
+ if (!index)
+ *dest_scan1 &= ~(1 << (7 - (col+span_left)%8));
+ else
+ *dest_scan1|= 1 << (7 - (col+span_left)%8);
+ }
+ dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8;
+ }
+ }
+ /*-----------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpanGray_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ ASSERT(!m_bRgbByteOrder);
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ if (cover_scan == 255 && m_Alpha == 255) {
+ FXSYS_memset32(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
+ return;
+ }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha);
+ dest_scan++;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanGray_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ ASSERT(!m_bRgbByteOrder);
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
+ ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ ori_scan += col_start;
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset32(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
+ } else {
+ int src_alpha = m_Alpha;
+#if 1
+ for (int col = col_start; col < col_end; col ++) {
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan ++;
+ }
+#else
+ if (m_bFullCover) {
+ if (src_alpha == 255) {
+ FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), col_end - col_start);
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++)
+ *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan++;
+ }
+ }
+#endif
+ }
+ }
+
+ void CFX_SkiaRenderer::CompositeSpanGray_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan ++;
+ continue;
+ }
+ if (src_alpha1 == 255)
+ *dest_scan++ = m_Gray;
+ else {
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1);
+ dest_scan ++;
+ }
+ }
+ }
+
+ void CFX_SkiaRenderer::CompositeSpanGray_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
+ ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left;
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start;
+ ori_scan += col_start;
+#if 1
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Gray;
+ ori_scan++;
+ continue;
+ }
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan++;
+ }
+
+#else
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan++;
+ ori_scan++;
+ continue;
+ }
+ if (src_alpha == 255){
+ *dest_scan++ = m_Gray;
+ ori_scan++;
+ continue;
+ }
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ }
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Gray;
+ ori_scan++;
+ continue;
+ }
+ int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
+ dest_scan++;
+ }
+ }
+#endif
+ }
+ /*--------------------------------------------------------------------------------------------------*/
+
+ void CFX_SkiaRenderer::CompositeSpanARGB_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start<<2;
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset32(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ int src_alpha;
+#if 0
+ if (m_bFullCover) {
+ if (m_Alpha == 255) {
+ FXSYS_memset32(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ }
+ else
+#endif
+ src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ FX_BYTE dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
+
+ void CFX_SkiaRenderer::CompositeSpanARGB_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ //ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ //ori_scan += col_start << 2;
+
+ if (m_Alpha == 255 && cover_scan == 255){
+ FXSYS_memset32(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ if (cover_scan == 255) {
+ int dst_color = (0x00ffffff&m_Color)|(m_Alpha<<24);
+ FXSYS_memset32(dest_scan, dst_color, (col_end - col_start)<<2);
+ return;
+ }
+ // Do not need origin bitmap, because of merge in pure transparent background
+ int src_alpha_covered = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++)
+ {
+ // shortcut
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha_covered;
+ *dest_scan ++ = m_Blue;
+ *dest_scan ++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ // We should do alpha transition and color transition
+ // alpha fg color fg
+ // alpha bg color bg
+ // alpha cover color cover
+ dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
+ dest_scan += 2;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanARGB_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+#if 1
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha* clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha1;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ FX_BYTE dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
+#else
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha == 255){
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ continue;
+ } else {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ FX_BYTE dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
+ } else {
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha* clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Argb
+ // calculate destination alpha (it's union of source and dest alpha)
+ if (dest_scan[3] == 0) {
+ dest_scan[3] = src_alpha1;
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ FX_BYTE dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan += 2;
+ }
+ }
+ }
+#endif
+ }
+
+ void CFX_SkiaRenderer::CompositeSpanARGB_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ //ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ //ori_scan += col_start << 2;
+ // Do not need origin bitmap, because of merge in pure transparent background
+ for (int col = col_start; col < col_end; col ++)
+ {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ int src_alpha_covered = src_alpha * cover_scan / 255;
+ // shortcut
+ if (src_alpha_covered == 0){
+ dest_scan += 4;
+ continue;
+ }
+ // shortcut
+ if (cover_scan == 255 || dest_scan[3] == 0)
+ {
+ // origin alpha always zero, just get src alpha
+ dest_scan[3] = src_alpha_covered;
+ *dest_scan ++ = m_Blue;
+ *dest_scan ++ = m_Green;
+ *dest_scan = m_Red;
+ dest_scan += 2;
+ continue;
+ }
+ // We should do alpha transition and color transition
+ // alpha fg color fg
+ // alpha bg color bg
+ // alpha cover color cover
+ dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan);
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
+ dest_scan += 2;
+ }
+ }
+
+ /*-----------------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpanRGB32_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += (col_start << 2);
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset32(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ int src_alpha;
+#if 0
+ if (m_bFullCover)
+ src_alpha = m_Alpha;
+ else
+#endif
+ src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan += 2;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB32_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ ori_scan += col_start << 2;
+ if (m_Alpha == 255 && cover_scan == 255) {
+ FXSYS_memset32(dest_scan, m_Color, (col_end - col_start)<<2);
+ return;
+ }
+ int src_alpha = m_Alpha;
+ for (int col = col_start; col < col_end; col ++) {
+#if 0
+ if (m_bFullCover) {
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ dest_scan += 2; ori_scan += 2;
+ continue;
+ }
+#endif
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ ori_scan += 2;
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan += 2;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB32_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+#if 1
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Rgb or Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan += 2;
+ }
+ }
+#else
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Rgb or Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan += 2;
+ }
+ }
+ } else {
+ // Rgb32
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 4;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ } else {
+ // Dest format: Rgb or Rgb32
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan += 2;
+ }
+ }
+ }
+#endif
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB32_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left<<2);
+ ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start << 2;
+ ori_scan += col_start << 2;
+#if 1
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ ori_scan += 2;
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan += 2;
+ }
+#else
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ *(FX_DWORD*)dest_scan = *(FX_DWORD*)ori_scan;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ dest_scan += 2; ori_scan += 2;
+ }
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *(FX_DWORD*)dest_scan = m_Color;
+ dest_scan += 4;
+ ori_scan += 4;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
+ ori_scan += 2;
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan += 2;
+ }
+ }
+#endif
+ }
+ /*-----------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaRenderer::CompositeSpanRGB24_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += (col_start<<1)+col_start;
+ int src_alpha;
+#if 0
+ if (m_bFullCover)
+ src_alpha = m_Alpha;
+ else
+#endif
+ src_alpha = m_Alpha * cover_scan / 255;
+ if (src_alpha == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ }
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan ++;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_left<<1);
+ ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left + (span_left<<1);
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += (col_start<<1) + col_start;
+ ori_scan += (col_start<<1) + col_start;
+ if (m_Alpha == 255&&cover_scan == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan ++ = m_Blue;
+ *dest_scan ++ = m_Green;
+ *dest_scan ++ = m_Red;
+ }
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++) {
+#if 0
+ if (m_bFullCover) {
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha);
+ continue;
+ }
+#endif
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan ++;
+ }
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start + (col_start << 1);
+#if 1
+ int src_alpha = m_Alpha * cover_scan /255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ } else {
+ // Dest format: Rgb
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan ++;
+ }
+ }
+#else
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ } else {
+ // Dest format: Rgb
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan ++;
+ }
+ }
+ } else {
+ int src_alpha = m_Alpha * cover_scan /255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ } else {
+ // Dest format: Rgb
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
+ dest_scan ++;
+ }
+ }
+ }
+#endif
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_pDevice->IsCmykImage());
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start + (col_start<<1);
+ ori_scan += col_start + (col_start<<1);
+#if 1
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ ori_scan += 3;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan ++;
+ }
+#else
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha){
+ *dest_scan++ = *ori_scan++;
+ *dest_scan++ = *ori_scan++;
+ *dest_scan++ = *ori_scan++;
+ continue;
+ }
+ if (src_alpha == 255){
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ ori_scan += 3;
+ continue;
+ }
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
+ }
+ } else {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (src_alpha == 255 && cover_scan == 255) {
+ *dest_scan++ = m_Blue;
+ *dest_scan++ = m_Green;
+ *dest_scan++ = m_Red;
+ ori_scan += 3;
+ continue;
+ }
+ int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
+ int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
+ int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
+ *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
+ dest_scan ++;
+ }
+ }
+#endif
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_10(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ dest_extra_alpha_scan = (FX_BYTE*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start+(col_start<<1);
+#if 1
+ if (m_Alpha == 255 && cover_scan == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = (FX_BYTE)m_Blue;
+ *dest_scan++ = (FX_BYTE)m_Green;
+ *dest_scan++ = (FX_BYTE)m_Red;
+ *dest_extra_alpha_scan++ = 255;
+ }
+ return;
+ }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+#else
+ if (m_bFullCover) {
+ if (m_Alpha == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = (FX_BYTE)m_Blue;
+ *dest_scan++ = (FX_BYTE)m_Green;
+ *dest_scan++ = (FX_BYTE)m_Red;
+ *dest_extra_alpha_scan++ = 255;
+ }
+ return;
+ }
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + m_Alpha -
+ (*dest_extra_alpha_scan) * m_Alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = m_Alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ } else {
+ if (m_Alpha == 255 && cover_scan == 255) {
+ for (int col = col_start; col < col_end; col ++) {
+ *dest_scan++ = (FX_BYTE)m_Blue;
+ *dest_scan++ = (FX_BYTE)m_Green;
+ *dest_scan++ = (FX_BYTE)m_Red;
+ *dest_extra_alpha_scan++ = 255;
+ }
+ return;
+ }
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
+#endif
+ }
+ void CFX_SkiaRenderer::CompositeSpanRGB24_14(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left+(span_left<<1);
+ dest_extra_alpha_scan = (FX_BYTE*)m_pDevice->m_pAlphaMask->GetScanline(span_top)+span_left;
+ clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top-clip_top) - clip_left + span_left;
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start + (col_start << 1);
+#if 1
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = src_alpha * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_extra_alpha_scan++;
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = (FX_BYTE)m_Blue;
+ *dest_scan++ = (FX_BYTE)m_Green;
+ *dest_scan++ = (FX_BYTE)m_Red;
+ *dest_extra_alpha_scan++ = (FX_BYTE)m_Alpha;
+ } else {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 -
+ (*dest_extra_alpha_scan) * src_alpha1 / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
+#else
+ if (m_bFullCover) {
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha = m_Alpha * clip_scan[col] / 255;
+ if (!src_alpha) {
+ dest_extra_alpha_scan++;
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha == 255) {
+ *dest_scan++ = (FX_BYTE)m_Blue;
+ *dest_scan++ = (FX_BYTE)m_Green;
+ *dest_scan++ = (FX_BYTE)m_Red;
+ *dest_extra_alpha_scan++ = (FX_BYTE)m_Alpha;
+ } else {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
+ } else {
+ int src_alpha = m_Alpha * cover_scan / 255;
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha1 = m_Alpha * cover_scan * clip_scan[col] / 255;
+ if (!src_alpha1) {
+ dest_extra_alpha_scan++;
+ dest_scan += 3;
+ continue;
+ }
+ if (src_alpha1 == 255) {
+ *dest_scan++ = (FX_BYTE)m_Blue;
+ *dest_scan++ = (FX_BYTE)m_Green;
+ *dest_scan++ = (FX_BYTE)m_Red;
+ *dest_extra_alpha_scan++ = (FX_BYTE)m_Alpha;
+ } else {
+ // Dest format: Rgba
+ // calculate destination alpha (it's union of source and dest alpha)
+ FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 -
+ (*dest_extra_alpha_scan) * src_alpha1 / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha1*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ }
+ }
+ }
+#endif
+ }
+ /*-----------------------------------------------------------------------------------------------------*/
+
+ // A general alpha merge function (with clipping mask). Cmyka/Cmyk device.
+ void CFX_SkiaRenderer::CompositeSpanCMYK(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan)
+ {
+ ASSERT(!m_bRgbByteOrder);
+ // Cmyk(a)
+ int col_start = span_left < clip_left ? clip_left - span_left : 0;
+ int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
+ if (col_end < col_start) return; // do nothing.
+ dest_scan += col_start * 4;
+ Bpp; // for avoid compile warning.
+
+ if (dest_extra_alpha_scan) {
+ // CMYKa
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha;
+ if (m_bFullCover) {
+ if (clip_scan)
+ src_alpha = m_Alpha * clip_scan[col] / 255;
+ else
+ src_alpha = m_Alpha;
+ } else {
+ if (clip_scan)
+ src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255;
+ else
+ src_alpha = m_Alpha * cover_scan / 255;
+ }
+
+ if (src_alpha) {
+ if (src_alpha == 255) {
+ *(FX_CMYK*)dest_scan = m_Color;
+ *dest_extra_alpha_scan = (FX_BYTE)m_Alpha;
+ } else {
+ // Dest format: Cmyka
+ // calculate destination alpha (it's union of source and dest alpha)
+ FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
+ (*dest_extra_alpha_scan) * src_alpha / 255;
+ *dest_extra_alpha_scan++ = dest_alpha;
+ int alpha_ratio = src_alpha*255/dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha_ratio);
+ dest_scan ++;
+ continue;
+ }
+ }
+ dest_extra_alpha_scan++;
+ dest_scan += 4;
+ }
+ } else {
+ // CMYK
+ for (int col = col_start; col < col_end; col ++) {
+ int src_alpha;
+ if (clip_scan)
+ src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255;
+ else
+ src_alpha = m_Alpha * cover_scan / 255;
+
+ if (src_alpha) {
+ if (src_alpha == 255) {
+ *(FX_CMYK*)dest_scan = m_Color;
+ } else {
+ // Dest format: cmyk
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
+ dest_scan ++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha);
+ dest_scan ++;
+ continue;
+ }
+ }
+ dest_scan += 4;
+ }
+ }
+ }
+
+
+
+ //--------------------------------------------------------------------
+ FX_BOOL CFX_SkiaRenderer::Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByteOrder,
+ int alpha_flag, void* pIccTransform) //The alpha flag must be fill_flag if exist.
+ {
+ m_pDevice = pDevice;
+ m_pClipRgn = pClipRgn;
+ m_bRgbByteOrder = bRgbByteOrder;
+ m_pOriDevice = pOriDevice;
+ m_pDestScan = NULL;
+ m_pDestExtraAlphaScan = NULL;
+ m_pOriScan = NULL;
+ m_pClipScan = NULL;
+ composite_span = NULL;
+ if (m_pClipRgn)
+ m_ClipBox = m_pClipRgn->GetBox();
+ else {
+ m_ClipBox.left = m_ClipBox.top = 0;
+ m_ClipBox.right = m_pDevice->GetWidth();
+ m_ClipBox.bottom = m_pDevice->GetHeight();
+ }
+ m_pClipMask = NULL;
+ if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF)
+ {
+ m_pClipMask = m_pClipRgn->GetMask();
+ m_pClipScan = m_pClipMask->GetBuffer();
+ }
+ if (m_pDevice->m_pAlphaMask)
+ m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer();
+ if (m_pOriDevice)
+ m_pOriScan = m_pOriDevice->GetBuffer();
+ m_pDestScan = m_pDevice->GetBuffer();
+
+ m_bFullCover = bFullCover;
+
+ FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
+ FX_BOOL bDeviceCMYK = pDevice->IsCmykImage();
+
+ m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
+
+ ICodec_IccModule* pIccModule = NULL;
+ // No lcms engine, we skip the transform
+ if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule())
+ pIccTransform = NULL;
+ else
+ pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
+
+ if (m_pDevice->GetBPP() == 8) { // Gray(a) device
+ ASSERT(!m_bRgbByteOrder);
+ if (m_pDevice->IsAlphaMask()) {
+ //Alpha Mask
+ m_Gray = 255;
+ } else {
+ //Gray(a) device
+ if (pIccTransform) {
+ FX_BYTE gray;
+ color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
+ pIccModule->TranslateScanline(pIccTransform, &gray, (FX_LPCBYTE)&color, 1);
+ m_Gray = gray;
+ } else {
+ if (bObjectCMYK) {
+ FX_BYTE r, g, b;
+ AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
+ r, g, b);
+ m_Gray = FXRGB2GRAY(r, g, b);
+ } else {
+ m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color));
+ }
+ }
+ }
+ } else {
+ if (bDeviceCMYK) { // Cmyk(a) Device
+ ASSERT(!m_bRgbByteOrder);
+ //TODO... opt for cmyk
+ composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK;
+ if (bObjectCMYK) {
+ m_Color = FXCMYK_TODIB(color);
+ if (pIccTransform)
+ pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&m_Color, (FX_LPCBYTE)&m_Color, 1);
+ } else { // Object RGB
+ if (!pIccTransform)
+ return FALSE;
+ color = FXARGB_TODIB(color);
+ pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&m_Color, (FX_LPCBYTE)&color, 1);
+ }
+ m_Red = ((FX_LPBYTE)&m_Color)[0];
+ m_Green = ((FX_LPBYTE)&m_Color)[1];
+ m_Blue = ((FX_LPBYTE)&m_Color)[2];
+ m_Gray = ((FX_LPBYTE)&m_Color)[3];
+ return TRUE;
+ } else {
+ if (pIccTransform) {
+ color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
+ pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&m_Color, (FX_LPCBYTE)&color, 1);
+ ((FX_LPBYTE)&m_Color)[3] = m_Alpha;
+ m_Red = ((FX_LPBYTE)&m_Color)[2];
+ m_Green = ((FX_LPBYTE)&m_Color)[1];
+ m_Blue = ((FX_LPBYTE)&m_Color)[0];
+ // Need Johnson to improvement it.
+ if (m_bRgbByteOrder) {
+ // swap
+ m_Red = ((FX_LPBYTE)&m_Color)[0];
+ m_Blue = ((FX_LPBYTE)&m_Color)[2];
+ m_Color = FXARGB_TODIB(m_Color);
+ m_Color = FXARGB_TOBGRORDERDIB(m_Color);
+ }
+ } else {
+ if (bObjectCMYK) {
+ FX_BYTE r, g, b;
+ AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
+ r, g, b);
+ m_Color = FXARGB_MAKE(m_Alpha, r, g, b);
+ if (m_bRgbByteOrder){
+ m_Color = FXARGB_TOBGRORDERDIB(m_Color);
+ m_Red = b; m_Green = g; m_Blue = r;//
+ }else {
+ m_Color = FXARGB_TODIB(m_Color);
+ m_Red = r; m_Green = g; m_Blue = b;//
+ }
+ } else {
+ if (m_bRgbByteOrder){
+ m_Color = FXARGB_TOBGRORDERDIB(color);
+ ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red); //
+ }else {
+ m_Color = FXARGB_TODIB(color);
+ ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue);
+ }
+ }
+ }
+ }
+ }
+ // Get palette transparency selector
+ m_ProcessFilter = (m_pOriDevice? 1 : 0) /* has Ori Device flag */
+ + (m_pDevice->GetBPP() >= 8 ? 2 : 0) /* bpp flag */
+ + (m_pClipMask? 4 : 0) /* has clip region flag */
+ + (m_pDevice->m_pAlphaMask? 8 : 0); /* has Alpha Mask chanel flag */
+ switch(m_ProcessFilter) {
+ case 0:
+ composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0;
+ break;
+ case 2:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_2 : &CFX_SkiaRenderer::CompositeSpanRGB32_2;
+ }
+ break;
+ case 3:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_3 : &CFX_SkiaRenderer::CompositeSpanRGB32_3;
+ }
+ break;
+ case 4:
+ composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4;
+ break;
+ case 6:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_6 : &CFX_SkiaRenderer::CompositeSpanRGB32_6;
+ }
+ break;
+ case 7:
+ {
+ if (m_pDevice->GetBPP() == 8)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7;
+ else if (m_pDevice->GetBPP() == 24)
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7;
+ else
+ composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer::CompositeSpanARGB_7 : &CFX_SkiaRenderer::CompositeSpanRGB32_7;
+ }
+ break;
+ case 1:
+ case 5:
+ case 8:
+ case 9:
+ case 11:
+ case 12:
+ case 13:
+ case 15:
+ //TODO...
+ break;
+ case 10:
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10;
+ break;
+ case 14:
+ composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14;
+ break;
+ }
+ if (composite_span == NULL)
+ return FALSE;
+ return TRUE;
+ }
+
+ /*----------------------------------------------------------------------------------------------------*/
+ void CFX_SkiaA8Renderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
+ {
+ FXSYS_assert(m_pDevice);
+ int dst_y = y - m_Top;
+ if (dst_y < 0 || dst_y >= m_pDevice->GetHeight())
+ return;
+
+ FX_LPBYTE dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y;
+ FX_LPBYTE dest_pos = dest_scan;
+ while (1)
+ {
+ if (x >= m_dstWidth)
+ return;
+ int width = runs[0];
+ SkASSERT(width >= 0);
+ if (width <= 0)
+ return;
+ unsigned aa = antialias[0];
+ if (aa) {
+ int col_start = x < m_Left ? 0 : x - m_Left;
+ int col_end = x + width;
+ col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth();
+ int result = col_end - col_start;
+ if (result > 0) {
+ dest_pos = dest_scan + col_start;
+ if (result >= 4)
+ FXSYS_memset32(dest_pos, FXARGB_MAKE(aa, aa, aa, aa),result);
+ else
+ FXSYS_memset(dest_pos,aa,result);
+ }
+ }
+ runs += width;
+ antialias += width;
+ x += width;
+ }
+ }
+ void CFX_SkiaA8Renderer::blitH(int x, int y, int width)
+ {
+ FXSYS_assert(m_pDevice);
+ int dst_y = y - m_Top;
+ if (dst_y < 0 || dst_y >= m_pDevice->GetHeight())
+ return;
+ if (x >= m_dstWidth)
+ return;
+ FX_LPBYTE dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y;
+ int col_start = x < m_Left ? 0 : x - m_Left;
+ int col_end = x + width;
+ col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth();
+ int result = col_end - col_start;
+ if (result > 0) {
+ FX_BYTE* dest_pos = dest_scan + col_start;
+ if (result >= 4)
+ FXSYS_memset32(dest_pos, 0xffffffff,result);
+ else
+ FXSYS_memset(dest_pos,255,result);
+ }
+ }
+ void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha)
+ {
+ FXSYS_assert(alpha);
+ if (alpha == 255) {
+ this->blitRect(x, y, 1, height);
+ } else {
+ int16_t runs[2];
+ runs[0] = 1;
+ runs[1] = 0;
+ while (--height >= 0) {
+ if (y >= m_dstHeight)
+ return;
+ this->blitAntiH(x, y ++, &alpha, runs);
+ }
+ }
+ }
+ void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height)
+ {
+ FXSYS_assert(m_pDevice);
+ while (--height >= 0) {
+ if (y >= m_dstHeight)
+ return;
+ blitH(x , y ++, width);
+ }
+ }
+
+ void CFX_SkiaA8Renderer::blitAntiRect(int x, int y, int width, int height,
+ SkAlpha leftAlpha, SkAlpha rightAlpha)
+ {
+ blitV(x++, y, height, leftAlpha);
+ if (width > 0) {
+ blitRect(x, y, width, height);
+ x += width;
+ }
+ blitV(x, y, height, rightAlpha);
+ }
+
+ FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top)
+ {
+ m_pDevice = pDevice;
+ m_Left = Left;
+ m_Top = Top;
+ if (pDevice){
+ m_dstWidth = m_Left + pDevice->GetWidth();
+ m_dstHeight = m_Top + pDevice->GetHeight();
+ }
+ return TRUE;
+ }
+#endif
diff --git a/core/src/fxge/skia/fx_skia_blitter_new.h b/core/src/fxge/skia/fx_skia_blitter_new.h
new file mode 100644
index 0000000000..6f88065d99
--- /dev/null
+++ b/core/src/fxge/skia/fx_skia_blitter_new.h
@@ -0,0 +1,225 @@
+#ifndef _FX_SKIABLITTER_H_
+#define _FX_SKIABLITTER_H_
+//#define _SKIA_SUPPORT_
+#if defined(_SKIA_SUPPORT_)
+class CFX_SkiaRenderer : public SkBlitter, public CFX_Object
+{
+protected:
+ int m_Alpha,
+ m_Red, // Or the complementary-color, Cyan
+ m_Green, // Magenta
+ m_Blue, // Yellow
+ m_Gray; // Black
+ FX_DWORD m_Color; // FX_ARGB or FX_CMYK
+ FX_BOOL m_bFullCover;
+ int m_ProcessFilter;
+ FX_BOOL m_bRgbByteOrder;
+
+ FX_RECT m_ClipBox;
+ CFX_DIBitmap* m_pDevice;
+ CFX_DIBitmap* m_pOriDevice;
+ const CFX_ClipRgn* m_pClipRgn;
+ const CFX_DIBitmap* m_pClipMask;
+
+ FX_LPBYTE m_pDestScan;
+ FX_LPBYTE m_pDestExtraAlphaScan;
+ FX_LPBYTE m_pOriScan;
+ FX_LPBYTE m_pClipScan;
+
+ void (CFX_SkiaRenderer::*composite_span)(FX_LPBYTE,FX_LPBYTE,int,int,int,int,FX_BYTE,int,int,int,FX_LPBYTE,FX_LPBYTE);
+public:
+
+ //--------------------------------------------------------------------
+ virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+ virtual void blitH(int x, int y, int width);
+ virtual void blitV(int x, int y, int height, SkAlpha alpha);
+ virtual void blitRect(int x, int y, int width, int height);
+ virtual void blitAntiRect(int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha);
+
+ /*------------------------------------------------------------------------------------------------------*/
+ // A general alpha merge function (with clipping mask). Gray device.
+ void CompositeSpan1bpp_0(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpan1bpp_1(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpan1bpp_4(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpan1bpp_5(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpan1bpp_8(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpan1bpp_9(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpan1bpp_12(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpan1bpp_13(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ /*--------------------------------------------------------------------------------------------------------*/
+
+ // A general alpha merge function (with clipping mask). Gray device.
+ void CompositeSpanGray_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ void CompositeSpanGray_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ void CompositeSpanGray_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ void CompositeSpanGray_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ void CompositeSpanGray_10(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+
+ void CompositeSpanGray_11(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ void CompositeSpanGray_14(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ void CompositeSpanGray_15(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ /*--------------------------------------------------------------------------------------------------------*/
+ void CompositeSpanARGB_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ void CompositeSpanARGB_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+
+ void CompositeSpanARGB_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+
+ void CompositeSpanARGB_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ // ...
+ /*--------------------------------------------------------------------------------------------------------*/
+ void CompositeSpanRGB32_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB32_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB32_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB32_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ /*---------------------------------------------------------------------------------------------------------*/
+
+ void CompositeSpanRGB24_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB24_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB24_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB24_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB24_10(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB24_11(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB24_14(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+ void CompositeSpanRGB24_15(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+ /*----------------------------------------------------------------------------------------------------------*/
+
+ // A general alpha merge function (with clipping mask). Cmyka/Cmyk device.
+ void CompositeSpanCMYK(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan,int Bpp,
+ int span_left, int span_len, int span_top, FX_BYTE cover_scan,
+ int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
+ FX_LPBYTE dest_extra_alpha_scan);
+
+
+ //--------------------------------------------------------------------
+ FX_BOOL Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByteOrder,
+ int alpha_flag = 0, void* pIccTransform = NULL); //The alpha flag must be fill_flag if exist.
+};
+class CFX_SkiaA8Renderer : public SkBlitter, public CFX_Object
+{
+public:
+ //--------------------------------------------------------------------
+ virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+ virtual void blitH(int x, int y, int width);
+ virtual void blitV(int x, int y, int height, SkAlpha alpha);
+ virtual void blitRect(int x, int y, int width, int height);
+ virtual void blitAntiRect(int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha);
+ //--------------------------------------------------------------------
+ FX_BOOL Init(CFX_DIBitmap* pDevice, int Left, int Top);
+ CFX_DIBitmap* m_pDevice;
+ int m_Left;
+ int m_Top;
+ int m_dstWidth;
+ int m_dstHeight;
+};
+#endif
+#endif \ No newline at end of file
diff --git a/core/src/fxge/skia/fx_skia_device.cpp b/core/src/fxge/skia/fx_skia_device.cpp
new file mode 100644
index 0000000000..3661d5d828
--- /dev/null
+++ b/core/src/fxge/skia/fx_skia_device.cpp
@@ -0,0 +1,527 @@
+#include "../../../include/fxge/fx_ge.h"
+//#define _SKIA_SUPPORT_
+#if defined(_SKIA_SUPPORT_)
+#include "../../../include/fxcodec/fx_codec.h"
+
+
+//#define _FOXIT_DEBUG_
+//#define _FOXIT_BENCHMARK_
+
+extern "C" {
+ extern void FX_OUTPUT_LOG_FUNC(const char*, ...);
+ extern int FX_GET_TICK_FUNC();
+};
+
+#ifdef _FOXIT_DEBUG_
+#define FOXIT_DEBUG1(msg) FX_OUTPUT_LOG_FUNC(msg)
+#define FOXIT_DEBUG2(msg,para) FX_OUTPUT_LOG_FUNC(msg,para)
+#define FOXIT_DEBUG3(msg,para1,para2) FX_OUTPUT_LOG_FUNC(msg,para1,para2)
+#define FOXIT_DEBUG4(msg,para1,para2,para3) FX_OUTPUT_LOG_FUNC(msg,para1,para2,para3)
+#define FOXIT_DEBUG5(msg,para1,para2,para3,param4) FX_OUTPUT_LOG_FUNC(msg,para1,para2,para3,param4)
+#else
+#define FOXIT_DEBUG1(msg)
+#define FOXIT_DEBUG2(msg,para)
+#define FOXIT_DEBUG3(msg,para1,para2)
+#define FOXIT_DEBUG4(msg,para1,para2,para3)
+#define FOXIT_DEBUG5(msg,para1,para2,para3,param4)
+#endif
+
+#include "SkDashPathEffect.h"
+#include "SkTLazy.h"
+#include "SkScan.h"
+#include "SkRasterClip.h"
+#include "SkStroke.h"
+
+
+#include "fx_skia_blitter_new.h"
+#include "../agg/fx_agg_driver.h"
+#include "fx_skia_device.h"
+/// Run-length-encoded supersampling antialiased blitter.
+class SuperBlitter_skia
+{
+public:
+ static void DrawPath(const SkPath& srcPath, SkBlitter* blitter, const SkRasterClip& rect, const SkPaint& origPaint);
+};
+FX_BOOL FxSkDrawTreatAsHairline(const SkPaint& paint, SkScalar* coverage) {
+ if (SkPaint::kStroke_Style != paint.getStyle())
+ return FALSE;
+ FXSYS_assert(coverage);
+ SkScalar strokeWidth = paint.getStrokeWidth();
+ if (0 == strokeWidth) {
+ *coverage = SK_Scalar1;
+ return TRUE;
+ }
+ // if we get here, we need to try to fake a thick-stroke with a modulated
+ // hairline
+ if (!paint.isAntiAlias())
+ return FALSE;
+ if (strokeWidth <= SK_Scalar1) {
+ *coverage = strokeWidth;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void SuperBlitter_skia::DrawPath(const SkPath& srcPath, SkBlitter* blitter, const SkRasterClip& rect, const SkPaint& origPaint)
+{
+ SkPath* pathPtr = (SkPath*)&srcPath;
+ bool doFill = true;
+ SkPath tmpPath;
+ SkTCopyOnFirstWrite<SkPaint> paint(origPaint);
+ {
+ SkScalar coverage;
+ if (FxSkDrawTreatAsHairline(origPaint, &coverage)) {
+ if (SK_Scalar1 == coverage) {
+ paint.writable()->setStrokeWidth(0);
+ } else if (1) {//xfermodeSupportsCoverageAsAlpha(xfer), we not use blend mode here, xfer aways NULL.
+ U8CPU newAlpha;
+ // this is the old technique, which we preserve for now so
+ // we don't change previous results (testing)
+ // the new way seems fine, its just (a tiny bit) different
+ int scale = (int)SkScalarMul(coverage, 256);
+ newAlpha = origPaint.getAlpha() * scale >> 8;
+ SkPaint* writablePaint = paint.writable();
+ writablePaint->setStrokeWidth(0);
+ writablePaint->setAlpha(newAlpha);
+ }
+ }
+ }
+ if (paint->getPathEffect() || paint->getStyle() != SkPaint::kFill_Style) {
+ SkIRect devBounds = rect.getBounds();
+ // outset to have slop for antialasing and hairlines
+ devBounds.outset(1, 1);
+ SkRect cullRect = SkRect::Make(devBounds);
+ doFill = paint->getFillPath(*pathPtr, &tmpPath, &cullRect);
+ pathPtr = &tmpPath;
+ }
+ // avoid possibly allocating a new path in transform if we can
+ SkPath* devPathPtr = pathPtr;
+ void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*);
+ if (doFill) {
+ if (paint->isAntiAlias()) {
+ proc = SkScan::AntiFillPath;
+ } else {
+ proc = SkScan::FillPath;
+ }
+ } else { // hairline
+ if (paint->isAntiAlias()) {
+ proc = SkScan::AntiHairPath;
+ } else {
+ proc = SkScan::HairPath;
+ }
+ }
+ proc(*devPathPtr, rect, blitter);
+}
+
+class CSkia_PathData : public CFX_Object
+{
+public:
+ CSkia_PathData() {}
+ ~CSkia_PathData() {}
+ SkPath m_PathData;
+
+ void BuildPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device);
+};
+
+void CSkia_PathData::BuildPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device)
+{
+ const CFX_PathData* pFPath = pPathData;
+ int nPoints = pFPath->GetPointCount();
+ FX_PATHPOINT* pPoints = pFPath->GetPoints();
+ for (int i = 0; i < nPoints; i ++) {
+ FX_FIXFLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY;
+ if (pObject2Device) pObject2Device->Transform(x, y);
+ int point_type = pPoints[i].m_Flag & FXPT_TYPE;
+ if (point_type == FXPT_MOVETO) {
+ m_PathData.moveTo(x, y);
+ } else if (point_type == FXPT_LINETO) {
+ if (pPoints[i-1].m_Flag == FXPT_MOVETO && (i == nPoints-1 || pPoints[i+1].m_Flag == FXPT_MOVETO) &&
+ FXSYS_abs(pPoints[i].m_PointX - pPoints[i-1].m_PointX) < 0.4f && FXSYS_abs(pPoints[i].m_PointY - pPoints[i-1].m_PointY)< 0.4f)
+ // PDF line includes the destination point, unlike Windows line.
+ // We received some PDF which actually draws zero length lines. TESTDOC: summer cha show.pdf
+ // Therefore, we have to extend the line by 0.4 pixel here.
+ // But only for standalone segment. TESTDOC: bug #1434 - maze.pdf; TESTDOC: bug#1508 di704P_QIG_111.pdf
+ x += 0.4;
+ // TODO: we should actually tell skia vertex generator to process zero length stroked line
+ // (only butts are drawn)
+ m_PathData.lineTo(x, y);
+ } else if (point_type == FXPT_BEZIERTO) {
+ FX_FIXFLOAT x2 = pPoints[i+1].m_PointX, y2 = pPoints[i+1].m_PointY;
+ FX_FIXFLOAT x3 = pPoints[i+2].m_PointX, y3 = pPoints[i+2].m_PointY;
+ if (pObject2Device){
+ pObject2Device->Transform(x2, y2);
+ pObject2Device->Transform(x3, y3);
+ }
+ m_PathData.cubicTo(x, y, x2, y2, x3, y3);
+ i += 2;
+ }
+ if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) m_PathData.close();
+ }
+}
+
+// convert a stroking path to scanlines
+static void SkRasterizeStroke(SkPaint& spaint, SkPath* dstPathData, SkPath& path_data,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState, FX_FIXFLOAT scale = FIX8_ONE,
+ FX_BOOL bStrokeAdjust = FALSE, FX_BOOL bTextMode = FALSE)
+{
+ SkPaint::Cap cap;
+ switch (pGraphState->m_LineCap) {
+ case CFX_GraphStateData::LineCapRound:
+ cap = SkPaint::kRound_Cap;
+ break;
+ case CFX_GraphStateData::LineCapSquare:
+ cap = SkPaint::kSquare_Cap;
+ break;
+ default:
+ cap = SkPaint::kButt_Cap;
+ break;
+ }
+ SkPaint::Join join;
+ switch (pGraphState->m_LineJoin) {
+ case CFX_GraphStateData::LineJoinRound:
+ join = SkPaint::kRound_Join;
+ break;
+ case CFX_GraphStateData::LineJoinBevel:
+ join = SkPaint::kBevel_Join;
+ break;
+ default:
+ join = SkPaint::kMiter_Join;
+ break;
+ }
+ FX_FIXFLOAT width = pGraphState->m_LineWidth*scale;
+ FX_FIXFLOAT unit = fix32_to_8(fixdiv_8_8_to_32(FIX8_ONE, (pObject2Device->GetXUnit() + pObject2Device->GetYUnit()) / 2));
+ if (width <= unit) width = unit;
+
+ if (pGraphState->m_DashArray == NULL) {
+ SkStroke stroker;
+ stroker.setCap(cap);
+ stroker.setJoin(join);
+ stroker.setMiterLimit(pGraphState->m_MiterLimit);
+ stroker.setWidth(width);
+ stroker.setDoFill(FALSE);
+ stroker.strokePath(path_data, dstPathData);
+ SkMatrix smatrix;
+ smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1);
+ dstPathData->transform(smatrix);
+ } else {
+ int count = (pGraphState->m_DashCount+1)/2;
+ SkScalar* intervals = FX_Alloc(SkScalar, count* sizeof (SkScalar));
+ // Set dash pattern
+ for (int i = 0; i < count; i ++) {
+ FX_FIXFLOAT on = pGraphState->m_DashArray[i*2];
+ if (on <= 0.000001f) on = FIX8_ONE/10;
+ FX_FIXFLOAT off = i*2+1 == pGraphState->m_DashCount ? on :
+ pGraphState->m_DashArray[i*2+1];
+ if (off < 0) off = 0;
+ intervals[i*2]=on*scale;
+ intervals[i*2+1]=off*scale;
+ }
+ SkDashPathEffect* pEffect = new SkDashPathEffect(intervals,count*2, pGraphState->m_DashPhase*scale);
+ spaint.setPathEffect(pEffect)->unref();
+ spaint.setStrokeWidth(width);
+ spaint.setStrokeMiter(pGraphState->m_MiterLimit);
+ spaint.setStrokeCap(cap);
+ spaint.setStrokeJoin(join);
+ spaint.getFillPath(path_data, dstPathData);
+ SkMatrix smatrix;
+ smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1);
+ dstPathData->transform(smatrix);
+ FX_Free(intervals);
+ }
+}
+
+CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout)
+{
+ m_pAggDriver = FX_NEW CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout);
+}
+CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver()
+{
+ if (m_pAggDriver) delete m_pAggDriver;
+}
+FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
+ CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FIXFLOAT font_size, FX_DWORD color,
+ int alpha_flag, void* pIccTransform)
+{
+ return m_pAggDriver->DrawDeviceText(nChars, pCharPos, pFont,pCache, pObject2Device, font_size, color,
+ alpha_flag, pIccTransform);
+}
+int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id)
+{
+ return m_pAggDriver->GetDeviceCaps(caps_id);
+}
+void CFX_SkiaDeviceDriver::SaveState()
+{
+ m_pAggDriver->SaveState();
+}
+
+void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved)
+{
+ m_pAggDriver->RestoreState(bKeepSaved);
+}
+void CFX_SkiaDeviceDriver::SetClipMask(rasterizer_scanline_aa& rasterizer)
+{
+ m_pAggDriver->SetClipMask(rasterizer);
+}
+void CFX_SkiaDeviceDriver::SetClipMask(SkPath& skPath, SkPaint* spaint)
+{
+ SkIRect clip_box;
+ clip_box.set(0, 0, fix0_to_8(GetDeviceCaps(FXDC_PIXEL_WIDTH)), fix0_to_8(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
+ clip_box.intersect(m_pAggDriver->m_pClipRgn->GetBox().left, m_pAggDriver->m_pClipRgn->GetBox().top,
+ m_pAggDriver->m_pClipRgn->GetBox().right, m_pAggDriver->m_pClipRgn->GetBox().bottom);
+
+ SkPath* pathPtr = &skPath;
+
+ SkRect path_rect = skPath.getBounds();
+
+ clip_box.intersect(FXSYS_floor(path_rect.fLeft), FXSYS_floor(path_rect.fTop), FXSYS_floor(path_rect.fRight)+1, FXSYS_floor(path_rect.fBottom)+1);
+ CFX_DIBitmapRef mask;
+ CFX_DIBitmap* pThisLayer = mask.New();
+ pThisLayer->Create(clip_box.width(), clip_box.height(), FXDIB_8bppMask);
+ pThisLayer->Clear(0);
+
+ CFX_SkiaA8Renderer render;
+ render.Init(pThisLayer, clip_box.fLeft, clip_box.fTop);
+
+ SkRasterClip rasterClip(clip_box);
+ SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, *spaint);
+
+ // Finally, we have got the mask that we need, intersect with current clip region
+ m_pAggDriver->m_pClipRgn->IntersectMaskF(clip_box.fLeft, clip_box.fTop, mask);
+
+}
+FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, // path info
+ const CFX_AffineMatrix* pObject2Device, // optional transformation
+ int fill_mode // fill mode, WINDING or ALTERNATE
+ )
+{
+ if (m_pAggDriver->m_pClipRgn == NULL)
+ m_pAggDriver->m_pClipRgn = FX_NEW CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+
+ if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) {
+ CFX_FloatRect rectf;
+ if (pPathData->IsRect(pObject2Device, &rectf)) {
+ rectf.Intersect(CFX_FloatRect(0, 0, (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
+ FX_RECT rect = rectf.GetOutterRect();
+ m_pAggDriver->m_pClipRgn->IntersectRect(rect);
+ return TRUE;
+ }
+ }
+ CSkia_PathData path_data;
+ path_data.BuildPath(pPathData, pObject2Device);
+ path_data.m_PathData.close();
+ path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING? SkPath::kWinding_FillType:SkPath::kEvenOdd_FillType);
+
+ SkPaint spaint;
+ spaint.setColor(0xffffffff);
+ spaint.setAntiAlias(TRUE);
+ spaint.setStyle(SkPaint::kFill_Style);
+
+ SetClipMask(path_data.m_PathData, &spaint);
+
+ return TRUE;
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData, // path info
+ const CFX_AffineMatrix* pObject2Device, // optional transformation
+ const CFX_GraphStateData* pGraphState // graphic state, for pen attributes
+ )
+{
+ if (m_pAggDriver->m_pClipRgn == NULL)
+ m_pAggDriver->m_pClipRgn = FX_NEW CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+
+ // build path data
+ CSkia_PathData path_data;
+ path_data.BuildPath(pPathData, NULL);
+ path_data.m_PathData.setFillType(SkPath::kWinding_FillType);
+
+ SkPaint spaint;
+ spaint.setColor(0xffffffff);
+ spaint.setStyle(SkPaint::kStroke_Style);
+ spaint.setAntiAlias(TRUE);
+
+ SkPath dst_path;
+ SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, pObject2Device, pGraphState, 1, FALSE, 0);
+ spaint.setStyle(SkPaint::kFill_Style);
+ SetClipMask(dst_path, &spaint);
+
+ return TRUE;
+}
+FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizer(rasterizer_scanline_aa& rasterizer, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout,
+ int alpha_flag, void* pIccTransform)
+{
+ return m_pAggDriver->RenderRasterizer(rasterizer, color, bFullCover, bGroupKnockout,alpha_flag, pIccTransform);
+}
+FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizerSkia(SkPath& skPath, const SkPaint& origPaint, SkIRect& rect, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout,
+ int alpha_flag, void* pIccTransform, FX_BOOL bFill)
+{
+ CFX_DIBitmap* pt = bGroupKnockout?m_pAggDriver->GetBackDrop():NULL;
+ CFX_SkiaRenderer render;
+ if (!render.Init(m_pAggDriver->m_pBitmap, pt, m_pAggDriver->m_pClipRgn, color, bFullCover, m_pAggDriver->m_bRgbByteOrder, alpha_flag, pIccTransform))
+ return FALSE;
+
+ SkRasterClip rasterClip(rect);
+ SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, origPaint);
+
+ return TRUE;
+
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::DrawPath(const CFX_PathData* pPathData, // path info
+ const CFX_AffineMatrix* pObject2Device, // optional transformation
+ const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes
+ FX_DWORD fill_color, // fill color
+ FX_DWORD stroke_color, // stroke color
+ int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled
+ int alpha_flag,
+ void* pIccTransform
+ )
+{
+ if (GetBuffer() == NULL) return TRUE;
+ FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering");
+ SkIRect rect;
+ rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+ if ((fill_mode & 3) && fill_color) {
+ // We have to transform before building path data, otherwise we'll have flatting problem
+ // when we enlarge a small path (flatten before transformed)
+ // TESTDOC: Bug #5115 - DS_S1Dimpact_lr.pdf
+ // build path data
+ CSkia_PathData path_data;
+ path_data.BuildPath(pPathData, pObject2Device);
+ //path_data.m_PathData.close();
+ path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING? SkPath::kWinding_FillType:SkPath::kEvenOdd_FillType);
+
+ SkPaint spaint;
+ spaint.setAntiAlias(TRUE);
+ spaint.setStyle(SkPaint::kFill_Style);
+ spaint.setColor(fill_color);
+ if (!RenderRasterizerSkia(path_data.m_PathData, spaint, rect, fill_color, fill_mode & FXFILL_FULLCOVER, FALSE, alpha_flag, pIccTransform))
+ return FALSE;
+ }
+
+ int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STROKE(alpha_flag) : FXARGB_A(stroke_color);
+
+ if (pGraphState && stroke_alpha) {
+ // We split the matrix into two parts: first part doing the scaling, so we won't have the
+ // flatness problem, second part doing the transformation, so we don't have stroking geo problem.
+ // TESTDOC: Bug #5253 - test[1].pdf
+ CFX_AffineMatrix matrix1, matrix2;
+ if (pObject2Device) {
+ matrix1.a = FXSYS_fabs(pObject2Device->a) > FXSYS_fabs(pObject2Device->b) ?
+ FXSYS_fabs(pObject2Device->a) : FXSYS_fabs(pObject2Device->b);
+ matrix1.d = matrix1.a;//FXSYS_fabs(pObject2Device->c) > FXSYS_fabs(pObject2Device->d) ?
+ //pObject2Device->c : pObject2Device->d;
+ matrix2.Set(pObject2Device->a/matrix1.a, pObject2Device->b/matrix1.a,
+ pObject2Device->c/matrix1.d, pObject2Device->d/matrix1.d,
+ pObject2Device->e, pObject2Device->f);
+ }
+ // build path data
+ CSkia_PathData path_data;
+ path_data.BuildPath(pPathData, &matrix1);
+ path_data.m_PathData.setFillType(SkPath::kWinding_FillType);
+
+ SkPaint spaint;
+ spaint.setColor(stroke_color);
+ spaint.setStyle(SkPaint::kStroke_Style);
+ spaint.setAntiAlias(TRUE);
+ SkPath dst_path;
+ SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, &matrix2, pGraphState, matrix1.a, FALSE, 0);
+ spaint.setStyle(SkPaint::kFill_Style);
+ int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag)<<8 | FXGETFLAG_ALPHA_STROKE(alpha_flag);
+
+ if (!RenderRasterizerSkia(dst_path, spaint, rect, stroke_color, fill_mode & FXFILL_FULLCOVER, FALSE, fill_flag, pIccTransform, FALSE))
+ return FALSE;
+
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::SetPixel(int x, int y, FX_DWORD color,
+ int alpha_flag, void* pIccTransform)
+{
+ return m_pAggDriver->SetPixel(x, y, color, alpha_flag, pIccTransform);
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, int alpha_flag, void* pIccTransform)
+{
+ return m_pAggDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform);
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect)
+{
+ return m_pAggDriver->GetClipBox(pRect);
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform, FX_BOOL bDEdge)
+{
+ return m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge);
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD argb, const FX_RECT* pSrcRect, int left, int top, int blend_type,
+ int alpha_flag, void* pIccTransform)
+{
+ return m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend_type, alpha_flag, pIccTransform);
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD argb, int dest_left, int dest_top,
+ int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,
+ int alpha_flag, void* pIccTransform)
+{
+ return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top,
+ dest_width, dest_height, pClipRect, flags,
+ alpha_flag, pIccTransform);
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitmap_alpha, FX_DWORD argb,
+ const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handle,
+ int alpha_flag, void* pIccTransform)
+{
+ return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb,
+ pMatrix, render_flags, handle, alpha_flag, pIccTransform);
+}
+
+FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(FX_LPVOID pHandle, IFX_Pause* pPause)
+{
+ return m_pAggDriver->ContinueDIBits(pHandle, pPause);
+}
+
+void CFX_SkiaDeviceDriver::CancelDIBits(FX_LPVOID pHandle)
+{
+ m_pAggDriver->CancelDIBits(pHandle);
+}
+
+CFX_SkiaDevice::CFX_SkiaDevice()
+{
+ m_bOwnedBitmap = FALSE;
+}
+
+FX_BOOL CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout)
+{
+ if (pBitmap == NULL)
+ return FALSE;
+ SetBitmap(pBitmap);
+ CFX_SkiaDeviceDriver* pDriver = FX_NEW CFX_SkiaDeviceDriver(pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout);
+ SetDeviceDriver(pDriver);
+ return TRUE;
+}
+
+FX_BOOL CFX_SkiaDevice::Create(int width, int height, FXDIB_Format format, int dither_bits, CFX_DIBitmap* pOriDevice)
+{
+ m_bOwnedBitmap = TRUE;
+ CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap;
+ if (!pBitmap->Create(width, height, format)) {
+ delete pBitmap;
+ return FALSE;
+ }
+ SetBitmap(pBitmap);
+ CFX_SkiaDeviceDriver* pDriver = FX_NEW CFX_SkiaDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE);
+ SetDeviceDriver(pDriver);
+ return TRUE;
+}
+CFX_SkiaDevice::~CFX_SkiaDevice()
+{
+ if (m_bOwnedBitmap && GetBitmap()) delete GetBitmap();
+}
+
+#endif \ No newline at end of file
diff --git a/core/src/fxge/skia/fx_skia_device.h b/core/src/fxge/skia/fx_skia_device.h
new file mode 100644
index 0000000000..a001d1a03f
--- /dev/null
+++ b/core/src/fxge/skia/fx_skia_device.h
@@ -0,0 +1,86 @@
+#ifndef _FX_SKIA_DEVICE_DRIVER_
+#define _FX_SKIA_DEVICE_DRIVER_
+//#define _SKIA_SUPPORT_
+#if defined(_SKIA_SUPPORT_)
+class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver
+{
+public:
+ CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout);
+ virtual ~CFX_SkiaDeviceDriver();
+
+ /** Options */
+ virtual int GetDeviceCaps(int caps_id);
+
+ /** Save and restore all graphic states */
+ virtual void SaveState();
+ virtual void RestoreState(FX_BOOL bKeepSaved);
+
+ /** Set clipping path using filled region */
+ virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, // path info
+ const CFX_AffineMatrix* pObject2Device, // optional transformation
+ int fill_mode // fill mode, WINDING or ALTERNATE
+ );
+
+ /** Set clipping path using stroked region */
+ virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, // path info
+ const CFX_AffineMatrix* pObject2Device, // optional transformation
+ const CFX_GraphStateData* pGraphState // graphic state, for pen attributes
+ );
+
+ /** Draw a path */
+ virtual FX_BOOL DrawPath(const CFX_PathData* pPathData,
+ const CFX_AffineMatrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState,
+ FX_DWORD fill_color,
+ FX_DWORD stroke_color,
+ int fill_mode,
+ int alpha_flag = 0,
+ void* pIccTransform = NULL
+ );
+
+ virtual FX_BOOL SetPixel(int x, int y, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ virtual FX_BOOL FillRect(const FX_RECT* pRect, FX_DWORD fill_color,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ /** Draw a single pixel (device dependant) line */
+ virtual FX_BOOL DrawCosmeticLine(FX_FIXFLOAT x1, FX_FIXFLOAT y1, FX_FIXFLOAT x2, FX_FIXFLOAT y2, FX_DWORD color,
+ int alpha_flag, void* pIccTransform, int blend_type) { return FALSE; }
+
+ virtual FX_BOOL GetClipBox(FX_RECT* pRect);
+
+ /** Load device buffer into a DIB */
+ virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL, FX_BOOL bDEdge = FALSE);
+
+ virtual CFX_DIBitmap* GetBackDrop() { return m_pAggDriver->GetBackDrop(); }
+
+ virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect,
+ int dest_left, int dest_top, int blend_type,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+ virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top,
+ int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color,
+ const CFX_AffineMatrix* pMatrix, FX_DWORD flags, FX_LPVOID& handle,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+ virtual FX_BOOL ContinueDIBits(FX_LPVOID handle, IFX_Pause* pPause);
+ virtual void CancelDIBits(FX_LPVOID handle);
+
+ virtual FX_BOOL DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont,
+ CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FIXFLOAT font_size, FX_DWORD color,
+ int alpha_flag = 0, void* pIccTransform = NULL);
+
+ virtual FX_BOOL RenderRasterizer(rasterizer_scanline_aa& rasterizer, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout,
+ int alpha_flag, void* pIccTransform);
+ virtual FX_BOOL RenderRasterizerSkia(SkPath& skPath, const SkPaint& origPaint, SkIRect& rect, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout,
+ int alpha_flag, void* pIccTransform, FX_BOOL bFill = TRUE);
+ void SetClipMask(rasterizer_scanline_aa& rasterizer);
+ void SetClipMask(SkPath& skPath, SkPaint* spaint);
+ virtual FX_LPBYTE GetBuffer() const {return m_pAggDriver->GetBuffer();}
+
+ CFX_AggDeviceDriver* m_pAggDriver;
+};
+#endif
+#endif// _FX_SKIA_DEVICE_DRIVER_ \ No newline at end of file