| OLD | NEW | 
|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "core/include/fxge/fx_ge.h" | 5 #include "core/include/fxge/fx_ge.h" | 
| 6 | 6 | 
| 7 //#define _SKIA_SUPPORT_ | 7 //#define _SKIA_SUPPORT_ | 
| 8 #if defined(_SKIA_SUPPORT_) | 8 #if defined(_SKIA_SUPPORT_) | 
| 9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" | 
| 10 #include "core/include/fxcodec/fx_codec.h" | 10 #include "core/include/fxcodec/fx_codec.h" | 
| 11 #include "fx_skia_blitter_new.h" | 11 #include "fx_skia_blitter_new.h" | 
| 12 | 12 | 
| 13 // We use our own renderer here to make it simple | 13 // We use our own renderer here to make it simple | 
| 14 void CFX_SkiaRenderer::blitAntiH(int x, | 14 void CFX_SkiaRenderer::blitAntiH(int x, | 
| 15                                  int y, | 15                                  int y, | 
| 16                                  const SkAlpha antialias[], | 16                                  const SkAlpha antialias[], | 
| 17                                  const int16_t runs[]) { | 17                                  const int16_t runs[]) { | 
| 18   FXSYS_assert(m_Alpha); | 18   FXSYS_assert(m_Alpha); | 
| 19   if (m_pOriDevice == NULL && composite_span == NULL) | 19   if (!m_pOriDevice && !composite_span) | 
| 20     return; | 20     return; | 
| 21   if (y < m_ClipBox.top || y >= m_ClipBox.bottom) | 21   if (y < m_ClipBox.top || y >= m_ClipBox.bottom) | 
| 22     return; | 22     return; | 
| 23   while (1) { | 23   while (1) { | 
| 24     int width = runs[0]; | 24     int width = runs[0]; | 
| 25     SkASSERT(width >= 0); | 25     SkASSERT(width >= 0); | 
| 26     if (width <= 0) | 26     if (width <= 0) | 
| 27       return; | 27       return; | 
| 28     unsigned aa = antialias[0]; | 28     unsigned aa = antialias[0]; | 
| 29     if (aa) | 29     if (aa) | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 99   ASSERT(!m_pDevice->IsCmykImage()); | 99   ASSERT(!m_pDevice->IsCmykImage()); | 
| 100   dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left / 8; | 100   dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left / 8; | 
| 101   int col_start = span_left < clip_left ? clip_left - span_left : 0; | 101   int col_start = span_left < clip_left ? clip_left - span_left : 0; | 
| 102   int col_end = | 102   int col_end = | 
| 103       (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); | 103       (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); | 
| 104   if (col_end < col_start) | 104   if (col_end < col_start) | 
| 105     return;  // do nothing. | 105     return;  // do nothing. | 
| 106   dest_scan += col_start / 8; | 106   dest_scan += col_start / 8; | 
| 107 | 107 | 
| 108   int index = 0; | 108   int index = 0; | 
| 109   if (m_pDevice->GetPalette() == NULL) | 109   if (m_pDevice->GetPalette()) { | 
| 110     index = ((uint8_t)m_Color == 0xff) ? 1 : 0; | 110     for (int i = 0; i < 2; i++) { | 
| 111   else { |  | 
| 112     for (int i = 0; i < 2; i++) |  | 
| 113       if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) | 111       if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) | 
| 114         index = i; | 112         index = i; | 
|  | 113     } | 
|  | 114   } else { | 
|  | 115     index = ((uint8_t)m_Color == 0xff) ? 1 : 0; | 
| 115   } | 116   } | 
| 116   uint8_t* dest_scan1 = dest_scan; | 117   uint8_t* dest_scan1 = dest_scan; | 
| 117   int src_alpha = m_Alpha * cover_scan / 255; | 118   int src_alpha = m_Alpha * cover_scan / 255; | 
| 118   for (int col = col_start; col < col_end; col++) { | 119   for (int col = col_start; col < col_end; col++) { | 
| 119     if (src_alpha) { | 120     if (src_alpha) { | 
| 120       if (!index) | 121       if (!index) | 
| 121         *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); | 122         *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); | 
| 122       else | 123       else | 
| 123         *dest_scan1 |= 1 << (7 - (col + span_left) % 8); | 124         *dest_scan1 |= 1 << (7 - (col + span_left) % 8); | 
| 124     } | 125     } | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 143   clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - | 144   clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - | 
| 144               clip_left + span_left; | 145               clip_left + span_left; | 
| 145   int col_start = span_left < clip_left ? clip_left - span_left : 0; | 146   int col_start = span_left < clip_left ? clip_left - span_left : 0; | 
| 146   int col_end = | 147   int col_end = | 
| 147       (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); | 148       (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); | 
| 148   if (col_end < col_start) | 149   if (col_end < col_start) | 
| 149     return;  // do nothing. | 150     return;  // do nothing. | 
| 150   dest_scan += col_start / 8; | 151   dest_scan += col_start / 8; | 
| 151 | 152 | 
| 152   int index = 0; | 153   int index = 0; | 
| 153   if (m_pDevice->GetPalette() == NULL) | 154   if (m_pDevice->GetPalette()) { | 
| 154     index = ((uint8_t)m_Color == 0xff) ? 1 : 0; | 155     for (int i = 0; i < 2; i++) { | 
| 155   else { |  | 
| 156     for (int i = 0; i < 2; i++) |  | 
| 157       if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) | 156       if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) | 
| 158         index = i; | 157         index = i; | 
|  | 158     } | 
|  | 159   } else { | 
|  | 160     index = ((uint8_t)m_Color == 0xff) ? 1 : 0; | 
| 159   } | 161   } | 
| 160   uint8_t* dest_scan1 = dest_scan; | 162   uint8_t* dest_scan1 = dest_scan; | 
| 161   int src_alpha = m_Alpha * cover_scan / 255; | 163   int src_alpha = m_Alpha * cover_scan / 255; | 
| 162   for (int col = col_start; col < col_end; col++) { | 164   for (int col = col_start; col < col_end; col++) { | 
| 163     int src_alpha1 = src_alpha * clip_scan[col] / 255; | 165     int src_alpha1 = src_alpha * clip_scan[col] / 255; | 
| 164     if (src_alpha1) { | 166     if (src_alpha1) { | 
| 165       if (!index) | 167       if (!index) | 
| 166         *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); | 168         *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); | 
| 167       else | 169       else | 
| 168         *dest_scan1 |= 1 << (7 - (col + span_left) % 8); | 170         *dest_scan1 |= 1 << (7 - (col + span_left) % 8); | 
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1729     case 15: | 1731     case 15: | 
| 1730       // TODO... | 1732       // TODO... | 
| 1731       break; | 1733       break; | 
| 1732     case 10: | 1734     case 10: | 
| 1733       composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; | 1735       composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; | 
| 1734       break; | 1736       break; | 
| 1735     case 14: | 1737     case 14: | 
| 1736       composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; | 1738       composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; | 
| 1737       break; | 1739       break; | 
| 1738   } | 1740   } | 
| 1739   if (composite_span == NULL) | 1741   return !!composite_span; | 
| 1740     return FALSE; |  | 
| 1741   return TRUE; |  | 
| 1742 } | 1742 } | 
| 1743 | 1743 | 
| 1744 /*------------------------------------------------------------------------------
      ----------------------*/ | 1744 /*------------------------------------------------------------------------------
      ----------------------*/ | 
| 1745 void CFX_SkiaA8Renderer::blitAntiH(int x, | 1745 void CFX_SkiaA8Renderer::blitAntiH(int x, | 
| 1746                                    int y, | 1746                                    int y, | 
| 1747                                    const SkAlpha antialias[], | 1747                                    const SkAlpha antialias[], | 
| 1748                                    const int16_t runs[]) { | 1748                                    const int16_t runs[]) { | 
| 1749   FXSYS_assert(m_pDevice); | 1749   FXSYS_assert(m_pDevice); | 
| 1750   int dst_y = y - m_Top; | 1750   int dst_y = y - m_Top; | 
| 1751   if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) | 1751   if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1841   m_pDevice = pDevice; | 1841   m_pDevice = pDevice; | 
| 1842   m_Left = Left; | 1842   m_Left = Left; | 
| 1843   m_Top = Top; | 1843   m_Top = Top; | 
| 1844   if (pDevice) { | 1844   if (pDevice) { | 
| 1845     m_dstWidth = m_Left + pDevice->GetWidth(); | 1845     m_dstWidth = m_Left + pDevice->GetWidth(); | 
| 1846     m_dstHeight = m_Top + pDevice->GetHeight(); | 1846     m_dstHeight = m_Top + pDevice->GetHeight(); | 
| 1847   } | 1847   } | 
| 1848   return TRUE; | 1848   return TRUE; | 
| 1849 } | 1849 } | 
| 1850 #endif | 1850 #endif | 
| OLD | NEW | 
|---|