| 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 #if defined(_SKIA_SUPPORT_) | 7 #if defined(_SKIA_SUPPORT_) |
| 8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
| 9 | 9 |
| 10 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" | 10 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 delete m_pCanvas; | 310 delete m_pCanvas; |
| 311 delete m_pAggDriver; | 311 delete m_pAggDriver; |
| 312 } | 312 } |
| 313 | 313 |
| 314 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, | 314 FX_BOOL CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, |
| 315 const FXTEXT_CHARPOS* pCharPos, | 315 const FXTEXT_CHARPOS* pCharPos, |
| 316 CFX_Font* pFont, | 316 CFX_Font* pFont, |
| 317 CFX_FontCache* pCache, | 317 CFX_FontCache* pCache, |
| 318 const CFX_Matrix* pObject2Device, | 318 const CFX_Matrix* pObject2Device, |
| 319 FX_FLOAT font_size, | 319 FX_FLOAT font_size, |
| 320 FX_DWORD color, | 320 uint32_t color, |
| 321 int alpha_flag, | 321 int alpha_flag, |
| 322 void* pIccTransform) { | 322 void* pIccTransform) { |
| 323 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromStream( | 323 SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromStream( |
| 324 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()))); | 324 new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()))); |
| 325 SkPaint paint; | 325 SkPaint paint; |
| 326 paint.setAntiAlias(true); | 326 paint.setAntiAlias(true); |
| 327 paint.setColor(color); | 327 paint.setColor(color); |
| 328 paint.setTypeface(typeface); | 328 paint.setTypeface(typeface); |
| 329 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 329 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| 330 paint.setTextSize(font_size); | 330 paint.setTextSize(font_size); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 dst_path.transform(skMatrix); | 423 dst_path.transform(skMatrix); |
| 424 DebugDrawSkiaClipPath(m_pCanvas, dst_path); | 424 DebugDrawSkiaClipPath(m_pCanvas, dst_path); |
| 425 m_pCanvas->clipPath(dst_path); | 425 m_pCanvas->clipPath(dst_path); |
| 426 return TRUE; | 426 return TRUE; |
| 427 } | 427 } |
| 428 | 428 |
| 429 FX_BOOL CFX_SkiaDeviceDriver::DrawPath( | 429 FX_BOOL CFX_SkiaDeviceDriver::DrawPath( |
| 430 const CFX_PathData* pPathData, // path info | 430 const CFX_PathData* pPathData, // path info |
| 431 const CFX_Matrix* pObject2Device, // optional transformation | 431 const CFX_Matrix* pObject2Device, // optional transformation |
| 432 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes | 432 const CFX_GraphStateData* pGraphState, // graphic state, for pen attributes |
| 433 FX_DWORD fill_color, // fill color | 433 uint32_t fill_color, // fill color |
| 434 FX_DWORD stroke_color, // stroke color | 434 uint32_t stroke_color, // stroke color |
| 435 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled | 435 int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled |
| 436 int alpha_flag, | 436 int alpha_flag, |
| 437 void* pIccTransform, | 437 void* pIccTransform, |
| 438 int blend_type) { | 438 int blend_type) { |
| 439 SkIRect rect; | 439 SkIRect rect; |
| 440 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), | 440 rect.set(0, 0, GetDeviceCaps(FXDC_PIXEL_WIDTH), |
| 441 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 441 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
| 442 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); | 442 SkMatrix skMatrix = ToSkMatrix(*pObject2Device); |
| 443 SkPaint skPaint; | 443 SkPaint skPaint; |
| 444 skPaint.setAntiAlias(true); | 444 skPaint.setAntiAlias(true); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 DebugShowCanvasMatrix(m_pCanvas); | 476 DebugShowCanvasMatrix(m_pCanvas); |
| 477 skPaint.setStyle(SkPaint::kStroke_Style); | 477 skPaint.setStyle(SkPaint::kStroke_Style); |
| 478 skPaint.setColor(stroke_color); | 478 skPaint.setColor(stroke_color); |
| 479 m_pCanvas->drawPath(skPath, skPaint); | 479 m_pCanvas->drawPath(skPath, skPaint); |
| 480 } | 480 } |
| 481 m_pCanvas->restore(); | 481 m_pCanvas->restore(); |
| 482 return TRUE; | 482 return TRUE; |
| 483 } | 483 } |
| 484 | 484 |
| 485 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, | 485 FX_BOOL CFX_SkiaDeviceDriver::FillRect(const FX_RECT* pRect, |
| 486 FX_DWORD fill_color, | 486 uint32_t fill_color, |
| 487 int alpha_flag, | 487 int alpha_flag, |
| 488 void* pIccTransform, | 488 void* pIccTransform, |
| 489 int blend_type) { | 489 int blend_type) { |
| 490 SkPaint spaint; | 490 SkPaint spaint; |
| 491 spaint.setAntiAlias(true); | 491 spaint.setAntiAlias(true); |
| 492 spaint.setColor(fill_color); | 492 spaint.setColor(fill_color); |
| 493 spaint.setXfermodeMode(GetSkiaBlendMode(blend_type)); | 493 spaint.setXfermodeMode(GetSkiaBlendMode(blend_type)); |
| 494 | 494 |
| 495 m_pCanvas->drawRect( | 495 m_pCanvas->drawRect( |
| 496 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom), | 496 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom), |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, | 576 FX_BOOL CFX_SkiaDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, |
| 577 int left, | 577 int left, |
| 578 int top, | 578 int top, |
| 579 void* pIccTransform, | 579 void* pIccTransform, |
| 580 FX_BOOL bDEdge) { | 580 FX_BOOL bDEdge) { |
| 581 return m_pAggDriver && | 581 return m_pAggDriver && |
| 582 m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge); | 582 m_pAggDriver->GetDIBits(pBitmap, left, top, pIccTransform, bDEdge); |
| 583 } | 583 } |
| 584 | 584 |
| 585 FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, | 585 FX_BOOL CFX_SkiaDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, |
| 586 FX_DWORD argb, | 586 uint32_t argb, |
| 587 const FX_RECT* pSrcRect, | 587 const FX_RECT* pSrcRect, |
| 588 int left, | 588 int left, |
| 589 int top, | 589 int top, |
| 590 int blend_type, | 590 int blend_type, |
| 591 int alpha_flag, | 591 int alpha_flag, |
| 592 void* pIccTransform) { | 592 void* pIccTransform) { |
| 593 return m_pAggDriver && | 593 return m_pAggDriver && |
| 594 m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend_type, | 594 m_pAggDriver->SetDIBits(pBitmap, argb, pSrcRect, left, top, blend_type, |
| 595 alpha_flag, pIccTransform); | 595 alpha_flag, pIccTransform); |
| 596 } | 596 } |
| 597 | 597 |
| 598 FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, | 598 FX_BOOL CFX_SkiaDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, |
| 599 FX_DWORD argb, | 599 uint32_t argb, |
| 600 int dest_left, | 600 int dest_left, |
| 601 int dest_top, | 601 int dest_top, |
| 602 int dest_width, | 602 int dest_width, |
| 603 int dest_height, | 603 int dest_height, |
| 604 const FX_RECT* pClipRect, | 604 const FX_RECT* pClipRect, |
| 605 FX_DWORD flags, | 605 uint32_t flags, |
| 606 int alpha_flag, | 606 int alpha_flag, |
| 607 void* pIccTransform, | 607 void* pIccTransform, |
| 608 int blend_type) { | 608 int blend_type) { |
| 609 return m_pAggDriver && | 609 return m_pAggDriver && |
| 610 m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top, | 610 m_pAggDriver->StretchDIBits(pSource, argb, dest_left, dest_top, |
| 611 dest_width, dest_height, pClipRect, flags, | 611 dest_width, dest_height, pClipRect, flags, |
| 612 alpha_flag, pIccTransform, blend_type); | 612 alpha_flag, pIccTransform, blend_type); |
| 613 } | 613 } |
| 614 | 614 |
| 615 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, | 615 FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, |
| 616 int bitmap_alpha, | 616 int bitmap_alpha, |
| 617 FX_DWORD argb, | 617 uint32_t argb, |
| 618 const CFX_Matrix* pMatrix, | 618 const CFX_Matrix* pMatrix, |
| 619 FX_DWORD render_flags, | 619 uint32_t render_flags, |
| 620 void*& handle, | 620 void*& handle, |
| 621 int alpha_flag, | 621 int alpha_flag, |
| 622 void* pIccTransform, | 622 void* pIccTransform, |
| 623 int blend_type) { | 623 int blend_type) { |
| 624 SkColorType colorType; | 624 SkColorType colorType; |
| 625 void* buffer = pSource->GetBuffer(); | 625 void* buffer = pSource->GetBuffer(); |
| 626 std::unique_ptr<uint8_t, FxFreeDeleter> dst8Storage; | 626 std::unique_ptr<uint8_t, FxFreeDeleter> dst8Storage; |
| 627 std::unique_ptr<uint32_t, FxFreeDeleter> dst32Storage; | 627 std::unique_ptr<uint32_t, FxFreeDeleter> dst32Storage; |
| 628 int width = pSource->GetWidth(); | 628 int width = pSource->GetWidth(); |
| 629 int height = pSource->GetHeight(); | 629 int height = pSource->GetHeight(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 SetDeviceDriver(pDriver); | 752 SetDeviceDriver(pDriver); |
| 753 return TRUE; | 753 return TRUE; |
| 754 } | 754 } |
| 755 | 755 |
| 756 CFX_SkiaDevice::~CFX_SkiaDevice() { | 756 CFX_SkiaDevice::~CFX_SkiaDevice() { |
| 757 if (m_bOwnedBitmap && GetBitmap()) | 757 if (m_bOwnedBitmap && GetBitmap()) |
| 758 delete GetBitmap(); | 758 delete GetBitmap(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 #endif | 761 #endif |
| OLD | NEW |