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