• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     ~SkLinearBitmapPipeline();
47 
48     void shadeSpan4f(int x, int y, SkPM4f* dst, int count);
49     void blitSpan(int32_t x, int32_t y, void* dst, int count);
50 
51     class PointProcessorInterface;
52     class SampleProcessorInterface;
53     class BlendProcessorInterface;
54     class DestinationInterface;
55     class PixelAccessorInterface;
56 
57     using MatrixCloner =
58         std::function<PointProcessorInterface* (PointProcessorInterface*, SkArenaAlloc*)>;
59     using TilerCloner =
60         std::function<PointProcessorInterface* (SampleProcessorInterface*, SkArenaAlloc*)>;
61 
62     PointProcessorInterface* chooseMatrix(
63         PointProcessorInterface* next,
64         const SkMatrix& inverse,
65         SkArenaAlloc* allocator);
66 
67     template <typename Tiler>
68     PointProcessorInterface* createTiler(SampleProcessorInterface* next, SkISize dimensions,
69                                          SkArenaAlloc* allocator);
70 
71     template <typename XStrategy>
72     PointProcessorInterface* chooseTilerYMode(
73         SampleProcessorInterface* next, SkShader::TileMode yMode, SkISize dimensions,
74         SkArenaAlloc* allocator);
75 
76     PointProcessorInterface* chooseTiler(
77         SampleProcessorInterface* next,
78         SkISize dimensions,
79         SkShader::TileMode xMode, SkShader::TileMode yMode,
80         SkFilterQuality filterQuality,
81         SkScalar dx,
82         SkArenaAlloc* allocator);
83 
84     template <SkColorType colorType>
85     PixelAccessorInterface* chooseSpecificAccessor(const SkPixmap& srcPixmap,
86                                                    SkArenaAlloc* allocator);
87 
88     PixelAccessorInterface* choosePixelAccessor(
89         const SkPixmap& srcPixmap,
90         const SkColor A8TintColor,
91         SkArenaAlloc* allocator);
92 
93     SampleProcessorInterface* chooseSampler(
94         BlendProcessorInterface* next,
95         SkFilterQuality filterQuality,
96         SkShader::TileMode xTile, SkShader::TileMode yTile,
97         const SkPixmap& srcPixmap,
98         const SkColor A8TintColor,
99         SkArenaAlloc* allocator);
100 
101     BlendProcessorInterface* chooseBlenderForShading(
102         SkAlphaType alphaType,
103         float postAlpha,
104         SkArenaAlloc* allocator);
105 
106     PointProcessorInterface* fFirstStage;
107     MatrixCloner             fMatrixStageCloner;
108     TilerCloner              fTileStageCloner;
109     DestinationInterface*    fLastStage;
110 };
111 
112 #endif  // SkLinearBitmapPipeline_DEFINED
113