1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CORE_SRC_FXGE_SKIA_FX_SKIA_DEVICE_H_ 6 #define CORE_SRC_FXGE_SKIA_FX_SKIA_DEVICE_H_ 7 8 #if defined(_SKIA_SUPPORT_) 9 class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver 10 { 11 public: 12 CFX_SkiaDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout); 13 virtual ~CFX_SkiaDeviceDriver(); 14 15 /** Options */ 16 virtual int GetDeviceCaps(int caps_id); 17 18 /** Save and restore all graphic states */ 19 virtual void SaveState(); 20 virtual void RestoreState(FX_BOOL bKeepSaved); 21 22 /** Set clipping path using filled region */ 23 virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, // path info 24 const CFX_AffineMatrix* pObject2Device, // optional transformation 25 int fill_mode // fill mode, WINDING or ALTERNATE 26 ); 27 28 /** Set clipping path using stroked region */ 29 virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, // path info 30 const CFX_AffineMatrix* pObject2Device, // optional transformation 31 const CFX_GraphStateData* pGraphState // graphic state, for pen attributes 32 ); 33 34 /** Draw a path */ 35 virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, 36 const CFX_AffineMatrix* pObject2Device, 37 const CFX_GraphStateData* pGraphState, 38 FX_DWORD fill_color, 39 FX_DWORD stroke_color, 40 int fill_mode, 41 int alpha_flag = 0, 42 void* pIccTransform = NULL 43 ); 44 45 virtual FX_BOOL SetPixel(int x, int y, FX_DWORD color, 46 int alpha_flag = 0, void* pIccTransform = NULL); 47 48 virtual FX_BOOL FillRect(const FX_RECT* pRect, FX_DWORD fill_color, 49 int alpha_flag = 0, void* pIccTransform = NULL); 50 51 /** Draw a single pixel (device dependant) line */ 52 virtual FX_BOOL DrawCosmeticLine(FX_FIXFLOAT x1, FX_FIXFLOAT y1, FX_FIXFLOAT x2, FX_FIXFLOAT y2, FX_DWORD color, 53 int alpha_flag, void* pIccTransform, int blend_type) { return FALSE; } 54 55 virtual FX_BOOL GetClipBox(FX_RECT* pRect); 56 57 /** Load device buffer into a DIB */ 58 virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void* pIccTransform = NULL, FX_BOOL bDEdge = FALSE); 59 60 virtual CFX_DIBitmap* GetBackDrop() { return m_pAggDriver->GetBackDrop(); } 61 62 virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, const FX_RECT* pSrcRect, 63 int dest_left, int dest_top, int blend_type, 64 int alpha_flag = 0, void* pIccTransform = NULL); 65 virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, FX_DWORD color, int dest_left, int dest_top, 66 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flags, 67 int alpha_flag = 0, void* pIccTransform = NULL); 68 69 virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, int bitmap_alpha, FX_DWORD color, 70 const CFX_AffineMatrix* pMatrix, FX_DWORD flags, FX_LPVOID& handle, 71 int alpha_flag = 0, void* pIccTransform = NULL); 72 virtual FX_BOOL ContinueDIBits(FX_LPVOID handle, IFX_Pause* pPause); 73 virtual void CancelDIBits(FX_LPVOID handle); 74 75 virtual FX_BOOL DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, 76 CFX_FontCache* pCache, const CFX_AffineMatrix* pObject2Device, FX_FIXFLOAT font_size, FX_DWORD color, 77 int alpha_flag = 0, void* pIccTransform = NULL); 78 79 virtual FX_BOOL RenderRasterizer(rasterizer_scanline_aa& rasterizer, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout, 80 int alpha_flag, void* pIccTransform); 81 virtual FX_BOOL RenderRasterizerSkia(SkPath& skPath, const SkPaint& origPaint, SkIRect& rect, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bGroupKnockout, 82 int alpha_flag, void* pIccTransform, FX_BOOL bFill = TRUE); 83 void SetClipMask(rasterizer_scanline_aa& rasterizer); 84 void SetClipMask(SkPath& skPath, SkPaint* spaint); 85 virtual FX_LPBYTE GetBuffer() const {return m_pAggDriver->GetBuffer();} 86 87 CFX_AggDeviceDriver* m_pAggDriver; 88 }; 89 #endif // defined(_SKIA_SUPPORT_) 90 91 #endif // CORE_SRC_FXGE_SKIA_FX_SKIA_DEVICE_H_ 92