Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <utility> | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "core/fxcodec/fx_codec.h" | 9 #include "core/fxcodec/fx_codec.h" |
| 10 #include "core/fxcrt/fx_memory.h" | 10 #include "core/fxcrt/fx_memory.h" |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1168 glyphs.setCount(nChars); | 1168 glyphs.setCount(nChars); |
| 1169 for (int index = 0; index < nChars; ++index) { | 1169 for (int index = 0; index < nChars; ++index) { |
| 1170 const FXTEXT_CHARPOS& cp = pCharPos[index]; | 1170 const FXTEXT_CHARPOS& cp = pCharPos[index]; |
| 1171 positions[index] = {cp.m_OriginX * flip, cp.m_OriginY * vFlip}; | 1171 positions[index] = {cp.m_OriginX * flip, cp.m_OriginY * vFlip}; |
| 1172 glyphs[index] = (uint16_t)cp.m_GlyphIndex; | 1172 glyphs[index] = (uint16_t)cp.m_GlyphIndex; |
| 1173 } | 1173 } |
| 1174 m_pCanvas->drawPosText(glyphs.begin(), nChars * 2, positions.begin(), paint); | 1174 m_pCanvas->drawPosText(glyphs.begin(), nChars * 2, positions.begin(), paint); |
| 1175 m_pCanvas->restore(); | 1175 m_pCanvas->restore(); |
| 1176 | 1176 |
| 1177 #ifdef _SKIA_SUPPORT_PATHS_ | 1177 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1178 if (FXARGB_A(color) < 255) { | 1178 if (m_pBitmap->GetBPP() == 32) { |
| 1179 m_pBitmap->MarkForUnPreMultiply(true); | 1179 m_pBitmap->MarkForUnPreMultiply(true); |
| 1180 } | 1180 } |
| 1181 #endif // _SKIA_SUPPORT_PATHS_ | 1181 #endif // _SKIA_SUPPORT_PATHS_ |
| 1182 return true; | 1182 return true; |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) const { | 1185 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) const { |
| 1186 switch (caps_id) { | 1186 switch (caps_id) { |
| 1187 case FXDC_DEVICE_CLASS: | 1187 case FXDC_DEVICE_CLASS: |
| 1188 return FXDC_DISPLAY; | 1188 return FXDC_DISPLAY; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1454 if (pGraphState && stroke_alpha) { | 1454 if (pGraphState && stroke_alpha) { |
| 1455 DebugShowSkiaPath(skPath); | 1455 DebugShowSkiaPath(skPath); |
| 1456 DebugShowCanvasMatrix(m_pCanvas); | 1456 DebugShowCanvasMatrix(m_pCanvas); |
| 1457 DebugShowCanvasClip(m_pCanvas); | 1457 DebugShowCanvasClip(m_pCanvas); |
| 1458 skPaint.setStyle(SkPaint::kStroke_Style); | 1458 skPaint.setStyle(SkPaint::kStroke_Style); |
| 1459 skPaint.setColor(stroke_color); | 1459 skPaint.setColor(stroke_color); |
| 1460 m_pCanvas->drawPath(skPath, skPaint); | 1460 m_pCanvas->drawPath(skPath, skPaint); |
| 1461 } | 1461 } |
| 1462 m_pCanvas->restore(); | 1462 m_pCanvas->restore(); |
| 1463 #ifdef _SKIA_SUPPORT_PATHS_ | 1463 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1464 if ((fill_mode & 3 && FXARGB_A(fill_color) < 255) || | 1464 if (m_pBitmap->GetBPP() == 32) { |
| 1465 (pGraphState && stroke_alpha < 255)) { | |
| 1466 m_pBitmap->MarkForUnPreMultiply(true); | 1465 m_pBitmap->MarkForUnPreMultiply(true); |
| 1467 } | 1466 } |
| 1468 #endif // _SKIA_SUPPORT_PATHS_ | 1467 #endif // _SKIA_SUPPORT_PATHS_ |
| 1469 return true; | 1468 return true; |
| 1470 } | 1469 } |
| 1471 | 1470 |
| 1472 bool CFX_SkiaDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, | 1471 bool CFX_SkiaDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, |
| 1473 FX_FLOAT y1, | 1472 FX_FLOAT y1, |
| 1474 FX_FLOAT x2, | 1473 FX_FLOAT x2, |
| 1475 FX_FLOAT y2, | 1474 FX_FLOAT y2, |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1859 #endif // _SKIA_SUPPORT_ | 1858 #endif // _SKIA_SUPPORT_ |
| 1860 | 1859 |
| 1861 #ifdef _SKIA_SUPPORT_PATHS_ | 1860 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1862 if (!m_pBitmap->GetBuffer()) { | 1861 if (!m_pBitmap->GetBuffer()) { |
| 1863 return true; | 1862 return true; |
| 1864 } | 1863 } |
| 1865 return static_cast<CFX_ImageRenderer*>(handle)->Continue(pPause); | 1864 return static_cast<CFX_ImageRenderer*>(handle)->Continue(pPause); |
| 1866 #endif // _SKIA_SUPPORT_PATHS_ | 1865 #endif // _SKIA_SUPPORT_PATHS_ |
| 1867 } | 1866 } |
| 1868 | 1867 |
| 1869 #ifdef _SKIA_SUPPORT_ | 1868 #if defined _SKIA_SUPPORT_ |
| 1870 void CFX_SkiaDeviceDriver::PreMultiply(CFX_DIBitmap* pDIBitmap) { | 1869 void CFX_SkiaDeviceDriver::PreMultiply(CFX_DIBitmap* pDIBitmap) { |
| 1871 void* buffer = pDIBitmap->GetBuffer(); | 1870 void* buffer = pDIBitmap->GetBuffer(); |
| 1872 if (!buffer) | 1871 if (!buffer) |
| 1873 return; | 1872 return; |
| 1874 if (pDIBitmap->GetBPP() != 32) { | 1873 if (pDIBitmap->GetBPP() != 32) { |
| 1875 return; | 1874 return; |
| 1876 } | 1875 } |
| 1877 int height = pDIBitmap->GetHeight(); | 1876 int height = pDIBitmap->GetHeight(); |
| 1878 int width = pDIBitmap->GetWidth(); | 1877 int width = pDIBitmap->GetWidth(); |
| 1879 int rowBytes = pDIBitmap->GetPitch(); | 1878 int rowBytes = pDIBitmap->GetPitch(); |
| 1880 SkImageInfo unpremultipliedInfo = | 1879 SkImageInfo unpremultipliedInfo = |
| 1881 SkImageInfo::Make(width, height, kN32_SkColorType, kUnpremul_SkAlphaType); | 1880 SkImageInfo::Make(width, height, kN32_SkColorType, kUnpremul_SkAlphaType); |
| 1882 SkPixmap unpremultiplied(unpremultipliedInfo, buffer, rowBytes); | 1881 SkPixmap unpremultiplied(unpremultipliedInfo, buffer, rowBytes); |
| 1883 SkImageInfo premultipliedInfo = | 1882 SkImageInfo premultipliedInfo = |
| 1884 SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); | 1883 SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); |
| 1885 SkPixmap premultiplied(premultipliedInfo, buffer, rowBytes); | 1884 SkPixmap premultiplied(premultipliedInfo, buffer, rowBytes); |
| 1886 unpremultiplied.readPixels(premultiplied); | 1885 unpremultiplied.readPixels(premultiplied); |
| 1887 pDIBitmap->DebugVerifyBitmapIsPreMultiplied(); | 1886 pDIBitmap->DebugVerifyBitmapIsPreMultiplied(); |
| 1888 } | 1887 } |
| 1889 #endif // _SKIA_SUPPORT_ | 1888 #endif // _SKIA_SUPPORT_ |
| 1890 | 1889 |
| 1891 #ifdef _SKIA_SUPPORT_PATHS_ | 1890 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1892 void CFX_SkiaDeviceDriver::UnPreMultiply(CFX_DIBitmap* pDIBitmap) { | 1891 void CFX_SkiaDeviceDriver::UnPreMultiply(CFX_DIBitmap* pDIBitmap) { |
| 1893 if (!pDIBitmap->IsMarkedForUnPreMultiply()) | 1892 pDIBitmap->UnPreMultiply(); |
| 1893 } | |
| 1894 | |
| 1895 void CFX_DIBitmap::UnPreMultiply() { | |
| 1896 if (!this->IsMarkedForUnPreMultiply()) | |
|
dsinclair
2016/11/21 22:01:49
Drop the this-> as it isn't needed.
| |
| 1894 return; | 1897 return; |
| 1895 pDIBitmap->DebugVerifyBitmapIsPreMultiplied(); | 1898 this->DebugVerifyBitmapIsPreMultiplied(); |
| 1896 void* buffer = pDIBitmap->GetBuffer(); | 1899 void* buffer = this->GetBuffer(); |
| 1897 if (!buffer) | 1900 if (!buffer) |
| 1898 return; | 1901 return; |
| 1899 if (pDIBitmap->GetBPP() != 32) { | 1902 if (this->GetBPP() != 32) { |
| 1900 return; | 1903 return; |
| 1901 } | 1904 } |
| 1902 int height = pDIBitmap->GetHeight(); | 1905 int height = this->GetHeight(); |
| 1903 int width = pDIBitmap->GetWidth(); | 1906 int width = this->GetWidth(); |
| 1904 int rowBytes = pDIBitmap->GetPitch(); | 1907 int rowBytes = this->GetPitch(); |
| 1905 SkImageInfo premultipliedInfo = | 1908 SkImageInfo premultipliedInfo = |
| 1906 SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); | 1909 SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); |
| 1907 SkPixmap premultiplied(premultipliedInfo, buffer, rowBytes); | 1910 SkPixmap premultiplied(premultipliedInfo, buffer, rowBytes); |
| 1908 SkImageInfo unpremultipliedInfo = | 1911 SkImageInfo unpremultipliedInfo = |
| 1909 SkImageInfo::Make(width, height, kN32_SkColorType, kUnpremul_SkAlphaType); | 1912 SkImageInfo::Make(width, height, kN32_SkColorType, kUnpremul_SkAlphaType); |
| 1910 SkPixmap unpremultiplied(unpremultipliedInfo, buffer, rowBytes); | 1913 SkPixmap unpremultiplied(unpremultipliedInfo, buffer, rowBytes); |
| 1911 premultiplied.readPixels(unpremultiplied); | 1914 premultiplied.readPixels(unpremultiplied); |
| 1912 pDIBitmap->MarkForUnPreMultiply(false); | 1915 this->MarkForUnPreMultiply(false); |
| 1913 } | 1916 } |
| 1914 #endif // _SKIA_SUPPORT_PATHS_ | 1917 #endif // _SKIA_SUPPORT_PATHS_ |
| 1915 | 1918 |
| 1916 #ifdef _SKIA_SUPPORT_ | 1919 #ifdef _SKIA_SUPPORT_ |
| 1917 bool CFX_SkiaDeviceDriver::DrawBitsWithMask(const CFX_DIBSource* pSource, | 1920 bool CFX_SkiaDeviceDriver::DrawBitsWithMask(const CFX_DIBSource* pSource, |
| 1918 const CFX_DIBSource* pMask, | 1921 const CFX_DIBSource* pMask, |
| 1919 int bitmap_alpha, | 1922 int bitmap_alpha, |
| 1920 const CFX_Matrix* pMatrix, | 1923 const CFX_Matrix* pMatrix, |
| 1921 int blend_type) { | 1924 int blend_type) { |
| 1922 DebugValidate(m_pBitmap, m_pOriDevice); | 1925 DebugValidate(m_pBitmap, m_pOriDevice); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1970 dest_top + pBitmap->GetHeight()); | 1973 dest_top + pBitmap->GetHeight()); |
| 1971 return DrawBitsWithMask(pBitmap, pMask, bitmap_alpha, &m, blend_type); | 1974 return DrawBitsWithMask(pBitmap, pMask, bitmap_alpha, &m, blend_type); |
| 1972 } | 1975 } |
| 1973 | 1976 |
| 1974 void CFX_SkiaDeviceDriver::Clear(uint32_t color) { | 1977 void CFX_SkiaDeviceDriver::Clear(uint32_t color) { |
| 1975 m_pCanvas->clear(color); | 1978 m_pCanvas->clear(color); |
| 1976 } | 1979 } |
| 1977 #endif // _SKIA_SUPPORT_ | 1980 #endif // _SKIA_SUPPORT_ |
| 1978 | 1981 |
| 1979 void CFX_SkiaDeviceDriver::Dump() const { | 1982 void CFX_SkiaDeviceDriver::Dump() const { |
| 1980 #if SHOW_SKIA_PATH | 1983 #if SHOW_SKIA_PATH && defined _SKIA_SUPPORT_ |
| 1981 if (m_pCache) | 1984 if (m_pCache) |
| 1982 m_pCache->Dump(this); | 1985 m_pCache->Dump(this); |
| 1983 #endif // SHOW_SKIA_PATH | 1986 #endif // SHOW_SKIA_PATH && defined _SKIA_SUPPORT_ |
| 1984 } | 1987 } |
| 1985 | 1988 |
| 1986 #ifdef _SKIA_SUPPORT_ | 1989 #ifdef _SKIA_SUPPORT_ |
| 1987 void CFX_SkiaDeviceDriver::DebugVerifyBitmapIsPreMultiplied() const { | 1990 void CFX_SkiaDeviceDriver::DebugVerifyBitmapIsPreMultiplied() const { |
| 1988 if (m_pOriDevice) | 1991 if (m_pOriDevice) |
| 1989 m_pOriDevice->DebugVerifyBitmapIsPreMultiplied(); | 1992 m_pOriDevice->DebugVerifyBitmapIsPreMultiplied(); |
| 1990 } | 1993 } |
| 1991 #endif // _SKIA_SUPPORT_ | 1994 #endif // _SKIA_SUPPORT_ |
| 1992 | 1995 |
| 1993 #ifdef _SKIA_SUPPORT_PATHS_ | 1996 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1994 void CFX_SkiaDeviceDriver::UnPreMultiplyDevice() { | 1997 void CFX_SkiaDeviceDriver::UnPreMultiplyDevice() { |
| 1995 UnPreMultiply(m_pBitmap); | 1998 if (!m_pBitmap->IsOffscreen()) |
| 1999 UnPreMultiply(m_pBitmap); | |
| 1996 } | 2000 } |
| 1997 #endif // _SKIA_SUPPORT_PATHS_ | 2001 #endif // _SKIA_SUPPORT_PATHS_ |
| 1998 | 2002 |
| 1999 CFX_FxgeDevice::CFX_FxgeDevice() { | 2003 CFX_FxgeDevice::CFX_FxgeDevice() { |
| 2000 #ifdef _SKIA_SUPPORT_ | 2004 #ifdef _SKIA_SUPPORT_ |
| 2001 m_bOwnedBitmap = false; | 2005 m_bOwnedBitmap = false; |
| 2002 #endif // _SKIA_SUPPORT_ | 2006 #endif // _SKIA_SUPPORT_ |
| 2003 } | 2007 } |
| 2004 | 2008 |
| 2005 #ifdef _SKIA_SUPPORT_ | 2009 #ifdef _SKIA_SUPPORT_ |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2942 } | 2946 } |
| 2943 } | 2947 } |
| 2944 if (m_pDevice->GetBPP() == 1) { | 2948 if (m_pDevice->GetBPP() == 1) { |
| 2945 composite_span = &CFX_Renderer::CompositeSpan1bpp; | 2949 composite_span = &CFX_Renderer::CompositeSpan1bpp; |
| 2946 } | 2950 } |
| 2947 return true; | 2951 return true; |
| 2948 } | 2952 } |
| 2949 }; | 2953 }; |
| 2950 | 2954 |
| 2951 #endif // _SKIA_SUPPORT_PATHS_ | 2955 #endif // _SKIA_SUPPORT_PATHS_ |
| OLD | NEW |