Flutter Engine
The Flutter Engine
Classes | Functions
SkRasterPipelineBlitter.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkBlender.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceProps.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkCPUTypes.h"
#include "include/private/base/SkTemplates.h"
#include "src/base/SkArenaAlloc.h"
#include "src/core/SkBlendModePriv.h"
#include "src/core/SkBlenderBase.h"
#include "src/core/SkBlitter.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkColorSpaceXformSteps.h"
#include "src/core/SkEffectPriv.h"
#include "src/core/SkMask.h"
#include "src/core/SkMemset.h"
#include "src/core/SkRasterPipeline.h"
#include "src/core/SkRasterPipelineOpContexts.h"
#include "src/core/SkRasterPipelineOpList.h"
#include "src/effects/colorfilters/SkColorFilterBase.h"
#include "src/shaders/SkShaderBase.h"
#include <cstdint>
#include <cstring>
#include <functional>
#include <optional>
#include <utility>

Go to the source code of this file.

Classes

class  SkRasterPipelineBlitter
 

Functions

static SkColor4f paint_color_to_dst (const SkPaint &paint, const SkPixmap &dst)
 
SkBlitterSkCreateRasterPipelineBlitter (const SkPixmap &dst, const SkPaint &paint, const SkMatrix &ctm, SkArenaAlloc *alloc, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
 
SkBlitterSkCreateRasterPipelineBlitter (const SkPixmap &dst, const SkPaint &paint, const SkRasterPipeline &shaderPipeline, bool is_opaque, SkArenaAlloc *alloc, sk_sp< SkShader > clipShader)
 

Function Documentation

◆ paint_color_to_dst()

static SkColor4f paint_color_to_dst ( const SkPaint paint,
const SkPixmap dst 
)
static

Definition at line 117 of file SkRasterPipelineBlitter.cpp.

117 {
118 SkColor4f paintColor = paint.getColor4f();
120 dst.colorSpace(), kUnpremul_SkAlphaType).apply(paintColor.vec());
121 return paintColor;
122}
kUnpremul_SkAlphaType
SkColorSpace * sk_srgb_singleton()
const Paint & paint
Definition: color_source.cc:38
dst
Definition: cp.py:12
void apply(float rgba[4]) const

◆ SkCreateRasterPipelineBlitter() [1/2]

SkBlitter * SkCreateRasterPipelineBlitter ( const SkPixmap dst,
const SkPaint paint,
const SkMatrix ctm,
SkArenaAlloc alloc,
sk_sp< SkShader clipShader,
const SkSurfaceProps props 
)

Definition at line 124 of file SkRasterPipelineBlitter.cpp.

129 {
130 SkColorSpace* dstCS = dst.colorSpace();
131 SkColorType dstCT = dst.colorType();
132 SkColor4f dstPaintColor = paint_color_to_dst(paint, dst);
133
134 auto shader = as_SB(paint.getShader());
135
136 SkRasterPipeline_<256> shaderPipeline;
137 if (!shader) {
138 // Having no shader makes things nice and easy... just use the paint color
139 shaderPipeline.appendConstantColor(alloc, dstPaintColor.premul().vec());
140 bool is_opaque = dstPaintColor.fA == 1.0f,
141 is_constant = true;
142 return SkRasterPipelineBlitter::Create(dst, paint, dstPaintColor, alloc, shaderPipeline,
143 is_opaque, is_constant, clipShader.get());
144 }
145
146 bool is_opaque = shader->isOpaque() && dstPaintColor.fA == 1.0f;
147 bool is_constant = shader->isConstant();
148
149 if (shader->appendRootStages({&shaderPipeline, alloc, dstCT, dstCS, dstPaintColor, props},
150 ctm)) {
151 if (dstPaintColor.fA != 1.0f) {
152 shaderPipeline.append(SkRasterPipelineOp::scale_1_float,
153 alloc->make<float>(dstPaintColor.fA));
154 }
155 return SkRasterPipelineBlitter::Create(dst, paint, dstPaintColor, alloc, shaderPipeline,
156 is_opaque, is_constant, clipShader.get());
157 }
158
159 // The shader can't draw with SkRasterPipeline.
160 return nullptr;
161}
SkColorType
Definition: SkColorType.h:19
static SkColor4f paint_color_to_dst(const SkPaint &paint, const SkPixmap &dst)
SkShaderBase * as_SB(SkShader *shader)
Definition: SkShaderBase.h:412
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
static SkBlitter * Create(const SkPixmap &dst, const SkPaint &paint, const SkColor4f &dstPaintColor, SkArenaAlloc *alloc, const SkRasterPipeline &shaderPipeline, bool is_opaque, bool is_constant, const SkShader *clipShader)
void append(SkRasterPipelineOp, void *=nullptr)
void appendConstantColor(SkArenaAlloc *, const float rgba[4])
T * get() const
Definition: SkRefCnt.h:303

◆ SkCreateRasterPipelineBlitter() [2/2]

SkBlitter * SkCreateRasterPipelineBlitter ( const SkPixmap dst,
const SkPaint paint,
const SkRasterPipeline shaderPipeline,
bool  is_opaque,
SkArenaAlloc alloc,
sk_sp< SkShader clipShader 
)

Definition at line 163 of file SkRasterPipelineBlitter.cpp.

168 {
169 bool is_constant = false; // If this were the case, it'd be better to just set a paint color.
171 shaderPipeline, is_opaque, is_constant,
172 clipShader.get());
173}