Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/core/SkLinearBitmapPipeline.h

Issue 1998793002: Make an embeddable container to hold linear pipelines. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unused defs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/core/SkLinearBitmapPipeline.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkLinearBitmapPipeline_DEFINED 8 #ifndef SkLinearBitmapPipeline_DEFINED
9 #define SkLinearBitmapPipeline_DEFINED 9 #define SkLinearBitmapPipeline_DEFINED
10 10
11 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "SkImageInfo.h" 12 #include "SkImageInfo.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 15
16 class SkEmbeddableLinearPipeline;
17
18 //////////////////////////////////////////////////////////////////////////////// ///////////////////
19 // SkLinearBitmapPipeline - encapsulates all the machinery for doing floating po int pixel
20 // processing in a linear color space.
21 // Note: this class has unusual alignment requirements due to its use of SIMD in structions. The
22 // class SkEmbeddableLinearPipeline below manages these requirements.
16 class SkLinearBitmapPipeline { 23 class SkLinearBitmapPipeline {
17 public: 24 public:
18 SkLinearBitmapPipeline( 25 SkLinearBitmapPipeline(
19 const SkMatrix& inverse, 26 const SkMatrix& inverse,
20 SkFilterQuality filterQuality, 27 SkFilterQuality filterQuality,
21 SkShader::TileMode xTile, SkShader::TileMode yTile, 28 SkShader::TileMode xTile, SkShader::TileMode yTile,
22 SkColor paintColor, 29 SkColor paintColor,
23 const SkPixmap& srcPixmap); 30 const SkPixmap& srcPixmap);
24 31
25 32 SkLinearBitmapPipeline(
33 const SkLinearBitmapPipeline& pipeline,
34 const SkPixmap& srcPixmap,
35 SkXfermode::Mode xferMode,
36 const SkImageInfo& dstInfo);
26 37
27 static bool ClonePipelineForBlitting( 38 static bool ClonePipelineForBlitting(
28 void* blitterStorage, 39 SkEmbeddableLinearPipeline* pipelineStorage,
29 const SkLinearBitmapPipeline& pipeline, 40 const SkLinearBitmapPipeline& pipeline,
30 SkMatrix::TypeMask matrixMask, 41 SkMatrix::TypeMask matrixMask,
31 SkShader::TileMode xTileMode, 42 SkShader::TileMode xTileMode,
32 SkShader::TileMode yTileMode, 43 SkShader::TileMode yTileMode,
33 SkFilterQuality filterQuality, 44 SkFilterQuality filterQuality,
34 const SkPixmap& srcPixmap, 45 const SkPixmap& srcPixmap,
35 float finalAlpha, 46 float finalAlpha,
36 SkXfermode::Mode xferMode, 47 SkXfermode::Mode xferMode,
37 const SkImageInfo& dstInfo); 48 const SkImageInfo& dstInfo);
38 49
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 class BlendProcessorInterface; 91 class BlendProcessorInterface;
81 class DestinationInterface; 92 class DestinationInterface;
82 93
83 // These values were generated by the assert above in Stage::init{Sink|Stage }. 94 // These values were generated by the assert above in Stage::init{Sink|Stage }.
84 using MatrixStage = Stage<PointProcessorInterface, 160, PointProcessorInte rface>; 95 using MatrixStage = Stage<PointProcessorInterface, 160, PointProcessorInte rface>;
85 using TileStage = Stage<PointProcessorInterface, 160, SampleProcessorInt erface>; 96 using TileStage = Stage<PointProcessorInterface, 160, SampleProcessorInt erface>;
86 using SampleStage = Stage<SampleProcessorInterface, 100, BlendProcessorInte rface>; 97 using SampleStage = Stage<SampleProcessorInterface, 100, BlendProcessorInte rface>;
87 using BlenderStage = Stage<BlendProcessorInterface, 40>; 98 using BlenderStage = Stage<BlendProcessorInterface, 40>;
88 99
89 private: 100 private:
90 SkLinearBitmapPipeline(
91 const SkLinearBitmapPipeline& pipeline,
92 const SkPixmap& srcPixmap,
93 SkXfermode::Mode xferMode,
94 const SkImageInfo& dstInfo);
95
96 PointProcessorInterface* fFirstStage; 101 PointProcessorInterface* fFirstStage;
97 MatrixStage fMatrixStage; 102 MatrixStage fMatrixStage;
98 TileStage fTileStage; 103 TileStage fTileStage;
99 SampleStage fSampleStage; 104 SampleStage fSampleStage;
100 BlenderStage fBlenderStage; 105 BlenderStage fBlenderStage;
101 DestinationInterface* fLastStage; 106 DestinationInterface* fLastStage;
102 }; 107 };
103 108
109 //////////////////////////////////////////////////////////////////////////////// ////////////////////
110 // SkEmbeddableLinearPipeline - manage stricter alignment needs for SkLinearBitm apPipeline.
111 class SkEmbeddableLinearPipeline {
112 public:
113 SkEmbeddableLinearPipeline() { }
114 ~SkEmbeddableLinearPipeline() {
115 if (get() != nullptr) {
116 get()->~SkLinearBitmapPipeline();
117 }
118 }
119
120 template <typename... Args>
121 void init(Args&&... args) {
122 // Ensure that our pipeline is created at a 16 byte aligned address.
123 fPipeline = (SkLinearBitmapPipeline*)SkAlign16((intptr_t)fPipelineStorag e);
124 new (fPipeline) SkLinearBitmapPipeline{std::forward<Args>(args)...};
125 }
126
127 SkLinearBitmapPipeline* get() const { return fPipeline; }
128 SkLinearBitmapPipeline& operator*() const { return *this->get(); }
129 SkLinearBitmapPipeline* operator->() const { return this->get(); }
130
131 private:
132 enum {
133 kActualSize = sizeof(SkLinearBitmapPipeline),
134 kPaddedSize = SkAlignPtr(kActualSize + 12),
135 };
136 void* fPipelineStorage[kPaddedSize / sizeof(void*)];
137 SkLinearBitmapPipeline* fPipeline{nullptr};
138 };
139
104 #endif // SkLinearBitmapPipeline_DEFINED 140 #endif // SkLinearBitmapPipeline_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/core/SkLinearBitmapPipeline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698