| 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 #ifndef CORE_FXGE_SKIA_FX_SKIA_DEVICE_H_ | 5 #ifndef CORE_FXGE_SKIA_FX_SKIA_DEVICE_H_ |
| 6 #define CORE_FXGE_SKIA_FX_SKIA_DEVICE_H_ | 6 #define CORE_FXGE_SKIA_FX_SKIA_DEVICE_H_ |
| 7 | 7 |
| 8 #if defined(_SKIA_SUPPORT_) | 8 #if defined(_SKIA_SUPPORT_) |
| 9 | 9 |
| 10 #include "core/fxge/cfx_pathdata.h" | 10 #include "core/fxge/cfx_pathdata.h" |
| 11 #include "core/fxge/ifx_renderdevicedriver.h" | 11 #include "core/fxge/ifx_renderdevicedriver.h" |
| 12 | 12 |
| 13 class SkCanvas; | 13 class SkCanvas; |
| 14 class SkMatrix; | 14 class SkMatrix; |
| 15 class SkPaint; | 15 class SkPaint; |
| 16 class SkPath; | 16 class SkPath; |
| 17 class SkPictureRecorder; | 17 class SkPictureRecorder; |
| 18 class SkiaState; | 18 class SkiaState; |
| 19 struct FXTEXT_CHARPOS; | 19 struct FXTEXT_CHARPOS; |
| 20 struct SkIRect; | 20 struct SkIRect; |
| 21 | 21 |
| 22 class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { | 22 class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { |
| 23 public: | 23 public: |
| 24 CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, | 24 CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, |
| 25 FX_BOOL bRgbByteOrder, | 25 bool bRgbByteOrder, |
| 26 CFX_DIBitmap* pOriDevice, | 26 CFX_DIBitmap* pOriDevice, |
| 27 FX_BOOL bGroupKnockout); | 27 bool bGroupKnockout); |
| 28 explicit CFX_SkiaDeviceDriver(SkPictureRecorder* recorder); | 28 explicit CFX_SkiaDeviceDriver(SkPictureRecorder* recorder); |
| 29 CFX_SkiaDeviceDriver(int size_x, int size_y); | 29 CFX_SkiaDeviceDriver(int size_x, int size_y); |
| 30 ~CFX_SkiaDeviceDriver() override; | 30 ~CFX_SkiaDeviceDriver() override; |
| 31 | 31 |
| 32 /** Options */ | 32 /** Options */ |
| 33 int GetDeviceCaps(int caps_id) const override; | 33 int GetDeviceCaps(int caps_id) const override; |
| 34 | 34 |
| 35 /** Save and restore all graphic states */ | 35 /** Save and restore all graphic states */ |
| 36 void SaveState() override; | 36 void SaveState() override; |
| 37 void RestoreState(bool bKeepSaved) override; | 37 void RestoreState(bool bKeepSaved) override; |
| 38 | 38 |
| 39 /** Set clipping path using filled region */ | 39 /** Set clipping path using filled region */ |
| 40 FX_BOOL SetClip_PathFill( | 40 bool SetClip_PathFill( |
| 41 const CFX_PathData* pPathData, // path info | 41 const CFX_PathData* pPathData, // path info |
| 42 const CFX_Matrix* pObject2Device, // optional transformation | 42 const CFX_Matrix* pObject2Device, // optional transformation |
| 43 int fill_mode) override; // fill mode, WINDING or ALTERNATE | 43 int fill_mode) override; // fill mode, WINDING or ALTERNATE |
| 44 | 44 |
| 45 /** Set clipping path using stroked region */ | 45 /** Set clipping path using stroked region */ |
| 46 FX_BOOL SetClip_PathStroke( | 46 bool SetClip_PathStroke( |
| 47 const CFX_PathData* pPathData, // path info | 47 const CFX_PathData* pPathData, // path info |
| 48 const CFX_Matrix* pObject2Device, // optional transformation | 48 const CFX_Matrix* pObject2Device, // optional transformation |
| 49 const CFX_GraphStateData* | 49 const CFX_GraphStateData* |
| 50 pGraphState) // graphic state, for pen attributes | 50 pGraphState) // graphic state, for pen attributes |
| 51 override; | 51 override; |
| 52 | 52 |
| 53 /** Draw a path */ | 53 /** Draw a path */ |
| 54 FX_BOOL DrawPath(const CFX_PathData* pPathData, | 54 bool DrawPath(const CFX_PathData* pPathData, |
| 55 const CFX_Matrix* pObject2Device, | 55 const CFX_Matrix* pObject2Device, |
| 56 const CFX_GraphStateData* pGraphState, | 56 const CFX_GraphStateData* pGraphState, |
| 57 uint32_t fill_color, | 57 uint32_t fill_color, |
| 58 uint32_t stroke_color, | 58 uint32_t stroke_color, |
| 59 int fill_mode, | 59 int fill_mode, |
| 60 int blend_type) override; | 60 int blend_type) override; |
| 61 | 61 |
| 62 FX_BOOL FillRectWithBlend(const FX_RECT* pRect, | 62 bool FillRectWithBlend(const FX_RECT* pRect, |
| 63 uint32_t fill_color, | 63 uint32_t fill_color, |
| 64 int blend_type) override; | 64 int blend_type) override; |
| 65 | 65 |
| 66 /** Draw a single pixel (device dependant) line */ | 66 /** Draw a single pixel (device dependant) line */ |
| 67 FX_BOOL DrawCosmeticLine(FX_FLOAT x1, | 67 bool DrawCosmeticLine(FX_FLOAT x1, |
| 68 FX_FLOAT y1, | 68 FX_FLOAT y1, |
| 69 FX_FLOAT x2, | 69 FX_FLOAT x2, |
| 70 FX_FLOAT y2, | 70 FX_FLOAT y2, |
| 71 uint32_t color, | 71 uint32_t color, |
| 72 int blend_type) override; | 72 int blend_type) override; |
| 73 | 73 |
| 74 FX_BOOL GetClipBox(FX_RECT* pRect) override; | 74 bool GetClipBox(FX_RECT* pRect) override; |
| 75 | 75 |
| 76 /** Load device buffer into a DIB */ | 76 /** Load device buffer into a DIB */ |
| 77 FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override; | 77 bool GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override; |
| 78 | 78 |
| 79 CFX_DIBitmap* GetBackDrop() override; | 79 CFX_DIBitmap* GetBackDrop() override; |
| 80 | 80 |
| 81 FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, | 81 bool SetDIBits(const CFX_DIBSource* pBitmap, |
| 82 uint32_t color, | 82 uint32_t color, |
| 83 const FX_RECT* pSrcRect, | 83 const FX_RECT* pSrcRect, |
| 84 int dest_left, | 84 int dest_left, |
| 85 int dest_top, | 85 int dest_top, |
| 86 int blend_type) override; | 86 int blend_type) override; |
| 87 bool SetBitsWithMask(const CFX_DIBSource* pBitmap, | 87 bool SetBitsWithMask(const CFX_DIBSource* pBitmap, |
| 88 const CFX_DIBSource* pMask, | 88 const CFX_DIBSource* pMask, |
| 89 int dest_left, | 89 int dest_left, |
| 90 int dest_top, | 90 int dest_top, |
| 91 int bitmap_alpha, | 91 int bitmap_alpha, |
| 92 int blend_type) override; | 92 int blend_type) override; |
| 93 FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, | 93 bool StretchDIBits(const CFX_DIBSource* pBitmap, |
| 94 uint32_t color, | 94 uint32_t color, |
| 95 int dest_left, | 95 int dest_left, |
| 96 int dest_top, | 96 int dest_top, |
| 97 int dest_width, | 97 int dest_width, |
| 98 int dest_height, | 98 int dest_height, |
| 99 const FX_RECT* pClipRect, | 99 const FX_RECT* pClipRect, |
| 100 uint32_t flags, | 100 uint32_t flags, |
| 101 int blend_type) override; | 101 int blend_type) override; |
| 102 | 102 |
| 103 FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, | 103 bool StartDIBits(const CFX_DIBSource* pBitmap, |
| 104 int bitmap_alpha, | 104 int bitmap_alpha, |
| 105 uint32_t color, | 105 uint32_t color, |
| 106 const CFX_Matrix* pMatrix, | 106 const CFX_Matrix* pMatrix, |
| 107 uint32_t flags, | 107 uint32_t flags, |
| 108 void*& handle, | 108 void*& handle, |
| 109 int blend_type) override; | 109 int blend_type) override; |
| 110 | 110 |
| 111 FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) override; | 111 bool ContinueDIBits(void* handle, IFX_Pause* pPause) override; |
| 112 | 112 |
| 113 void CancelDIBits(void* handle) override {} | 113 void CancelDIBits(void* handle) override {} |
| 114 | 114 |
| 115 bool DrawBitsWithMask(const CFX_DIBSource* pBitmap, | 115 bool DrawBitsWithMask(const CFX_DIBSource* pBitmap, |
| 116 const CFX_DIBSource* pMask, | 116 const CFX_DIBSource* pMask, |
| 117 int bitmap_alpha, | 117 int bitmap_alpha, |
| 118 const CFX_Matrix* pMatrix, | 118 const CFX_Matrix* pMatrix, |
| 119 int blend_type); | 119 int blend_type); |
| 120 | 120 |
| 121 FX_BOOL DrawDeviceText(int nChars, | 121 bool DrawDeviceText(int nChars, |
| 122 const FXTEXT_CHARPOS* pCharPos, | 122 const FXTEXT_CHARPOS* pCharPos, |
| 123 CFX_Font* pFont, | 123 CFX_Font* pFont, |
| 124 const CFX_Matrix* pObject2Device, | 124 const CFX_Matrix* pObject2Device, |
| 125 FX_FLOAT font_size, | 125 FX_FLOAT font_size, |
| 126 uint32_t color) override; | 126 uint32_t color) override; |
| 127 | 127 |
| 128 FX_BOOL DrawShading(const CPDF_ShadingPattern* pPattern, | 128 bool DrawShading(const CPDF_ShadingPattern* pPattern, |
| 129 const CFX_Matrix* pMatrix, | 129 const CFX_Matrix* pMatrix, |
| 130 const FX_RECT& clip_rect, | 130 const FX_RECT& clip_rect, |
| 131 int alpha, | 131 int alpha, |
| 132 FX_BOOL bAlphaMode) override; | 132 bool bAlphaMode) override; |
| 133 | 133 |
| 134 virtual uint8_t* GetBuffer() const; | 134 virtual uint8_t* GetBuffer() const; |
| 135 | 135 |
| 136 void PaintStroke(SkPaint* spaint, | 136 void PaintStroke(SkPaint* spaint, |
| 137 const CFX_GraphStateData* pGraphState, | 137 const CFX_GraphStateData* pGraphState, |
| 138 const SkMatrix& matrix); | 138 const SkMatrix& matrix); |
| 139 void Clear(uint32_t color); | 139 void Clear(uint32_t color); |
| 140 void Flush(); | 140 void Flush(); |
| 141 SkPictureRecorder* GetRecorder() const { return m_pRecorder; } | 141 SkPictureRecorder* GetRecorder() const { return m_pRecorder; } |
| 142 static void PreMultiply(CFX_DIBitmap* pDIBitmap); | 142 static void PreMultiply(CFX_DIBitmap* pDIBitmap); |
| 143 SkCanvas* SkiaCanvas() { return m_pCanvas; } | 143 SkCanvas* SkiaCanvas() { return m_pCanvas; } |
| 144 void DebugVerifyBitmapIsPreMultiplied() const; | 144 void DebugVerifyBitmapIsPreMultiplied() const; |
| 145 void Dump() const; | 145 void Dump() const; |
| 146 | 146 |
| 147 private: | 147 private: |
| 148 friend class SkiaState; | 148 friend class SkiaState; |
| 149 | 149 |
| 150 CFX_DIBitmap* m_pBitmap; | 150 CFX_DIBitmap* m_pBitmap; |
| 151 CFX_DIBitmap* m_pOriDevice; | 151 CFX_DIBitmap* m_pOriDevice; |
| 152 SkCanvas* m_pCanvas; | 152 SkCanvas* m_pCanvas; |
| 153 SkPictureRecorder* const m_pRecorder; | 153 SkPictureRecorder* const m_pRecorder; |
| 154 std::unique_ptr<SkiaState> m_pCache; | 154 std::unique_ptr<SkiaState> m_pCache; |
| 155 FX_BOOL m_bGroupKnockout; | 155 bool m_bGroupKnockout; |
| 156 }; | 156 }; |
| 157 #endif // defined(_SKIA_SUPPORT_) | 157 #endif // defined(_SKIA_SUPPORT_) |
| 158 | 158 |
| 159 #endif // CORE_FXGE_SKIA_FX_SKIA_DEVICE_H_ | 159 #endif // CORE_FXGE_SKIA_FX_SKIA_DEVICE_H_ |
| OLD | NEW |