summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.cpp1809
-rw-r--r--core/src/fxge/skia/fx_skia_blitter_new.h522
-rw-r--r--core/src/fxge/skia/fx_skia_device.cpp468
-rw-r--r--core/src/fxge/skia/fx_skia_device.h50
4 files changed, 160 insertions, 2689 deletions
diff --git a/core/src/fxge/skia/fx_skia_blitter_new.cpp b/core/src/fxge/skia/fx_skia_blitter_new.cpp
deleted file mode 100644
index 7a8cb1bfac..0000000000
--- a/core/src/fxge/skia/fx_skia_blitter_new.cpp
+++ /dev/null
@@ -1,1809 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "core/include/fxge/fx_ge.h"
-
-#if defined(_SKIA_SUPPORT_)
-#include "SkBlitter.h"
-#include "core/include/fxcodec/fx_codec.h"
-#include "core/src/fxge/skia/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 && !composite_span)
- 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)
- (*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;
- (*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) {
- 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;
- 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_bRgbByteOrder);
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)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()) {
- for (int i = 0; i < 2; i++) {
- if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
- index = i;
- }
- } else {
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- }
- uint8_t* 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_bRgbByteOrder);
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left / 8;
- clip_scan = (uint8_t*)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()) {
- for (int i = 0; i < 2; i++) {
- if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
- index = i;
- }
- } else {
- index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
- }
- uint8_t* 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- ASSERT(!m_bRgbByteOrder);
- dest_scan = (uint8_t*)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_memset(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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- ASSERT(!m_bRgbByteOrder);
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
- ori_scan = (uint8_t*)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_memset(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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_bRgbByteOrder);
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
- clip_scan = (uint8_t*)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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left;
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left;
- clip_scan = (uint8_t*)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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan = (uint8_t*)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_memset(dest_scan, m_Color, (col_end - col_start) << 2);
- return;
- }
- int 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;
- }
- uint8_t 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2);
- // ori_scan = (uint8_t*)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_memset(dest_scan, m_Color, (col_end - col_start) << 2);
- return;
- }
- if (cover_scan == 255) {
- int dst_color = (0x00ffffff & m_Color) | (m_Alpha << 24);
- FXSYS_memset(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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2);
- clip_scan = (uint8_t*)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;
- }
- uint8_t 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;
- }
- uint8_t 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;
- }
- uint8_t 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2);
- // ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2);
- clip_scan = (uint8_t*)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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan = (uint8_t*)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_memset(dest_scan, m_Color, (col_end - col_start) << 2);
- return;
- }
- int 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2);
- ori_scan = (uint8_t*)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_memset(dest_scan, m_Color, (col_end - col_start) << 2);
- return;
- }
- int src_alpha = m_Alpha;
- for (int col = col_start; col < col_end; col++) {
- 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2);
- clip_scan = (uint8_t*)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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2);
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left << 2);
- clip_scan = (uint8_t*)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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan =
- (uint8_t*)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 = 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan =
- (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1);
- ori_scan = (uint8_t*)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++) {
- 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan =
- (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1);
- clip_scan = (uint8_t*)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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- ASSERT(!m_pDevice->IsCmykImage());
- dest_scan =
- (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1);
- ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left +
- (span_left << 1);
- clip_scan = (uint8_t*)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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan =
- (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1);
- dest_extra_alpha_scan =
- (uint8_t*)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++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)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)
- uint8_t 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++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)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)
- uint8_t 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++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)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)
- uint8_t 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan) {
- dest_scan =
- (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1);
- dest_extra_alpha_scan =
- (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top) + span_left;
- clip_scan = (uint8_t*)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++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
- } else {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t 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++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
- } else {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t 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++ = (uint8_t)m_Blue;
- *dest_scan++ = (uint8_t)m_Green;
- *dest_scan++ = (uint8_t)m_Red;
- *dest_extra_alpha_scan++ = (uint8_t)m_Alpha;
- } else {
- // Dest format: Rgba
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* 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 = (uint8_t)m_Alpha;
- } else {
- // Dest format: Cmyka
- // calculate destination alpha (it's union of source and dest alpha)
- uint8_t 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) {
- uint8_t gray;
- color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
- pIccModule->TranslateScanline(pIccTransform, &gray,
- (const uint8_t*)&color, 1);
- m_Gray = gray;
- } else {
- if (bObjectCMYK) {
- uint8_t 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, (uint8_t*)&m_Color,
- (const uint8_t*)&m_Color, 1);
- } else { // Object RGB
- if (!pIccTransform)
- return FALSE;
- color = FXARGB_TODIB(color);
- pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color,
- (const uint8_t*)&color, 1);
- }
- m_Red = ((uint8_t*)&m_Color)[0];
- m_Green = ((uint8_t*)&m_Color)[1];
- m_Blue = ((uint8_t*)&m_Color)[2];
- m_Gray = ((uint8_t*)&m_Color)[3];
- return TRUE;
- }
- if (pIccTransform) {
- color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
- pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color,
- (const uint8_t*)&color, 1);
- ((uint8_t*)&m_Color)[3] = m_Alpha;
- m_Red = ((uint8_t*)&m_Color)[2];
- m_Green = ((uint8_t*)&m_Color)[1];
- m_Blue = ((uint8_t*)&m_Color)[0];
- // Need Johnson to improvement it.
- if (m_bRgbByteOrder) {
- // swap
- m_Red = ((uint8_t*)&m_Color)[0];
- m_Blue = ((uint8_t*)&m_Color)[2];
- m_Color = FXARGB_TODIB(m_Color);
- m_Color = FXARGB_TOBGRORDERDIB(m_Color);
- }
- } else {
- if (bObjectCMYK) {
- uint8_t 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;
- }
- return !!composite_span;
-}
-
-/*----------------------------------------------------------------------------------------------------*/
-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;
-
- uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y;
- uint8_t* 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_memset(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;
- uint8_t* 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) {
- uint8_t* dest_pos = dest_scan + col_start;
- if (result >= 4)
- FXSYS_memset(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) {
- blitRect(x, y, 1, height);
- } else {
- int16_t runs[2];
- runs[0] = 1;
- runs[1] = 0;
- while (--height >= 0) {
- if (y >= m_dstHeight)
- return;
- 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
deleted file mode 100644
index 36a6b438f1..0000000000
--- a/core/src/fxge/skia/fx_skia_blitter_new.h
+++ /dev/null
@@ -1,522 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CORE_SRC_FXGE_SKIA_FX_SKIA_BLITTER_NEW_H_
-#define CORE_SRC_FXGE_SKIA_FX_SKIA_BLITTER_NEW_H_
-
-#if defined(_SKIA_SUPPORT_)
-class CFX_SkiaRenderer : public SkBlitter {
- 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;
-
- uint8_t* m_pDestScan;
- uint8_t* m_pDestExtraAlphaScan;
- uint8_t* m_pOriScan;
- uint8_t* m_pClipScan;
-
- void (CFX_SkiaRenderer::*composite_span)(uint8_t*,
- uint8_t*,
- int,
- int,
- int,
- int,
- uint8_t,
- int,
- int,
- int,
- uint8_t*,
- uint8_t*);
-
- 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(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpan1bpp_1(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpan1bpp_4(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpan1bpp_5(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpan1bpp_8(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpan1bpp_9(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpan1bpp_12(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpan1bpp_13(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- /*--------------------------------------------------------------------------------------------------------*/
-
- // A general alpha merge function (with clipping mask). Gray device.
- void CompositeSpanGray_2(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanGray_3(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanGray_6(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanGray_7(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanGray_10(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanGray_11(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanGray_14(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanGray_15(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- /*--------------------------------------------------------------------------------------------------------*/
- void CompositeSpanARGB_2(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanARGB_3(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanARGB_6(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- void CompositeSpanARGB_7(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- // ...
- /*--------------------------------------------------------------------------------------------------------*/
- void CompositeSpanRGB32_2(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB32_3(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB32_6(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB32_7(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- /*---------------------------------------------------------------------------------------------------------*/
-
- void CompositeSpanRGB24_2(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB24_3(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB24_6(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB24_7(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB24_10(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB24_11(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB24_14(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
- void CompositeSpanRGB24_15(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* dest_extra_alpha_scan);
-
- /*----------------------------------------------------------------------------------------------------------*/
-
- // A general alpha merge function (with clipping mask). Cmyka/Cmyk device.
- void CompositeSpanCMYK(uint8_t* dest_scan,
- uint8_t* ori_scan,
- int Bpp,
- int span_left,
- int span_len,
- int span_top,
- uint8_t cover_scan,
- int clip_top,
- int clip_left,
- int clip_right,
- uint8_t* clip_scan,
- uint8_t* 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:
- //--------------------------------------------------------------------
- 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 // CORE_SRC_FXGE_SKIA_FX_SKIA_BLITTER_NEW_H_
diff --git a/core/src/fxge/skia/fx_skia_device.cpp b/core/src/fxge/skia/fx_skia_device.cpp
index dede637575..6bfa05f342 100644
--- a/core/src/fxge/skia/fx_skia_device.cpp
+++ b/core/src/fxge/skia/fx_skia_device.cpp
@@ -7,181 +7,49 @@
#if defined(_SKIA_SUPPORT_)
#include "core/include/fxcodec/fx_codec.h"
-#include "SkDashPathEffect.h"
-#include "SkRasterClip.h"
-#include "SkScan.h"
-#include "SkStroke.h"
-#include "SkTLazy.h"
-
#include "core/src/fxge/agg/include/fx_agg_driver.h"
-#include "core/src/fxge/skia/fx_skia_blitter_new.h"
#include "core/src/fxge/skia/fx_skia_device.h"
-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
-
-/// 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:
- CSkia_PathData() {}
- ~CSkia_PathData() {}
- SkPath m_PathData;
-
- void BuildPath(const CFX_PathData* pPathData,
- const CFX_Matrix* pObject2Device);
-};
+#include "SkCanvas.h"
+#include "SkDashPathEffect.h"
+#include "SkPaint.h"
+#include "SkPath.h"
-void CSkia_PathData::BuildPath(const CFX_PathData* pPathData,
- const CFX_Matrix* pObject2Device) {
+static SkPath BuildPath(const CFX_PathData* pPathData,
+ const CFX_Matrix* pObject2Device) {
+ SkPath skPath;
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;
+ FX_FLOAT x = pPoints[i].m_PointX;
+ FX_FLOAT 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);
+ skPath.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);
+ skPath.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;
+ FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY;
+ FX_FLOAT 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);
+ skPath.cubicTo(x, y, x2, y2, x3, y3);
i += 2;
}
if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE)
- m_PathData.close();
+ skPath.close();
}
+ return skPath;
}
// convert a stroking path to scanlines
-static void SkRasterizeStroke(SkPaint& spaint,
- SkPath* dstPathData,
- SkPath& path_data,
- const CFX_Matrix* pObject2Device,
- const CFX_GraphStateData* pGraphState,
- FX_FIXFLOAT scale = FIX8_ONE,
- FX_BOOL bStrokeAdjust = FALSE,
- FX_BOOL bTextMode = FALSE) {
+void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint,
+ const CFX_GraphStateData* pGraphState) {
SkPaint::Cap cap;
switch (pGraphState->m_LineCap) {
case CFX_GraphStateData::LineCapRound:
@@ -206,56 +74,35 @@ static void SkRasterizeStroke(SkPaint& spaint,
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;
+ FX_FLOAT width = pGraphState->m_LineWidth;
if (pGraphState->m_DashArray) {
int count = (pGraphState->m_DashCount + 1) / 2;
SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar));
// Set dash pattern
for (int i = 0; i < count; i++) {
- FX_FIXFLOAT on = pGraphState->m_DashArray[i * 2];
+ FX_FLOAT 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];
+ on = 1.f / 10;
+ FX_FLOAT 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;
+ intervals[i * 2] = on;
+ intervals[i * 2 + 1] = off;
}
- 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);
- } else {
- 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);
+ spaint
+ ->setPathEffect(SkDashPathEffect::Create(intervals, count * 2,
+ pGraphState->m_DashPhase))
+ ->unref();
}
+ spaint->setStyle(SkPaint::kStroke_Style);
+ spaint->setAntiAlias(TRUE);
+ spaint->setStrokeWidth(width);
+ spaint->setStrokeMiter(pGraphState->m_MiterLimit);
+ spaint->setStrokeCap(cap);
+ spaint->setStrokeJoin(join);
}
CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap,
@@ -265,16 +112,30 @@ CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap,
FX_BOOL bGroupKnockout) {
m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder,
pOriDevice, bGroupKnockout);
+ SkBitmap skBitmap;
+ const CFX_DIBitmap* bitmap = m_pAggDriver->m_pBitmap;
+ SkImageInfo imageInfo =
+ SkImageInfo::Make(bitmap->GetWidth(), bitmap->GetHeight(),
+ kN32_SkColorType, kOpaque_SkAlphaType);
+ skBitmap.installPixels(imageInfo, bitmap->GetBuffer(), bitmap->GetPitch(),
+ nullptr, /* to do : set color table */
+ nullptr, nullptr);
+ m_canvas = new SkCanvas(skBitmap);
}
+
CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() {
+#if 0 // TODO(caryclark) : mismatch on allocator ?
+ delete m_canvas;
+#endif
delete m_pAggDriver;
}
+
FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars,
const FXTEXT_CHARPOS* pCharPos,
CFX_Font* pFont,
CFX_FontCache* pCache,
const CFX_Matrix* pObject2Device,
- FX_FIXFLOAT font_size,
+ FX_FLOAT font_size,
FX_DWORD color,
int alpha_flag,
void* pIccTransform) {
@@ -282,50 +143,26 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars,
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_canvas->save();
m_pAggDriver->SaveState();
}
void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) {
m_pAggDriver->RestoreState(bKeepSaved);
+ m_canvas->restore();
}
-void CFX_SkiaDeviceDriver::SetClipMask(rasterizer_scanline_aa& rasterizer) {
+
+void CFX_SkiaDeviceDriver::SetClipMask(
+ agg::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_Matrix* pObject2Device, // optional transformation
@@ -340,26 +177,28 @@ FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill(
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)));
+ CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH),
+ (FX_FLOAT)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);
+ SkPath clip = BuildPath(pPathData, pObject2Device);
+ clip.setFillType((fill_mode & 3) == FXFILL_WINDING
+ ? SkPath::kWinding_FillType
+ : SkPath::kEvenOdd_FillType);
+ const CFX_Matrix& m = *pObject2Device;
+#if 0
+ // TODO(caryclark) : don't clip quite yet
+ // need to understand how to save/restore to balance the clip
+ printf("m:(%g,%g,%g) (%g,%g,%g)\n", m.a, m.b, m.c, m.d, m.e, m.f);
+ clip.dump();
+ SkMatrix skMatrix;
+ skMatrix.setAll(m.a, m.b, m.c, m.d, m.e, m.f, 0, 0, 1);
+ m_canvas->setMatrix(skMatrix);
+ m_canvas->clipPath(clip, SkRegion::kReplace_Op);
+#endif
return TRUE;
}
@@ -375,25 +214,27 @@ FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke(
}
// build path data
- CSkia_PathData path_data;
- path_data.BuildPath(pPathData, NULL);
- path_data.m_PathData.setFillType(SkPath::kWinding_FillType);
+ SkPath skPath = BuildPath(pPathData, NULL);
+ skPath.setFillType(SkPath::kWinding_FillType);
SkPaint spaint;
- spaint.setColor(0xffffffff);
- spaint.setStyle(SkPaint::kStroke_Style);
- spaint.setAntiAlias(TRUE);
-
+ PaintStroke(&spaint, pGraphState);
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);
-
+ spaint.getFillPath(skPath, &dst_path);
+#if 01
+ SkMatrix skMatrix;
+ const CFX_Matrix& m = *pObject2Device;
+ skMatrix.setAll(m.a, m.b, m.c, m.d, m.e, m.f, 0, 0, 1);
+ m_canvas->setMatrix(skMatrix);
+ // TODO(caryclark) : don't clip quite yet
+ // need to understand how to save/restore so that clip is later undone
+ m_canvas->clipPath(dst_path, SkRegion::kReplace_Op);
+#endif
return TRUE;
}
+
FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizer(
- rasterizer_scanline_aa& rasterizer,
+ agg::rasterizer_scanline_aa& rasterizer,
FX_DWORD color,
FX_BOOL bFullCover,
FX_BOOL bGroupKnockout,
@@ -402,28 +243,6 @@ FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizer(
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
@@ -433,78 +252,33 @@ FX_BOOL CFX_SkiaDeviceDriver::DrawPath(
FX_DWORD stroke_color, // stroke color
int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled
int alpha_flag,
- void* pIccTransform) {
+ void* pIccTransform,
+ int blend_type) {
if (!GetBuffer())
return TRUE;
- FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering");
SkIRect rect;
rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH),
GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+ SkPath skPath = BuildPath(pPathData, pObject2Device);
+ SkPaint spaint;
+ spaint.setAntiAlias(TRUE);
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);
+ skPath.setFillType((fill_mode & 3) == FXFILL_WINDING
+ ? SkPath::kWinding_FillType
+ : SkPath::kEvenOdd_FillType);
+
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;
+ m_canvas->drawPath(skPath, spaint);
}
-
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_Matrix 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;
+ PaintStroke(&spaint, pGraphState);
+ m_canvas->drawPath(skPath, spaint);
}
return TRUE;
@@ -521,8 +295,16 @@ FX_BOOL CFX_SkiaDeviceDriver::SetPixel(int x,
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);
+ void* pIccTransform,
+ int blend_type) {
+ SkPaint spaint;
+ spaint.setAntiAlias(true);
+ spaint.setColor(fill_color);
+
+ m_canvas->drawRect(
+ SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom),
+ spaint);
+ return TRUE;
}
FX_BOOL CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) {
@@ -558,10 +340,11 @@ FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
const FX_RECT* pClipRect,
FX_DWORD flags,
int alpha_flag,
- void* pIccTransform) {
+ void* pIccTransform,
+ int blend_type) {
return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top,
dest_width, dest_height, pClipRect, flags,
- alpha_flag, pIccTransform);
+ alpha_flag, pIccTransform, blend_type);
}
FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
@@ -571,10 +354,11 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
FX_DWORD render_flags,
void*& handle,
int alpha_flag,
- void* pIccTransform) {
+ void* pIccTransform,
+ int blend_type) {
return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb, pMatrix,
render_flags, handle, alpha_flag,
- pIccTransform);
+ pIccTransform, blend_type);
}
FX_BOOL CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
@@ -620,9 +404,23 @@ FX_BOOL CFX_SkiaDevice::Create(int width,
SetDeviceDriver(pDriver);
return TRUE;
}
+
CFX_SkiaDevice::~CFX_SkiaDevice() {
if (m_bOwnedBitmap && GetBitmap())
delete GetBitmap();
}
+#if 0
+#include <stdarg.h>
+#include <stdio.h>
+
+void SkDebugf(const char format[], ...) {
+ va_list args;
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+}
+
+#endif
+
#endif
diff --git a/core/src/fxge/skia/fx_skia_device.h b/core/src/fxge/skia/fx_skia_device.h
index e26bc8cbcc..31c5982188 100644
--- a/core/src/fxge/skia/fx_skia_device.h
+++ b/core/src/fxge/skia/fx_skia_device.h
@@ -6,6 +6,12 @@
#define CORE_SRC_FXGE_SKIA_FX_SKIA_DEVICE_H_
#if defined(_SKIA_SUPPORT_)
+
+class SkCanvas;
+class SkPaint;
+class SkPath;
+struct SkIRect;
+
class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
public:
CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap,
@@ -43,7 +49,8 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
FX_DWORD stroke_color,
int fill_mode,
int alpha_flag = 0,
- void* pIccTransform = NULL);
+ void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL);
virtual FX_BOOL SetPixel(int x,
int y,
@@ -54,17 +61,18 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
virtual FX_BOOL FillRect(const FX_RECT* pRect,
FX_DWORD fill_color,
int alpha_flag = 0,
- void* pIccTransform = NULL);
+ void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL);
/** Draw a single pixel (device dependant) line */
- virtual FX_BOOL DrawCosmeticLine(FX_FIXFLOAT x1,
- FX_FIXFLOAT y1,
- FX_FIXFLOAT x2,
- FX_FIXFLOAT y2,
+ virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
FX_DWORD color,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
+ int alpha_flag = 0,
+ void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL) {
return FALSE;
}
@@ -96,7 +104,8 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
const FX_RECT* pClipRect,
FX_DWORD flags,
int alpha_flag = 0,
- void* pIccTransform = NULL);
+ void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL);
virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
int bitmap_alpha,
@@ -105,7 +114,8 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
FX_DWORD flags,
void*& handle,
int alpha_flag = 0,
- void* pIccTransform = NULL);
+ void* pIccTransform = NULL,
+ int blend_type = FXDIB_BLEND_NORMAL);
virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause);
virtual void CancelDIBits(void* handle);
@@ -114,31 +124,25 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
CFX_Font* pFont,
CFX_FontCache* pCache,
const CFX_Matrix* pObject2Device,
- FX_FIXFLOAT font_size,
+ FX_FLOAT font_size,
FX_DWORD color,
int alpha_flag = 0,
void* pIccTransform = NULL);
- virtual FX_BOOL RenderRasterizer(rasterizer_scanline_aa& rasterizer,
+ virtual FX_BOOL RenderRasterizer(agg::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(agg::rasterizer_scanline_aa& rasterizer);
void SetClipMask(SkPath& skPath, SkPaint* spaint);
virtual uint8_t* GetBuffer() const { return m_pAggDriver->GetBuffer(); }
+ void PaintStroke(SkPaint* spaint, const CFX_GraphStateData* pGraphState);
+ private:
CFX_AggDeviceDriver* m_pAggDriver;
+ SkCanvas* m_canvas;
};
#endif // defined(_SKIA_SUPPORT_)