| 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/fxge/include/fx_ge.h" | 5 #include "core/fxge/include/fx_ge.h" |
| 6 | 6 |
| 7 #if defined(_SKIA_SUPPORT_) | 7 #if defined(_SKIA_SUPPORT_) |
| 8 #include "core/fxcodec/include/fx_codec.h" | 8 #include "core/fxcodec/include/fx_codec.h" |
| 9 | 9 |
| 10 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" | 10 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes | 716 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes |
| 717 uint32_t fill_color, // fill color | 717 uint32_t fill_color, // fill color |
| 718 uint32_t stroke_color, // stroke color | 718 uint32_t stroke_color, // stroke color |
| 719 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled | 719 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled |
| 720 int alpha_flag, | 720 int alpha_flag, |
| 721 void* pIccTransform, | 721 void* pIccTransform, |
| 722 int blend_type) { | 722 int blend_type) { |
| 723 SkIRect rect; | 723 SkIRect rect; |
| 724 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), | 724 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), |
| 725 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 725 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
| 726 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); | 726 SkMatrix skMatrix; |
| 727 if (pObject2Device) |
| 728 skMatrix = ToSkMatrix(*pObject2Device); |
| 729 else |
| 730 skMatrix.setIdentity(); |
| 727 SkPaint skPaint; | 731 SkPaint skPaint; |
| 728 skPaint.setAntiAlias(true); | 732 skPaint.setAntiAlias(true); |
| 729 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) | 733 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) |
| 730 ? FXGETFLAG_ALPHA_STROKE(alpha_flag) | 734 ? FXGETFLAG_ALPHA_STROKE(alpha_flag) |
| 731 : FXARGB_A(stroke_color); | 735 : FXARGB_A(stroke_color); |
| 732 if (pGraphState && stroke_alpha) | 736 if (pGraphState && stroke_alpha) |
| 733 PaintStroke(&skPaint, pGraphState, skMatrix); | 737 PaintStroke(&skPaint, pGraphState, skMatrix); |
| 734 SkPath skPath = BuildPath(pPathData); | 738 SkPath skPath = BuildPath(pPathData); |
| 735 m_pCanvas->save(); | 739 m_pCanvas->save(); |
| 736 m_pCanvas->concat(skMatrix); | 740 m_pCanvas->concat(skMatrix); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 pRect->right = canvasSize.width(); | 930 pRect->right = canvasSize.width(); |
| 927 pRect->bottom = canvasSize.height(); | 931 pRect->bottom = canvasSize.height(); |
| 928 return TRUE; | 932 return TRUE; |
| 929 } | 933 } |
| 930 | 934 |
| 931 FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, | 935 FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, |
| 932 int left, | 936 int left, |
| 933 int top, | 937 int top, |
| 934 void* pIccTransform, | 938 void* pIccTransform, |
| 935 FX_BOOL bDEdge) { | 939 FX_BOOL bDEdge) { |
| 936 if (!m_pBitmap->GetBuffer()) | 940 if (!m_pBitmap || !m_pBitmap->GetBuffer()) |
| 937 return TRUE; | 941 return TRUE; |
| 938 if (bDEdge) { | 942 if (bDEdge) { |
| 939 if (m_bRgbByteOrder) { | 943 if (m_bRgbByteOrder) { |
| 940 RgbByteOrderTransferBitmap(pBitmap, 0, 0, pBitmap->GetWidth(), | 944 RgbByteOrderTransferBitmap(pBitmap, 0, 0, pBitmap->GetWidth(), |
| 941 pBitmap->GetHeight(), m_pBitmap, left, top); | 945 pBitmap->GetHeight(), m_pBitmap, left, top); |
| 942 } else { | 946 } else { |
| 943 return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(), | 947 return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(), |
| 944 pBitmap->GetHeight(), m_pBitmap, left, top, | 948 pBitmap->GetHeight(), m_pBitmap, left, top, |
| 945 pIccTransform); | 949 pIccTransform); |
| 946 } | 950 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 975 } | 979 } |
| 976 | 980 |
| 977 FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, | 981 FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, |
| 978 uint32_t argb, | 982 uint32_t argb, |
| 979 const FX_RECT* pSrcRect, | 983 const FX_RECT* pSrcRect, |
| 980 int left, | 984 int left, |
| 981 int top, | 985 int top, |
| 982 int blend_type, | 986 int blend_type, |
| 983 int alpha_flag, | 987 int alpha_flag, |
| 984 void* pIccTransform) { | 988 void* pIccTransform) { |
| 985 if (!m_pBitmap->GetBuffer()) | 989 if (!m_pBitmap || !m_pBitmap->GetBuffer()) |
| 986 return TRUE; | 990 return TRUE; |
| 987 if (pBitmap->IsAlphaMask()) { | 991 if (pBitmap->IsAlphaMask()) { |
| 988 return m_pBitmap->CompositeMask( | 992 return m_pBitmap->CompositeMask( |
| 989 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, | 993 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, |
| 990 pSrcRect->left, pSrcRect->top, blend_type, nullptr, m_bRgbByteOrder, | 994 pSrcRect->left, pSrcRect->top, blend_type, nullptr, m_bRgbByteOrder, |
| 991 alpha_flag, pIccTransform); | 995 alpha_flag, pIccTransform); |
| 992 } | 996 } |
| 993 return m_pBitmap->CompositeBitmap( | 997 return m_pBitmap->CompositeBitmap( |
| 994 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, | 998 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, |
| 995 pSrcRect->top, blend_type, nullptr, m_bRgbByteOrder, pIccTransform); | 999 pSrcRect->top, blend_type, nullptr, m_bRgbByteOrder, pIccTransform); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 const uint8_t* srcRow = | 1062 const uint8_t* srcRow = |
| 1059 static_cast<const uint8_t*>(buffer) + y * rowBytes; | 1063 static_cast<const uint8_t*>(buffer) + y * rowBytes; |
| 1060 uint8_t* dstRow = dst8Pixels + y * width; | 1064 uint8_t* dstRow = dst8Pixels + y * width; |
| 1061 for (int x = 0; x < width; ++x) | 1065 for (int x = 0; x < width; ++x) |
| 1062 dstRow[x] = srcRow[x >> 3] & (1 << (~x & 0x07)) ? one : zero; | 1066 dstRow[x] = srcRow[x >> 3] & (1 << (~x & 0x07)) ? one : zero; |
| 1063 } | 1067 } |
| 1064 buffer = dst8Storage.get(); | 1068 buffer = dst8Storage.get(); |
| 1065 rowBytes = width; | 1069 rowBytes = width; |
| 1066 colorType = SkColorType::kGray_8_SkColorType; | 1070 colorType = SkColorType::kGray_8_SkColorType; |
| 1067 } break; | 1071 } break; |
| 1072 case 8: |
| 1073 colorType = SkColorType::kGray_8_SkColorType; |
| 1074 break; |
| 1068 case 24: { | 1075 case 24: { |
| 1069 dst32Storage.reset(FX_Alloc2D(uint32_t, width, height)); | 1076 dst32Storage.reset(FX_Alloc2D(uint32_t, width, height)); |
| 1070 uint32_t* dst32Pixels = dst32Storage.get(); | 1077 uint32_t* dst32Pixels = dst32Storage.get(); |
| 1071 for (int y = 0; y < height; ++y) { | 1078 for (int y = 0; y < height; ++y) { |
| 1072 const uint8_t* srcRow = | 1079 const uint8_t* srcRow = |
| 1073 static_cast<const uint8_t*>(buffer) + y * rowBytes; | 1080 static_cast<const uint8_t*>(buffer) + y * rowBytes; |
| 1074 uint32_t* dstRow = dst32Pixels + y * width; | 1081 uint32_t* dstRow = dst32Pixels + y * width; |
| 1075 for (int x = 0; x < width; ++x) | 1082 for (int x = 0; x < width; ++x) |
| 1076 dstRow[x] = SkPackARGB32(0xFF, srcRow[x * 3 + 2], srcRow[x * 3 + 1], | 1083 dstRow[x] = SkPackARGB32(0xFF, srcRow[x * 3 + 2], srcRow[x * 3 + 1], |
| 1077 srcRow[x * 3 + 0]); | 1084 srcRow[x * 3 + 0]); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 SetDeviceDriver(pDriver); | 1184 SetDeviceDriver(pDriver); |
| 1178 return TRUE; | 1185 return TRUE; |
| 1179 } | 1186 } |
| 1180 | 1187 |
| 1181 CFX_SkiaDevice::~CFX_SkiaDevice() { | 1188 CFX_SkiaDevice::~CFX_SkiaDevice() { |
| 1182 if (m_bOwnedBitmap && GetBitmap()) | 1189 if (m_bOwnedBitmap && GetBitmap()) |
| 1183 delete GetBitmap(); | 1190 delete GetBitmap(); |
| 1184 } | 1191 } |
| 1185 | 1192 |
| 1186 #endif | 1193 #endif |
| OLD | NEW |