| 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 "../../../include/fxge/fx_ge.h" | 5 #include "../../../include/fxge/fx_ge.h" |
| 6 //#define _SKIA_SUPPORT_ | 6 //#define _SKIA_SUPPORT_ |
| 7 #if defined(_SKIA_SUPPORT_) | 7 #if defined(_SKIA_SUPPORT_) |
| 8 #include "../../../include/fxcodec/fx_codec.h" | 8 #include "../../../include/fxcodec/fx_codec.h" |
| 9 | 9 |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 #include "fx_skia_blitter_new.h" | 40 #include "fx_skia_blitter_new.h" |
| 41 #include "../agg/fx_agg_driver.h" | 41 #include "../agg/fx_agg_driver.h" |
| 42 #include "fx_skia_device.h" | 42 #include "fx_skia_device.h" |
| 43 /// Run-length-encoded supersampling antialiased blitter. | 43 /// Run-length-encoded supersampling antialiased blitter. |
| 44 class SuperBlitter_skia | 44 class SuperBlitter_skia |
| 45 { | 45 { |
| 46 public: | 46 public: |
| 47 static void DrawPath(const SkPath& srcPath, SkBlitter* blitter, const S
kRasterClip& rect, const SkPaint& origPaint); | 47 static void DrawPath(const SkPath& srcPath, SkBlitter* blitter, const S
kRasterClip& rect, const SkPaint& origPaint); |
| 48 }; | 48 }; |
| 49 FX_BOOL FxSkDrawTreatAsHairline(const SkPaint& paint, SkScalar* coverage) { | 49 bool FxSkDrawTreatAsHairline(const SkPaint& paint, SkScalar* coverage) { |
| 50 if (SkPaint::kStroke_Style != paint.getStyle()) | 50 if (SkPaint::kStroke_Style != paint.getStyle()) |
| 51 » » return FALSE; | 51 » » return false; |
| 52 FXSYS_assert(coverage); | 52 FXSYS_assert(coverage); |
| 53 SkScalar strokeWidth = paint.getStrokeWidth(); | 53 SkScalar strokeWidth = paint.getStrokeWidth(); |
| 54 if (0 == strokeWidth) { | 54 if (0 == strokeWidth) { |
| 55 *coverage = SK_Scalar1; | 55 *coverage = SK_Scalar1; |
| 56 » » return TRUE; | 56 » » return true; |
| 57 } | 57 } |
| 58 // if we get here, we need to try to fake a thick-stroke with a modulate
d | 58 // if we get here, we need to try to fake a thick-stroke with a modulate
d |
| 59 // hairline | 59 // hairline |
| 60 if (!paint.isAntiAlias()) | 60 if (!paint.isAntiAlias()) |
| 61 » » return FALSE; | 61 » » return false; |
| 62 if (strokeWidth <= SK_Scalar1) { | 62 if (strokeWidth <= SK_Scalar1) { |
| 63 *coverage = strokeWidth; | 63 *coverage = strokeWidth; |
| 64 » » return TRUE; | 64 » » return true; |
| 65 } | 65 } |
| 66 » return FALSE; | 66 » return false; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void SuperBlitter_skia::DrawPath(const SkPath& srcPath, SkBlitter* blitter, cons
t SkRasterClip& rect, const SkPaint& origPaint) | 69 void SuperBlitter_skia::DrawPath(const SkPath& srcPath, SkBlitter* blitter, cons
t SkRasterClip& rect, const SkPaint& origPaint) |
| 70 { | 70 { |
| 71 SkPath* pathPtr = (SkPath*)&srcPath; | 71 SkPath* pathPtr = (SkPath*)&srcPath; |
| 72 bool doFill = true; | 72 bool doFill = true; |
| 73 SkPath tmpPath; | 73 SkPath tmpPath; |
| 74 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); | 74 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); |
| 75 { | 75 { |
| 76 SkScalar coverage; | 76 SkScalar coverage; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 i += 2; | 160 i += 2; |
| 161 } | 161 } |
| 162 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) m_PathData.close(); | 162 if (pPoints[i].m_Flag & FXPT_CLOSEFIGURE) m_PathData.close(); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 // convert a stroking path to scanlines | 166 // convert a stroking path to scanlines |
| 167 static void SkRasterizeStroke(SkPaint& spaint, SkPath* dstPathData, SkPath& path
_data, | 167 static void SkRasterizeStroke(SkPaint& spaint, SkPath* dstPathData, SkPath& path
_data, |
| 168 const CFX_AffineMatrix* pObject2Device, | 168 const CFX_AffineMatrix* pObject2Device, |
| 169 const CFX_GraphStateData* pGraphState,
FX_FIXFLOAT scale = FIX8_ONE, | 169 const CFX_GraphStateData* pGraphState,
FX_FIXFLOAT scale = FIX8_ONE, |
| 170 » » » » » FX_BOOL bStrokeAdjust = FALSE, FX_BOOL
bTextMode = FALSE) | 170 » » » » » bool bStrokeAdjust = false, bool bTextM
ode = false) |
| 171 { | 171 { |
| 172 SkPaint::Cap cap; | 172 SkPaint::Cap cap; |
| 173 switch (pGraphState->m_LineCap) { | 173 switch (pGraphState->m_LineCap) { |
| 174 case CFX_GraphStateData::LineCapRound: | 174 case CFX_GraphStateData::LineCapRound: |
| 175 cap = SkPaint::kRound_Cap; | 175 cap = SkPaint::kRound_Cap; |
| 176 break; | 176 break; |
| 177 case CFX_GraphStateData::LineCapSquare: | 177 case CFX_GraphStateData::LineCapSquare: |
| 178 cap = SkPaint::kSquare_Cap; | 178 cap = SkPaint::kSquare_Cap; |
| 179 break; | 179 break; |
| 180 default: | 180 default: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 196 FX_FIXFLOAT width = pGraphState->m_LineWidth*scale; | 196 FX_FIXFLOAT width = pGraphState->m_LineWidth*scale; |
| 197 FX_FIXFLOAT unit = fix32_to_8(fixdiv_8_8_to_32(FIX8_ONE, (pObject2Device
->GetXUnit() + pObject2Device->GetYUnit()) / 2)); | 197 FX_FIXFLOAT unit = fix32_to_8(fixdiv_8_8_to_32(FIX8_ONE, (pObject2Device
->GetXUnit() + pObject2Device->GetYUnit()) / 2)); |
| 198 if (width <= unit) width = unit; | 198 if (width <= unit) width = unit; |
| 199 | 199 |
| 200 if (pGraphState->m_DashArray == NULL) { | 200 if (pGraphState->m_DashArray == NULL) { |
| 201 SkStroke stroker; | 201 SkStroke stroker; |
| 202 stroker.setCap(cap); | 202 stroker.setCap(cap); |
| 203 stroker.setJoin(join); | 203 stroker.setJoin(join); |
| 204 stroker.setMiterLimit(pGraphState->m_MiterLimit); | 204 stroker.setMiterLimit(pGraphState->m_MiterLimit); |
| 205 stroker.setWidth(width); | 205 stroker.setWidth(width); |
| 206 » » stroker.setDoFill(FALSE); | 206 » » stroker.setDoFill(false); |
| 207 stroker.strokePath(path_data, dstPathData); | 207 stroker.strokePath(path_data, dstPathData); |
| 208 SkMatrix smatrix; | 208 SkMatrix smatrix; |
| 209 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Dev
ice->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1); | 209 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Dev
ice->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1); |
| 210 dstPathData->transform(smatrix); | 210 dstPathData->transform(smatrix); |
| 211 } else { | 211 } else { |
| 212 int count = (pGraphState->m_DashCount+1)/2; | 212 int count = (pGraphState->m_DashCount+1)/2; |
| 213 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScala
r)); | 213 SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScala
r)); |
| 214 // Set dash pattern | 214 // Set dash pattern |
| 215 for (int i = 0; i < count; i ++) { | 215 for (int i = 0; i < count; i ++) { |
| 216 FX_FIXFLOAT on = pGraphState->m_DashArray[i*2]; | 216 FX_FIXFLOAT on = pGraphState->m_DashArray[i*2]; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 228 spaint.setStrokeCap(cap); | 228 spaint.setStrokeCap(cap); |
| 229 spaint.setStrokeJoin(join); | 229 spaint.setStrokeJoin(join); |
| 230 spaint.getFillPath(path_data, dstPathData); | 230 spaint.getFillPath(path_data, dstPathData); |
| 231 SkMatrix smatrix; | 231 SkMatrix smatrix; |
| 232 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Dev
ice->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1); | 232 smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Dev
ice->e, pObject2Device->b, pObject2Device->d, pObject2Device->f, 0, 0, 1); |
| 233 dstPathData->transform(smatrix); | 233 dstPathData->transform(smatrix); |
| 234 FX_Free(intervals); | 234 FX_Free(intervals); |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bit
s, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 238 CFX_SkiaDeviceDriver::CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bit
s, bool bRgbByteOrder, CFX_DIBitmap* pOriDevice, bool bGroupKnockout) |
| 239 { | 239 { |
| 240 m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrd
er, pOriDevice, bGroupKnockout); | 240 m_pAggDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrd
er, pOriDevice, bGroupKnockout); |
| 241 } | 241 } |
| 242 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() | 242 CFX_SkiaDeviceDriver::~CFX_SkiaDeviceDriver() |
| 243 { | 243 { |
| 244 delete m_pAggDriver; | 244 delete m_pAggDriver; |
| 245 } | 245 } |
| 246 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* p
CharPos, CFX_Font* pFont, | 246 bool CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCha
rPos, CFX_Font* pFont, |
| 247 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, F
X_FIXFLOAT font_size, FX_DWORD color, | 247 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, F
X_FIXFLOAT font_size, FX_DWORD color, |
| 248 int alpha_flag, void* pIccTransform) | 248 int alpha_flag, void* pIccTransform) |
| 249 { | 249 { |
| 250 return m_pAggDriver->DrawDeviceText(nChars, pCharPos, pFont,pCache, pObj
ect2Device, font_size, color, | 250 return m_pAggDriver->DrawDeviceText(nChars, pCharPos, pFont,pCache, pObj
ect2Device, font_size, color, |
| 251 alpha_flag, pIccTransform); | 251 alpha_flag, pIccTransform); |
| 252 } | 252 } |
| 253 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) | 253 int CFX_SkiaDeviceDriver::GetDeviceCaps(int caps_id) |
| 254 { | 254 { |
| 255 return m_pAggDriver->GetDeviceCaps(caps_id); | 255 return m_pAggDriver->GetDeviceCaps(caps_id); |
| 256 } | 256 } |
| 257 void CFX_SkiaDeviceDriver::SaveState() | 257 void CFX_SkiaDeviceDriver::SaveState() |
| 258 { | 258 { |
| 259 m_pAggDriver->SaveState(); | 259 m_pAggDriver->SaveState(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void CFX_SkiaDeviceDriver::RestoreState(FX_BOOL bKeepSaved) | 262 void CFX_SkiaDeviceDriver::RestoreState(bool bKeepSaved) |
| 263 { | 263 { |
| 264 m_pAggDriver->RestoreState(bKeepSaved); | 264 m_pAggDriver->RestoreState(bKeepSaved); |
| 265 } | 265 } |
| 266 void CFX_SkiaDeviceDriver::SetClipMask(rasterizer_scanline_aa& rasterizer) | 266 void CFX_SkiaDeviceDriver::SetClipMask(rasterizer_scanline_aa& rasterizer) |
| 267 { | 267 { |
| 268 m_pAggDriver->SetClipMask(rasterizer); | 268 m_pAggDriver->SetClipMask(rasterizer); |
| 269 } | 269 } |
| 270 void CFX_SkiaDeviceDriver::SetClipMask(SkPath& skPath, SkPaint* spaint) | 270 void CFX_SkiaDeviceDriver::SetClipMask(SkPath& skPath, SkPaint* spaint) |
| 271 { | 271 { |
| 272 SkIRect clip_box; | 272 SkIRect clip_box; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 287 CFX_SkiaA8Renderer render; | 287 CFX_SkiaA8Renderer render; |
| 288 render.Init(pThisLayer, clip_box.fLeft, clip_box.fTop); | 288 render.Init(pThisLayer, clip_box.fLeft, clip_box.fTop); |
| 289 | 289 |
| 290 SkRasterClip rasterClip(clip_box); | 290 SkRasterClip rasterClip(clip_box); |
| 291 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, *sp
aint); | 291 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, *sp
aint); |
| 292 | 292 |
| 293 // Finally, we have got the mask that we need, intersect with current cl
ip region | 293 // Finally, we have got the mask that we need, intersect with current cl
ip region |
| 294 m_pAggDriver->m_pClipRgn->IntersectMaskF(clip_box.fLeft, clip_box.fTop,
mask); | 294 m_pAggDriver->m_pClipRgn->IntersectMaskF(clip_box.fLeft, clip_box.fTop,
mask); |
| 295 | 295 |
| 296 } | 296 } |
| 297 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,»
// path info | 297 bool CFX_SkiaDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,»
// path info |
| 298 const CFX_AffineMatrix* pObject2
Device, // optional transformation | 298 const CFX_AffineMatrix* pObject2
Device, // optional transformation |
| 299 int fill_mode // fill mode, WI
NDING or ALTERNATE | 299 int fill_mode // fill mode, WI
NDING or ALTERNATE |
| 300 ) | 300 ) |
| 301 { | 301 { |
| 302 if (m_pAggDriver->m_pClipRgn == NULL) | 302 if (m_pAggDriver->m_pClipRgn == NULL) |
| 303 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PI
XEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 303 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PI
XEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
| 304 | 304 |
| 305 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4)
{ | 305 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4)
{ |
| 306 CFX_FloatRect rectf; | 306 CFX_FloatRect rectf; |
| 307 if (pPathData->IsRect(pObject2Device, &rectf)) { | 307 if (pPathData->IsRect(pObject2Device, &rectf)) { |
| 308 rectf.Intersect(CFX_FloatRect(0, 0, (FX_FIXFLOAT)GetDevi
ceCaps(FXDC_PIXEL_WIDTH), (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 308 rectf.Intersect(CFX_FloatRect(0, 0, (FX_FIXFLOAT)GetDevi
ceCaps(FXDC_PIXEL_WIDTH), (FX_FIXFLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
| 309 FX_RECT rect = rectf.GetOutterRect(); | 309 FX_RECT rect = rectf.GetOutterRect(); |
| 310 m_pAggDriver->m_pClipRgn->IntersectRect(rect); | 310 m_pAggDriver->m_pClipRgn->IntersectRect(rect); |
| 311 » » » return TRUE; | 311 » » » return true; |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 CSkia_PathData path_data; | 314 CSkia_PathData path_data; |
| 315 path_data.BuildPath(pPathData, pObject2Device); | 315 path_data.BuildPath(pPathData, pObject2Device); |
| 316 path_data.m_PathData.close(); | 316 path_data.m_PathData.close(); |
| 317 path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING? SkPath
::kWinding_FillType:SkPath::kEvenOdd_FillType); | 317 path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING? SkPath
::kWinding_FillType:SkPath::kEvenOdd_FillType); |
| 318 | 318 |
| 319 SkPaint spaint; | 319 SkPaint spaint; |
| 320 spaint.setColor(0xffffffff); | 320 spaint.setColor(0xffffffff); |
| 321 » spaint.setAntiAlias(TRUE); | 321 » spaint.setAntiAlias(true); |
| 322 spaint.setStyle(SkPaint::kFill_Style); | 322 spaint.setStyle(SkPaint::kFill_Style); |
| 323 | 323 |
| 324 SetClipMask(path_data.m_PathData, &spaint); | 324 SetClipMask(path_data.m_PathData, &spaint); |
| 325 | 325 |
| 326 » return TRUE; | 326 » return true; |
| 327 } | 327 } |
| 328 | 328 |
| 329 FX_BOOL CFX_SkiaDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData,»
// path info | 329 bool CFX_SkiaDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData,»
// path info |
| 330 const CFX_AffineMatrix* pObject2
Device, // optional transformation | 330 const CFX_AffineMatrix* pObject2
Device, // optional transformation |
| 331 const CFX_GraphStateData* pGraph
State // graphic state, for pen attributes | 331 const CFX_GraphStateData* pGraph
State // graphic state, for pen attributes |
| 332 ) | 332 ) |
| 333 { | 333 { |
| 334 if (m_pAggDriver->m_pClipRgn == NULL) | 334 if (m_pAggDriver->m_pClipRgn == NULL) |
| 335 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PI
XEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 335 m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PI
XEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
| 336 | 336 |
| 337 // build path data | 337 // build path data |
| 338 CSkia_PathData path_data; | 338 CSkia_PathData path_data; |
| 339 path_data.BuildPath(pPathData, NULL); | 339 path_data.BuildPath(pPathData, NULL); |
| 340 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); | 340 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); |
| 341 | 341 |
| 342 SkPaint spaint; | 342 SkPaint spaint; |
| 343 spaint.setColor(0xffffffff); | 343 spaint.setColor(0xffffffff); |
| 344 spaint.setStyle(SkPaint::kStroke_Style); | 344 spaint.setStyle(SkPaint::kStroke_Style); |
| 345 » spaint.setAntiAlias(TRUE); | 345 » spaint.setAntiAlias(true); |
| 346 | 346 |
| 347 SkPath dst_path; | 347 SkPath dst_path; |
| 348 » SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, pObject2Devic
e, pGraphState, 1, FALSE, 0); | 348 » SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, pObject2Devic
e, pGraphState, 1, false, 0); |
| 349 spaint.setStyle(SkPaint::kFill_Style); | 349 spaint.setStyle(SkPaint::kFill_Style); |
| 350 SetClipMask(dst_path, &spaint); | 350 SetClipMask(dst_path, &spaint); |
| 351 | 351 |
| 352 » return TRUE; | 352 » return true; |
| 353 } | 353 } |
| 354 FX_BOOL CFX_SkiaDeviceDriver::RenderRasterizer(rasterizer_scanline_aa& rasterize
r, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout, | 354 bool CFX_SkiaDeviceDriver::RenderRasterizer(rasterizer_scanline_aa& rasterizer,
FX_DWORD color, bool bFullCover, bool bGroupKnockout, |
| 355
int alpha_flag, void* pIccTransform) | 355
int alpha_flag, void* pIccTransform) |
| 356 { | 356 { |
| 357 return m_pAggDriver->RenderRasterizer(rasterizer, color, bFullCover, bGr
oupKnockout,alpha_flag, pIccTransform); | 357 return m_pAggDriver->RenderRasterizer(rasterizer, color, bFullCover, bGr
oupKnockout,alpha_flag, pIccTransform); |
| 358 } | 358 } |
| 359 FX_BOOL»CFX_SkiaDeviceDriver::RenderRasterizerSkia(SkPath& skPath, const SkPaint
& origPaint, SkIRect& rect, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKn
ockout, | 359 bool» CFX_SkiaDeviceDriver::RenderRasterizerSkia(SkPath& skPath, const SkPaint
& origPaint, SkIRect& rect, FX_DWORD color, bool bFullCover, bool bGroupKnockout
, |
| 360 » » » » » » » int alpha_flag, void* pI
ccTransform, FX_BOOL bFill) | 360 » » » » » » » int alpha_flag, void* pI
ccTransform, bool bFill) |
| 361 { | 361 { |
| 362 CFX_DIBitmap* pt = bGroupKnockout?m_pAggDriver->GetBackDrop():NULL; | 362 CFX_DIBitmap* pt = bGroupKnockout?m_pAggDriver->GetBackDrop():NULL; |
| 363 CFX_SkiaRenderer render; | 363 CFX_SkiaRenderer render; |
| 364 if (!render.Init(m_pAggDriver->m_pBitmap, pt, m_pAggDriver->m_pClipRgn,
color, bFullCover, m_pAggDriver->m_bRgbByteOrder, alpha_flag, pIccTransform)) | 364 if (!render.Init(m_pAggDriver->m_pBitmap, pt, m_pAggDriver->m_pClipRgn,
color, bFullCover, m_pAggDriver->m_bRgbByteOrder, alpha_flag, pIccTransform)) |
| 365 » » return FALSE; | 365 » » return false; |
| 366 | 366 |
| 367 SkRasterClip rasterClip(rect); | 367 SkRasterClip rasterClip(rect); |
| 368 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, or
igPaint); | 368 SuperBlitter_skia::DrawPath(skPath, (SkBlitter*)&render, rasterClip, or
igPaint); |
| 369 | 369 |
| 370 » return TRUE; | 370 » return true; |
| 371 | 371 |
| 372 } | 372 } |
| 373 | 373 |
| 374 FX_BOOL»CFX_SkiaDeviceDriver::DrawPath(const CFX_PathData* pPathData,» // path
info | 374 bool» CFX_SkiaDeviceDriver::DrawPath(const CFX_PathData* pPathData,» // path
info |
| 375 const CFX_AffineMatrix* pObject2
Device, // optional transformation | 375 const CFX_AffineMatrix* pObject2
Device, // optional transformation |
| 376 const CFX_GraphStateData* pGraph
State, // graphic state, for pen attributes | 376 const CFX_GraphStateData* pGraph
State, // graphic state, for pen attributes |
| 377 FX_DWORD fill_color,
// fill color | 377 FX_DWORD fill_color,
// fill color |
| 378 FX_DWORD stroke_color,
// stroke color | 378 FX_DWORD stroke_color,
// stroke color |
| 379 int fill_mode,
// fill mode, WINDING or ALTERNATE. 0 for not filled | 379 int fill_mode,
// fill mode, WINDING or ALTERNATE. 0 for not filled |
| 380 int alpha_flag, | 380 int alpha_flag, |
| 381 void* pIccTransform | 381 void* pIccTransform |
| 382 ) | 382 ) |
| 383 { | 383 { |
| 384 » if (GetBuffer() == NULL) return TRUE; | 384 » if (GetBuffer() == NULL) return true; |
| 385 FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering"); | 385 FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering"); |
| 386 SkIRect rect; | 386 SkIRect rect; |
| 387 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL
_HEIGHT)); | 387 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL
_HEIGHT)); |
| 388 if ((fill_mode & 3) && fill_color) { | 388 if ((fill_mode & 3) && fill_color) { |
| 389 // We have to transform before building path data, otherwise we'
ll have flatting problem | 389 // We have to transform before building path data, otherwise we'
ll have flatting problem |
| 390 // when we enlarge a small path (flatten before transformed) | 390 // when we enlarge a small path (flatten before transformed) |
| 391 // TESTDOC: Bug #5115 - DS_S1Dimpact_lr.pdf | 391 // TESTDOC: Bug #5115 - DS_S1Dimpact_lr.pdf |
| 392 // build path data | 392 // build path data |
| 393 CSkia_PathData path_data; | 393 CSkia_PathData path_data; |
| 394 path_data.BuildPath(pPathData, pObject2Device); | 394 path_data.BuildPath(pPathData, pObject2Device); |
| 395 //path_data.m_PathData.close(); | 395 //path_data.m_PathData.close(); |
| 396 path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING
? SkPath::kWinding_FillType:SkPath::kEvenOdd_FillType); | 396 path_data.m_PathData.setFillType((fill_mode&3) == FXFILL_WINDING
? SkPath::kWinding_FillType:SkPath::kEvenOdd_FillType); |
| 397 | 397 |
| 398 SkPaint spaint; | 398 SkPaint spaint; |
| 399 » » spaint.setAntiAlias(TRUE); | 399 » » spaint.setAntiAlias(true); |
| 400 spaint.setStyle(SkPaint::kFill_Style); | 400 spaint.setStyle(SkPaint::kFill_Style); |
| 401 spaint.setColor(fill_color); | 401 spaint.setColor(fill_color); |
| 402 » » if (!RenderRasterizerSkia(path_data.m_PathData, spaint, rect, fi
ll_color, fill_mode & FXFILL_FULLCOVER, FALSE, alpha_flag, pIccTransform)) | 402 » » if (!RenderRasterizerSkia(path_data.m_PathData, spaint, rect, fi
ll_color, fill_mode & FXFILL_FULLCOVER, false, alpha_flag, pIccTransform)) |
| 403 » » » return FALSE; | 403 » » » return false; |
| 404 } | 404 } |
| 405 | 405 |
| 406 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STR
OKE(alpha_flag) : FXARGB_A(stroke_color); | 406 int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STR
OKE(alpha_flag) : FXARGB_A(stroke_color); |
| 407 | 407 |
| 408 if (pGraphState && stroke_alpha) { | 408 if (pGraphState && stroke_alpha) { |
| 409 // We split the matrix into two parts: first part doing the scal
ing, so we won't have the | 409 // We split the matrix into two parts: first part doing the scal
ing, so we won't have the |
| 410 // flatness problem, second part doing the transformation, so we
don't have stroking geo problem. | 410 // flatness problem, second part doing the transformation, so we
don't have stroking geo problem. |
| 411 // TESTDOC: Bug #5253 - test[1].pdf | 411 // TESTDOC: Bug #5253 - test[1].pdf |
| 412 CFX_AffineMatrix matrix1, matrix2; | 412 CFX_AffineMatrix matrix1, matrix2; |
| 413 if (pObject2Device) { | 413 if (pObject2Device) { |
| 414 matrix1.a = FXSYS_fabs(pObject2Device->a) > FXSYS_fabs(p
Object2Device->b) ? | 414 matrix1.a = FXSYS_fabs(pObject2Device->a) > FXSYS_fabs(p
Object2Device->b) ? |
| 415 FXSYS_fabs(pObject2Device->a) : FXSYS_fa
bs(pObject2Device->b); | 415 FXSYS_fabs(pObject2Device->a) : FXSYS_fa
bs(pObject2Device->b); |
| 416 matrix1.d = matrix1.a;//FXSYS_fabs(pObject2Device->c) >
FXSYS_fabs(pObject2Device->d) ? | 416 matrix1.d = matrix1.a;//FXSYS_fabs(pObject2Device->c) >
FXSYS_fabs(pObject2Device->d) ? |
| 417 //pObject2Device->c : pObject2Device->d; | 417 //pObject2Device->c : pObject2Device->d; |
| 418 matrix2.Set(pObject2Device->a/matrix1.a, pObject2Device-
>b/matrix1.a, | 418 matrix2.Set(pObject2Device->a/matrix1.a, pObject2Device-
>b/matrix1.a, |
| 419 pObject2Device->c/matrix1.d, pObject2Dev
ice->d/matrix1.d, | 419 pObject2Device->c/matrix1.d, pObject2Dev
ice->d/matrix1.d, |
| 420 pObject2Device->e, pObject2Device->f); | 420 pObject2Device->e, pObject2Device->f); |
| 421 } | 421 } |
| 422 // build path data | 422 // build path data |
| 423 CSkia_PathData path_data; | 423 CSkia_PathData path_data; |
| 424 path_data.BuildPath(pPathData, &matrix1); | 424 path_data.BuildPath(pPathData, &matrix1); |
| 425 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); | 425 path_data.m_PathData.setFillType(SkPath::kWinding_FillType); |
| 426 | 426 |
| 427 SkPaint spaint; | 427 SkPaint spaint; |
| 428 spaint.setColor(stroke_color); | 428 spaint.setColor(stroke_color); |
| 429 spaint.setStyle(SkPaint::kStroke_Style); | 429 spaint.setStyle(SkPaint::kStroke_Style); |
| 430 » » spaint.setAntiAlias(TRUE); | 430 » » spaint.setAntiAlias(true); |
| 431 SkPath dst_path; | 431 SkPath dst_path; |
| 432 » » SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, &matr
ix2, pGraphState, matrix1.a, FALSE, 0); | 432 » » SkRasterizeStroke(spaint, &dst_path, path_data.m_PathData, &matr
ix2, pGraphState, matrix1.a, false, 0); |
| 433 spaint.setStyle(SkPaint::kFill_Style); | 433 spaint.setStyle(SkPaint::kFill_Style); |
| 434 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag)<<8 | FXGETFLAG_A
LPHA_STROKE(alpha_flag); | 434 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag)<<8 | FXGETFLAG_A
LPHA_STROKE(alpha_flag); |
| 435 | 435 |
| 436 » » if (!RenderRasterizerSkia(dst_path, spaint, rect, stroke_color,
fill_mode & FXFILL_FULLCOVER, FALSE, fill_flag, pIccTransform, FALSE)) | 436 » » if (!RenderRasterizerSkia(dst_path, spaint, rect, stroke_color,
fill_mode & FXFILL_FULLCOVER, false, fill_flag, pIccTransform, false)) |
| 437 » » » return FALSE; | 437 » » » return false; |
| 438 | 438 |
| 439 } | 439 } |
| 440 | 440 |
| 441 » return TRUE; | 441 » return true; |
| 442 } | 442 } |
| 443 | 443 |
| 444 FX_BOOL CFX_SkiaDeviceDriver::SetPixel(int x, int y, FX_DWORD color, | 444 bool CFX_SkiaDeviceDriver::SetPixel(int x, int y, FX_DWORD color, |
| 445 int alpha_flag, void* pIccTransf
orm) | 445 int alpha_flag, void* pIccTransf
orm) |
| 446 { | 446 { |
| 447 return m_pAggDriver->SetPixel(x, y, color, alpha_flag, pIccTransform); | 447 return m_pAggDriver->SetPixel(x, y, color, alpha_flag, pIccTransform); |
| 448 } | 448 } |
| 449 | 449 |
| 450 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color
, int alpha_flag, void* pIccTransform) | 450 bool CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, i
nt alpha_flag, void* pIccTransform) |
| 451 { | 451 { |
| 452 return m_pAggDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransfo
rm); | 452 return m_pAggDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransfo
rm); |
| 453 } | 453 } |
| 454 | 454 |
| 455 FX_BOOL CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) | 455 bool CFX_SkiaDeviceDriver::GetClipBox(FX_RECT* pRect) |
| 456 { | 456 { |
| 457 return m_pAggDriver->GetClipBox(pRect); | 457 return m_pAggDriver->GetClipBox(pRect); |
| 458 } | 458 } |
| 459 | 459 |
| 460 FX_BOOL»CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top
, void* pIccTransform, FX_BOOL bDEdge) | 460 bool» CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top
, void* pIccTransform, bool bDEdge) |
| 461 { | 461 { |
| 462 return m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge
); | 462 return m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge
); |
| 463 } | 463 } |
| 464 | 464 |
| 465 FX_BOOL»CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD a
rgb, const FX_RECT* pSrcRect, int left, int top, int blend_type, | 465 bool» CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD a
rgb, const FX_RECT* pSrcRect, int left, int top, int blend_type, |
| 466 int a
lpha_flag, void* pIccTransform) | 466 int a
lpha_flag, void* pIccTransform) |
| 467 { | 467 { |
| 468 return m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend
_type, alpha_flag, pIccTransform); | 468 return m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend
_type, alpha_flag, pIccTransform); |
| 469 } | 469 } |
| 470 | 470 |
| 471 FX_BOOL»CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWO
RD argb, int dest_left, int dest_top, | 471 bool» CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWO
RD argb, int dest_left, int dest_top, |
| 472 int dest_width, int dest
_height, const FX_RECT* pClipRect, FX_DWORD flags, | 472 int dest_width, int dest
_height, const FX_RECT* pClipRect, FX_DWORD flags, |
| 473 int alpha_flag, void* pI
ccTransform) | 473 int alpha_flag, void* pI
ccTransform) |
| 474 { | 474 { |
| 475 return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top, | 475 return m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top, |
| 476 dest_width, dest_height,
pClipRect, flags, | 476 dest_width, dest_height,
pClipRect, flags, |
| 477 alpha_flag, pIccTransfor
m); | 477 alpha_flag, pIccTransfor
m); |
| 478 } | 478 } |
| 479 | 479 |
| 480 FX_BOOL»CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitm
ap_alpha, FX_DWORD argb, | 480 bool» CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitm
ap_alpha, FX_DWORD argb, |
| 481 const CFX_AffineMatrix* pMatrix,
FX_DWORD render_flags, void*& handle, | 481 const CFX_AffineMatrix* pMatrix,
FX_DWORD render_flags, void*& handle, |
| 482 int alpha_flag, void* pIccTransf
orm) | 482 int alpha_flag, void* pIccTransf
orm) |
| 483 { | 483 { |
| 484 return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb, | 484 return m_pAggDriver->StartDIBits(pSource, bitmap_alpha, argb, |
| 485 pMatrix, render_flags, handle, a
lpha_flag, pIccTransform); | 485 pMatrix, render_flags, handle, a
lpha_flag, pIccTransform); |
| 486 } | 486 } |
| 487 | 487 |
| 488 FX_BOOL»CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) | 488 bool» CFX_SkiaDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) |
| 489 { | 489 { |
| 490 return m_pAggDriver->ContinueDIBits(pHandle, pPause); | 490 return m_pAggDriver->ContinueDIBits(pHandle, pPause); |
| 491 } | 491 } |
| 492 | 492 |
| 493 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) | 493 void CFX_SkiaDeviceDriver::CancelDIBits(void* pHandle) |
| 494 { | 494 { |
| 495 m_pAggDriver->CancelDIBits(pHandle); | 495 m_pAggDriver->CancelDIBits(pHandle); |
| 496 } | 496 } |
| 497 | 497 |
| 498 CFX_SkiaDevice::CFX_SkiaDevice() | 498 CFX_SkiaDevice::CFX_SkiaDevice() |
| 499 { | 499 { |
| 500 » m_bOwnedBitmap = FALSE; | 500 » m_bOwnedBitmap = false; |
| 501 } | 501 } |
| 502 | 502 |
| 503 FX_BOOL CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL b
RgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 503 bool CFX_SkiaDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, bool bRgbByt
eOrder, CFX_DIBitmap* pOriDevice, bool bGroupKnockout) |
| 504 { | 504 { |
| 505 if (pBitmap == NULL) | 505 if (pBitmap == NULL) |
| 506 » » return FALSE; | 506 » » return false; |
| 507 SetBitmap(pBitmap); | 507 SetBitmap(pBitmap); |
| 508 CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(pBitmap, dither
_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); | 508 CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(pBitmap, dither
_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); |
| 509 SetDeviceDriver(pDriver); | 509 SetDeviceDriver(pDriver); |
| 510 » return TRUE; | 510 » return true; |
| 511 } | 511 } |
| 512 | 512 |
| 513 FX_BOOL CFX_SkiaDevice::Create(int width, int height, FXDIB_Format format, int d
ither_bits, CFX_DIBitmap* pOriDevice) | 513 bool CFX_SkiaDevice::Create(int width, int height, FXDIB_Format format, int dith
er_bits, CFX_DIBitmap* pOriDevice) |
| 514 { | 514 { |
| 515 » m_bOwnedBitmap = TRUE; | 515 » m_bOwnedBitmap = true; |
| 516 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 516 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
| 517 if (!pBitmap->Create(width, height, format)) { | 517 if (!pBitmap->Create(width, height, format)) { |
| 518 delete pBitmap; | 518 delete pBitmap; |
| 519 » » return FALSE; | 519 » » return false; |
| 520 } | 520 } |
| 521 SetBitmap(pBitmap); | 521 SetBitmap(pBitmap); |
| 522 » CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(pBitmap, dithe
r_bits, FALSE, pOriDevice, FALSE); | 522 » CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(pBitmap, dithe
r_bits, false, pOriDevice, false); |
| 523 SetDeviceDriver(pDriver); | 523 SetDeviceDriver(pDriver); |
| 524 » return TRUE; | 524 » return true; |
| 525 } | 525 } |
| 526 CFX_SkiaDevice::~CFX_SkiaDevice() | 526 CFX_SkiaDevice::~CFX_SkiaDevice() |
| 527 { | 527 { |
| 528 if (m_bOwnedBitmap && GetBitmap()) delete GetBitmap(); | 528 if (m_bOwnedBitmap && GetBitmap()) delete GetBitmap(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 #endif | 531 #endif |
| OLD | NEW |