1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkLinearBitmapPipeline_DEFINED 9 #define SkLinearBitmapPipeline_DEFINED 10 11 #include "SkArenaAlloc.h" 12 #include "SkColor.h" 13 #include "SkImageInfo.h" 14 #include "SkMatrix.h" 15 #include "SkShader.h" 16 17 class SkEmbeddableLinearPipeline; 18 19 enum SkGammaType { 20 kLinear_SkGammaType, 21 kSRGB_SkGammaType, 22 }; 23 24 /////////////////////////////////////////////////////////////////////////////////////////////////// 25 // SkLinearBitmapPipeline - encapsulates all the machinery for doing floating point pixel 26 // processing in a linear color space. 27 // Note: this class has unusual alignment requirements due to its use of SIMD instructions. The 28 // class SkEmbeddableLinearPipeline below manages these requirements. 29 class SkLinearBitmapPipeline { 30 public: 31 SkLinearBitmapPipeline( 32 const SkMatrix& inverse, 33 SkFilterQuality filterQuality, 34 SkShader::TileMode xTile, SkShader::TileMode yTile, 35 SkColor paintColor, 36 const SkPixmap& srcPixmap, 37 SkArenaAlloc* allocator); 38 39 SkLinearBitmapPipeline( 40 const SkLinearBitmapPipeline& pipeline, 41 const SkPixmap& srcPixmap, 42 SkBlendMode, 43 const SkImageInfo& dstInfo, 44 SkArenaAlloc* allocator); 45 46 static SkLinearBitmapPipeline* ClonePipelineForBlitting( 47 const SkLinearBitmapPipeline& pipeline, 48 SkMatrix::TypeMask matrixMask, 49 SkFilterQuality filterQuality, 50 const SkPixmap& srcPixmap, 51 float finalAlpha, 52 SkBlendMode, 53 const SkImageInfo& dstInfo, 54 SkArenaAlloc* allocator); 55 56 ~SkLinearBitmapPipeline(); 57 58 void shadeSpan4f(int x, int y, SkPM4f* dst, int count); 59 void blitSpan(int32_t x, int32_t y, void* dst, int count); 60 61 class PointProcessorInterface; 62 class SampleProcessorInterface; 63 class BlendProcessorInterface; 64 class DestinationInterface; 65 class PixelAccessorInterface; 66 67 using MatrixCloner = 68 std::function<PointProcessorInterface* (PointProcessorInterface*, SkArenaAlloc*)>; 69 using TilerCloner = 70 std::function<PointProcessorInterface* (SampleProcessorInterface*, SkArenaAlloc*)>; 71 72 PointProcessorInterface* chooseMatrix( 73 PointProcessorInterface* next, 74 const SkMatrix& inverse, 75 SkArenaAlloc* allocator); 76 77 template <typename Tiler> 78 PointProcessorInterface* createTiler(SampleProcessorInterface* next, SkISize dimensions, 79 SkArenaAlloc* allocator); 80 81 template <typename XStrategy> 82 PointProcessorInterface* chooseTilerYMode( 83 SampleProcessorInterface* next, SkShader::TileMode yMode, SkISize dimensions, 84 SkArenaAlloc* allocator); 85 86 PointProcessorInterface* chooseTiler( 87 SampleProcessorInterface* next, 88 SkISize dimensions, 89 SkShader::TileMode xMode, SkShader::TileMode yMode, 90 SkFilterQuality filterQuality, 91 SkScalar dx, 92 SkArenaAlloc* allocator); 93 94 template <SkColorType colorType> 95 PixelAccessorInterface* chooseSpecificAccessor(const SkPixmap& srcPixmap, 96 SkArenaAlloc* allocator); 97 98 PixelAccessorInterface* choosePixelAccessor( 99 const SkPixmap& srcPixmap, 100 const SkColor A8TintColor, 101 SkArenaAlloc* allocator); 102 103 SampleProcessorInterface* chooseSampler( 104 BlendProcessorInterface* next, 105 SkFilterQuality filterQuality, 106 SkShader::TileMode xTile, SkShader::TileMode yTile, 107 const SkPixmap& srcPixmap, 108 const SkColor A8TintColor, 109 SkArenaAlloc* allocator); 110 111 BlendProcessorInterface* chooseBlenderForShading( 112 SkAlphaType alphaType, 113 float postAlpha, 114 SkArenaAlloc* allocator); 115 116 PointProcessorInterface* fFirstStage; 117 MatrixCloner fMatrixStageCloner; 118 TilerCloner fTileStageCloner; 119 DestinationInterface* fLastStage; 120 }; 121 122 #endif // SkLinearBitmapPipeline_DEFINED 123