Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkColorFilterBase.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
8
10#include "include/core/SkColorSpace.h" // IWYU pragma: keep
20
21#include <cstddef>
22
23enum class SkBlendMode;
24
26 return false;
27}
28
29bool SkColorFilterBase::onAsAColorMatrix(float matrix[20]) const {
30 return false;
31}
32
34 SkColorSpace* dstCS) const {
35 constexpr size_t kEnoughForCommonFilters = 2048; // big enough for a tiny SkSL program
37 SkRasterPipeline pipeline(&alloc);
38 pipeline.appendConstantColor(&alloc, color.vec());
39 SkSurfaceProps props{}; // default OK; colorFilters don't render text
40 SkStageRec rec = {&pipeline, &alloc, kRGBA_F32_SkColorType, dstCS, color.unpremul(), props};
41
42 if (as_CFB(this)->appendStages(rec, color.fA == 1)) {
43 SkPMColor4f dst;
44 SkRasterPipeline_MemoryCtx dstPtr = { &dst, 0 };
45 pipeline.append(SkRasterPipelineOp::store_f32, &dstPtr);
46 pipeline.run(0,0, 1,1);
47 return dst;
48 }
49
50 SkDEBUGFAIL("onFilterColor4f unimplemented for this filter");
51 return SkPMColor4f{0,0,0,0};
52}
SkColor4f color
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
SkBlendMode
Definition SkBlendMode.h:38
static SkColorFilterBase * as_CFB(SkColorFilter *filter)
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition SkColorType.h:40
uint32_t SkColor
Definition SkColor.h:37
virtual bool onAsAColorMatrix(float[20]) const
virtual SkPMColor4f onFilterColor4f(const SkPMColor4f &color, SkColorSpace *dstCS) const
virtual bool appendStages(const SkStageRec &rec, bool shaderIsOpaque) const =0
virtual bool onAsAColorMode(SkColor *color, SkBlendMode *bmode) const
void run(size_t x, size_t y, size_t w, size_t h) const
void append(SkRasterPipelineOp, void *=nullptr)
void appendConstantColor(SkArenaAlloc *, const float rgba[4])